Cocoa: Keep the window's screen position through SDL_SetWindowSize().
authorRyan C. Gordon <icculus@icculus.org>
Fri, 14 Aug 2015 01:20:41 -0400
changeset 9841 aa1321ce8425
parent 9840 bf7734a34f13
child 9842 8a89b58895c1
Cocoa: Keep the window's screen position through SDL_SetWindowSize(). The Y coordinate is flipped in Cocoa, so if you change the height, the window will move and maybe clip against the screen edge if you don't adjust its Y coordinate to match. Possibly fixes Bugzilla #3066.
src/video/cocoa/SDL_cocoawindow.m
--- a/src/video/cocoa/SDL_cocoawindow.m	Thu Aug 13 21:40:32 2015 -0400
+++ b/src/video/cocoa/SDL_cocoawindow.m	Fri Aug 14 01:20:41 2015 -0400
@@ -1288,11 +1288,13 @@
 {
     SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
     NSWindow *nswindow = windata->nswindow;
-    NSSize size;
 
-    size.width = window->w;
-    size.height = window->h;
-    [nswindow setContentSize:size];
+    NSRect frame = [nswindow frame];
+    frame.origin.y = (frame.origin.y + frame.size.height) - ((float) window->h);
+    frame.size.width = window->w;
+    frame.size.height = window->h;
+
+    [nswindow setFrame:frame display:YES];
 
     ScheduleContextUpdates(windata);
 }}