From f36a10c448232a2eae0e42c81d3bdab36feaae77 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 18 Jan 2012 22:22:54 -0500 Subject: [PATCH] Fixed bug 1372 - OSX Window Maximize/Resize Doesn't Update Window Position Alex Nankervis 2012-01-15 14:20:01 PST SDL_cocoawindow.m, windowDidResize needs to also send a window move event. Depending on the corner you resize a window from, or when maximizing a window, the window position will change. Discovered this when creating a maximized window and found that the window position was stuck at the un-maximized window's value. Diff with fix attached. --- src/video/cocoa/SDL_cocoawindow.m | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m index 16f4b7d8c..b48de4f94 100755 --- a/src/video/cocoa/SDL_cocoawindow.m +++ b/src/video/cocoa/SDL_cocoawindow.m @@ -153,8 +153,11 @@ static __inline__ void ConvertNSRect(NSRect *r) - (void)windowDidResize:(NSNotification *)aNotification { SDL_VideoDevice *device = SDL_GetVideoDevice(); - int w, h; + int x, y, w, h; NSRect rect = [_data->nswindow contentRectForFrameRect:[_data->nswindow frame]]; + ConvertNSRect(&rect); + x = (int)rect.origin.x; + y = (int)rect.origin.y; w = (int)rect.size.width; h = (int)rect.size.height; if (SDL_IsShapedWindow(_data->window)) @@ -164,6 +167,9 @@ static __inline__ void ConvertNSRect(NSRect *r) [((NSOpenGLContext *) device->current_glctx) update]; } + /* The window can move during a resize event, such as when maximizing + or resizing from a corner */ + SDL_SendWindowEvent(_data->window, SDL_WINDOWEVENT_MOVED, x, y); SDL_SendWindowEvent(_data->window, SDL_WINDOWEVENT_RESIZED, w, h); }