src/video/x11/SDL_x11window.c
changeset 2931 e705adf6f3dc
parent 2876 3fcb0d447bcd
child 2940 b93965a16fe0
     1.1 --- a/src/video/x11/SDL_x11window.c	Tue Dec 30 17:02:53 2008 +0000
     1.2 +++ b/src/video/x11/SDL_x11window.c	Tue Dec 30 17:09:42 2008 +0000
     1.3 @@ -28,6 +28,25 @@
     1.4  #include "SDL_x11video.h"
     1.5  #include "../Xext/extensions/StdCmap.h"
     1.6  
     1.7 +static void
     1.8 +X11_GetDisplaySize(_THIS, SDL_Window * window, int *w, int *h)
     1.9 +{
    1.10 +    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
    1.11 +    SDL_DisplayData *displaydata =
    1.12 +        (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
    1.13 +    XWindowAttributes attr;
    1.14 +
    1.15 +    XGetWindowAttributes(data->display, RootWindow(data->display,
    1.16 +                                                   displaydata->screen),
    1.17 +                         &attr);
    1.18 +    if (w) {
    1.19 +        *w = attr.width;
    1.20 +    }
    1.21 +    if (h) {
    1.22 +        *h = attr.height;
    1.23 +    }
    1.24 +}
    1.25 +
    1.26  static int
    1.27  SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created)
    1.28  {
    1.29 @@ -289,8 +308,8 @@
    1.30  
    1.31      if ((window->flags & SDL_WINDOW_FULLSCREEN)
    1.32          || window->x == SDL_WINDOWPOS_CENTERED) {
    1.33 -        x = (DisplayWidth(data->display, displaydata->screen) -
    1.34 -             window->w) / 2;
    1.35 +        X11_GetDisplaySize(_this, window, &x, NULL);
    1.36 +        x = (x - window->w) / 2;
    1.37      } else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
    1.38          x = 0;
    1.39      } else {
    1.40 @@ -298,8 +317,8 @@
    1.41      }
    1.42      if ((window->flags & SDL_WINDOW_FULLSCREEN)
    1.43          || window->y == SDL_WINDOWPOS_CENTERED) {
    1.44 -        y = (DisplayHeight(data->display, displaydata->screen) -
    1.45 -             window->h) / 2;
    1.46 +        X11_GetDisplaySize(_this, window, NULL, &y);
    1.47 +        y = (y - window->h) / 2;
    1.48      } else if (window->y == SDL_WINDOWPOS_UNDEFINED) {
    1.49          y = 0;
    1.50      } else {
    1.51 @@ -608,13 +627,15 @@
    1.52  
    1.53      if ((window->flags & SDL_WINDOW_FULLSCREEN)
    1.54          || window->x == SDL_WINDOWPOS_CENTERED) {
    1.55 -        x = (DisplayWidth(display, displaydata->screen) - window->w) / 2;
    1.56 +        X11_GetDisplaySize(_this, window, &x, NULL);
    1.57 +        x = (x - window->w) / 2;
    1.58      } else {
    1.59          x = window->x;
    1.60      }
    1.61      if ((window->flags & SDL_WINDOW_FULLSCREEN)
    1.62          || window->y == SDL_WINDOWPOS_CENTERED) {
    1.63 -        y = (DisplayHeight(display, displaydata->screen) - window->h) / 2;
    1.64 +        X11_GetDisplaySize(_this, window, NULL, &y);
    1.65 +        y = (y - window->h) / 2;
    1.66      } else {
    1.67          y = window->y;
    1.68      }
    1.69 @@ -627,7 +648,7 @@
    1.70      SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
    1.71      Display *display = data->videodata->display;
    1.72  
    1.73 -    XMoveWindow(display, data->window, window->w, window->h);
    1.74 +    XResizeWindow(display, data->window, window->w, window->h);
    1.75  }
    1.76  
    1.77  void