mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
fix(gtk): detect modifier keys without cursor movement
This commit is contained in:
@ -76,10 +76,21 @@ pub const App = struct {
|
||||
}
|
||||
|
||||
pub fn eventMods(
|
||||
_: *App,
|
||||
_: ?*c.GdkDevice,
|
||||
_: App,
|
||||
device: ?*c.GdkDevice,
|
||||
_: c.GdkModifierType,
|
||||
) ?input.Mods {
|
||||
if (device) |dev| {
|
||||
const device_mods = c.gdk_device_get_modifier_state(dev);
|
||||
return input.Mods{
|
||||
.shift = (device_mods & c.GDK_SHIFT_MASK) != 0,
|
||||
.ctrl = (device_mods & c.GDK_CONTROL_MASK) != 0,
|
||||
.alt = (device_mods & c.GDK_ALT_MASK) != 0,
|
||||
.super = (device_mods & c.GDK_SUPER_MASK) != 0,
|
||||
.caps_lock = (device_mods & c.GDK_LOCK_MASK) != 0,
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -122,8 +122,18 @@ pub const App = struct {
|
||||
device: ?*c.GdkDevice,
|
||||
gtk_mods: c.GdkModifierType,
|
||||
) ?input.Mods {
|
||||
_ = device;
|
||||
_ = gtk_mods;
|
||||
if (device) |dev| {
|
||||
const device_mods = c.gdk_device_get_modifier_state(dev);
|
||||
if (device_mods != gtk_mods) {
|
||||
return input.Mods{
|
||||
.shift = (device_mods & c.GDK_SHIFT_MASK) != 0,
|
||||
.ctrl = (device_mods & c.GDK_CONTROL_MASK) != 0,
|
||||
.alt = (device_mods & c.GDK_ALT_MASK) != 0,
|
||||
.super = (device_mods & c.GDK_SUPER_MASK) != 0,
|
||||
.caps_lock = (device_mods & c.GDK_LOCK_MASK) != 0,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Shoutout to Mozilla for figuring out a clean way to do this, this is
|
||||
// paraphrased from Firefox/Gecko in widget/gtk/nsGtkKeyUtils.cpp.
|
||||
|
Reference in New Issue
Block a user