Fix shortcuts from global menubar not working when keyboard grabbed on macOS

This commit is contained in:
Kovid Goyal 2025-05-18 14:23:38 +05:30
parent abc9b1fc48
commit cc4d4eeaca
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C

View file

@ -17,6 +17,7 @@
SingleKey,
get_boss,
get_options,
grab_keyboard,
is_modifier_key,
ring_bell,
set_ignore_os_keyboard_processing,
@ -157,11 +158,14 @@ def dispatch_possible_special_key(self, ev: KeyEvent) -> bool:
is_root_mode = not self.keyboard_mode_stack
mode = self.keyboard_modes[''] if is_root_mode else self.keyboard_mode_stack[-1]
key_action = get_shortcut(mode.keymap, ev)
if key_action is None and self.global_shortcuts_map and (global_key_action := get_shortcut(self.global_shortcuts_map, ev)) is not None:
if grab_keyboard(None):
key_action = global_key_action
else:
return True
if key_action is None:
if is_modifier_key(ev.key):
return False
if self.global_shortcuts_map and get_shortcut(self.global_shortcuts_map, ev):
return True
if not is_root_mode:
if mode.sequence_keys is not None:
self.pop_keyboard_mode()