Fixed fullscreen origin for multi-head displays
authorSam Lantinga <slouken@libsdl.org>
Thu, 27 Sep 2012 13:23:34 -0700
changeset 647571d39944810b
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
     1.1 --- a/src/video/x11/SDL_x11modes.c	Thu Sep 27 13:22:34 2012 -0700
     1.2 +++ b/src/video/x11/SDL_x11modes.c	Thu Sep 27 13:23:34 2012 -0700
     1.3 @@ -151,9 +151,8 @@
     1.4       */
     1.5      if (CheckXinerama(data->display, &xinerama_major, &xinerama_minor)) {
     1.6          xinerama = XineramaQueryScreens(data->display, &screencount);
     1.7 -        if (!xinerama) screencount = ScreenCount(data->display);
     1.8      }
     1.9 -    else {
    1.10 +    if (!xinerama) {
    1.11          screencount = ScreenCount(data->display);
    1.12      }
    1.13  #else
    1.14 @@ -807,14 +806,11 @@
    1.15          return 0;
    1.16      }
    1.17  #endif
    1.18 -    if (_this->windows) {
    1.19 -        rect->x = 0;
    1.20 -        rect->y = 0;
    1.21 -        rect->w = _this->windows->w;
    1.22 -        rect->h = _this->windows->h;
    1.23 -        return 0;
    1.24 -    }
    1.25 -    return -1;
    1.26 +    rect->x = 0;
    1.27 +    rect->y = 0;
    1.28 +    rect->w = sdl_display->current_mode.w;
    1.29 +    rect->h = sdl_display->current_mode.h;
    1.30 +    return 0;
    1.31  }
    1.32  
    1.33  #endif /* SDL_VIDEO_DRIVER_X11 */
     2.1 --- a/src/video/x11/SDL_x11window.c	Thu Sep 27 13:22:34 2012 -0700
     2.2 +++ b/src/video/x11/SDL_x11window.c	Thu Sep 27 13:23:34 2012 -0700
     2.3 @@ -996,13 +996,14 @@
     2.4      unsigned long xattrmask = 0;
     2.5      XSetWindowAttributes xattr;
     2.6      XEvent ev;
     2.7 -    int x = 0;
     2.8 -    int y = 0;
     2.9 +    SDL_Rect rect;
    2.10  
    2.11      if ( data->fswindow ) {
    2.12          return;  /* already fullscreen, I hope. */
    2.13      }
    2.14  
    2.15 +    X11_GetDisplayBounds(_this, _display, &rect);
    2.16 +
    2.17      /* Ungrab the input so that we can move the mouse around */
    2.18      XUngrabPointer(display, CurrentTime);
    2.19  
    2.20 @@ -1020,7 +1021,8 @@
    2.21      xattr.colormap = data->colormap;
    2.22      xattrmask |= CWColormap;
    2.23  
    2.24 -    data->fswindow = XCreateWindow(display, root, x, y, w, h, 0,
    2.25 +    data->fswindow = XCreateWindow(display, root,
    2.26 +                                   rect.x, rect.y, rect.w, rect.h, 0,
    2.27                                     displaydata->depth, InputOutput,
    2.28                                     visual, xattrmask, &xattr);
    2.29  
    2.30 @@ -1048,9 +1050,9 @@
    2.31      //XIfEvent(display, &ev, &isConfigureNotify, (XPointer)&data->xwindow);
    2.32  
    2.33      /* Center actual window within our cover-the-screen window. */
    2.34 -    x += (w - window->w) / 2;
    2.35 -    y += (h - window->h) / 2;
    2.36 -    XReparentWindow(display, data->xwindow, data->fswindow, x, y);
    2.37 +    rect.x += (rect.w - window->w) / 2;
    2.38 +    rect.y += (rect.h - window->h) / 2;
    2.39 +    XReparentWindow(display, data->xwindow, data->fswindow, rect.x, rect.y);
    2.40      XRaiseWindow(display, data->xwindow);
    2.41  
    2.42      /* Make sure the fswindow is in view by warping mouse to the corner */
    2.43 @@ -1058,9 +1060,9 @@
    2.44      XFlush(display);
    2.45  
    2.46      /* Center mouse in the window. */
    2.47 -    x += (window->w / 2);
    2.48 -    y += (window->h / 2);
    2.49 -    XWarpPointer(display, None, root, 0, 0, 0, 0, x, y);
    2.50 +    rect.x += (window->w / 2);
    2.51 +    rect.y += (window->h / 2);
    2.52 +    XWarpPointer(display, None, root, 0, 0, 0, 0, rect.x, rect.y);
    2.53  
    2.54      /* Wait to be mapped, filter Unmap event out if it arrives. */
    2.55      XIfEvent(display, &ev, &isMapNotify, (XPointer)&data->xwindow);