From 9d59915fdc2e6690fa8c8c35fd3b570c48c2aad6 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Fri, 17 May 2002 03:17:33 +0000 Subject: [PATCH] it's a little hacky, but this might do better with keeping vid_gamma_avail straight. --- libs/video/targets/context_x11.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/libs/video/targets/context_x11.c b/libs/video/targets/context_x11.c index 22e2dfd90..604b20c4e 100644 --- a/libs/video/targets/context_x11.c +++ b/libs/video/targets/context_x11.c @@ -376,6 +376,7 @@ void X11_SetVidMode (int width, int height) { const char *str = getenv ("MESA_GLX_FX"); + static int initialized = 0; if (vidmode_active) return; @@ -388,21 +389,22 @@ X11_SetVidMode (int width, int height) if (!vidmode_avail) vidmode_avail = VID_CheckVMode (x_disp, NULL, NULL); - if (vidmode_avail) { + if (!initialized && vidmode_avail) { vec3_t *temp; - if (x_gamma[0] > 0) { // already initialized + initialized = 1; + + vid_gamma_avail = true; + + temp = X11_GetGamma (); + if (temp && temp[0] > 0) { + x_gamma[0] = (*temp)[0]; + x_gamma[1] = (*temp)[1]; + x_gamma[2] = (*temp)[2]; vid_gamma_avail = true; - } else { // do the init - temp = X11_GetGamma (); - if (temp && temp[0] > 0) { - x_gamma[0] = (*temp)[0]; - x_gamma[1] = (*temp)[1]; - x_gamma[2] = (*temp)[2]; - vid_gamma_avail = true; - free (temp); - } + free (temp); } + } if (vid_fullscreen->int_val && vidmode_avail) { @@ -442,7 +444,7 @@ X11_SetVidMode (int width, int height) } else { Con_Printf ("VID: Mode %dx%d can't go fullscreen.\n", vid.width, vid.height); - vid_gamma_avail = vidmode_avail = vidmode_active = false; + vidmode_avail = vidmode_active = false; } } #endif @@ -747,7 +749,7 @@ X11_GetGamma (void) XF86VidModeGamma xgamma; vec3_t *temp; - if (vidmode_avail && vid_system_gamma->int_val) { + if (vid_gamma_avail && vid_system_gamma->int_val) { if (XF86VidModeGetGamma (x_disp, x_screen, &xgamma)) { if ((temp = malloc (sizeof (vec3_t)))) { (*temp)[0] = xgamma.red; @@ -760,6 +762,7 @@ X11_GetGamma (void) } # endif #endif + vid_gamma_avail = false; return NULL; }