Fixed detection of display bounds after a mode switch when Xinerama is enabled.
authorSam Lantinga <slouken@libsdl.org>
Fri, 28 Sep 2012 11:51:16 -0700
changeset 6502 f41a82de351e
parent 6501 2efafb933bd5
child 6503 8ff31baded38
Fixed detection of display bounds after a mode switch when Xinerama is enabled.
src/video/x11/SDL_x11modes.c
--- a/src/video/x11/SDL_x11modes.c	Fri Sep 28 10:54:26 2012 -0700
+++ b/src/video/x11/SDL_x11modes.c	Fri Sep 28 11:51:16 2012 -0700
@@ -637,6 +637,16 @@
 
 #if SDL_VIDEO_DRIVER_X11_XINERAMA
     if (data->use_xinerama) {
+        int screencount;
+        XineramaScreenInfo *xinerama;
+
+        /* Update the current screen layout information */
+        xinerama = XineramaQueryScreens(display, &screencount);
+        if (xinerama && data->screen < screencount) {
+            data->xinerama_info = xinerama[data->screen];
+        }
+        if (xinerama) XFree(xinerama);
+
         *w = data->xinerama_info.width;
         *h = data->xinerama_info.height;
         *rate = 0;
@@ -789,21 +799,20 @@
 int
 X11_GetDisplayBounds(_THIS, SDL_VideoDisplay * sdl_display, SDL_Rect * rect)
 {
+    Display *display = ((SDL_VideoData *) _this->driverdata)->display;
     SDL_DisplayData *data = (SDL_DisplayData *) sdl_display->driverdata;
+    int real_rate;
+
+    rect->x = 0;
+    rect->y = 0;
+    get_real_resolution(display, data, &rect->w, &rect->h, &real_rate);
 
 #if SDL_VIDEO_DRIVER_X11_XINERAMA
-    if (data && data->use_xinerama) {
+    if (data->use_xinerama) {
         rect->x = data->xinerama_info.x_org;
         rect->y = data->xinerama_info.y_org;
-        rect->w = data->xinerama_info.width;
-        rect->h = data->xinerama_info.height;
-        return 0;
     }
 #endif
-    rect->x = 0;
-    rect->y = 0;
-    rect->w = sdl_display->current_mode.w;
-    rect->h = sdl_display->current_mode.h;
     return 0;
 }