mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-13 23:36:09 +03:00
apprt/gtk: set key modifier flag if physical modifier key is pressed
Fixes #5191
This commit is contained in:
@ -1757,6 +1757,7 @@ pub fn keyEvent(
|
|||||||
event,
|
event,
|
||||||
physical_key,
|
physical_key,
|
||||||
gtk_mods,
|
gtk_mods,
|
||||||
|
action,
|
||||||
&self.app.winproto,
|
&self.app.winproto,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -108,6 +108,7 @@ pub fn eventMods(
|
|||||||
event: *c.GdkEvent,
|
event: *c.GdkEvent,
|
||||||
physical_key: input.Key,
|
physical_key: input.Key,
|
||||||
gtk_mods: c.GdkModifierType,
|
gtk_mods: c.GdkModifierType,
|
||||||
|
action: input.Action,
|
||||||
app_winproto: *winproto.App,
|
app_winproto: *winproto.App,
|
||||||
) input.Mods {
|
) input.Mods {
|
||||||
const device = c.gdk_event_get_device(event);
|
const device = c.gdk_event_get_device(event);
|
||||||
@ -115,15 +116,55 @@ pub fn eventMods(
|
|||||||
var mods = app_winproto.eventMods(device, gtk_mods);
|
var mods = app_winproto.eventMods(device, gtk_mods);
|
||||||
mods.num_lock = c.gdk_device_get_num_lock_state(device) == 1;
|
mods.num_lock = c.gdk_device_get_num_lock_state(device) == 1;
|
||||||
|
|
||||||
|
// We use the physical key to determine sided modifiers. As
|
||||||
|
// far as I can tell there's no other way to reliably determine
|
||||||
|
// this.
|
||||||
|
//
|
||||||
|
// We also set the main modifier to true if either side is true,
|
||||||
|
// since on both X11/Wayland, GTK doesn't set the main modifier
|
||||||
|
// if only the modifier key is pressed, but our core logic
|
||||||
|
// relies on it.
|
||||||
switch (physical_key) {
|
switch (physical_key) {
|
||||||
.left_shift => mods.sides.shift = .left,
|
.left_shift => {
|
||||||
.right_shift => mods.sides.shift = .right,
|
mods.shift = action != .release;
|
||||||
.left_control => mods.sides.ctrl = .left,
|
mods.sides.shift = .left;
|
||||||
.right_control => mods.sides.ctrl = .right,
|
},
|
||||||
.left_alt => mods.sides.alt = .left,
|
|
||||||
.right_alt => mods.sides.alt = .right,
|
.right_shift => {
|
||||||
.left_super => mods.sides.super = .left,
|
mods.shift = action != .release;
|
||||||
.right_super => mods.sides.super = .right,
|
mods.sides.shift = .right;
|
||||||
|
},
|
||||||
|
|
||||||
|
.left_control => {
|
||||||
|
mods.ctrl = action != .release;
|
||||||
|
mods.sides.ctrl = .left;
|
||||||
|
},
|
||||||
|
|
||||||
|
.right_control => {
|
||||||
|
mods.ctrl = action != .release;
|
||||||
|
mods.sides.ctrl = .right;
|
||||||
|
},
|
||||||
|
|
||||||
|
.left_alt => {
|
||||||
|
mods.alt = action != .release;
|
||||||
|
mods.sides.alt = .left;
|
||||||
|
},
|
||||||
|
|
||||||
|
.right_alt => {
|
||||||
|
mods.alt = action != .release;
|
||||||
|
mods.sides.alt = .right;
|
||||||
|
},
|
||||||
|
|
||||||
|
.left_super => {
|
||||||
|
mods.super = action != .release;
|
||||||
|
mods.sides.super = .left;
|
||||||
|
},
|
||||||
|
|
||||||
|
.right_super => {
|
||||||
|
mods.super = action != .release;
|
||||||
|
mods.sides.super = .right;
|
||||||
|
},
|
||||||
|
|
||||||
else => {},
|
else => {},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user