From 2a32a783a738bd3499c146d242b807e33a111b4e Mon Sep 17 00:00:00 2001 From: IntellectualKitty Date: Sat, 5 Nov 2016 17:23:55 -0600 Subject: [PATCH] Command-tabbing fix for OS X. --- src/cocoa_window.m | 56 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 3 deletions(-) diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 41c7dbd5c..876e713b5 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -1249,12 +1249,30 @@ void _glfwPlatformMaximizeWindow(_GLFWwindow* window) void _glfwPlatformShowWindow(_GLFWwindow* window) { - [window->ns.object orderFront:nil]; + if (window->monitor) + { + [window->ns.object makeKeyAndOrderFront:window->ns.object]; + + NSApplicationPresentationOptions options = + NSApplicationPresentationHideDock + + NSApplicationPresentationHideMenuBar + + NSApplicationPresentationDisableProcessSwitching + + NSApplicationPresentationDisableHideApplication; + [NSApp setPresentationOptions:options]; + } + else + { + [window->ns.object orderFront:window->ns.object]; + + NSApplicationPresentationOptions options = + NSApplicationPresentationDefault; + [NSApp setPresentationOptions:options]; + } } void _glfwPlatformHideWindow(_GLFWwindow* window) { - [window->ns.object orderOut:nil]; + [window->ns.object orderOut:window->ns.object]; } void _glfwPlatformFocusWindow(_GLFWwindow* window) @@ -1265,7 +1283,23 @@ void _glfwPlatformFocusWindow(_GLFWwindow* window) // should probably not be done every time any window is shown [NSApp activateIgnoringOtherApps:YES]; - [window->ns.object makeKeyAndOrderFront:nil]; + [window->ns.object makeKeyAndOrderFront:window->ns.object]; + + if (window->monitor) + { + NSApplicationPresentationOptions options = + NSApplicationPresentationHideDock + + NSApplicationPresentationHideMenuBar + + NSApplicationPresentationDisableProcessSwitching + + NSApplicationPresentationDisableHideApplication; + [NSApp setPresentationOptions:options]; + } + else + { + NSApplicationPresentationOptions options = + NSApplicationPresentationDefault; + [NSApp setPresentationOptions:options]; + } } void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, @@ -1363,6 +1397,22 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, [window->ns.object setHasShadow:YES]; } + + if (window->monitor) + { + NSApplicationPresentationOptions options = + NSApplicationPresentationHideDock + + NSApplicationPresentationHideMenuBar + + NSApplicationPresentationDisableProcessSwitching + + NSApplicationPresentationDisableHideApplication; + [NSApp setPresentationOptions:options]; + } + else + { + NSApplicationPresentationOptions options = + NSApplicationPresentationDefault; + [NSApp setPresentationOptions:options]; + } } int _glfwPlatformWindowFocused(_GLFWwindow* window)