Commit 15a731ac authored by Sam Lantinga's avatar Sam Lantinga

The window positions are relative to the origin of the windowing system (upper...

The window positions are relative to the origin of the windowing system (upper left of the primary display).
Fixed the mouse positions for windowed mouse movement.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404248
parent 10bd98ff
...@@ -98,11 +98,10 @@ static __inline__ void ConvertNSRect(NSRect *r) ...@@ -98,11 +98,10 @@ static __inline__ void ConvertNSRect(NSRect *r)
- (void)windowDidMove:(NSNotification *)aNotification - (void)windowDidMove:(NSNotification *)aNotification
{ {
int x, y; int x, y;
NSRect disp = CGDisplayBounds(_data->display);
NSRect rect = [_data->window contentRectForFrameRect:[_data->window frame]]; NSRect rect = [_data->window contentRectForFrameRect:[_data->window frame]];
ConvertNSRect(&rect); ConvertNSRect(&rect);
x = (int)rect.origin.x - disp.origin.x; x = (int)rect.origin.x;
y = (int)rect.origin.y - disp.origin.y; y = (int)rect.origin.y;
SDL_SendWindowEvent(_data->windowID, SDL_WINDOWEVENT_MOVED, x, y); SDL_SendWindowEvent(_data->windowID, SDL_WINDOWEVENT_MOVED, x, y);
} }
...@@ -245,11 +244,11 @@ static __inline__ void ConvertNSRect(NSRect *r) ...@@ -245,11 +244,11 @@ static __inline__ void ConvertNSRect(NSRect *r)
point.x = point.x - rect.origin.x; point.x = point.x - rect.origin.x;
point.y = rect.size.height - point.y; point.y = rect.size.height - point.y;
} else { } else {
rect = [_data->window contentRectForFrameRect:[_data->window frame]]; point.x -= window->x;
point.y = rect.size.height - (point.y - rect.origin.y); point.y = CGDisplayPixelsHigh(kCGDirectMainDisplay) - point.y - window->y;
} }
if ( point.x < 0 || point.x >= rect.size.width || if ( point.x < 0 || point.x >= window->w ||
point.y < 0 || point.y >= rect.size.height ) { point.y < 0 || point.y >= window->h ) {
if (mouse->focus != 0) { if (mouse->focus != 0) {
SDL_SetMouseFocus(index, 0); SDL_SetMouseFocus(index, 0);
} }
...@@ -332,11 +331,10 @@ SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created ...@@ -332,11 +331,10 @@ 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 */
{ {
NSRect disp = CGDisplayBounds(data->display);
NSRect rect = [nswindow contentRectForFrameRect:[nswindow frame]]; NSRect rect = [nswindow contentRectForFrameRect:[nswindow frame]];
ConvertNSRect(&rect); ConvertNSRect(&rect);
window->x = (int)rect.origin.x - disp.origin.x; window->x = (int)rect.origin.x;
window->y = (int)rect.origin.y - disp.origin.y; window->y = (int)rect.origin.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;
} }
...@@ -401,13 +399,13 @@ Cocoa_CreateWindow(_THIS, SDL_Window * window) ...@@ -401,13 +399,13 @@ Cocoa_CreateWindow(_THIS, SDL_Window * window)
|| window->x == SDL_WINDOWPOS_CENTERED) { || window->x == SDL_WINDOWPOS_CENTERED) {
rect.origin.x += (rect.size.width - window->w) / 2; rect.origin.x += (rect.size.width - window->w) / 2;
} else if (window->x != SDL_WINDOWPOS_UNDEFINED) { } else if (window->x != SDL_WINDOWPOS_UNDEFINED) {
rect.origin.x += window->x; rect.origin.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 += (rect.size.height - window->h) / 2; rect.origin.y += (rect.size.height - window->h) / 2;
} else if (window->x != SDL_WINDOWPOS_UNDEFINED) { } else if (window->x != SDL_WINDOWPOS_UNDEFINED) {
rect.origin.y += window->y; rect.origin.y = window->y;
} }
rect.size.width = window->w; rect.size.width = window->w;
rect.size.height = window->h; rect.size.height = window->h;
...@@ -500,13 +498,13 @@ Cocoa_SetWindowPosition(_THIS, SDL_Window * window) ...@@ -500,13 +498,13 @@ Cocoa_SetWindowPosition(_THIS, SDL_Window * window)
|| window->x == SDL_WINDOWPOS_CENTERED) { || window->x == SDL_WINDOWPOS_CENTERED) {
rect.origin.x += (rect.size.width - window->w) / 2; rect.origin.x += (rect.size.width - window->w) / 2;
} else { } else {
rect.origin.x += window->x; rect.origin.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 += (rect.size.height - window->h) / 2; rect.origin.y += (rect.size.height - window->h) / 2;
} else { } else {
rect.origin.y += window->y; rect.origin.y = window->y;
} }
rect.size.width = window->w; rect.size.width = window->w;
rect.size.height = window->h; rect.size.height = window->h;
......
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