macOS: When checking for global shortcuts handle shifted form of cmd+`

This commit is contained in:
Kovid Goyal 2022-01-15 10:14:06 +05:30
parent c3c7ad78c1
commit 396906860d
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 15 additions and 2 deletions

View File

@ -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) {

View File

@ -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);

View File

@ -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;