From 8a4cc8a526d69ffd1a3961da7a7d660c39a4f2b9 Mon Sep 17 00:00:00 2001 From: Jeff Teunissen Date: Sun, 13 May 2001 09:07:57 +0000 Subject: [PATCH] Restore gamma properly in X11 targets, regardless of the value of vid_system_gamma --- include/context_x11.h | 1 + source/context_x11.c | 29 ++++++++++++++++++++++------- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/include/context_x11.h b/include/context_x11.h index a8844d1..a838f0c 100644 --- a/include/context_x11.h +++ b/include/context_x11.h @@ -63,6 +63,7 @@ void X11_Init_Cvars (void); void X11_OpenDisplay (void); void X11_ProcessEvent (void); void X11_ProcessEvents (void); +void X11_RestoreGamma (void); void X11_RestoreVidMode (void); void X11_SetCaption (char *); void X11_SetVidMode (int, int); diff --git a/source/context_x11.c b/source/context_x11.c index d74a84d..f87ebf2 100644 --- a/source/context_x11.c +++ b/source/context_x11.c @@ -97,11 +97,11 @@ static int original_mode = 0; static qboolean vidmode_avail = false; static qboolean vidmode_active = false; -cvar_t *vid_fullscreen; -cvar_t *vid_system_gamma; -qboolean vid_gamma_avail; -qboolean vid_fullscreen_active; +cvar_t *vid_fullscreen; +cvar_t *vid_system_gamma; +qboolean vid_fullscreen_active; static double x_gamma; +extern qboolean vid_gamma_avail; static int xss_timeout; static int xss_interval; @@ -323,7 +323,7 @@ X11_Init_Cvars (void) { vid_fullscreen = Cvar_Get ("vid_fullscreen", "0", CVAR_ROM, NULL, "Toggles fullscreen game mode"); - vid_system_gamma = Cvar_Get ("vid_system_gamma", "1", CVAR_ARCHIVE, NULL, + vid_system_gamma = Cvar_Get ("vid_system_gamma", "0", CVAR_ARCHIVE, NULL, "Use system gamma control if available"); } @@ -406,7 +406,7 @@ X11_RestoreVidMode (void) #ifdef HAVE_VIDMODE if (vidmode_active) { - X11_SetGamma (x_gamma); + X11_RestoreGamma (); XF86VidModeSwitchToMode (x_disp, x_screen, vidmodes[original_mode]); XFree (vidmodes); } @@ -471,7 +471,7 @@ X11_SetGamma (double gamma) # ifdef X_XF86VidModeSetGamma XF86VidModeGamma xgamma; - if (vidmode_avail && vid_system_gamma->int_val) { + if (vid_gamma_avail && vid_system_gamma->int_val) { xgamma.red = xgamma.green = xgamma.blue = (float) gamma; if (XF86VidModeSetGamma (x_disp, x_screen, &xgamma)) return true; @@ -480,3 +480,18 @@ X11_SetGamma (double gamma) #endif return false; } + +void +X11_RestoreGamma (void) +{ +#ifdef HAVE_VIDMODE +# ifdef X_XF86VidModeSetGamma + XF86VidModeGamma xgamma; + + if (vid_gamma_avail) { + xgamma.red = xgamma.green = xgamma.blue = (float) x_gamma; + XF86VidModeSetGamma (x_disp, x_screen, &xgamma); + } +# endif +#endif +}