diff --git a/glfw/cocoa_init.m b/glfw/cocoa_init.m index cd5a74a09..d2695fdd4 100644 --- a/glfw/cocoa_init.m +++ b/glfw/cocoa_init.m @@ -602,6 +602,18 @@ is_active_apple_global_shortcut(NSEvent *event) { snprintf(lookup_key, sizeof(lookup_key) - 1, "c:%lx:%ld", (unsigned long)modifierFlags, (long)ch); NSNumber *sc = global_shortcuts[@(lookup_key)]; if (sc != nil) return [sc intValue]; + if (modifierFlags & NSEventModifierFlagShift) { + // the move to next window shortcuts also respond to the same shortcut + shift so check for that + const uint32_t ch_without_shift = vk_to_unicode_key_with_current_layout([event keyCode]); + if (ch_without_shift < GLFW_FKEY_FIRST || ch_without_shift > GLFW_FKEY_LAST) { + snprintf(lookup_key, sizeof(lookup_key) - 1, "c:%lx:%ld", (unsigned long)(modifierFlags & ~NSEventModifierFlagShift), (long)ch_without_shift); + NSNumber *sc = global_shortcuts[@(lookup_key)]; + if (sc != nil) { + int scv = [sc intValue]; + if (scv == kSHKMoveFocusToActiveOrNextWindow || scv == kSHKMoveFocusToNextWindow) return scv; + } + } + } } unsigned short vk = [event keyCode]; if (vk != 0xffff) { diff --git a/glfw/cocoa_platform.h b/glfw/cocoa_platform.h index 7c84820b6..11b0bef59 100644 --- a/glfw/cocoa_platform.h +++ b/glfw/cocoa_platform.h @@ -249,3 +249,4 @@ void _glfwShutdownCVDisplayLink(unsigned long long, void*); void _glfwCocoaPostEmptyEvent(void); void _glfw_create_cv_display_link(_GLFWDisplayLinkNS *entry); _GLFWDisplayLinkNS* _glfw_create_display_link(CGDirectDisplayID); +uint32_t vk_to_unicode_key_with_current_layout(uint16_t keycode); diff --git a/glfw/cocoa_window.m b/glfw/cocoa_window.m index 52435c7e2..e8f58fbe7 100644 --- a/glfw/cocoa_window.m +++ b/glfw/cocoa_window.m @@ -259,7 +259,7 @@ is_pua_char(uint32_t ch) { return (0xE000 <= ch && ch <= 0xF8FF) || (0xF0000 <= ch && ch <= 0xFFFFF) || (0x100000 <= ch && ch <= 0x10FFFF); } -static uint32_t +uint32_t vk_to_unicode_key_with_current_layout(uint16_t keycode) { UInt32 dead_key_state = 0; @@ -736,7 +736,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; - (void)doCommandBySelector:(SEL)selector { // interpretKeyEvents: May call insertText: or doCommandBySelector:. - // With the default macOS keybindings, pressing certain key combinations + // With the default macOS keybindings, pressing certain key combinations // (e.g. Ctrl+/, Ctrl+Cmd+Down/Left/Right) will produce a beep sound. debug_key("\n\tTextInputCtx: doCommandBySelector: (%s)\n", [NSStringFromSelector(selector) UTF8String]); }