Date: Mon, 29 Dec 2008 23:29:52 +0100
authorSam Lantinga <slouken@libsdl.org>
Tue, 30 Dec 2008 17:09:42 +0000
changeset 2931 e705adf6f3dc
parent 2930 8acbb14124c5
child 2932 676754cc1acb
Date: Mon, 29 Dec 2008 23:29:52 +0100 From: Couriersud Subject: SDL1.3: Some X11 diffs The attached diff fixes the following issues in the X11 backend: a) When calling resize, actually a move was performed. This has been corrected. b) DisplayHeight and DisplayWidth do not return up-to-date information after a modeswitch using the xrandr code, which I enabled in x11_modes.c Height and width are now queried from the root window and all occurrences of DisplayHeight and DisplayWidth changed.
src/video/x11/SDL_x11window.c
--- a/src/video/x11/SDL_x11window.c	Tue Dec 30 17:02:53 2008 +0000
+++ b/src/video/x11/SDL_x11window.c	Tue Dec 30 17:09:42 2008 +0000
@@ -28,6 +28,25 @@
 #include "SDL_x11video.h"
 #include "../Xext/extensions/StdCmap.h"
 
+static void
+X11_GetDisplaySize(_THIS, SDL_Window * window, int *w, int *h)
+{
+    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
+    SDL_DisplayData *displaydata =
+        (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
+    XWindowAttributes attr;
+
+    XGetWindowAttributes(data->display, RootWindow(data->display,
+                                                   displaydata->screen),
+                         &attr);
+    if (w) {
+        *w = attr.width;
+    }
+    if (h) {
+        *h = attr.height;
+    }
+}
+
 static int
 SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created)
 {
@@ -289,8 +308,8 @@
 
     if ((window->flags & SDL_WINDOW_FULLSCREEN)
         || window->x == SDL_WINDOWPOS_CENTERED) {
-        x = (DisplayWidth(data->display, displaydata->screen) -
-             window->w) / 2;
+        X11_GetDisplaySize(_this, window, &x, NULL);
+        x = (x - window->w) / 2;
     } else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
         x = 0;
     } else {
@@ -298,8 +317,8 @@
     }
     if ((window->flags & SDL_WINDOW_FULLSCREEN)
         || window->y == SDL_WINDOWPOS_CENTERED) {
-        y = (DisplayHeight(data->display, displaydata->screen) -
-             window->h) / 2;
+        X11_GetDisplaySize(_this, window, NULL, &y);
+        y = (y - window->h) / 2;
     } else if (window->y == SDL_WINDOWPOS_UNDEFINED) {
         y = 0;
     } else {
@@ -608,13 +627,15 @@
 
     if ((window->flags & SDL_WINDOW_FULLSCREEN)
         || window->x == SDL_WINDOWPOS_CENTERED) {
-        x = (DisplayWidth(display, displaydata->screen) - window->w) / 2;
+        X11_GetDisplaySize(_this, window, &x, NULL);
+        x = (x - window->w) / 2;
     } else {
         x = window->x;
     }
     if ((window->flags & SDL_WINDOW_FULLSCREEN)
         || window->y == SDL_WINDOWPOS_CENTERED) {
-        y = (DisplayHeight(display, displaydata->screen) - window->h) / 2;
+        X11_GetDisplaySize(_this, window, NULL, &y);
+        y = (y - window->h) / 2;
     } else {
         y = window->y;
     }
@@ -627,7 +648,7 @@
     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
     Display *display = data->videodata->display;
 
-    XMoveWindow(display, data->window, window->w, window->h);
+    XResizeWindow(display, data->window, window->w, window->h);
 }
 
 void