Added WF_FULLSCREEN_DESKTOP and WF_FULLSCREEN on macos x

This commit is contained in:
Carlos Aragones 2020-04-26 23:33:30 +02:00
parent 78efec66c5
commit 2b1d7633ae

View File

@ -133,9 +133,6 @@ mfb_open_ex(const char *title, unsigned width, unsigned height, unsigned flags)
memset(window_data_osx, 0, sizeof(SWindowData_OSX)); memset(window_data_osx, 0, sizeof(SWindowData_OSX));
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;
@ -158,16 +155,43 @@ mfb_open_ex(const char *title, unsigned width, unsigned height, unsigned flags)
} }
#endif #endif
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)
return 0x0; return 0x0;