macOS: Make full screening of kitty much faster by using the "traditional full screen" mode of cocoa, similar to iTerm and MacVim

Hopefully workaround a bug in glfw that causes crashes when unplugging
monitors with full screen windows.

Fixes #911
Fixes #898
This commit is contained in:
Kovid Goyal
2018-09-12 15:45:08 +05:30
parent 21d586cc86
commit ec1f219850
8 changed files with 122 additions and 26 deletions

View File

@@ -224,6 +224,24 @@ cocoa_focus_window(void *w) {
[window makeKeyWindow];
}
bool
cocoa_toggle_fullscreen(void *w) {
NSWindow *window = (NSWindow*)w;
NSWindowStyleMask sm = [window styleMask];
bool made_fullscreen;
if (!(sm & NSWindowStyleMaskFullScreen)) {
made_fullscreen = true;
sm |= NSWindowStyleMaskBorderless | NSWindowStyleMaskFullScreen;
[[NSApplication sharedApplication] setPresentationOptions: NSApplicationPresentationAutoHideMenuBar | NSApplicationPresentationAutoHideDock];
} else {
made_fullscreen = false;
sm &= ~(NSWindowStyleMaskBorderless | NSWindowStyleMaskFullScreen);
[[NSApplication sharedApplication] setPresentationOptions: NSApplicationPresentationDefault];
}
[window setStyleMask: sm];
return made_fullscreen;
}
static PyObject*
cocoa_get_lang(PyObject UNUSED *self) {
NSString* locale = nil;