Fixed fullscreen origin for multi-head displays
authorSam Lantinga <slouken@libsdl.org>
Thu, 27 Sep 2012 13:23:34 -0700
changeset 6475 71d39944810b
parent 6474 39087ac884d7
child 6476 9010d6830cdf
Fixed fullscreen origin for multi-head displays
src/video/x11/SDL_x11modes.c
src/video/x11/SDL_x11window.c
--- a/src/video/x11/SDL_x11modes.c	Thu Sep 27 13:22:34 2012 -0700
+++ b/src/video/x11/SDL_x11modes.c	Thu Sep 27 13:23:34 2012 -0700
@@ -151,9 +151,8 @@
      */
     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 @@
         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 */
--- a/src/video/x11/SDL_x11window.c	Thu Sep 27 13:22:34 2012 -0700
+++ b/src/video/x11/SDL_x11window.c	Thu Sep 27 13:23:34 2012 -0700
@@ -996,13 +996,14 @@
     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 @@
     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 @@
     //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 @@
     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);