core: don't send release events for key bindings

Fixes #482
This commit is contained in:
Mitchell Hashimoto
2023-09-17 14:31:15 -07:00
parent ef7e0f7fdb
commit dbd8add23e

View File

@ -963,9 +963,9 @@ 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.
if (event.action == .press or event.action == .repeat) { binding: {
const binding_mods = event.mods.binding(); const binding_action: input.Binding.Action = action: {
const binding_action_: ?input.Binding.Action = action: { const binding_mods = event.mods.binding();
var trigger: input.Binding.Trigger = .{ var trigger: input.Binding.Trigger = .{
.mods = binding_mods, .mods = binding_mods,
.key = event.key, .key = event.key,
@ -978,14 +978,17 @@ pub fn keyCallback(
trigger.physical = true; trigger.physical = true;
if (set.get(trigger)) |v| break :action v; if (set.get(trigger)) |v| break :action v;
break :action null; break :binding;
}; };
if (binding_action_) |binding_action| { // We only execute the binding on press/repeat but we still consume
//log.warn("BINDING ACTION={}", .{binding_action}); // the key on release so that we don't send any release events.
log.debug("key event consumed by binding action={}", .{binding_action});
if (event.action == .press or event.action == .repeat) {
try self.performBindingAction(binding_action); try self.performBindingAction(binding_action);
return true;
} }
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.