From 21f2a75b80193c21c1e5458f531445b979f20454 Mon Sep 17 00:00:00 2001 From: divverent Date: Fri, 20 Sep 2013 07:22:34 +0000 Subject: [PATCH] GLX: Fix desktopfullscreen size when we actually switched to it. Should fix a few possible issues with getresolution(-1) on a multihead setup with some window managers. Also, remove a superfluous memory allocation on GLX when not using DPSOFTRAST. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12011 d7cf8633-e32d-0410-b094-e92efae38249 --- vid_glx.c | 35 ++++++++++++++++++++++------------- vid_sdl.c | 3 +++ 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/vid_glx.c b/vid_glx.c index 69155d1e..9e33fdc9 100644 --- a/vid_glx.c +++ b/vid_glx.c @@ -654,6 +654,15 @@ static void HandleEvents(void) // window changed size/location win_x = event.xconfigure.x; win_y = event.xconfigure.y; + // HACK on X11, we just request fullscreen mode, but + // cannot guess what the window manager will do for us + // exactly. That is why we read back the resolution we + // actually got here. + if(vid_isdesktopfullscreen) + { + desktop_mode.width = event.xconfigure.width; + desktop_mode.height = event.xconfigure.height; + } if((vid_resizable.integer < 2 || vid_isdesktopfullscreen) && (vid.width != event.xconfigure.width || vid.height != event.xconfigure.height)) { vid.width = event.xconfigure.width; @@ -663,19 +672,19 @@ static void HandleEvents(void) else Con_DPrintf("Updating to ConfigureNotify resolution %dx%d\n", vid.width, vid.height); - DPSOFTRAST_Flush(); - - if(vid.softdepthpixels) - free(vid.softdepthpixels); - - DestroyXImages(); - XSync(vidx11_display, False); - if(!BuildXImages(vid.width, vid.height)) - return; - XSync(vidx11_display, False); - - vid.softpixels = (unsigned int *) vidx11_ximage[vidx11_ximage_pos]->data; - vid.softdepthpixels = (unsigned int *)calloc(4, vid.width * vid.height); + if(vid.renderpath == RENDERPATH_SOFT) + { + DPSOFTRAST_Flush(); + if(vid.softdepthpixels) + free(vid.softdepthpixels); + DestroyXImages(); + XSync(vidx11_display, False); + if(!BuildXImages(vid.width, vid.height)) + return; + XSync(vidx11_display, False); + vid.softpixels = (unsigned int *) vidx11_ximage[vidx11_ximage_pos]->data; + vid.softdepthpixels = (unsigned int *)calloc(4, vid.width * vid.height); + } } break; case DestroyNotify: diff --git a/vid_sdl.c b/vid_sdl.c index c9600ce7..abb90970 100644 --- a/vid_sdl.c +++ b/vid_sdl.c @@ -2885,6 +2885,9 @@ vid_mode_t *VID_GetDesktopMode(void) modes[k].refreshrate = mode.refreshrate; modes[k].pixelheight_num = 1; modes[k].pixelheight_denom = 1; // SDL does not provide this + // TODO check whether this actually works, or whether we do still need + // a read-window-size-after-entering-desktop-fullscreen hack for + // multiscreen setups. #endif return &desktop_mode; } -- 2.39.2