mirror of https://github.com/encounter/SDL.git
Mac: Fixed SDL_SetWindowSize to set the size of the content area of the window, rather than the total size including decorations.
This commit is contained in:
parent
c964ac91bf
commit
6a32ca7a39
|
@ -1288,13 +1288,23 @@ Cocoa_SetWindowSize(_THIS, SDL_Window * window)
|
||||||
{
|
{
|
||||||
SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
|
SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
|
||||||
NSWindow *nswindow = windata->nswindow;
|
NSWindow *nswindow = windata->nswindow;
|
||||||
|
NSRect rect;
|
||||||
|
Uint32 moveHack;
|
||||||
|
|
||||||
NSRect frame = [nswindow frame];
|
/* Cocoa will resize the window from the bottom-left rather than the
|
||||||
frame.origin.y = (frame.origin.y + frame.size.height) - ((float) window->h);
|
* top-left when -[nswindow setContentSize:] is used, so we must set the
|
||||||
frame.size.width = window->w;
|
* entire frame based on the new size, in order to preserve the position.
|
||||||
frame.size.height = window->h;
|
*/
|
||||||
|
rect.origin.x = window->x;
|
||||||
|
rect.origin.y = window->y;
|
||||||
|
rect.size.width = window->w;
|
||||||
|
rect.size.height = window->h;
|
||||||
|
ConvertNSRect([nswindow screen], (window->flags & FULLSCREEN_MASK), &rect);
|
||||||
|
|
||||||
[nswindow setFrame:frame display:YES];
|
moveHack = s_moveHack;
|
||||||
|
s_moveHack = 0;
|
||||||
|
[nswindow setFrame:[nswindow frameRectForContentRect:rect] display:YES];
|
||||||
|
s_moveHack = moveHack;
|
||||||
|
|
||||||
ScheduleContextUpdates(windata);
|
ScheduleContextUpdates(windata);
|
||||||
}}
|
}}
|
||||||
|
|
Loading…
Reference in New Issue