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 9841aa1321ce8425
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
     1.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Thu Aug 13 21:40:32 2015 -0400
     1.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Fri Aug 14 01:20:41 2015 -0400
     1.3 @@ -1288,11 +1288,13 @@
     1.4  {
     1.5      SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
     1.6      NSWindow *nswindow = windata->nswindow;
     1.7 -    NSSize size;
     1.8  
     1.9 -    size.width = window->w;
    1.10 -    size.height = window->h;
    1.11 -    [nswindow setContentSize:size];
    1.12 +    NSRect frame = [nswindow frame];
    1.13 +    frame.origin.y = (frame.origin.y + frame.size.height) - ((float) window->h);
    1.14 +    frame.size.width = window->w;
    1.15 +    frame.size.height = window->h;
    1.16 +
    1.17 +    [nswindow setFrame:frame display:YES];
    1.18  
    1.19      ScheduleContextUpdates(windata);
    1.20  }}