From 3569073ff5b28e76bd83ecce3dad7e32c7c77f99 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 29 Sep 2023 21:37:30 -0700 Subject: [PATCH] core: handle unconsumed bindings in key callbacks --- src/Surface.zig | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/Surface.zig b/src/Surface.zig index 587e166dc..e3faa8dc1 100644 --- a/src/Surface.zig +++ b/src/Surface.zig @@ -902,7 +902,7 @@ pub fn keyCallback( // Before encoding, we see if we have any keybindings for this // key. Those always intercept before any encoding tasks. binding: { - const binding_action: input.Binding.Action = action: { + const binding_action: input.Binding.Action, const consumed = action: { const binding_mods = event.mods.binding(); var trigger: input.Binding.Trigger = .{ .mods = binding_mods, @@ -910,11 +910,17 @@ pub fn keyCallback( }; const set = self.config.keybind.set; - if (set.get(trigger)) |v| break :action v; + if (set.get(trigger)) |v| break :action .{ + v, + set.getConsumed(trigger), + }; trigger.key = event.physical_key; trigger.physical = true; - if (set.get(trigger)) |v| break :action v; + if (set.get(trigger)) |v| break :action .{ + v, + set.getConsumed(trigger), + }; break :binding; }; @@ -926,7 +932,10 @@ pub fn keyCallback( try self.performBindingAction(binding_action); } - return true; + // If we consume this event, then we are done. If we don't consume + // it, we processed the action but we still want to process our + // encodings, too. + if (consumed) return true; } // If this input event has text, then we hide the mouse if configured.