Added configuration option for fullscreen check

This commit is contained in:
Jarcode
2018-08-05 21:24:18 -07:00
parent fc80db664b
commit 45b614a692
4 changed files with 22 additions and 8 deletions

View File

@@ -279,10 +279,7 @@ int main(int argc, char** argv) {
}
pthread_mutex_unlock(&audio.mutex);
/* Only render if needed (ie. stop rendering when fullscreen windows are focused) */
if (xwin_should_render(r)) {
rd_update(r, lb, rb, r->bufsize_request, modified);
} else {
if (!rd_update(r, lb, rb, r->bufsize_request, modified)) {
/* Sleep for 50ms and then attempt to render again */
struct timespec tv = {
.tv_sec = 0, .tv_nsec = 50 * 1000000

View File

@@ -109,7 +109,7 @@ struct gl_data {
double tcounter;
int fcounter, ucounter, kcounter;
bool print_fps, avg_window, interpolate, force_geometry, copy_desktop,
smooth_pass, premultiply_alpha;
smooth_pass, premultiply_alpha, check_fullscreen;
void** t_data;
float gravity_step, target_spu, fr, ur, smooth_distance, smooth_ratio,
smooth_factor, fft_scale, fft_cutoff;
@@ -721,6 +721,7 @@ struct renderer* rd_new(const char** paths, const char* entry,
.sm_prog = 0,
.copy_desktop = true,
.premultiply_alpha = true,
.check_fullscreen = true,
.smooth_pass = true,
.fft_scale = 10.2F,
.fft_cutoff = 0.3F,
@@ -823,6 +824,10 @@ struct renderer* rd_new(const char** paths, const char* entry,
.name = "setmirror", .fmt = "b",
.handler = RHANDLER(name, args, { r->mirror_input = *(bool*) args[0]; })
},
{
.name = "setfullscreencheck", .fmt = "b",
.handler = RHANDLER(name, args, { gl->check_fullscreen = *(bool*) args[0]; })
},
{
.name = "setbg", .fmt = "s",
.handler = RHANDLER(name, args, {
@@ -1276,13 +1281,17 @@ void rd_time(struct renderer* r) {
gl->wcb->set_time(gl->w, 0.0D); /* reset time for measuring this frame */
}
void rd_update(struct renderer* r, float* lb, float* rb, size_t bsz, bool modified) {
bool rd_update(struct renderer* r, float* lb, float* rb, size_t bsz, bool modified) {
struct gl_data* gl = r->gl;
size_t t, a, fbsz = bsz * sizeof(float);
r->alive = !gl->wcb->should_close(gl->w);
if (!r->alive)
return;
return true;
/* Stop rendering when fullscreen windows are focused */
if (gl->check_fullscreen && !xwin_should_render(r))
return false;
/* Force disable interpolation if the update rate is close to or higher than the frame rate */
float uratio = (gl->ur / gl->fr); /* update : framerate ratio */
@@ -1628,6 +1637,8 @@ void rd_update(struct renderer* r, float* lb, float* rb, size_t bsz, bool modifi
/* Restore interpolation settings */
gl->interpolate = old_interpolate;
return true;
}
void* rd_get_impl_window (struct renderer* r) { return r->gl->w; }

View File

@@ -13,7 +13,7 @@ typedef struct renderer {
struct renderer* rd_new (const char** paths, const char* entry,
const char* force_mod, const char* force_backend);
void rd_update (struct renderer*, float* lb, float* rb,
bool rd_update (struct renderer*, float* lb, float* rb,
size_t bsz, bool modified);
void rd_destroy (struct renderer*);
void rd_time (struct renderer*);

View File

@@ -124,6 +124,12 @@
simple set to zero (or lower) to disable the frame limiter. */
#request setframerate 0
/* Enable/disable fullscreen checks. This looks at the currently
focused window and halts GLava's rendering if it is
fullscreen. This prevents rendering from interfering with
other graphically intensive tasks. */
#request setfullscreencheck true
/* Enable/disable printing framerate every second. 'FPS' stands
for 'Frames Per Second', and 'UPS' stands for 'Updates Per
Second'. Updates are performed when new data is submitted