From 48e901481ac15d3d571675fe0fb4d39a7df48698 Mon Sep 17 00:00:00 2001 From: Jeff Teunissen Date: Fri, 9 Feb 2001 22:36:30 +0000 Subject: [PATCH] Even more VidMode paranoia: We now save the mode we started with and explicitly go back to that mode instead of the first in the list. --- source/context_x11.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/source/context_x11.c b/source/context_x11.c index f290786..c6f5338 100644 --- a/source/context_x11.c +++ b/source/context_x11.c @@ -92,7 +92,12 @@ static Atom aWMDelete = 0; #ifdef HAVE_VIDMODE static XF86VidModeModeInfo **vidmodes; static int nummodes; + +static int screen_width; +static int screen_height; +static int original_mode; #endif + static qboolean vidmode_avail = false; static qboolean vidmode_active = false; @@ -266,14 +271,23 @@ x11_set_vidmode (int width, int height) #ifdef HAVE_VIDMODE vidmode_avail = VID_CheckVMode (x_disp, NULL, NULL); - XF86VidModeGetAllModeLines (x_disp, x_screen, &nummodes, &vidmodes); - if (vid_fullscreen->int_val && vidmode_avail) { int i; int best_mode = 0; qboolean found_mode = false; + XF86VidModeGetAllModeLines (x_disp, x_screen, &nummodes, &vidmodes); + XF86VidModeGetViewPort (x_disp, x_screen, &screen_width, &screen_height); + + for (i = 0; i < nummodes; i++) { + if ((vidmodes[i]->hdisplay == screen_width) && + (vidmodes[i]->vdisplay == screen_height)) { + original_mode = i; + break; + } + } + for (i = 0; i < nummodes; i++) { if ((vidmodes[i]->hdisplay == vid.width) && (vidmodes[i]->vdisplay == vid.height)) { @@ -384,7 +398,7 @@ x11_restore_vidmode (void) #ifdef HAVE_VIDMODE if (vidmode_active) { - XF86VidModeSwitchToMode (x_disp, x_screen, vidmodes[0]); + XF86VidModeSwitchToMode (x_disp, x_screen, vidmodes[original_mode]); XFree (vidmodes); } #endif