mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 16:56:09 +03:00
apprt/gtk: translate modifier-only presses to proper modifier state
This commit is contained in:
@ -912,7 +912,6 @@ fn keyEvent(
|
|||||||
ud: ?*anyopaque,
|
ud: ?*anyopaque,
|
||||||
) bool {
|
) bool {
|
||||||
const self = userdataSelf(ud.?);
|
const self = userdataSelf(ud.?);
|
||||||
const mods = translateMods(gtk_mods);
|
|
||||||
const keyval_unicode = c.gdk_keyval_to_unicode(keyval);
|
const keyval_unicode = c.gdk_keyval_to_unicode(keyval);
|
||||||
const event = c.gtk_event_controller_get_current_event(@ptrCast(ec_key));
|
const event = c.gtk_event_controller_get_current_event(@ptrCast(ec_key));
|
||||||
|
|
||||||
@ -986,6 +985,57 @@ fn keyEvent(
|
|||||||
if (entry.native == keycode) break :keycode entry.key;
|
if (entry.native == keycode) break :keycode entry.key;
|
||||||
} else .invalid;
|
} else .invalid;
|
||||||
|
|
||||||
|
// Get our modifiers. We have to translate modifier-only presses here
|
||||||
|
// to state in the mods manually because GTK only does it AFTER the press
|
||||||
|
// event.
|
||||||
|
const mods = mods: {
|
||||||
|
var mods = translateMods(gtk_mods);
|
||||||
|
switch (physical_key) {
|
||||||
|
.left_shift => {
|
||||||
|
mods.shift = action == .press;
|
||||||
|
if (mods.shift) mods.sides.shift = .left;
|
||||||
|
},
|
||||||
|
|
||||||
|
.right_shift => {
|
||||||
|
mods.shift = action == .press;
|
||||||
|
if (mods.shift) mods.sides.shift = .right;
|
||||||
|
},
|
||||||
|
|
||||||
|
.left_control => {
|
||||||
|
mods.ctrl = action == .press;
|
||||||
|
if (mods.ctrl) mods.sides.ctrl = .left;
|
||||||
|
},
|
||||||
|
|
||||||
|
.right_control => {
|
||||||
|
mods.ctrl = action == .press;
|
||||||
|
if (mods.ctrl) mods.sides.ctrl = .right;
|
||||||
|
},
|
||||||
|
|
||||||
|
.left_alt => {
|
||||||
|
mods.alt = action == .press;
|
||||||
|
if (mods.alt) mods.sides.alt = .left;
|
||||||
|
},
|
||||||
|
|
||||||
|
.right_alt => {
|
||||||
|
mods.alt = action == .press;
|
||||||
|
if (mods.alt) mods.sides.alt = .right;
|
||||||
|
},
|
||||||
|
|
||||||
|
.left_super => {
|
||||||
|
mods.super = action == .press;
|
||||||
|
if (mods.super) mods.sides.super = .left;
|
||||||
|
},
|
||||||
|
|
||||||
|
.right_super => {
|
||||||
|
mods.super = action == .press;
|
||||||
|
if (mods.super) mods.sides.super = .right;
|
||||||
|
},
|
||||||
|
|
||||||
|
else => {},
|
||||||
|
}
|
||||||
|
break :mods mods;
|
||||||
|
};
|
||||||
|
|
||||||
// Get our consumed modifiers
|
// Get our consumed modifiers
|
||||||
const consumed_mods: input.Mods = consumed: {
|
const consumed_mods: input.Mods = consumed: {
|
||||||
const raw = c.gdk_key_event_get_consumed_modifiers(event);
|
const raw = c.gdk_key_event_get_consumed_modifiers(event);
|
||||||
|
Reference in New Issue
Block a user