mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-10-09 11:26:41 +00:00
input: kitty keyboard modifier event changes from Kitty 0.32
> When the key event is related to an actual modifier key, the corresponding > modifier's bit must be set to the modifier state including the effect for the > current event. For example, when pressing the :kbd:`LEFT_CONTROL` key, the > ``ctrl`` bit must be set and when releasing it, it must be reset. When both > left and right control keys are pressed and one is released, the release event > must have the ``ctrl`` bit set. See :iss:`6913` for discussion of this design.
This commit is contained in:
@@ -612,22 +612,13 @@ const KittyMods = packed struct(u8) {
|
||||
k: key.Key,
|
||||
mods: key.Mods,
|
||||
) KittyMods {
|
||||
// Annoying boolean logic, but according to the Kitty spec:
|
||||
// "When both left and right control keys are pressed and one is
|
||||
// released, the release event must again have the modifier bit reset"
|
||||
// In other words, we allow a modifier if it is set AND the action
|
||||
// is NOT a release. Or if the action is a release, then the key being
|
||||
// released must not be the associated modifier key.
|
||||
const shift = mods.shift and (action != .release or (k != .left_shift and k != .right_shift));
|
||||
const alt = mods.alt and (action != .release or (k != .left_alt and k != .right_alt));
|
||||
const ctrl = mods.ctrl and (action != .release or (k != .left_control and k != .right_control));
|
||||
const super = mods.super and (action != .release or (k != .left_super and k != .right_super));
|
||||
|
||||
_ = action;
|
||||
_ = k;
|
||||
return .{
|
||||
.shift = shift,
|
||||
.alt = alt,
|
||||
.ctrl = ctrl,
|
||||
.super = super,
|
||||
.shift = mods.shift,
|
||||
.alt = mods.alt,
|
||||
.ctrl = mods.ctrl,
|
||||
.super = mods.super,
|
||||
.caps_lock = mods.caps_lock,
|
||||
.num_lock = mods.num_lock,
|
||||
};
|
||||
@@ -1026,7 +1017,7 @@ test "kitty: ctrl release with ctrl mod set" {
|
||||
},
|
||||
};
|
||||
const actual = try enc.kitty(&buf);
|
||||
try testing.expectEqualStrings("[57442;1:3u", actual[1..]);
|
||||
try testing.expectEqualStrings("[57442;5:3u", actual[1..]);
|
||||
}
|
||||
|
||||
test "kitty: delete" {
|
||||
|
Reference in New Issue
Block a user