Merge branch 'master' into ios_support

This commit is contained in:
Carlos Aragones 2020-05-17 18:34:20 +02:00
commit 235dc1e670

View File

@ -44,9 +44,6 @@ create_window_data(unsigned width, unsigned height) {
window_data->specific = window_data_osx; window_data->specific = window_data_osx;
window_data->window_width = width;
window_data->window_height = height;
window_data->dst_width = width; window_data->dst_width = width;
window_data->dst_height = height; window_data->dst_height = height;
@ -82,16 +79,43 @@ mfb_open_ex(const char *title, unsigned width, unsigned height, unsigned flags)
[NSApplication sharedApplication]; [NSApplication sharedApplication];
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
NSWindowStyleMask styles = NSWindowStyleMaskClosable | NSWindowStyleMaskTitled; NSRect rectangle, frameRect;
NSWindowStyleMask styles = 0;
if (flags & WF_BORDERLESS) if (flags & WF_BORDERLESS) {
styles |= NSWindowStyleMaskBorderless; styles |= NSWindowStyleMaskBorderless;
}
else {
styles |= NSWindowStyleMaskClosable | NSWindowStyleMaskTitled;
}
if (flags & WF_RESIZABLE) if (flags & WF_RESIZABLE)
styles |= NSWindowStyleMaskResizable; styles |= NSWindowStyleMaskResizable;
NSRect rectangle = NSMakeRect(0, 0, width, height); if (flags & WF_FULLSCREEN) {
NSRect frameRect = [NSWindow frameRectForContentRect:rectangle styleMask:styles]; styles = NSWindowStyleMaskFullScreen;
NSScreen *mainScreen = [NSScreen mainScreen];
NSRect screenRect = [mainScreen frame];
window_data->window_width = screenRect.size.width;
window_data->window_height = screenRect.size.height;
rectangle = NSMakeRect(0, 0, window_data->window_width, window_data->window_height);
frameRect = rectangle;
}
else if (flags & WF_FULLSCREEN_DESKTOP) {
NSScreen *mainScreen = [NSScreen mainScreen];
NSRect screenRect = [mainScreen visibleFrame];
window_data->window_width = screenRect.size.width;
window_data->window_height = screenRect.size.height;
rectangle = NSMakeRect(0, 0, window_data->window_width, window_data->window_height);
frameRect = rectangle;
}
else {
window_data->window_width = width;
window_data->window_height = height;
rectangle = NSMakeRect(0, 0, window_data->window_width, window_data->window_height);
frameRect = [NSWindow frameRectForContentRect:rectangle styleMask:styles];
}
window_data_osx->window = [[OSXWindow alloc] initWithContentRect:frameRect styleMask:styles backing:NSBackingStoreBuffered defer:NO windowData:window_data]; window_data_osx->window = [[OSXWindow alloc] initWithContentRect:frameRect styleMask:styles backing:NSBackingStoreBuffered defer:NO windowData:window_data];
if (!window_data_osx->window) { if (!window_data_osx->window) {
NSLog(@"Cannot create window"); NSLog(@"Cannot create window");