core: handle unconsumed bindings in key callbacks

This commit is contained in:
Mitchell Hashimoto
2023-09-29 21:37:30 -07:00
parent 47ee1e7355
commit 3569073ff5

View File

@ -902,7 +902,7 @@ pub fn keyCallback(
// Before encoding, we see if we have any keybindings for this // Before encoding, we see if we have any keybindings for this
// key. Those always intercept before any encoding tasks. // key. Those always intercept before any encoding tasks.
binding: { binding: {
const binding_action: input.Binding.Action = action: { const binding_action: input.Binding.Action, const consumed = action: {
const binding_mods = event.mods.binding(); const binding_mods = event.mods.binding();
var trigger: input.Binding.Trigger = .{ var trigger: input.Binding.Trigger = .{
.mods = binding_mods, .mods = binding_mods,
@ -910,11 +910,17 @@ pub fn keyCallback(
}; };
const set = self.config.keybind.set; 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.key = event.physical_key;
trigger.physical = true; trigger.physical = true;
if (set.get(trigger)) |v| break :action v; if (set.get(trigger)) |v| break :action .{
v,
set.getConsumed(trigger),
};
break :binding; break :binding;
}; };
@ -926,7 +932,10 @@ pub fn keyCallback(
try self.performBindingAction(binding_action); 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. // If this input event has text, then we hide the mouse if configured.