apprt/gtk: handle global actions with chains

This commit is contained in:
Mitchell Hashimoto
2025-12-22 13:19:09 -08:00
parent 442146cf9f
commit 578b4c284b

View File

@@ -169,13 +169,16 @@ pub const GlobalShortcuts = extern struct {
var trigger_buf: [1024]u8 = undefined;
var it = config.keybind.set.bindings.iterator();
while (it.next()) |entry| {
const leaf = switch (entry.value_ptr.*) {
// Global shortcuts can't have leaders
const leaf: Binding.Set.GenericLeaf = switch (entry.value_ptr.*) {
.leader => continue,
.leaf => |leaf| leaf,
inline .leaf, .leaf_chained => |leaf| leaf.generic(),
};
if (!leaf.flags.global) continue;
// We only allow global keybinds that map to exactly a single
// action for now. TODO: remove this restriction
if (leaf.actions.len != 1) continue;
const trigger = if (key.xdgShortcutFromTrigger(
&trigger_buf,
entry.key_ptr.*,
@@ -197,7 +200,7 @@ pub const GlobalShortcuts = extern struct {
try priv.map.put(
alloc,
try alloc.dupeZ(u8, trigger),
leaf.action,
leaf.actions[0],
);
}