Commit 5c77d00a authored by Sam Lantinga's avatar Sam Lantinga

The window position is display relative, at least for now...

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404273
parent 712ccbd1
...@@ -298,7 +298,8 @@ SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created ...@@ -298,7 +298,8 @@ SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created
{ {
NSAutoreleasePool *pool; NSAutoreleasePool *pool;
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
SDL_DisplayData *displaydata = (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata; SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
SDL_DisplayData *displaydata = (SDL_DisplayData *) display->driverdata;
SDL_WindowData *data; SDL_WindowData *data;
/* Allocate the window data */ /* Allocate the window data */
...@@ -321,10 +322,12 @@ SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created ...@@ -321,10 +322,12 @@ SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created
/* Fill in the SDL window with the window data */ /* Fill in the SDL window with the window data */
{ {
SDL_Rect bounds;
NSRect rect = [nswindow contentRectForFrameRect:[nswindow frame]]; NSRect rect = [nswindow contentRectForFrameRect:[nswindow frame]];
ConvertNSRect(&rect); ConvertNSRect(&rect);
window->x = (int)rect.origin.x; Cocoa_GetDisplayBounds(_this, display, &bounds);
window->y = (int)rect.origin.y; window->x = (int)rect.origin.x - bounds.x;
window->y = (int)rect.origin.y - bounds.y;
window->w = (int)rect.size.width; window->w = (int)rect.size.width;
window->h = (int)rect.size.height; window->h = (int)rect.size.height;
} }
...@@ -392,7 +395,7 @@ Cocoa_CreateWindow(_THIS, SDL_Window * window) ...@@ -392,7 +395,7 @@ Cocoa_CreateWindow(_THIS, SDL_Window * window)
} else if (window->x == SDL_WINDOWPOS_UNDEFINED) { } else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
rect.origin.x = bounds.x; rect.origin.x = bounds.x;
} else { } else {
rect.origin.x = window->x; rect.origin.x = bounds.x + window->x;
} }
if ((window->flags & SDL_WINDOW_FULLSCREEN) if ((window->flags & SDL_WINDOW_FULLSCREEN)
|| window->y == SDL_WINDOWPOS_CENTERED) { || window->y == SDL_WINDOWPOS_CENTERED) {
...@@ -400,7 +403,7 @@ Cocoa_CreateWindow(_THIS, SDL_Window * window) ...@@ -400,7 +403,7 @@ Cocoa_CreateWindow(_THIS, SDL_Window * window)
} else if (window->x == SDL_WINDOWPOS_UNDEFINED) { } else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
rect.origin.y = bounds.y; rect.origin.y = bounds.y;
} else { } else {
rect.origin.y = window->y; rect.origin.y = bounds.y + window->y;
} }
rect.size.width = window->w; rect.size.width = window->w;
rect.size.height = window->h; rect.size.height = window->h;
...@@ -496,13 +499,13 @@ Cocoa_SetWindowPosition(_THIS, SDL_Window * window) ...@@ -496,13 +499,13 @@ Cocoa_SetWindowPosition(_THIS, SDL_Window * window)
|| window->x == SDL_WINDOWPOS_CENTERED) { || window->x == SDL_WINDOWPOS_CENTERED) {
rect.origin.x = bounds.x + (bounds.w - window->w) / 2; rect.origin.x = bounds.x + (bounds.w - window->w) / 2;
} else { } else {
rect.origin.x = window->x; rect.origin.x = bounds.x + window->x;
} }
if ((window->flags & SDL_WINDOW_FULLSCREEN) if ((window->flags & SDL_WINDOW_FULLSCREEN)
|| window->y == SDL_WINDOWPOS_CENTERED) { || window->y == SDL_WINDOWPOS_CENTERED) {
rect.origin.y = bounds.y + (bounds.h - window->h) / 2; rect.origin.y = bounds.y + (bounds.h - window->h) / 2;
} else { } else {
rect.origin.y = window->y; rect.origin.y = bounds.y + window->y;
} }
rect.size.width = window->w; rect.size.width = window->w;
rect.size.height = window->h; rect.size.height = window->h;
......
...@@ -86,6 +86,7 @@ static int ...@@ -86,6 +86,7 @@ static int
SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created) SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created)
{ {
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
SDL_WindowData *data; SDL_WindowData *data;
/* Allocate the window data */ /* Allocate the window data */
...@@ -123,8 +124,10 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created) ...@@ -123,8 +124,10 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created)
point.x = 0; point.x = 0;
point.y = 0; point.y = 0;
if (ClientToScreen(hwnd, &point)) { if (ClientToScreen(hwnd, &point)) {
window->x = point.x; SDL_Rect bounds;
window->y = point.y; WIN_GetDisplayBounds(_this, display, &bounds);
window->x = point.x - bounds.x;
window->y = point.y - bounds.y;
} }
} }
{ {
...@@ -232,7 +235,7 @@ WIN_CreateWindow(_THIS, SDL_Window * window) ...@@ -232,7 +235,7 @@ WIN_CreateWindow(_THIS, SDL_Window * window)
x = bounds.x; x = bounds.x;
} }
} else { } else {
x = window->x + rect.left; x = bounds.x + window->x + rect.left;
} }
if ((window->flags & SDL_WINDOW_FULLSCREEN) if ((window->flags & SDL_WINDOW_FULLSCREEN)
|| window->y == SDL_WINDOWPOS_CENTERED) { || window->y == SDL_WINDOWPOS_CENTERED) {
...@@ -244,7 +247,7 @@ WIN_CreateWindow(_THIS, SDL_Window * window) ...@@ -244,7 +247,7 @@ WIN_CreateWindow(_THIS, SDL_Window * window)
y = bounds.y; y = bounds.y;
} }
} else { } else {
y = window->y + rect.top; y = bounds.y + window->y + rect.top;
} }
hwnd = hwnd =
...@@ -459,13 +462,13 @@ WIN_SetWindowPosition(_THIS, SDL_Window * window) ...@@ -459,13 +462,13 @@ WIN_SetWindowPosition(_THIS, SDL_Window * window)
|| window->x == SDL_WINDOWPOS_CENTERED) { || window->x == SDL_WINDOWPOS_CENTERED) {
x = bounds.x + (bounds.w - window->w) / 2; x = bounds.x + (bounds.w - window->w) / 2;
} else { } else {
x = window->x + rect.left; x = bounds.x + window->x + rect.left;
} }
if ((window->flags & SDL_WINDOW_FULLSCREEN) if ((window->flags & SDL_WINDOW_FULLSCREEN)
|| window->y == SDL_WINDOWPOS_CENTERED) { || window->y == SDL_WINDOWPOS_CENTERED) {
y = bounds.y + (bounds.h - window->h) / 2; y = bounds.y + (bounds.h - window->h) / 2;
} else { } else {
y = window->y + rect.top; y = bounds.y + window->y + rect.top;
} }
SetWindowPos(hwnd, top, x, y, 0, 0, (SWP_NOCOPYBITS | SWP_NOSIZE)); SetWindowPos(hwnd, top, x, y, 0, 0, (SWP_NOCOPYBITS | SWP_NOSIZE));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment