Change GetClientWidth/GetClientHeight on macOS to grab size from view.

Fix that GetClientWidth/Height returns 0 when queried before initial show.
Allow window to be resizable on macOS.
This commit is contained in:
Magnus Norddahl 2016-08-13 17:49:20 +02:00 committed by Christoph Oelckers
parent 647ef5d029
commit 4e38f31a86

View file

@ -169,7 +169,7 @@ namespace
const NSInteger LEVEL_WINDOWED = NSNormalWindowLevel;
const NSUInteger STYLE_MASK_FULLSCREEN = NSBorderlessWindowMask;
const NSUInteger STYLE_MASK_WINDOWED = NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask;
const NSUInteger STYLE_MASK_WINDOWED = NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask;
}
@ -1207,12 +1207,18 @@ void SDLGLFB::ResetGammaTable()
int SDLGLFB::GetClientWidth()
{
return static_cast<int>(rbOpts.width + 2.0f * rbOpts.shiftX);
NSView *view = [[NSOpenGLContext currentContext] view];
NSRect backingBounds = [view convertRectToBacking: [view bounds]];
int clientWidth = (int)backingBounds.size.width;
return clientWidth > 0 ? clientWidth : Width;
}
int SDLGLFB::GetClientHeight()
{
return static_cast<int>(rbOpts.height + 2.0f * rbOpts.shiftY);
NSView *view = [[NSOpenGLContext currentContext] view];
NSRect backingBounds = [view convertRectToBacking: [view bounds]];
int clientHeight = (int)backingBounds.size.height;
return clientHeight > 0 ? clientHeight : Height;
}