Simplified driver window creation code.
authorSam Lantinga <slouken@libsdl.org>
Sat, 29 Jul 2006 21:51:00 +0000
changeset 1956ba0d62354872
parent 1955 8c6106e45fc1
child 1957 c7803e4c21d3
Simplified driver window creation code.
Implemented several Cocoa window functions
include/SDL_syswm.h
include/SDL_video.h
src/video/SDL_video.c
src/video/cocoa/SDL_cocoawindow.h
src/video/cocoa/SDL_cocoawindow.m
src/video/win32/SDL_win32window.c
src/video/x11/SDL_x11opengl.c
src/video/x11/SDL_x11window.c
     1.1 --- a/include/SDL_syswm.h	Sat Jul 29 03:57:55 2006 +0000
     1.2 +++ b/include/SDL_syswm.h	Sat Jul 29 21:51:00 2006 +0000
     1.3 @@ -148,7 +148,6 @@
     1.4  {
     1.5      SDL_version version;
     1.6      HWND window;                /* The Win32 display window */
     1.7 -    HGLRC hglrc;                /* The OpenGL context, if any */
     1.8  };
     1.9  
    1.10  #elif defined(SDL_VIDEO_DRIVER_RISCOS)
     2.1 --- a/include/SDL_video.h	Sat Jul 29 03:57:55 2006 +0000
     2.2 +++ b/include/SDL_video.h	Sat Jul 29 21:51:00 2006 +0000
     2.3 @@ -574,17 +574,15 @@
     2.4   *
     2.5   * \brief Create a window with the specified position, dimensions, and flags.
     2.6   *
     2.7 - * \param title The title of the window
     2.8 - * \param x The x position of the window
     2.9 - * \param y The y position of the window
    2.10 + * \param title The title of the window, in UTF-8 encoding
    2.11 + * \param x The x position of the window, SDL_WINDOWPOS_CENTERED, or SDL_WINDOWPOS_UNDEFINED
    2.12 + * \param y The y position of the window, SDL_WINDOWPOS_CENTERED, or SDL_WINDOWPOS_UNDEFINED
    2.13   * \param w The width of the window
    2.14   * \param h The height of the window
    2.15   * \param flags The flags for the window, a mask of any of the following: SDL_WINDOW_FULLSCREEN, SDL_WINDOW_OPENGL, SDL_WINDOW_SHOWN, SDL_WINDOW_BORDERLESS, SDL_WINDOW_RESIZABLE, SDL_WINDOW_MAXIMIZED, SDL_WINDOW_MINIMIZED, SDL_WINDOW_INPUT_GRABBED
    2.16   *
    2.17   * \return The id of the window created, or zero if window creation failed.
    2.18   *
    2.19 - * \note Setting the position to -1, -1, indicates any position is fine.
    2.20 - *
    2.21   * \sa SDL_DestroyWindow()
    2.22   */
    2.23  extern DECLSPEC SDL_WindowID SDLCALL SDL_CreateWindow(const char *title,
     3.1 --- a/src/video/SDL_video.c	Sat Jul 29 03:57:55 2006 +0000
     3.2 +++ b/src/video/SDL_video.c	Sat Jul 29 21:51:00 2006 +0000
     3.3 @@ -614,9 +614,8 @@
     3.4      for (i = 0; i < display->num_windows; ++i) {
     3.5          SDL_Window *window = &display->windows[i];
     3.6          if (FULLSCREEN_VISIBLE(window)) {
     3.7 -            SDL_SetWindowPosition(window->id,
     3.8 -                                  ((display_mode.w - window->w) / 2),
     3.9 -                                  ((display_mode.h - window->h) / 2));
    3.10 +            SDL_SetWindowPosition(window->id, SDL_WINDOWPOS_CENTERED,
    3.11 +                                  SDL_WINDOWPOS_CENTERED);
    3.12          }
    3.13      }
    3.14  
    3.15 @@ -718,12 +717,8 @@
    3.16  {
    3.17      const Uint32 allowed_flags = (SDL_WINDOW_FULLSCREEN |
    3.18                                    SDL_WINDOW_OPENGL |
    3.19 -                                  SDL_WINDOW_SHOWN |
    3.20                                    SDL_WINDOW_BORDERLESS |
    3.21 -                                  SDL_WINDOW_RESIZABLE |
    3.22 -                                  SDL_WINDOW_MAXIMIZED |
    3.23 -                                  SDL_WINDOW_MINIMIZED |
    3.24 -                                  SDL_WINDOW_INPUT_GRABBED);
    3.25 +                                  SDL_WINDOW_RESIZABLE);
    3.26      SDL_VideoDisplay *display;
    3.27      SDL_Window window;
    3.28      int num_windows;
    3.29 @@ -739,9 +734,14 @@
    3.30          return 0;
    3.31      }
    3.32  
    3.33 +    /* Fullscreen windows don't have any window decorations */
    3.34 +    if (flags & SDL_WINDOW_FULLSCREEN) {
    3.35 +        flags |= SDL_WINDOW_BORDERLESS;
    3.36 +        flags &= ~SDL_WINDOW_RESIZABLE;
    3.37 +    }
    3.38 +
    3.39      SDL_zero(window);
    3.40      window.id = _this->next_object_id++;
    3.41 -    window.title = title ? SDL_strdup(title) : NULL;
    3.42      window.x = x;
    3.43      window.y = y;
    3.44      window.w = w;
    3.45 @@ -750,9 +750,6 @@
    3.46      window.display = _this->current_display;
    3.47  
    3.48      if (_this->CreateWindow && _this->CreateWindow(_this, &window) < 0) {
    3.49 -        if (window.title) {
    3.50 -            SDL_free(window.title);
    3.51 -        }
    3.52          return 0;
    3.53      }
    3.54  
    3.55 @@ -764,27 +761,27 @@
    3.56          if (_this->DestroyWindow) {
    3.57              _this->DestroyWindow(_this, &window);
    3.58          }
    3.59 -        if (window.title) {
    3.60 -            SDL_free(window.title);
    3.61 -        }
    3.62          return 0;
    3.63      }
    3.64      windows[num_windows] = window;
    3.65      display->windows = windows;
    3.66      display->num_windows++;
    3.67  
    3.68 -    if (FULLSCREEN_VISIBLE(&window)) {
    3.69 -        /* Hide any other fullscreen windows */
    3.70 -        int i;
    3.71 -        for (i = 0; i < display->num_windows; ++i) {
    3.72 -            SDL_Window *other = &display->windows[i];
    3.73 -            if (other->id != window.id && FULLSCREEN_VISIBLE(other)) {
    3.74 -                SDL_MinimizeWindow(other->id);
    3.75 -            }
    3.76 -        }
    3.77 -        SDL_SetDisplayMode(display->fullscreen_mode);
    3.78 +    if (title) {
    3.79 +        SDL_SetWindowTitle(window.id, title);
    3.80      }
    3.81 -
    3.82 +    if (flags & SDL_WINDOW_MAXIMIZED) {
    3.83 +        SDL_MaximizeWindow(window.id);
    3.84 +    }
    3.85 +    if (flags & SDL_WINDOW_MINIMIZED) {
    3.86 +        SDL_MinimizeWindow(window.id);
    3.87 +    }
    3.88 +    if (flags & SDL_WINDOW_SHOWN) {
    3.89 +        SDL_ShowWindow(window.id);
    3.90 +    }
    3.91 +    if (flags & SDL_WINDOW_INPUT_GRABBED) {
    3.92 +        SDL_SetWindowGrab(window.id, 1);
    3.93 +    }
    3.94      return window.id;
    3.95  }
    3.96  
    3.97 @@ -833,15 +830,44 @@
    3.98  int
    3.99  SDL_RecreateWindow(SDL_Window * window, Uint32 flags)
   3.100  {
   3.101 +    char *title = window->title;
   3.102 +
   3.103      if ((flags & SDL_WINDOW_OPENGL) && !_this->GL_CreateContext) {
   3.104          SDL_SetError("No OpenGL support in video driver");
   3.105          return -1;
   3.106      }
   3.107 +
   3.108      if (_this->DestroyWindow) {
   3.109          _this->DestroyWindow(_this, window);
   3.110      }
   3.111 -    window->flags = flags;
   3.112 -    return _this->CreateWindow(_this, window);
   3.113 +
   3.114 +    window->title = NULL;
   3.115 +    window->flags =
   3.116 +        (flags &
   3.117 +         ~(SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED | SDL_WINDOW_SHOWN |
   3.118 +           SDL_WINDOW_INPUT_GRABBED));
   3.119 +
   3.120 +    if (_this->CreateWindow && _this->CreateWindow(_this, window) < 0) {
   3.121 +        return -1;
   3.122 +    }
   3.123 +
   3.124 +    if (title) {
   3.125 +        SDL_SetWindowTitle(window->id, title);
   3.126 +        SDL_free(title);
   3.127 +    }
   3.128 +    if (flags & SDL_WINDOW_MAXIMIZED) {
   3.129 +        SDL_MaximizeWindow(window->id);
   3.130 +    }
   3.131 +    if (flags & SDL_WINDOW_MINIMIZED) {
   3.132 +        SDL_MinimizeWindow(window->id);
   3.133 +    }
   3.134 +    if (flags & SDL_WINDOW_SHOWN) {
   3.135 +        SDL_ShowWindow(window->id);
   3.136 +    }
   3.137 +    if (flags & SDL_WINDOW_INPUT_GRABBED) {
   3.138 +        SDL_SetWindowGrab(window->id, 1);
   3.139 +    }
   3.140 +    return 0;
   3.141  }
   3.142  
   3.143  SDL_Window *
   3.144 @@ -873,6 +899,9 @@
   3.145          SDL_UninitializedVideo();
   3.146          return NULL;
   3.147      }
   3.148 +    if (!window) {
   3.149 +        return NULL;
   3.150 +    }
   3.151      return &_this->displays[window->display];
   3.152  }
   3.153  
   3.154 @@ -891,14 +920,20 @@
   3.155  SDL_SetWindowTitle(SDL_WindowID windowID, const char *title)
   3.156  {
   3.157      SDL_Window *window = SDL_GetWindowFromID(windowID);
   3.158 +    const char *last_title;
   3.159  
   3.160 -    if (!window) {
   3.161 +    if (!window || title == window->title) {
   3.162          return;
   3.163      }
   3.164 +
   3.165      if (window->title) {
   3.166          SDL_free(window->title);
   3.167      }
   3.168 -    window->title = SDL_strdup(title);
   3.169 +    if (title) {
   3.170 +        window->title = SDL_strdup(title);
   3.171 +    } else {
   3.172 +        window->title = NULL;
   3.173 +    }
   3.174  
   3.175      if (_this->SetWindowTitle) {
   3.176          _this->SetWindowTitle(_this, window);
   3.177 @@ -942,15 +977,20 @@
   3.178  SDL_SetWindowPosition(SDL_WindowID windowID, int x, int y)
   3.179  {
   3.180      SDL_Window *window = SDL_GetWindowFromID(windowID);
   3.181 +    SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
   3.182  
   3.183      if (!window) {
   3.184          return;
   3.185      }
   3.186  
   3.187 -    if (x != SDL_WINDOWPOS_UNDEFINED) {
   3.188 +    if (x == SDL_WINDOWPOS_CENTERED) {
   3.189 +        window->x = (display->current_mode.w - window->w) / 2;
   3.190 +    } else if (x != SDL_WINDOWPOS_UNDEFINED) {
   3.191          window->x = x;
   3.192      }
   3.193 -    if (y != SDL_WINDOWPOS_UNDEFINED) {
   3.194 +    if (y == SDL_WINDOWPOS_CENTERED) {
   3.195 +        window->y = (display->current_mode.h - window->h) / 2;
   3.196 +    } else if (y != SDL_WINDOWPOS_UNDEFINED) {
   3.197          window->y = y;
   3.198      }
   3.199  
   3.200 @@ -1045,7 +1085,7 @@
   3.201  {
   3.202      SDL_Window *window = SDL_GetWindowFromID(windowID);
   3.203  
   3.204 -    if (!window) {
   3.205 +    if (!window || !(window->flags & SDL_WINDOW_SHOWN)) {
   3.206          return;
   3.207      }
   3.208  
     4.1 --- a/src/video/cocoa/SDL_cocoawindow.h	Sat Jul 29 03:57:55 2006 +0000
     4.2 +++ b/src/video/cocoa/SDL_cocoawindow.h	Sat Jul 29 21:51:00 2006 +0000
     4.3 @@ -55,8 +55,6 @@
     4.4  -(void) otherMouseUp:(NSEvent *) theEvent;
     4.5  -(void) mouseMoved:(NSEvent *) theEvent;
     4.6  -(void) scrollWheel:(NSEvent *) theEvent;
     4.7 --(void) mouseEntered:(NSEvent *) theEvent;
     4.8 --(void) mouseExited:(NSEvent *) theEvent;
     4.9  -(void) keyDown:(NSEvent *) theEvent;
    4.10  -(void) keyUp:(NSEvent *) theEvent;
    4.11  @end
     5.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Sat Jul 29 03:57:55 2006 +0000
     5.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Sat Jul 29 21:51:00 2006 +0000
     5.3 @@ -195,6 +195,7 @@
     5.4  
     5.5  - (void)mouseMoved:(NSEvent *)theEvent
     5.6  {
     5.7 +    SDL_Window *window = SDL_GetWindowFromID(_data->windowID);
     5.8      int index;
     5.9      SDL_Mouse *mouse;
    5.10      NSPoint point;
    5.11 @@ -207,6 +208,18 @@
    5.12      }
    5.13  
    5.14      point = [NSEvent mouseLocation];
    5.15 +    if (point.x < rect.origin.x ||
    5.16 +        point.x > (rect.origin.x + rect.size.width) ||
    5.17 +        point.y < rect.origin.y ||
    5.18 +        point.y > (rect.origin.y + rect.size.height)) {
    5.19 +        if (window->flags & SDL_WINDOW_MOUSE_FOCUS) {
    5.20 +            SDL_SendWindowEvent(_data->windowID, SDL_WINDOWEVENT_LEAVE, 0, 0);
    5.21 +        }
    5.22 +    } else {
    5.23 +        if (!(window->flags & SDL_WINDOW_MOUSE_FOCUS)) {
    5.24 +            SDL_SendWindowEvent(_data->windowID, SDL_WINDOWEVENT_ENTER, 0, 0);
    5.25 +        }
    5.26 +    }
    5.27      point.x = point.x - rect.origin.x;
    5.28      point.y = rect.size.height - (point.y - rect.origin.y);
    5.29      SDL_SendMouseMotion(index, 0, (int)point.x, (int)point.y);
    5.30 @@ -217,18 +230,6 @@
    5.31  fprintf(stderr, "scrollWheel\n");
    5.32  }
    5.33  
    5.34 -- (void)mouseEntered:(NSEvent *)theEvent
    5.35 -{
    5.36 -fprintf(stderr, "mouseEntered\n");
    5.37 -    SDL_SendWindowEvent(_data->windowID, SDL_WINDOWEVENT_ENTER, 0, 0);
    5.38 -}
    5.39 -
    5.40 -- (void)mouseExited:(NSEvent *)theEvent
    5.41 -{
    5.42 -fprintf(stderr, "mouseExited\n");
    5.43 -    SDL_SendWindowEvent(_data->windowID, SDL_WINDOWEVENT_LEAVE, 0, 0);
    5.44 -}
    5.45 -
    5.46  - (void)keyDown:(NSEvent *)theEvent
    5.47  {
    5.48  fprintf(stderr, "keyDown\n");
    5.49 @@ -282,7 +283,7 @@
    5.50      {
    5.51          unsigned int style = [nswindow styleMask];
    5.52  
    5.53 -        if (style == NSBorderlessWindowMask) {
    5.54 +        if ((style & ~NSResizableWindowMask) == NSBorderlessWindowMask) {
    5.55              window->flags |= SDL_WINDOW_BORDERLESS;
    5.56          } else {
    5.57              window->flags &= ~SDL_WINDOW_BORDERLESS;
    5.58 @@ -331,16 +332,14 @@
    5.59  
    5.60      pool = [[NSAutoreleasePool alloc] init];
    5.61  
    5.62 -    if ((window->flags & SDL_WINDOW_FULLSCREEN) ||
    5.63 -        window->x == SDL_WINDOWPOS_CENTERED) {
    5.64 +    if (window->x == SDL_WINDOWPOS_CENTERED) {
    5.65          rect.origin.x = (CGDisplayPixelsWide(kCGDirectMainDisplay) - window->w) / 2;
    5.66      } else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
    5.67          rect.origin.x = 0;
    5.68      } else {
    5.69          rect.origin.x = window->x;
    5.70      }
    5.71 -    if ((window->flags & SDL_WINDOW_FULLSCREEN) ||
    5.72 -        window->y == SDL_WINDOWPOS_CENTERED) {
    5.73 +    if (window->y == SDL_WINDOWPOS_CENTERED) {
    5.74          rect.origin.y = (CGDisplayPixelsHigh(kCGDirectMainDisplay) - window->h) / 2;
    5.75      } else if (window->y == SDL_WINDOWPOS_UNDEFINED) {
    5.76          rect.origin.y = 0;
    5.77 @@ -362,23 +361,6 @@
    5.78  
    5.79      nswindow = [[NSWindow alloc] initWithContentRect:rect styleMask:style backing:NSBackingStoreBuffered defer:FALSE];
    5.80  
    5.81 -    if (window->flags & SDL_WINDOW_SHOWN) {
    5.82 -        [nswindow makeKeyAndOrderFront:nil];
    5.83 -    }
    5.84 -    if (window->flags & SDL_WINDOW_MAXIMIZED) {
    5.85 -        [nswindow performZoom:nil];
    5.86 -    }
    5.87 -    if (window->flags & SDL_WINDOW_MINIMIZED) {
    5.88 -        [nswindow performMiniaturize:nil];
    5.89 -    }
    5.90 -
    5.91 -    if (window->title) {
    5.92 -        title = [[NSString alloc] initWithUTF8String:window->title];
    5.93 -        [nswindow setTitle:title];
    5.94 -        [nswindow setMiniwindowTitle:title];
    5.95 -        [title release];
    5.96 -    }
    5.97 -
    5.98      [pool release];
    5.99  
   5.100      if (SetupWindowData(_this, window, nswindow, SDL_TRUE) < 0) {
   5.101 @@ -424,10 +406,14 @@
   5.102      NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   5.103      NSString *string;
   5.104  
   5.105 -    string = [[NSString alloc] initWithUTF8String:window->title];
   5.106 +    if(window->title) {
   5.107 +        string = [[NSString alloc] initWithUTF8String:window->title];
   5.108 +    } else {
   5.109 +        string = [[NSString alloc] init];
   5.110 +    }
   5.111      [nswindow setTitle:string];
   5.112 -    [nswindow setMiniwindowTitle:string];
   5.113      [string release];
   5.114 +
   5.115      [pool release];
   5.116  }
   5.117  
   5.118 @@ -467,16 +453,20 @@
   5.119      NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   5.120      NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   5.121  
   5.122 -    [nswindow makeKeyAndOrderFront:nil];
   5.123 +    if (![nswindow isMiniaturized]) {
   5.124 +        [nswindow makeKeyAndOrderFront:nil];
   5.125 +    }
   5.126      [pool release];
   5.127  }
   5.128  
   5.129  void
   5.130  Cocoa_HideWindow(_THIS, SDL_Window * window)
   5.131  {
   5.132 +    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   5.133      NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   5.134  
   5.135 -    /* FIXME */
   5.136 +    [nswindow orderOut:nil];
   5.137 +    [pool release];
   5.138  }
   5.139  
   5.140  void
   5.141 @@ -495,7 +485,7 @@
   5.142      NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   5.143      NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   5.144  
   5.145 -    [nswindow performZoom:nil];
   5.146 +    [nswindow zoom:nil];
   5.147      [pool release];
   5.148  }
   5.149  
   5.150 @@ -505,16 +495,22 @@
   5.151      NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   5.152      NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   5.153  
   5.154 -    [nswindow performMiniaturize:nil];
   5.155 +    [nswindow miniaturize:nil];
   5.156      [pool release];
   5.157  }
   5.158  
   5.159  void
   5.160  Cocoa_RestoreWindow(_THIS, SDL_Window * window)
   5.161  {
   5.162 +    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   5.163      NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
   5.164  
   5.165 -    /* FIXME */
   5.166 +    if ([nswindow isMiniaturized]) {
   5.167 +        [nswindow deminiaturize:nil];
   5.168 +    } else if ([nswindow isZoomed]) {
   5.169 +        [nswindow zoom:nil];
   5.170 +    }
   5.171 +    [pool release];
   5.172  }
   5.173  
   5.174  void
     6.1 --- a/src/video/win32/SDL_win32window.c	Sat Jul 29 03:57:55 2006 +0000
     6.2 +++ b/src/video/win32/SDL_win32window.c	Sat Jul 29 21:51:00 2006 +0000
     6.3 @@ -133,23 +133,13 @@
     6.4  WIN_CreateWindow(_THIS, SDL_Window * window)
     6.5  {
     6.6      HWND hwnd;
     6.7 -    LPTSTR title = NULL;
     6.8      HWND top;
     6.9      RECT rect;
    6.10      DWORD style = (WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
    6.11      int x, y;
    6.12      int w, h;
    6.13  
    6.14 -    if (window->title) {
    6.15 -        title = WIN_UTF8ToString(window->title);
    6.16 -    } else {
    6.17 -        title = NULL;
    6.18 -    }
    6.19 -
    6.20 -    if (window->flags & SDL_WINDOW_SHOWN) {
    6.21 -        style |= WS_VISIBLE;
    6.22 -    }
    6.23 -    if ((window->flags & (SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS))) {
    6.24 +    if (window->flags & SDL_WINDOW_BORDERLESS) {
    6.25          style |= WS_POPUP;
    6.26      } else {
    6.27          style |= (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX);
    6.28 @@ -157,12 +147,6 @@
    6.29      if (window->flags & SDL_WINDOW_RESIZABLE) {
    6.30          style |= (WS_THICKFRAME | WS_MAXIMIZEBOX);
    6.31      }
    6.32 -    if (window->flags & SDL_WINDOW_MAXIMIZED) {
    6.33 -        style |= WS_MAXIMIZE;
    6.34 -    }
    6.35 -    if (window->flags & SDL_WINDOW_MINIMIZED) {
    6.36 -        style |= WS_MINIMIZE;
    6.37 -    }
    6.38  
    6.39      /* Figure out what the window area will be */
    6.40      if (window->flags & SDL_WINDOW_FULLSCREEN) {
    6.41 @@ -178,16 +162,14 @@
    6.42      w = (rect.right - rect.left);
    6.43      h = (rect.bottom - rect.top);
    6.44  
    6.45 -    if ((window->flags & SDL_WINDOW_FULLSCREEN) ||
    6.46 -        window->x == SDL_WINDOWPOS_CENTERED) {
    6.47 +    if (window->x == SDL_WINDOWPOS_CENTERED) {
    6.48          x = (GetSystemMetrics(SM_CXSCREEN) - w) / 2;
    6.49      } else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
    6.50          x = CW_USEDEFAULT;
    6.51      } else {
    6.52          x = window->x + rect.left;
    6.53      }
    6.54 -    if ((window->flags & SDL_WINDOW_FULLSCREEN) ||
    6.55 -        window->y == SDL_WINDOWPOS_CENTERED) {
    6.56 +    if (window->y == SDL_WINDOWPOS_CENTERED) {
    6.57          y = (GetSystemMetrics(SM_CYSCREEN) - h) / 2;
    6.58      } else if (window->y == SDL_WINDOWPOS_UNDEFINED) {
    6.59          y = CW_USEDEFAULT;
    6.60 @@ -195,15 +177,11 @@
    6.61          y = window->y + rect.top;
    6.62      }
    6.63  
    6.64 -    hwnd = CreateWindow(SDL_Appname,
    6.65 -                        title ? title : TEXT(""),
    6.66 -                        style, x, y, w, h, NULL, NULL, SDL_Instance, NULL);
    6.67 +    hwnd =
    6.68 +        CreateWindow(SDL_Appname, TEXT(""), style, x, y, w, h, NULL, NULL,
    6.69 +                     SDL_Instance, NULL);
    6.70      WIN_PumpEvents(_this);
    6.71  
    6.72 -    if (title) {
    6.73 -        SDL_free(title);
    6.74 -    }
    6.75 -
    6.76      if (!hwnd) {
    6.77          WIN_SetError("Couldn't create window");
    6.78          return -1;
    6.79 @@ -277,7 +255,6 @@
    6.80      DWORD style;
    6.81      HWND top;
    6.82      int x, y;
    6.83 -    int w, h;
    6.84  
    6.85      /* Figure out what the window area will be */
    6.86      if (window->flags & SDL_WINDOW_FULLSCREEN) {
    6.87 @@ -293,24 +270,10 @@
    6.88      AdjustWindowRectEx(&rect, style,
    6.89                         (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) !=
    6.90                                                             NULL), 0);
    6.91 -    w = (rect.right - rect.left);
    6.92 -    h = (rect.bottom - rect.top);
    6.93 +    x = window->x + rect.left;
    6.94 +    y = window->y + rect.top;
    6.95  
    6.96 -    if ((window->flags & SDL_WINDOW_FULLSCREEN) ||
    6.97 -        window->x == SDL_WINDOWPOS_CENTERED) {
    6.98 -        x = (GetSystemMetrics(SM_CXSCREEN) - w) / 2;
    6.99 -        window->x = x - rect.left;
   6.100 -    } else {
   6.101 -        x = window->x + rect.left;
   6.102 -    }
   6.103 -    if ((window->flags & SDL_WINDOW_FULLSCREEN) ||
   6.104 -        window->y == SDL_WINDOWPOS_CENTERED) {
   6.105 -        y = (GetSystemMetrics(SM_CYSCREEN) - h) / 2;
   6.106 -        window->y = y - rect.top;
   6.107 -    } else {
   6.108 -        y = window->y + rect.top;
   6.109 -    }
   6.110 -    SetWindowPos(hwnd, top, x, y, h, w, (SWP_NOCOPYBITS | SWP_NOSIZE));
   6.111 +    SetWindowPos(hwnd, top, x, y, 0, 0, (SWP_NOCOPYBITS | SWP_NOSIZE));
   6.112  }
   6.113  
   6.114  void
   6.115 @@ -438,8 +401,6 @@
   6.116      HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
   6.117      if (info->version.major <= SDL_MAJOR_VERSION) {
   6.118          info->window = hwnd;
   6.119 -        /* FIXME! */
   6.120 -        info->hglrc = NULL;
   6.121          return SDL_TRUE;
   6.122      } else {
   6.123          SDL_SetError("Application not compiled with SDL %d.%d\n",
     7.1 --- a/src/video/x11/SDL_x11opengl.c	Sat Jul 29 03:57:55 2006 +0000
     7.2 +++ b/src/video/x11/SDL_x11opengl.c	Sat Jul 29 21:51:00 2006 +0000
     7.3 @@ -113,8 +113,7 @@
     7.4      if (!_this->gl_data->glXChooseVisual ||
     7.5          !_this->gl_data->glXCreateContext ||
     7.6          !_this->gl_data->glXDestroyContext ||
     7.7 -        !_this->gl_data->glXMakeCurrent ||
     7.8 -        !_this->gl_data->glXSwapBuffers) {
     7.9 +        !_this->gl_data->glXMakeCurrent || !_this->gl_data->glXSwapBuffers) {
    7.10          SDL_SetError("Could not retrieve OpenGL functions");
    7.11          return -1;
    7.12      }
     8.1 --- a/src/video/x11/SDL_x11window.c	Sat Jul 29 03:57:55 2006 +0000
     8.2 +++ b/src/video/x11/SDL_x11window.c	Sat Jul 29 21:51:00 2006 +0000
     8.3 @@ -193,8 +193,7 @@
     8.4                              visual, AllocNone);
     8.5      }
     8.6  
     8.7 -    if ((window->flags & SDL_WINDOW_FULLSCREEN) ||
     8.8 -        window->x == SDL_WINDOWPOS_CENTERED) {
     8.9 +    if (window->x == SDL_WINDOWPOS_CENTERED) {
    8.10          x = (DisplayWidth(data->display, displaydata->screen) -
    8.11               window->w) / 2;
    8.12      } else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
    8.13 @@ -202,8 +201,7 @@
    8.14      } else {
    8.15          x = window->x;
    8.16      }
    8.17 -    if ((window->flags & SDL_WINDOW_FULLSCREEN) ||
    8.18 -        window->y == SDL_WINDOWPOS_CENTERED) {
    8.19 +    if (window->y == SDL_WINDOWPOS_CENTERED) {
    8.20          y = (DisplayHeight(data->display, displaydata->screen) -
    8.21               window->h) / 2;
    8.22      } else if (window->y == SDL_WINDOWPOS_UNDEFINED) {
    8.23 @@ -360,14 +358,7 @@
    8.24      wmhints = XAllocWMHints();
    8.25      if (wmhints) {
    8.26          wmhints->input = True;
    8.27 -        if (window->flags & SDL_WINDOW_MINIMIZED) {
    8.28 -            wmhints->initial_state = IconicState;
    8.29 -        } else if (window->flags & SDL_WINDOW_SHOWN) {
    8.30 -            wmhints->initial_state = NormalState;
    8.31 -        } else {
    8.32 -            wmhints->initial_state = WithdrawnState;
    8.33 -        }
    8.34 -        wmhints->flags = InputHint | StateHint;
    8.35 +        wmhints->flags = InputHint;
    8.36          XSetWMHints(data->display, w, wmhints);
    8.37          XFree(wmhints);
    8.38      }
    8.39 @@ -391,16 +382,6 @@
    8.40      /* Allow the window to be deleted by the window manager */
    8.41      XSetWMProtocols(data->display, w, &data->WM_DELETE_WINDOW, 1);
    8.42  
    8.43 -    /* Finally, show the window */
    8.44 -    if (window->flags & SDL_WINDOW_SHOWN) {
    8.45 -        XEvent event;
    8.46 -
    8.47 -        XMapRaised(data->display, w);
    8.48 -        do {
    8.49 -            XCheckWindowEvent(data->display, w, StructureNotifyMask, &event);
    8.50 -        } while (event.type != MapNotify);
    8.51 -    }
    8.52 -
    8.53      if (SetupWindowData(_this, window, w, SDL_TRUE) < 0) {
    8.54  #ifdef SDL_VIDEO_OPENGL_GLX
    8.55          if (window->flags & SDL_WINDOW_OPENGL) {
    8.56 @@ -410,9 +391,6 @@
    8.57          XDestroyWindow(data->display, w);
    8.58          return -1;
    8.59      }
    8.60 -
    8.61 -    X11_SetWindowTitle(_this, window);
    8.62 -
    8.63      return 0;
    8.64  }
    8.65  
    8.66 @@ -510,25 +488,8 @@
    8.67      SDL_DisplayData *displaydata =
    8.68          (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
    8.69      Display *display = data->videodata->display;
    8.70 -    int x, y;
    8.71  
    8.72 -    if ((window->flags & SDL_WINDOW_FULLSCREEN) ||
    8.73 -        window->x == SDL_WINDOWPOS_CENTERED) {
    8.74 -        x = (DisplayWidth(display, displaydata->screen) - window->w) / 2;
    8.75 -    } else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
    8.76 -        x = 0;
    8.77 -    } else {
    8.78 -        x = window->x;
    8.79 -    }
    8.80 -    if ((window->flags & SDL_WINDOW_FULLSCREEN) ||
    8.81 -        window->y == SDL_WINDOWPOS_CENTERED) {
    8.82 -        y = (DisplayHeight(display, displaydata->screen) - window->h) / 2;
    8.83 -    } else if (window->y == SDL_WINDOWPOS_UNDEFINED) {
    8.84 -        y = 0;
    8.85 -    } else {
    8.86 -        y = window->y;
    8.87 -    }
    8.88 -    XMoveWindow(display, data->window, x, y);
    8.89 +    XMoveWindow(display, data->window, window->x, window->y);
    8.90  }
    8.91  
    8.92  void