Simplified the X11 window creation
authorSam Lantinga <slouken@libsdl.org>
Mon, 21 Feb 2011 22:52:31 -0800
changeset 5386762e67f81fc7
parent 5385 5f9c2515fc08
child 5387 03c79d46bf5c
Simplified the X11 window creation
src/video/x11/SDL_x11window.c
     1.1 --- a/src/video/x11/SDL_x11window.c	Mon Feb 21 22:52:07 2011 -0800
     1.2 +++ b/src/video/x11/SDL_x11window.c	Mon Feb 21 22:52:31 2011 -0800
     1.3 @@ -265,20 +265,15 @@
     1.4      Visual *visual;
     1.5      int depth;
     1.6      XSetWindowAttributes xattr;
     1.7 -    int x, y;
     1.8      Window w;
     1.9      XSizeHints *sizehints;
    1.10      XWMHints *wmhints;
    1.11      XClassHint *classhints;
    1.12 -    SDL_bool oldstyle_fullscreen;
    1.13      Atom _NET_WM_WINDOW_TYPE;
    1.14      Atom _NET_WM_WINDOW_TYPE_NORMAL;
    1.15      int wmstate_count;
    1.16      Atom wmstate_atoms[3];
    1.17  
    1.18 -    /* ICCCM2.0-compliant window managers can handle fullscreen windows */
    1.19 -    oldstyle_fullscreen = X11_IsWindowOldFullscreen(_this, window);
    1.20 -
    1.21  #if SDL_VIDEO_DRIVER_X11_XINERAMA
    1.22  /* FIXME
    1.23      if ( use_xinerama ) {
    1.24 @@ -318,36 +313,14 @@
    1.25          depth = displaydata->depth;
    1.26      }
    1.27  
    1.28 -    if (oldstyle_fullscreen) {
    1.29 -        xattr.override_redirect = True;
    1.30 -    } else {
    1.31 -        xattr.override_redirect = False;
    1.32 -    }
    1.33 +    xattr.override_redirect = False;
    1.34      xattr.background_pixel = 0;
    1.35      xattr.border_pixel = 0;
    1.36      xattr.colormap = XCreateColormap(display, RootWindow(display, screen), visual, AllocNone);
    1.37  
    1.38 -    if (oldstyle_fullscreen
    1.39 -        || SDL_WINDOWPOS_ISCENTERED(window->x)) {
    1.40 -        X11_GetDisplaySize(_this, window, &x, NULL);
    1.41 -        x = (x - window->w) / 2;
    1.42 -    } else if (SDL_WINDOWPOS_ISUNDEFINED(window->x)) {
    1.43 -        x = 0;
    1.44 -    } else {
    1.45 -        x = window->x;
    1.46 -    }
    1.47 -    if (oldstyle_fullscreen
    1.48 -        || SDL_WINDOWPOS_ISCENTERED(window->y)) {
    1.49 -        X11_GetDisplaySize(_this, window, NULL, &y);
    1.50 -        y = (y - window->h) / 2;
    1.51 -    } else if (SDL_WINDOWPOS_ISUNDEFINED(window->y)) {
    1.52 -        y = 0;
    1.53 -    } else {
    1.54 -        y = window->y;
    1.55 -    }
    1.56 -
    1.57 -    w = XCreateWindow(display, RootWindow(display, screen), x, y,
    1.58 -                      window->w, window->h, 0, depth, InputOutput, visual,
    1.59 +    w = XCreateWindow(display, RootWindow(display, screen),
    1.60 +                      window->x, window->y, window->w, window->h,
    1.61 +                      0, depth, InputOutput, visual,
    1.62                        (CWOverrideRedirect | CWBackPixel | CWBorderPixel |
    1.63                         CWColormap), &xattr);
    1.64      if (!w) {
    1.65 @@ -370,24 +343,19 @@
    1.66  
    1.67      sizehints = XAllocSizeHints();
    1.68      if (sizehints) {
    1.69 -        if (!(window->flags & SDL_WINDOW_RESIZABLE)
    1.70 -            || oldstyle_fullscreen) {
    1.71 +        if (!(window->flags & SDL_WINDOW_RESIZABLE)) {
    1.72              sizehints->min_width = sizehints->max_width = window->w;
    1.73              sizehints->min_height = sizehints->max_height = window->h;
    1.74              sizehints->flags = PMaxSize | PMinSize;
    1.75          }
    1.76 -        if (!oldstyle_fullscreen
    1.77 -            && !SDL_WINDOWPOS_ISUNDEFINED(window->x)
    1.78 -            && !SDL_WINDOWPOS_ISUNDEFINED(window->y)) {
    1.79 -            sizehints->x = x;
    1.80 -            sizehints->y = y;
    1.81 -            sizehints->flags |= USPosition;
    1.82 -        }
    1.83 +        sizehints->x = window->x;
    1.84 +        sizehints->y = window->y;
    1.85 +        sizehints->flags |= USPosition;
    1.86          XSetWMNormalHints(display, w, sizehints);
    1.87          XFree(sizehints);
    1.88      }
    1.89  
    1.90 -    if ((window->flags & SDL_WINDOW_BORDERLESS) || oldstyle_fullscreen) {
    1.91 +    if (window->flags & SDL_WINDOW_BORDERLESS) {
    1.92          SDL_bool set;
    1.93          Atom WM_HINTS;
    1.94  
    1.95 @@ -512,6 +480,7 @@
    1.96          XDestroyWindow(display, w);
    1.97          return -1;
    1.98      }
    1.99 +
   1.100  #ifdef X_HAVE_UTF8_STRING
   1.101      {
   1.102          Uint32 fevent = 0;