From 0726a8d1faaa10934d3c947bbb4b0624666422d9 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 27 Jan 2024 11:14:16 -0800 Subject: [PATCH] apprt/embedded: ctrl-only should use binding-mods only This allows it to ignore control side differences. --- src/apprt/embedded.zig | 2 +- src/input/KeyEncoder.zig | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/apprt/embedded.zig b/src/apprt/embedded.zig index 8b6d7c51e..511c2da36 100644 --- a/src/apprt/embedded.zig +++ b/src/apprt/embedded.zig @@ -780,7 +780,7 @@ pub const Surface = struct { // we just avoid this by never allowing AppKit to translate // ctrl+ and instead do it ourselves. const ctrl_only = comptime (input.Mods{ .ctrl = true }).int(); - break :event_text if (mods.int() == ctrl_only) null else event.text; + break :event_text if (mods.binding().int() == ctrl_only) null else event.text; }; // Translate our key using the keymap for our localized keyboard layout. diff --git a/src/input/KeyEncoder.zig b/src/input/KeyEncoder.zig index fc6bc5121..485029677 100644 --- a/src/input/KeyEncoder.zig +++ b/src/input/KeyEncoder.zig @@ -1895,6 +1895,11 @@ test "ctrlseq: normal ctrl c" { try testing.expectEqual(@as(u8, 0x03), seq.?); } +test "ctrlseq: normal ctrl c, right control" { + const seq = ctrlSeq("c", .{ .ctrl = true, .sides = .{ .ctrl = .right } }); + try testing.expectEqual(@as(u8, 0x03), seq.?); +} + test "ctrlseq: alt should be allowed" { const seq = ctrlSeq("c", .{ .alt = true, .ctrl = true }); try testing.expectEqual(@as(u8, 0x03), seq.?);