From 2c07f9f35b1ea1d8769589267679f63c7d9c486b Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 27 Sep 2012 13:23:34 -0700 Subject: [PATCH] Fixed fullscreen origin for multi-head displays --- src/video/x11/SDL_x11modes.c | 16 ++++++---------- src/video/x11/SDL_x11window.c | 20 +++++++++++--------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/video/x11/SDL_x11modes.c b/src/video/x11/SDL_x11modes.c index ef6e08a7b..2095310a6 100755 --- a/src/video/x11/SDL_x11modes.c +++ b/src/video/x11/SDL_x11modes.c @@ -151,9 +151,8 @@ X11_InitModes(_THIS) */ if (CheckXinerama(data->display, &xinerama_major, &xinerama_minor)) { xinerama = XineramaQueryScreens(data->display, &screencount); - if (!xinerama) screencount = ScreenCount(data->display); } - else { + if (!xinerama) { screencount = ScreenCount(data->display); } #else @@ -807,14 +806,11 @@ X11_GetDisplayBounds(_THIS, SDL_VideoDisplay * sdl_display, SDL_Rect * rect) return 0; } #endif - if (_this->windows) { - rect->x = 0; - rect->y = 0; - rect->w = _this->windows->w; - rect->h = _this->windows->h; - return 0; - } - return -1; + rect->x = 0; + rect->y = 0; + rect->w = sdl_display->current_mode.w; + rect->h = sdl_display->current_mode.h; + return 0; } #endif /* SDL_VIDEO_DRIVER_X11 */ diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index ca2741bb7..aca8f7981 100755 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -996,13 +996,14 @@ X11_BeginWindowFullscreenLegacy(_THIS, SDL_Window * window, SDL_VideoDisplay * _ unsigned long xattrmask = 0; XSetWindowAttributes xattr; XEvent ev; - int x = 0; - int y = 0; + SDL_Rect rect; if ( data->fswindow ) { return; /* already fullscreen, I hope. */ } + X11_GetDisplayBounds(_this, _display, &rect); + /* Ungrab the input so that we can move the mouse around */ XUngrabPointer(display, CurrentTime); @@ -1020,7 +1021,8 @@ X11_BeginWindowFullscreenLegacy(_THIS, SDL_Window * window, SDL_VideoDisplay * _ xattr.colormap = data->colormap; xattrmask |= CWColormap; - data->fswindow = XCreateWindow(display, root, x, y, w, h, 0, + data->fswindow = XCreateWindow(display, root, + rect.x, rect.y, rect.w, rect.h, 0, displaydata->depth, InputOutput, visual, xattrmask, &xattr); @@ -1048,9 +1050,9 @@ X11_BeginWindowFullscreenLegacy(_THIS, SDL_Window * window, SDL_VideoDisplay * _ //XIfEvent(display, &ev, &isConfigureNotify, (XPointer)&data->xwindow); /* Center actual window within our cover-the-screen window. */ - x += (w - window->w) / 2; - y += (h - window->h) / 2; - XReparentWindow(display, data->xwindow, data->fswindow, x, y); + rect.x += (rect.w - window->w) / 2; + rect.y += (rect.h - window->h) / 2; + XReparentWindow(display, data->xwindow, data->fswindow, rect.x, rect.y); XRaiseWindow(display, data->xwindow); /* Make sure the fswindow is in view by warping mouse to the corner */ @@ -1058,9 +1060,9 @@ X11_BeginWindowFullscreenLegacy(_THIS, SDL_Window * window, SDL_VideoDisplay * _ XFlush(display); /* Center mouse in the window. */ - x += (window->w / 2); - y += (window->h / 2); - XWarpPointer(display, None, root, 0, 0, 0, 0, x, y); + rect.x += (window->w / 2); + rect.y += (window->h / 2); + XWarpPointer(display, None, root, 0, 0, 0, 0, rect.x, rect.y); /* Wait to be mapped, filter Unmap event out if it arrives. */ XIfEvent(display, &ev, &isMapNotify, (XPointer)&data->xwindow);