Ensure global shortcuts are never sent to children

This was happening with ctrl+tab and ctrl+shift+tab because cocoa eats
these and so glfw has a workaround to always send them. If they are
added as global shortcuts, for exmaple for next/previous tab they were
then being sent to children
This commit is contained in:
Kovid Goyal
2021-02-28 21:42:57 +05:30
parent 3ee7e5f800
commit b811976018
2 changed files with 4 additions and 1 deletions

View File

@@ -168,6 +168,7 @@ class Boss:
set_boss(self)
self.opts, self.args = opts, args
self.keymap = self.opts.keymap.copy()
self.global_shortcuts_map = {v: KeyAction(k) for k, v in global_shortcuts.items()}
for sc in global_shortcuts.values():
self.keymap.pop(sc, None)
if is_macos:
@@ -668,6 +669,8 @@ class Boss:
self.pending_sequences = sequences
set_in_sequence_mode(True)
return True
if self.global_shortcuts_map and get_shortcut(self.global_shortcuts_map, ev):
return True
elif isinstance(key_action, KeyAction):
return self.dispatch_action(key_action)

View File

@@ -35,7 +35,7 @@ SequenceMap = Dict[SingleKey, SubSequenceMap]
class KeyAction(NamedTuple):
func: str
args: Sequence[str]
args: Sequence[str] = ()
func_with_args, args_funcs = key_func()