diff --git a/include/QF/vid.h b/include/QF/vid.h index 8b4987b1b..ebad01a5c 100644 --- a/include/QF/vid.h +++ b/include/QF/vid.h @@ -87,6 +87,7 @@ extern unsigned int d_8to24table[256]; extern int scr_width, scr_height; extern byte gammatable[256]; +extern struct cvar_s *vid_gamma; extern qboolean vid_gamma_avail; // called at startup and after any gamma correction diff --git a/include/context_x11.h b/include/context_x11.h index 1c0d07420..8eeee328b 100644 --- a/include/context_x11.h +++ b/include/context_x11.h @@ -47,6 +47,7 @@ extern int x_shmeventtype; extern Time x_time; extern qboolean doShm; extern qboolean oktodraw; +extern qboolean x_have_focus; void GetEvent (void); diff --git a/libs/video/targets/context_x11.c b/libs/video/targets/context_x11.c index 95dadc0e5..398bbf48f 100644 --- a/libs/video/targets/context_x11.c +++ b/libs/video/targets/context_x11.c @@ -91,7 +91,9 @@ Window x_win; Cursor nullcursor = None; Time x_time; -#define X_MASK (VisibilityChangeMask | StructureNotifyMask | ExposureMask) +qboolean x_have_focus = false; + +#define X_MASK (VisibilityChangeMask | StructureNotifyMask | ExposureMask | FocusChangeMask) #define MOUSE_MASK (ButtonPressMask | ButtonReleaseMask | PointerMotionMask) #ifdef HAVE_VIDMODE @@ -667,7 +669,7 @@ X11_SetGamma (double gamma) # ifdef X_XF86VidModeSetGamma XF86VidModeGamma xgamma; - if (vid_gamma_avail && vid_system_gamma->int_val) { + if (vid_gamma_avail && vid_system_gamma->int_val && x_have_focus) { xgamma.red = xgamma.green = xgamma.blue = (float) gamma; if (XF86VidModeSetGamma (x_disp, x_screen, &xgamma)) return true; diff --git a/libs/video/targets/in_x11.c b/libs/video/targets/in_x11.c index ce8c89cb9..856540f14 100644 --- a/libs/video/targets/in_x11.c +++ b/libs/video/targets/in_x11.c @@ -480,22 +480,26 @@ event_button (XEvent *event) static void event_focusout (XEvent *event) { + x_have_focus = false; XAutoRepeatOn (x_disp); if (in_snd_block->int_val) { S_BlockSound (); CDAudio_Pause (); } + X11_RestoreGamma (); } static void event_focusin (XEvent *event) { + x_have_focus = true; if (key_dest == key_game) XAutoRepeatOff (x_disp); if (in_snd_block->int_val) { S_UnblockSound (); CDAudio_Resume (); } + VID_UpdateGamma (vid_gamma); } static void diff --git a/libs/video/targets/vid_x11.c b/libs/video/targets/vid_x11.c index 65468c176..4dfecee19 100644 --- a/libs/video/targets/vid_x11.c +++ b/libs/video/targets/vid_x11.c @@ -387,14 +387,14 @@ x11_init_buffers (void) vid.aspect = ((float) vid.height / (float) vid.width) * (320.0 / 240.0); } - +#if 0 static void event_shm (XEvent * event) { if (doShm) oktodraw = true; } - +#endif static void VID_Center_f (void) { X11_ForceViewPort (); @@ -548,7 +548,7 @@ VID_Init (unsigned char *palette) VID_InitBuffers (); // XSynchronize (x_disp, False); - X11_AddEvent (x_shmeventtype, event_shm); +// X11_AddEvent (x_shmeventtype, event_shm); vid.initialized = true; }