Window coordinates are in the global space and windows are not tied to a particular display.
Also added Ctrl-Enter keybinding to the test code to toggle fullscreen mode for testing.
1.1 --- a/include/SDL_video.h Thu Feb 10 14:36:09 2011 -0800
1.2 +++ b/include/SDL_video.h Thu Feb 10 14:44:25 2011 -0800
1.3 @@ -113,12 +113,20 @@
1.4 /**
1.5 * \brief Used to indicate that you don't care what the window position is.
1.6 */
1.7 -#define SDL_WINDOWPOS_UNDEFINED 0x7FFFFFF
1.8 +#define SDL_WINDOWPOS_UNDEFINED_MASK 0x1FFF0000
1.9 +#define SDL_WINDOWPOS_UNDEFINED_DISPLAY(X) (SDL_WINDOWPOS_UNDEFINED_MASK|(X))
1.10 +#define SDL_WINDOWPOS_UNDEFINED SDL_WINDOWPOS_UNDEFINED_DISPLAY(0)
1.11 +#define SDL_WINDOWPOS_ISUNDEFINED(X) \
1.12 + (((X)&0xFFFF0000) == SDL_WINDOWPOS_UNDEFINED_MASK)
1.13
1.14 /**
1.15 * \brief Used to indicate that the window position should be centered.
1.16 */
1.17 -#define SDL_WINDOWPOS_CENTERED 0x7FFFFFE
1.18 +#define SDL_WINDOWPOS_CENTERED_MASK 0x2FFF0000
1.19 +#define SDL_WINDOWPOS_CENTERED_DISPLAY(X) (SDL_WINDOWPOS_CENTERED_MASK|(X))
1.20 +#define SDL_WINDOWPOS_CENTERED SDL_WINDOWPOS_CENTERED_DISPLAY(0)
1.21 +#define SDL_WINDOWPOS_ISCENTERED(X) \
1.22 + (((X)&0xFFFF0000) == SDL_WINDOWPOS_CENTERED_MASK)
1.23
1.24 /**
1.25 * \brief Event subtype for window events
1.26 @@ -304,6 +312,14 @@
1.27 extern DECLSPEC SDL_DisplayMode * SDLCALL SDL_GetClosestDisplayMode(int displayIndex, const SDL_DisplayMode * mode, SDL_DisplayMode * closest);
1.28
1.29 /**
1.30 + * \brief Get the display index associated with a window.
1.31 + *
1.32 + * \return the display index of the display containing the center of the
1.33 + * window, or -1 on error.
1.34 + */
1.35 +extern DECLSPEC int SDLCALL SDL_GetWindowDisplay(SDL_Window * window);
1.36 +
1.37 +/**
1.38 * \brief Set the display mode used when a fullscreen window is visible.
1.39 *
1.40 * By default the window's dimensions and the desktop format and refresh rate
1.41 @@ -531,7 +547,7 @@
1.42 * \sa SDL_GetWindowDisplayMode()
1.43 */
1.44 extern DECLSPEC int SDLCALL SDL_SetWindowFullscreen(SDL_Window * window,
1.45 - int fullscreen);
1.46 + SDL_bool fullscreen);
1.47
1.48 /**
1.49 * \brief Get an SDL surface associated with the window.
2.1 --- a/src/video/SDL_shape.c Thu Feb 10 14:36:09 2011 -0800
2.2 +++ b/src/video/SDL_shape.c Thu Feb 10 14:44:25 2011 -0800
2.3 @@ -35,7 +35,7 @@
2.4 SDL_Window *result = NULL;
2.5 result = SDL_CreateWindow(title,-1000,-1000,w,h,(flags | SDL_WINDOW_BORDERLESS) & (~SDL_WINDOW_FULLSCREEN) & (~SDL_WINDOW_RESIZABLE) /*& (~SDL_WINDOW_SHOWN)*/);
2.6 if(result != NULL) {
2.7 - result->shaper = result->display->device->shape_driver.CreateShaper(result);
2.8 + result->shaper = SDL_GetVideoDevice()->shape_driver.CreateShaper(result);
2.9 if(result->shaper != NULL) {
2.10 result->shaper->userx = x;
2.11 result->shaper->usery = y;
2.12 @@ -240,7 +240,7 @@
2.13
2.14 if(shape_mode != NULL)
2.15 window->shaper->mode = *shape_mode;
2.16 - result = window->display->device->shape_driver.SetWindowShape(window->shaper,shape,shape_mode);
2.17 + result = SDL_GetVideoDevice()->shape_driver.SetWindowShape(window->shaper,shape,shape_mode);
2.18 window->shaper->hasshape = SDL_TRUE;
2.19 if(window->shaper->userx != 0 && window->shaper->usery != 0) {
2.20 SDL_SetWindowPosition(window,window->shaper->userx,window->shaper->usery);
3.1 --- a/src/video/SDL_sysvideo.h Thu Feb 10 14:36:09 2011 -0800
3.2 +++ b/src/video/SDL_sysvideo.h Thu Feb 10 14:44:25 2011 -0800
3.3 @@ -76,8 +76,6 @@
3.4 int w, h;
3.5 Uint32 flags;
3.6
3.7 - SDL_VideoDisplay *display;
3.8 -
3.9 SDL_DisplayMode fullscreen_mode;
3.10
3.11 SDL_Surface *surface;
3.12 @@ -110,7 +108,6 @@
3.13 SDL_DisplayMode current_mode;
3.14 SDL_bool updating_fullscreen;
3.15
3.16 - SDL_Window *windows;
3.17 SDL_Window *fullscreen_window;
3.18
3.19 SDL_VideoDevice *device;
3.20 @@ -153,8 +150,7 @@
3.21 int (*GetDisplayBounds) (_THIS, SDL_VideoDisplay * display, SDL_Rect * rect);
3.22
3.23 /*
3.24 - * Get a list of the available display modes. e.g.
3.25 - * SDL_AddDisplayMode(_this->current_display, mode)
3.26 + * Get a list of the available display modes for a display.
3.27 */
3.28 void (*GetDisplayModes) (_THIS, SDL_VideoDisplay * display);
3.29
3.30 @@ -236,7 +232,7 @@
3.31 SDL_bool suspend_screensaver;
3.32 int num_displays;
3.33 SDL_VideoDisplay *displays;
3.34 - int current_display;
3.35 + SDL_Window *windows;
3.36 Uint8 window_magic;
3.37 Uint32 next_object_id;
3.38 char * clipboard_text;
3.39 @@ -326,6 +322,7 @@
3.40 extern int SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode);
3.41 extern int SDL_AddVideoDisplay(const SDL_VideoDisplay * display);
3.42 extern SDL_bool SDL_AddDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode * mode);
3.43 +extern SDL_VideoDisplay *SDL_GetDisplayForWindow(SDL_Window *window);
3.44
3.45 extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags);
3.46
4.1 --- a/src/video/SDL_video.c Thu Feb 10 14:36:09 2011 -0800
4.2 +++ b/src/video/SDL_video.c Thu Feb 10 14:44:25 2011 -0800
4.3 @@ -655,6 +655,12 @@
4.4 return SDL_TRUE;
4.5 }
4.6
4.7 +SDL_VideoDisplay *
4.8 +SDL_GetFirstDisplay(void)
4.9 +{
4.10 + return &_this->displays[0];
4.11 +}
4.12 +
4.13 static int
4.14 SDL_GetNumDisplayModesForDisplay(SDL_VideoDisplay * display)
4.15 {
4.16 @@ -893,6 +899,67 @@
4.17 }
4.18
4.19 int
4.20 +SDLCALL SDL_GetWindowDisplay(SDL_Window * window)
4.21 +{
4.22 + int displayIndex;
4.23 + int i, dist;
4.24 + int closest = -1;
4.25 + int closest_dist = 0x7FFFFFFF;
4.26 + SDL_Point center;
4.27 + SDL_Point delta;
4.28 + SDL_Rect rect;
4.29 +
4.30 + CHECK_WINDOW_MAGIC(window, -1);
4.31 +
4.32 + if (SDL_WINDOWPOS_ISUNDEFINED(window->x) ||
4.33 + SDL_WINDOWPOS_ISCENTERED(window->x)) {
4.34 + displayIndex = (window->x & 0xFFFF);
4.35 + if (displayIndex >= _this->num_displays) {
4.36 + displayIndex = 0;
4.37 + }
4.38 + return displayIndex;
4.39 + }
4.40 + if (SDL_WINDOWPOS_ISUNDEFINED(window->y) ||
4.41 + SDL_WINDOWPOS_ISCENTERED(window->y)) {
4.42 + displayIndex = (window->y & 0xFFFF);
4.43 + if (displayIndex >= _this->num_displays) {
4.44 + displayIndex = 0;
4.45 + }
4.46 + return displayIndex;
4.47 + }
4.48 +
4.49 + /* Find the display containing the window */
4.50 + center.x = window->x + window->w / 2;
4.51 + center.y = window->y + window->h / 2;
4.52 + for (i = 0; i < _this->num_displays; ++i) {
4.53 + SDL_VideoDisplay *display = &_this->displays[i];
4.54 +
4.55 + SDL_GetDisplayBounds(i, &rect);
4.56 + if (display->fullscreen_window == window || SDL_EnclosePoints(¢er, 1, &rect, NULL)) {
4.57 + return i;
4.58 + }
4.59 +
4.60 + delta.x = center.x - (rect.x + rect.w / 2);
4.61 + delta.y = center.y - (rect.y + rect.h / 2);
4.62 + dist = (delta.x*delta.x + delta.y*delta.y);
4.63 + if (dist < closest_dist) {
4.64 + closest = i;
4.65 + closest_dist = dist;
4.66 + }
4.67 + }
4.68 + if (closest < 0) {
4.69 + SDL_SetError("Couldn't find any displays");
4.70 + }
4.71 + return closest;
4.72 +}
4.73 +
4.74 +SDL_VideoDisplay *
4.75 +SDL_GetDisplayForWindow(SDL_Window *window)
4.76 +{
4.77 + return &_this->displays[SDL_GetWindowDisplay(window)];
4.78 +}
4.79 +
4.80 +int
4.81 SDL_SetWindowDisplayMode(SDL_Window * window, const SDL_DisplayMode * mode)
4.82 {
4.83 CHECK_WINDOW_MAGIC(window, -1);
4.84 @@ -920,7 +987,7 @@
4.85 fullscreen_mode.h = window->h;
4.86 }
4.87
4.88 - if (!SDL_GetClosestDisplayModeForDisplay(window->display,
4.89 + if (!SDL_GetClosestDisplayModeForDisplay(SDL_GetDisplayForWindow(window),
4.90 &fullscreen_mode,
4.91 &fullscreen_mode)) {
4.92 SDL_SetError("Couldn't find display mode match");
4.93 @@ -936,15 +1003,19 @@
4.94 Uint32
4.95 SDL_GetWindowPixelFormat(SDL_Window * window)
4.96 {
4.97 - SDL_VideoDisplay *display = window->display;
4.98 - SDL_DisplayMode *displayMode = &display->current_mode;
4.99 - return displayMode->format;
4.100 + SDL_VideoDisplay *display;
4.101 + SDL_DisplayMode *displayMode;
4.102 +
4.103 + CHECK_WINDOW_MAGIC(window, SDL_PIXELFORMAT_UNKNOWN);
4.104 +
4.105 + display = SDL_GetDisplayForWindow(window);
4.106 + return display->current_mode.format;
4.107 }
4.108
4.109 static void
4.110 SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool attempt)
4.111 {
4.112 - SDL_VideoDisplay *display = window->display;
4.113 + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
4.114
4.115 /* See if we're already processing a window */
4.116 if (display->updating_fullscreen) {
4.117 @@ -971,19 +1042,17 @@
4.118
4.119 if (FULLSCREEN_VISIBLE(window)) {
4.120 /* Hide any other fullscreen windows */
4.121 - SDL_Window *other;
4.122 - for (other = display->windows; other; other = other->next) {
4.123 - if (other != window && FULLSCREEN_VISIBLE(other)) {
4.124 - SDL_MinimizeWindow(other);
4.125 - }
4.126 + if (display->fullscreen_window != window) {
4.127 + SDL_MinimizeWindow(display->fullscreen_window);
4.128 }
4.129 }
4.130
4.131 display->updating_fullscreen = SDL_FALSE;
4.132
4.133 /* See if there are any fullscreen windows */
4.134 - for (window = display->windows; window; window = window->next) {
4.135 - if (FULLSCREEN_VISIBLE(window)) {
4.136 + for (window = _this->windows; window; window = window->next) {
4.137 + if (FULLSCREEN_VISIBLE(window) &&
4.138 + SDL_GetDisplayForWindow(window) == display) {
4.139 SDL_DisplayMode fullscreen_mode;
4.140 if (SDL_GetWindowDisplayMode(window, &fullscreen_mode) == 0) {
4.141 SDL_SetDisplayModeForDisplay(display, &fullscreen_mode);
4.142 @@ -1022,7 +1091,6 @@
4.143 }
4.144 SDL_GL_LoadLibrary(NULL);
4.145 }
4.146 - display = &_this->displays[0]; /* FIXME */
4.147 window = (SDL_Window *)SDL_calloc(1, sizeof(*window));
4.148 window->magic = &_this->window_magic;
4.149 window->id = _this->next_object_id++;
4.150 @@ -1031,12 +1099,11 @@
4.151 window->w = w;
4.152 window->h = h;
4.153 window->flags = (flags & allowed_flags);
4.154 - window->display = display;
4.155 - window->next = display->windows;
4.156 - if (display->windows) {
4.157 - display->windows->prev = window;
4.158 + window->next = _this->windows;
4.159 + if (_this->windows) {
4.160 + _this->windows->prev = window;
4.161 }
4.162 - display->windows = window;
4.163 + _this->windows = window;
4.164
4.165 if (_this->CreateWindow && _this->CreateWindow(_this, window) < 0) {
4.166 SDL_DestroyWindow(window);
4.167 @@ -1063,24 +1130,21 @@
4.168 SDL_Window *
4.169 SDL_CreateWindowFrom(const void *data)
4.170 {
4.171 - SDL_VideoDisplay *display;
4.172 SDL_Window *window;
4.173
4.174 if (!_this) {
4.175 SDL_UninitializedVideo();
4.176 return NULL;
4.177 }
4.178 - display = &_this->displays[0]; /* FIXME */
4.179 window = (SDL_Window *)SDL_calloc(1, sizeof(*window));
4.180 window->magic = &_this->window_magic;
4.181 window->id = _this->next_object_id++;
4.182 window->flags = SDL_WINDOW_FOREIGN;
4.183 - window->display = display;
4.184 - window->next = display->windows;
4.185 - if (display->windows) {
4.186 - display->windows->prev = window;
4.187 + window->next = _this->windows;
4.188 + if (_this->windows) {
4.189 + _this->windows->prev = window;
4.190 }
4.191 - display->windows = window;
4.192 + _this->windows = window;
4.193
4.194 if (!_this->CreateWindowFrom ||
4.195 _this->CreateWindowFrom(_this, window, data) < 0) {
4.196 @@ -1171,13 +1235,9 @@
4.197 if (!_this) {
4.198 return NULL;
4.199 }
4.200 - /* FIXME: Should we keep a separate hash table for these? */
4.201 - for (i = _this->num_displays; i--;) {
4.202 - SDL_VideoDisplay *display = &_this->displays[i];
4.203 - for (window = display->windows; window; window = window->next) {
4.204 - if (window->id == id) {
4.205 - return window;
4.206 - }
4.207 + for (window = _this->windows; window; window = window->next) {
4.208 + if (window->id == id) {
4.209 + return window;
4.210 }
4.211 }
4.212 return NULL;
4.213 @@ -1298,29 +1358,36 @@
4.214 if (y != SDL_WINDOWPOS_UNDEFINED) {
4.215 window->y = y;
4.216 }
4.217 - if (_this->SetWindowPosition) {
4.218 - _this->SetWindowPosition(_this, window);
4.219 + if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
4.220 + if (_this->SetWindowPosition) {
4.221 + _this->SetWindowPosition(_this, window);
4.222 + }
4.223 + SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MOVED, x, y);
4.224 }
4.225 - SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MOVED, x, y);
4.226 }
4.227
4.228 void
4.229 SDL_GetWindowPosition(SDL_Window * window, int *x, int *y)
4.230 {
4.231 - if (_this && window && window->magic == &_this->window_magic) {
4.232 + /* Clear the values */
4.233 + if (x) {
4.234 + *x = 0;
4.235 + }
4.236 + if (y) {
4.237 + *y = 0;
4.238 + }
4.239 +
4.240 + CHECK_WINDOW_MAGIC(window, );
4.241 +
4.242 + /* Fullscreen windows are always at their display's origin */
4.243 + if (window->flags & SDL_WINDOW_FULLSCREEN) {
4.244 + } else {
4.245 if (x) {
4.246 *x = window->x;
4.247 }
4.248 if (y) {
4.249 *y = window->y;
4.250 }
4.251 - } else {
4.252 - if (x) {
4.253 - *x = 0;
4.254 - }
4.255 - if (y) {
4.256 - *y = 0;
4.257 - }
4.258 }
4.259 }
4.260
4.261 @@ -1341,6 +1408,20 @@
4.262 void
4.263 SDL_GetWindowSize(SDL_Window * window, int *w, int *h)
4.264 {
4.265 + int dummy;
4.266 +
4.267 + if (!w) {
4.268 + w = &dummy;
4.269 + }
4.270 + if (!h) {
4.271 + h = &dummy;
4.272 + }
4.273 +
4.274 + *w = 0;
4.275 + *h = 0;
4.276 +
4.277 + CHECK_WINDOW_MAGIC(window, );
4.278 +
4.279 if (_this && window && window->magic == &_this->window_magic) {
4.280 if (w) {
4.281 *w = window->w;
4.282 @@ -1450,7 +1531,7 @@
4.283 }
4.284
4.285 int
4.286 -SDL_SetWindowFullscreen(SDL_Window * window, int fullscreen)
4.287 +SDL_SetWindowFullscreen(SDL_Window * window, SDL_bool fullscreen)
4.288 {
4.289 CHECK_WINDOW_MAGIC(window, -1);
4.290
4.291 @@ -1610,8 +1691,6 @@
4.292 void
4.293 SDL_OnWindowFocusGained(SDL_Window * window)
4.294 {
4.295 - SDL_VideoDisplay *display = window->display;
4.296 -
4.297 if ((window->flags & (SDL_WINDOW_INPUT_GRABBED | SDL_WINDOW_FULLSCREEN))
4.298 && _this->SetWindowGrab) {
4.299 _this->SetWindowGrab(_this, window);
4.300 @@ -1621,8 +1700,6 @@
4.301 void
4.302 SDL_OnWindowFocusLost(SDL_Window * window)
4.303 {
4.304 - SDL_VideoDisplay *display = window->display;
4.305 -
4.306 /* If we're fullscreen on a single-head system and lose focus, minimize */
4.307 if ((window->flags & SDL_WINDOW_FULLSCREEN) &&
4.308 _this->num_displays == 1) {
4.309 @@ -1638,14 +1715,12 @@
4.310 SDL_Window *
4.311 SDL_GetFocusWindow(void)
4.312 {
4.313 - SDL_VideoDisplay *display;
4.314 SDL_Window *window;
4.315
4.316 if (!_this) {
4.317 return NULL;
4.318 }
4.319 - display = &_this->displays[0]; /* FIXME */
4.320 - for (window = display->windows; window; window = window->next) {
4.321 + for (window = _this->windows; window; window = window->next) {
4.322 if (window->flags & SDL_WINDOW_INPUT_FOCUS) {
4.323 return window;
4.324 }
4.325 @@ -1677,6 +1752,11 @@
4.326 SDL_GL_UnloadLibrary();
4.327 }
4.328
4.329 + display = SDL_GetDisplayForWindow(window);
4.330 + if (display->fullscreen_window == window) {
4.331 + display->fullscreen_window = NULL;
4.332 + }
4.333 +
4.334 /* Now invalidate magic */
4.335 window->magic = NULL;
4.336
4.337 @@ -1693,14 +1773,13 @@
4.338 }
4.339
4.340 /* Unlink the window from the list */
4.341 - display = window->display;
4.342 if (window->next) {
4.343 window->next->prev = window->prev;
4.344 }
4.345 if (window->prev) {
4.346 window->prev->next = window->next;
4.347 } else {
4.348 - display->windows = window->next;
4.349 + _this->windows = window->next;
4.350 }
4.351
4.352 SDL_free(window);
4.353 @@ -1763,11 +1842,8 @@
4.354 SDL_EnableScreenSaver();
4.355
4.356 /* Clean up the system video */
4.357 - for (i = _this->num_displays; i--;) {
4.358 - SDL_VideoDisplay *display = &_this->displays[i];
4.359 - while (display->windows) {
4.360 - SDL_DestroyWindow(display->windows);
4.361 - }
4.362 + while (_this->windows) {
4.363 + SDL_DestroyWindow(_this->windows);
4.364 }
4.365 _this->VideoQuit(_this);
4.366
5.1 --- a/src/video/cocoa/SDL_cocoaopengl.m Thu Feb 10 14:36:09 2011 -0800
5.2 +++ b/src/video/cocoa/SDL_cocoaopengl.m Thu Feb 10 14:44:25 2011 -0800
5.3 @@ -72,7 +72,7 @@
5.4 Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
5.5 {
5.6 NSAutoreleasePool *pool;
5.7 - SDL_VideoDisplay *display = window->display;
5.8 + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
5.9 SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata;
5.10 NSOpenGLPixelFormatAttribute attr[32];
5.11 NSOpenGLPixelFormat *fmt;
6.1 --- a/src/video/cocoa/SDL_cocoawindow.h Thu Feb 10 14:36:09 2011 -0800
6.2 +++ b/src/video/cocoa/SDL_cocoawindow.h Thu Feb 10 14:44:25 2011 -0800
6.3 @@ -86,7 +86,6 @@
6.4 SDL_Window *window;
6.5 NSWindow *nswindow;
6.6 SDL_bool created;
6.7 - CGDirectDisplayID display;
6.8 Cocoa_WindowListener *listener;
6.9 struct SDL_VideoData *videodata;
6.10 };
7.1 --- a/src/video/cocoa/SDL_cocoawindow.m Thu Feb 10 14:36:09 2011 -0800
7.2 +++ b/src/video/cocoa/SDL_cocoawindow.m Thu Feb 10 14:44:25 2011 -0800
7.3 @@ -403,8 +403,6 @@
7.4 {
7.5 NSAutoreleasePool *pool;
7.6 SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
7.7 - SDL_VideoDisplay *display = window->display;
7.8 - SDL_DisplayData *displaydata = (SDL_DisplayData *) display->driverdata;
7.9 SDL_WindowData *data;
7.10
7.11 /* Allocate the window data */
7.12 @@ -416,7 +414,6 @@
7.13 data->window = window;
7.14 data->nswindow = nswindow;
7.15 data->created = created;
7.16 - data->display = displaydata->display;
7.17 data->videodata = videodata;
7.18
7.19 pool = [[NSAutoreleasePool alloc] init];
7.20 @@ -438,9 +435,8 @@
7.21 [contentView release];
7.22
7.23 ConvertNSRect(&rect);
7.24 - Cocoa_GetDisplayBounds(_this, display, &bounds);
7.25 - window->x = (int)rect.origin.x - bounds.x;
7.26 - window->y = (int)rect.origin.y - bounds.y;
7.27 + window->x = (int)rect.origin.x;
7.28 + window->y = (int)rect.origin.y;
7.29 window->w = (int)rect.size.width;
7.30 window->h = (int)rect.size.height;
7.31 }
7.32 @@ -493,27 +489,27 @@
7.33 {
7.34 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
7.35 NSWindow *nswindow;
7.36 - SDL_VideoDisplay *display = window->display;
7.37 + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
7.38 NSRect rect;
7.39 SDL_Rect bounds;
7.40 unsigned int style;
7.41
7.42 Cocoa_GetDisplayBounds(_this, display, &bounds);
7.43 if ((window->flags & SDL_WINDOW_FULLSCREEN)
7.44 - || window->x == SDL_WINDOWPOS_CENTERED) {
7.45 + || SDL_WINDOWPOS_ISCENTERED(window->x)) {
7.46 rect.origin.x = bounds.x + (bounds.w - window->w) / 2;
7.47 - } else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
7.48 + } else if (SDL_WINDOWPOS_ISUNDEFINED(window->x)) {
7.49 rect.origin.x = bounds.x;
7.50 } else {
7.51 - rect.origin.x = bounds.x + window->x;
7.52 + rect.origin.x = window->x;
7.53 }
7.54 if ((window->flags & SDL_WINDOW_FULLSCREEN)
7.55 - || window->y == SDL_WINDOWPOS_CENTERED) {
7.56 + || SDL_WINDOWPOS_ISCENTERED(window->y)) {
7.57 rect.origin.y = bounds.y + (bounds.h - window->h) / 2;
7.58 - } else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
7.59 + } else if (SDL_WINDOWPOS_ISUNDEFINED(window->y)) {
7.60 rect.origin.y = bounds.y;
7.61 } else {
7.62 - rect.origin.y = bounds.y + window->y;
7.63 + rect.origin.y = window->y;
7.64 }
7.65 rect.size.width = window->w;
7.66 rect.size.height = window->h;
7.67 @@ -599,22 +595,22 @@
7.68 {
7.69 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
7.70 NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
7.71 - SDL_VideoDisplay *display = window->display;
7.72 + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
7.73 NSRect rect;
7.74 SDL_Rect bounds;
7.75
7.76 Cocoa_GetDisplayBounds(_this, display, &bounds);
7.77 if ((window->flags & SDL_WINDOW_FULLSCREEN)
7.78 - || window->x == SDL_WINDOWPOS_CENTERED) {
7.79 + || SDL_WINDOWPOS_ISCENTERED(window->x)) {
7.80 rect.origin.x = bounds.x + (bounds.w - window->w) / 2;
7.81 } else {
7.82 - rect.origin.x = bounds.x + window->x;
7.83 + rect.origin.x = window->x;
7.84 }
7.85 if ((window->flags & SDL_WINDOW_FULLSCREEN)
7.86 - || window->y == SDL_WINDOWPOS_CENTERED) {
7.87 + || SDL_WINDOWPOS_ISCENTERED(window->y)) {
7.88 rect.origin.y = bounds.y + (bounds.h - window->h) / 2;
7.89 } else {
7.90 - rect.origin.y = bounds.y + window->y;
7.91 + rect.origin.y = window->y;
7.92 }
7.93 rect.size.width = window->w;
7.94 rect.size.height = window->h;
8.1 --- a/src/video/directfb/SDL_DirectFB_modes.c Thu Feb 10 14:36:09 2011 -0800
8.2 +++ b/src/video/directfb/SDL_DirectFB_modes.c Thu Feb 10 14:44:25 2011 -0800
8.3 @@ -135,7 +135,7 @@
8.4 * This has simply no effect.
8.5 */
8.6
8.7 - SDL_VideoDisplay *display = window->display;
8.8 + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
8.9 DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata;
8.10
8.11 /* FIXME: should we handle the error */
9.1 --- a/src/video/directfb/SDL_DirectFB_mouse.c Thu Feb 10 14:36:09 2011 -0800
9.2 +++ b/src/video/directfb/SDL_DirectFB_mouse.c Thu Feb 10 14:44:25 2011 -0800
9.3 @@ -170,7 +170,7 @@
9.4 if (!window)
9.5 return -1;
9.6 else {
9.7 - SDL_VideoDisplay *display = window->display;
9.8 + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
9.9
9.10 if (display) {
9.11 DFB_DisplayData *dispdata =
9.12 @@ -222,7 +222,7 @@
9.13 static void
9.14 DirectFB_WarpMouse(SDL_Mouse * mouse, SDL_Window * window, int x, int y)
9.15 {
9.16 - SDL_VideoDisplay *display = window->display;
9.17 + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
9.18 DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata;
9.19 DFB_WindowData *windata = (DFB_WindowData *) window->driverdata;
9.20 DFBResult ret;
10.1 --- a/src/video/directfb/SDL_DirectFB_render.c Thu Feb 10 14:36:09 2011 -0800
10.2 +++ b/src/video/directfb/SDL_DirectFB_render.c Thu Feb 10 14:44:25 2011 -0800
10.3 @@ -301,7 +301,7 @@
10.4 DirectFB_CreateRenderer(SDL_Window * window, Uint32 flags)
10.5 {
10.6 SDL_DFB_WINDOWDATA(window);
10.7 - SDL_VideoDisplay *display = window->display;
10.8 + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
10.9 SDL_Renderer *renderer = NULL;
10.10 DirectFB_RenderData *data = NULL;
10.11 DFBSurfaceCapabilities scaps;
10.12 @@ -409,7 +409,7 @@
10.13 {
10.14 //SDL_DFB_RENDERERDATA(renderer);
10.15 SDL_Window *window = renderer->window;
10.16 - SDL_VideoDisplay *display = window->display;
10.17 + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
10.18 SDL_DFB_DEVICEDATA(display->device);
10.19 DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata;
10.20 DirectFB_TextureData *data = texture->driverdata;
10.21 @@ -465,7 +465,7 @@
10.22 DirectFB_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
10.23 {
10.24 SDL_Window *window = renderer->window;
10.25 - SDL_VideoDisplay *display = window->display;
10.26 + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
10.27 SDL_DFB_DEVICEDATA(display->device);
10.28 DirectFB_TextureData *data;
10.29 DFBSurfaceDescription dsc;
10.30 @@ -1129,7 +1129,7 @@
10.31 DirectFB_DestroyRenderer(SDL_Renderer * renderer)
10.32 {
10.33 DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
10.34 - SDL_VideoDisplay *display = renderer->window->display;
10.35 + SDL_VideoDisplay *display = renderer->SDL_GetDisplayForWindow(window);
10.36
10.37 #if 0
10.38 if (display->palette) {
11.1 --- a/src/video/directfb/SDL_DirectFB_window.c Thu Feb 10 14:36:09 2011 -0800
11.2 +++ b/src/video/directfb/SDL_DirectFB_window.c Thu Feb 10 14:44:25 2011 -0800
11.3 @@ -62,17 +62,17 @@
11.4 bshaped = 1;
11.5
11.6 /* Fill the window description. */
11.7 - if (window->x == SDL_WINDOWPOS_CENTERED) {
11.8 + if (SDL_WINDOWPOS_ISCENTERED(window->x)) {
11.9 x = (dispdata->cw - window->w) / 2;
11.10 - } else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
11.11 + } else if (SDL_WINDOWPOS_ISUNDEFINED(window->x)) {
11.12 x = 0;
11.13 } else {
11.14 x = window->x;
11.15 }
11.16
11.17 - if (window->y == SDL_WINDOWPOS_CENTERED) {
11.18 + if (SDL_WINDOWPOS_ISCENTERED(window->y)) {
11.19 y = (dispdata->ch - window->h) / 2;
11.20 - } else if (window->y == SDL_WINDOWPOS_UNDEFINED) {
11.21 + } else if (SDL_WINDOWPOS_ISUNDEFINED(window->y)) {
11.22 y = 0;
11.23 } else {
11.24 y = window->y;
11.25 @@ -264,17 +264,17 @@
11.26 SDL_DFB_DISPLAYDATA(window);
11.27 int x, y;
11.28
11.29 - if (window->x == SDL_WINDOWPOS_CENTERED) {
11.30 + if (SDL_WINDOWPOS_ISCENTERED(window->x)) {
11.31 x = (dispdata->cw - window->w) / 2;
11.32 - } else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
11.33 + } else if (SDL_WINDOWPOS_ISUNDEFINED(window->x)) {
11.34 x = 0;
11.35 } else {
11.36 x = window->x;
11.37 }
11.38
11.39 - if (window->y == SDL_WINDOWPOS_CENTERED) {
11.40 + if (SDL_WINDOWPOS_ISCENTERED(window->y)) {
11.41 y = (dispdata->ch - window->h) / 2;
11.42 - } else if (window->y == SDL_WINDOWPOS_UNDEFINED) {
11.43 + } else if (SDL_WINDOWPOS_ISUNDEFINED(window->y)) {
11.44 y = 0;
11.45 } else {
11.46 y = window->y;
11.47 @@ -358,7 +358,7 @@
11.48 DirectFB_MaximizeWindow(_THIS, SDL_Window * window)
11.49 {
11.50 SDL_DFB_WINDOWDATA(window);
11.51 - SDL_VideoDisplay *display = window->display;
11.52 + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
11.53 DFBWindowOptions wopts;
11.54
11.55 SDL_DFB_CHECK(windata->dfbwin->GetPosition(windata->dfbwin,
11.56 @@ -526,7 +526,7 @@
11.57
11.58 if (adjust) {
11.59 #if SDL_DIRECTFB_OPENGL
11.60 - DirectFB_GL_FreeWindowContexts(window->display->device, window);
11.61 + DirectFB_GL_FreeWindowContexts(SDL_GetVideoDevice(), window);
11.62 #endif
11.63
11.64 #if (DFB_VERSION_ATLEAST(1,2,1))
11.65 @@ -552,10 +552,10 @@
11.66 GetSubSurface(windata->window_surface,
11.67 &windata->client, &windata->surface));
11.68 #endif
11.69 - DirectFB_WM_RedrawLayout(window->display->device, window);
11.70 + DirectFB_WM_RedrawLayout(SDL_GetVideoDevice(), window);
11.71
11.72 #if SDL_DIRECTFB_OPENGL
11.73 - DirectFB_GL_ReAllocWindowContexts(window->display->device, window);
11.74 + DirectFB_GL_ReAllocWindowContexts(SDL_GetVideoDevice(), window);
11.75 #endif
11.76 }
11.77 error:
12.1 --- a/src/video/nds/SDL_ndsrender.c Thu Feb 10 14:36:09 2011 -0800
12.2 +++ b/src/video/nds/SDL_ndsrender.c Thu Feb 10 14:44:25 2011 -0800
12.3 @@ -107,7 +107,7 @@
12.4 SDL_Renderer *
12.5 NDS_CreateRenderer(SDL_Window * window, Uint32 flags)
12.6 {
12.7 - SDL_VideoDisplay *display = window->display;
12.8 + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
12.9 SDL_DisplayMode *displayMode = &display->current_mode;
12.10 SDL_Renderer *renderer;
12.11 NDS_RenderData *data;
12.12 @@ -462,7 +462,7 @@
12.13 NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
12.14 NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
12.15 SDL_Window *window = renderer->window;
12.16 - SDL_VideoDisplay *display = window->display;
12.17 + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
12.18 int Bpp = SDL_BYTESPERPIXEL(texture->format);
12.19
12.20 if (txdat->type == NDSTX_BG) {
12.21 @@ -487,7 +487,7 @@
12.22 {
12.23 NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
12.24 SDL_Window *window = renderer->window;
12.25 - SDL_VideoDisplay *display = window->display;
12.26 + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
12.27
12.28 /* update sprites */
12.29 // NDS_OAM_Update(&(data->oam_copy), data->sub);
13.1 --- a/src/video/pandora/SDL_pandora.c Thu Feb 10 14:36:09 2011 -0800
13.2 +++ b/src/video/pandora/SDL_pandora.c Thu Feb 10 14:44:25 2011 -0800
13.3 @@ -417,7 +417,7 @@
13.4 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
13.5 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
13.6 SDL_DisplayData *didata =
13.7 - (SDL_DisplayData *) window->display->driverdata;
13.8 + (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata;
13.9 EGLBoolean status;
13.10 int32_t gfstatus;
13.11 EGLint configs;
13.12 @@ -816,7 +816,7 @@
13.13 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
13.14 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
13.15 SDL_DisplayData *didata =
13.16 - (SDL_DisplayData *) window->display->driverdata;
13.17 + (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata;
13.18
13.19
13.20 if (phdata->egl_initialized != SDL_TRUE) {
14.1 --- a/src/video/uikit/SDL_uikitopengles.m Thu Feb 10 14:36:09 2011 -0800
14.2 +++ b/src/video/uikit/SDL_uikitopengles.m Thu Feb 10 14:44:25 2011 -0800
14.3 @@ -103,7 +103,7 @@
14.4 {
14.5 SDL_uikitopenglview *view;
14.6 SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
14.7 - UIScreen *uiscreen = (UIScreen *) window->display->driverdata;
14.8 + UIScreen *uiscreen = (UIScreen *) SDL_GetDisplayForWindow(window)->driverdata;
14.9 UIWindow *uiwindow = data->uiwindow;
14.10
14.11 /* construct our view, passing in SDL's OpenGL configuration data */
15.1 --- a/src/video/uikit/SDL_uikitwindow.m Thu Feb 10 14:36:09 2011 -0800
15.2 +++ b/src/video/uikit/SDL_uikitwindow.m Thu Feb 10 14:44:25 2011 -0800
15.3 @@ -40,7 +40,7 @@
15.4
15.5 static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bool created)
15.6 {
15.7 - SDL_VideoDisplay *display = window->display;
15.8 + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
15.9 UIScreen *uiscreen = (UIScreen *) display->driverdata;
15.10 SDL_WindowData *data;
15.11
15.12 @@ -85,9 +85,9 @@
15.13 }
15.14
15.15 int
15.16 -UIKit_CreateWindow(_THIS, SDL_Window *window) {
15.17 -
15.18 - SDL_VideoDisplay *display = window->display;
15.19 +UIKit_CreateWindow(_THIS, SDL_Window *window)
15.20 +{
15.21 + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
15.22 UIScreen *uiscreen = (UIScreen *) display->driverdata;
15.23
15.24 // SDL currently puts this window at the start of display's linked list. We rely on this.
16.1 --- a/src/video/windows/SDL_windowswindow.c Thu Feb 10 14:36:09 2011 -0800
16.2 +++ b/src/video/windows/SDL_windowswindow.c Thu Feb 10 14:44:25 2011 -0800
16.3 @@ -46,7 +46,7 @@
16.4 SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created)
16.5 {
16.6 SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
16.7 - SDL_VideoDisplay *display = window->display;
16.8 + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
16.9 SDL_WindowData *data;
16.10
16.11 /* Allocate the window data */
16.12 @@ -93,10 +93,8 @@
16.13 point.x = 0;
16.14 point.y = 0;
16.15 if (ClientToScreen(hwnd, &point)) {
16.16 - SDL_Rect bounds;
16.17 - WIN_GetDisplayBounds(_this, display, &bounds);
16.18 - window->x = point.x - bounds.x;
16.19 - window->y = point.y - bounds.y;
16.20 + window->x = point.x;
16.21 + window->y = point.y;
16.22 }
16.23 }
16.24 {
16.25 @@ -166,7 +164,7 @@
16.26 int
16.27 WIN_CreateWindow(_THIS, SDL_Window * window)
16.28 {
16.29 - SDL_VideoDisplay *display = window->display;
16.30 + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
16.31 HWND hwnd;
16.32 RECT rect;
16.33 SDL_Rect bounds;
16.34 @@ -203,28 +201,28 @@
16.35 }
16.36 }
16.37 if ((window->flags & SDL_WINDOW_FULLSCREEN)
16.38 - || window->x == SDL_WINDOWPOS_CENTERED) {
16.39 + || SDL_WINDOWPOS_ISCENTERED(window->x)) {
16.40 x = bounds.x + (bounds.w - w) / 2;
16.41 - } else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
16.42 + } else if (SDL_WINDOWPOS_ISUNDEFINED(window->x)) {
16.43 if (bounds.x == 0) {
16.44 x = CW_USEDEFAULT;
16.45 } else {
16.46 x = bounds.x;
16.47 }
16.48 } else {
16.49 - x = bounds.x + window->x + rect.left;
16.50 + x = window->x + rect.left;
16.51 }
16.52 if ((window->flags & SDL_WINDOW_FULLSCREEN)
16.53 - || window->y == SDL_WINDOWPOS_CENTERED) {
16.54 + || SDL_WINDOWPOS_ISCENTERED(window->y)) {
16.55 y = bounds.y + (bounds.h - h) / 2;
16.56 - } else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
16.57 + } else if (SDL_WINDOWPOS_ISUNDEFINED(window->x)) {
16.58 if (bounds.x == 0) {
16.59 y = CW_USEDEFAULT;
16.60 } else {
16.61 y = bounds.y;
16.62 }
16.63 } else {
16.64 - y = bounds.y + window->y + rect.top;
16.65 + y = window->y + rect.top;
16.66 }
16.67
16.68 hwnd =
16.69 @@ -366,7 +364,7 @@
16.70 void
16.71 WIN_SetWindowPosition(_THIS, SDL_Window * window)
16.72 {
16.73 - SDL_VideoDisplay *display = window->display;
16.74 + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
16.75 HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
16.76 RECT rect;
16.77 SDL_Rect bounds;
16.78 @@ -406,16 +404,16 @@
16.79 }
16.80 }
16.81 if ((window->flags & SDL_WINDOW_FULLSCREEN)
16.82 - || window->x == SDL_WINDOWPOS_CENTERED) {
16.83 + || SDL_WINDOWPOS_ISCENTERED(window->x)) {
16.84 x = bounds.x + (bounds.w - w) / 2;
16.85 } else {
16.86 - x = bounds.x + window->x + rect.left;
16.87 + x = window->x + rect.left;
16.88 }
16.89 if ((window->flags & SDL_WINDOW_FULLSCREEN)
16.90 - || window->y == SDL_WINDOWPOS_CENTERED) {
16.91 + || SDL_WINDOWPOS_ISCENTERED(window->y)) {
16.92 y = bounds.y + (bounds.h - h) / 2;
16.93 } else {
16.94 - y = bounds.y + window->y + rect.top;
16.95 + y = window->y + rect.top;
16.96 }
16.97
16.98 SetWindowPos(hwnd, top, x, y, 0, 0, (SWP_NOCOPYBITS | SWP_NOSIZE));
16.99 @@ -452,35 +450,35 @@
16.100 h = (rect.bottom - rect.top);
16.101
16.102 SetWindowPos(hwnd, top, 0, 0, w, h, (SWP_NOCOPYBITS | SWP_NOMOVE));
16.103 -}
16.104 +}
16.105 +
16.106 +#ifdef _WIN32_WCE
16.107 +void WINCE_ShowWindow(_THIS, SDL_Window* window, int visible)
16.108 +{
16.109 + SDL_WindowData* windowdata = (SDL_WindowData*) window->driverdata;
16.110 + SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
16.111 +
16.112 + if(visible) {
16.113 + if(window->flags & SDL_WINDOW_FULLSCREEN) {
16.114 + if(videodata->SHFullScreen)
16.115 + videodata->SHFullScreen(windowdata->hwnd, SHFS_HIDETASKBAR | SHFS_HIDESTARTICON | SHFS_HIDESIPBUTTON);
16.116
16.117 -#ifdef _WIN32_WCE
16.118 -void WINCE_ShowWindow(_THIS, SDL_Window* window, int visible)
16.119 -{
16.120 - SDL_WindowData* windowdata = (SDL_WindowData*) window->driverdata;
16.121 - SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
16.122 -
16.123 - if(visible) {
16.124 - if(window->flags & SDL_WINDOW_FULLSCREEN) {
16.125 - if(videodata->SHFullScreen)
16.126 - videodata->SHFullScreen(windowdata->hwnd, SHFS_HIDETASKBAR | SHFS_HIDESTARTICON | SHFS_HIDESIPBUTTON);
16.127 -
16.128 - ShowWindow(FindWindow(TEXT("HHTaskBar"), NULL), SW_HIDE);
16.129 - }
16.130 -
16.131 - ShowWindow(windowdata->hwnd, SW_SHOW);
16.132 - SetForegroundWindow(windowdata->hwnd);
16.133 - } else {
16.134 - ShowWindow(windowdata->hwnd, SW_HIDE);
16.135 -
16.136 - if(window->flags & SDL_WINDOW_FULLSCREEN) {
16.137 - if(videodata->SHFullScreen)
16.138 - videodata->SHFullScreen(windowdata->hwnd, SHFS_SHOWTASKBAR | SHFS_SHOWSTARTICON | SHFS_SHOWSIPBUTTON);
16.139 -
16.140 - ShowWindow(FindWindow(TEXT("HHTaskBar"), NULL), SW_SHOW);
16.141 -
16.142 - }
16.143 - }
16.144 + ShowWindow(FindWindow(TEXT("HHTaskBar"), NULL), SW_HIDE);
16.145 + }
16.146 +
16.147 + ShowWindow(windowdata->hwnd, SW_SHOW);
16.148 + SetForegroundWindow(windowdata->hwnd);
16.149 + } else {
16.150 + ShowWindow(windowdata->hwnd, SW_HIDE);
16.151 +
16.152 + if(window->flags & SDL_WINDOW_FULLSCREEN) {
16.153 + if(videodata->SHFullScreen)
16.154 + videodata->SHFullScreen(windowdata->hwnd, SHFS_SHOWTASKBAR | SHFS_SHOWSTARTICON | SHFS_SHOWSIPBUTTON);
16.155 +
16.156 + ShowWindow(FindWindow(TEXT("HHTaskBar"), NULL), SW_SHOW);
16.157 +
16.158 + }
16.159 + }
16.160 }
16.161 #endif /* _WIN32_WCE */
16.162
17.1 --- a/src/video/x11/SDL_x11clipboard.c Thu Feb 10 14:36:09 2011 -0800
17.2 +++ b/src/video/x11/SDL_x11clipboard.c Thu Feb 10 14:44:25 2011 -0800
17.3 @@ -38,15 +38,11 @@
17.4 static Window
17.5 GetWindow(_THIS)
17.6 {
17.7 - SDL_VideoDisplay *display;
17.8 SDL_Window *window;
17.9
17.10 - display = _this->displays;
17.11 - if (display) {
17.12 - window = display->windows;
17.13 - if (window) {
17.14 - return ((SDL_WindowData *) window->driverdata)->xwindow;
17.15 - }
17.16 + window = _this->windows;
17.17 + if (window) {
17.18 + return ((SDL_WindowData *) window->driverdata)->xwindow;
17.19 }
17.20 return None;
17.21 }
18.1 --- a/src/video/x11/SDL_x11opengl.c Thu Feb 10 14:36:09 2011 -0800
18.2 +++ b/src/video/x11/SDL_x11opengl.c Thu Feb 10 14:44:25 2011 -0800
18.3 @@ -380,7 +380,7 @@
18.4 SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
18.5 Display *display = data->videodata->display;
18.6 int screen =
18.7 - ((SDL_DisplayData *) window->display->driverdata)->screen;
18.8 + ((SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata)->screen;
18.9 XWindowAttributes xattr;
18.10 XVisualInfo v, *vinfo;
18.11 int n;
19.1 --- a/src/video/x11/SDL_x11window.c Thu Feb 10 14:36:09 2011 -0800
19.2 +++ b/src/video/x11/SDL_x11window.c Thu Feb 10 14:44:25 2011 -0800
19.3 @@ -90,7 +90,7 @@
19.4 {
19.5 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
19.6 SDL_DisplayData *displaydata =
19.7 - (SDL_DisplayData *) window->display->driverdata;
19.8 + (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata;
19.9 XWindowAttributes attr;
19.10
19.11 XGetWindowAttributes(data->display, RootWindow(data->display, displaydata->screen), &attr);
19.12 @@ -259,7 +259,7 @@
19.13 {
19.14 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
19.15 SDL_DisplayData *displaydata =
19.16 - (SDL_DisplayData *) window->display->driverdata;
19.17 + (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata;
19.18 Display *display = data->display;
19.19 int screen = displaydata->screen;
19.20 Visual *visual;
19.21 @@ -328,19 +328,19 @@
19.22 xattr.colormap = XCreateColormap(display, RootWindow(display, screen), visual, AllocNone);
19.23
19.24 if (oldstyle_fullscreen
19.25 - || window->x == SDL_WINDOWPOS_CENTERED) {
19.26 + || SDL_WINDOWPOS_ISCENTERED(window->x)) {
19.27 X11_GetDisplaySize(_this, window, &x, NULL);
19.28 x = (x - window->w) / 2;
19.29 - } else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
19.30 + } else if (SDL_WINDOWPOS_ISUNDEFINED(window->x)) {
19.31 x = 0;
19.32 } else {
19.33 x = window->x;
19.34 }
19.35 if (oldstyle_fullscreen
19.36 - || window->y == SDL_WINDOWPOS_CENTERED) {
19.37 + || SDL_WINDOWPOS_ISCENTERED(window->y)) {
19.38 X11_GetDisplaySize(_this, window, NULL, &y);
19.39 y = (y - window->h) / 2;
19.40 - } else if (window->y == SDL_WINDOWPOS_UNDEFINED) {
19.41 + } else if (SDL_WINDOWPOS_ISUNDEFINED(window->y)) {
19.42 y = 0;
19.43 } else {
19.44 y = window->y;
19.45 @@ -377,8 +377,8 @@
19.46 sizehints->flags = PMaxSize | PMinSize;
19.47 }
19.48 if (!oldstyle_fullscreen
19.49 - && window->x != SDL_WINDOWPOS_UNDEFINED
19.50 - && window->y != SDL_WINDOWPOS_UNDEFINED) {
19.51 + && !SDL_WINDOWPOS_ISUNDEFINED(window->x)
19.52 + && !SDL_WINDOWPOS_ISUNDEFINED(window->y)) {
19.53 sizehints->x = x;
19.54 sizehints->y = y;
19.55 sizehints->flags |= USPosition;
19.56 @@ -713,14 +713,14 @@
19.57 oldstyle_fullscreen = X11_IsWindowOldFullscreen(_this, window);
19.58
19.59 if (oldstyle_fullscreen
19.60 - || window->x == SDL_WINDOWPOS_CENTERED) {
19.61 + || SDL_WINDOWPOS_ISCENTERED(window->x)) {
19.62 X11_GetDisplaySize(_this, window, &x, NULL);
19.63 x = (x - window->w) / 2;
19.64 } else {
19.65 x = window->x;
19.66 }
19.67 if (oldstyle_fullscreen
19.68 - || window->y == SDL_WINDOWPOS_CENTERED) {
19.69 + || SDL_WINDOWPOS_ISCENTERED(window->y)) {
19.70 X11_GetDisplaySize(_this, window, NULL, &y);
19.71 y = (y - window->h) / 2;
19.72 } else {
19.73 @@ -777,7 +777,7 @@
19.74 {
19.75 SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
19.76 SDL_DisplayData *displaydata =
19.77 - (SDL_DisplayData *) window->display->driverdata;
19.78 + (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata;
19.79 Display *display = data->videodata->display;
19.80 Atom _NET_WM_STATE = data->videodata->_NET_WM_STATE;
19.81 Atom _NET_WM_STATE_MAXIMIZED_VERT = data->videodata->_NET_WM_STATE_MAXIMIZED_VERT;
19.82 @@ -832,7 +832,7 @@
19.83 {
19.84 SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
19.85 SDL_DisplayData *displaydata =
19.86 - (SDL_DisplayData *) window->display->driverdata;
19.87 + (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata;
19.88 Display *display = data->videodata->display;
19.89
19.90 XIconifyWindow(display, data->xwindow, displaydata->screen);
20.1 --- a/test/common.c Thu Feb 10 14:36:09 2011 -0800
20.2 +++ b/test/common.c Thu Feb 10 14:44:25 2011 -0800
20.3 @@ -1015,12 +1015,14 @@
20.4 case SDLK_m:
20.5 if (event->key.keysym.mod & KMOD_CTRL) {
20.6 /* Ctrl-M maximize */
20.7 - /* FIXME: Which window has focus for this keyboard? */
20.8 for (i = 0; i < state->num_windows; ++i) {
20.9 - if (SDL_GetWindowFlags(state->windows[i]) & SDL_WINDOW_MAXIMIZED) {
20.10 - SDL_RestoreWindow(state->windows[i]);
20.11 - } else {
20.12 - SDL_MaximizeWindow(state->windows[i]);
20.13 + Uint32 flags = SDL_GetWindowFlags(state->windows[i]);
20.14 + if (flags & SDL_WINDOW_INPUT_FOCUS) {
20.15 + if (flags & SDL_WINDOW_MAXIMIZED) {
20.16 + SDL_RestoreWindow(state->windows[i]);
20.17 + } else {
20.18 + SDL_MaximizeWindow(state->windows[i]);
20.19 + }
20.20 }
20.21 }
20.22 }
20.23 @@ -1028,9 +1030,26 @@
20.24 case SDLK_z:
20.25 if (event->key.keysym.mod & KMOD_CTRL) {
20.26 /* Ctrl-Z minimize */
20.27 - /* FIXME: Which window has focus for this keyboard? */
20.28 for (i = 0; i < state->num_windows; ++i) {
20.29 - SDL_MinimizeWindow(state->windows[i]);
20.30 + Uint32 flags = SDL_GetWindowFlags(state->windows[i]);
20.31 + if (flags & SDL_WINDOW_INPUT_FOCUS) {
20.32 + SDL_MinimizeWindow(state->windows[i]);
20.33 + }
20.34 + }
20.35 + }
20.36 + break;
20.37 + case SDLK_RETURN:
20.38 + if (event->key.keysym.mod & KMOD_CTRL) {
20.39 + /* Ctrl-Enter toggle fullscreen */
20.40 + for (i = 0; i < state->num_windows; ++i) {
20.41 + Uint32 flags = SDL_GetWindowFlags(state->windows[i]);
20.42 + if (flags & SDL_WINDOW_INPUT_FOCUS) {
20.43 + if (flags & SDL_WINDOW_FULLSCREEN) {
20.44 + SDL_SetWindowFullscreen(state->windows[i], SDL_FALSE);
20.45 + } else {
20.46 + SDL_SetWindowFullscreen(state->windows[i], SDL_TRUE);
20.47 + }
20.48 + }
20.49 }
20.50 }
20.51 break;
21.1 --- a/test/testwm2.c Thu Feb 10 14:36:09 2011 -0800
21.2 +++ b/test/testwm2.c Thu Feb 10 14:44:25 2011 -0800
21.3 @@ -49,6 +49,19 @@
21.4 /* Check for events */
21.5 while (SDL_PollEvent(&event)) {
21.6 CommonEvent(state, &event, &done);
21.7 +
21.8 + if (event.type == SDL_WINDOWEVENT) {
21.9 + if (event.window.event == SDL_WINDOWEVENT_MOVED) {
21.10 + SDL_Window *window = SDL_GetWindowFromID(event.window.windowID);
21.11 + if (window) {
21.12 + printf("Window %d moved to %d,%d (display %d)\n",
21.13 + event.window.windowID,
21.14 + event.window.data1,
21.15 + event.window.data2,
21.16 + SDL_GetWindowDisplay(window));
21.17 + }
21.18 + }
21.19 + }
21.20 }
21.21 }
21.22 quit(0);