mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-06-09 05:14:27 +00:00
Merge pull request #1075 from rockorager/keypad
fix: keypad key encoding on GTK
This commit is contained in:
@@ -1333,6 +1333,10 @@ fn keyEvent(
|
||||
// event.
|
||||
const mods = mods: {
|
||||
var mods = translateMods(gtk_mods);
|
||||
|
||||
const device = c.gdk_event_get_device(event);
|
||||
mods.num_lock = c.gdk_device_get_num_lock_state(device) == 1;
|
||||
|
||||
switch (physical_key) {
|
||||
.left_shift => {
|
||||
mods.shift = action == .press;
|
||||
@@ -1376,6 +1380,7 @@ fn keyEvent(
|
||||
|
||||
else => {},
|
||||
}
|
||||
|
||||
break :mods mods;
|
||||
};
|
||||
|
||||
@@ -1389,6 +1394,13 @@ fn keyEvent(
|
||||
// If we're not in a dead key state, we want to translate our text
|
||||
// to some input.Key.
|
||||
const key = if (!self.im_composing) key: {
|
||||
// First, try to convert the keyval directly to a key. This allows the
|
||||
// use of key remapping and identification of keypad numerics (as
|
||||
// opposed to their ASCII counterparts)
|
||||
if (gtk_key.keyFromKeyval(keyval)) |key| {
|
||||
break :key key;
|
||||
}
|
||||
|
||||
// A completed key. If the length of the key is one then we can
|
||||
// attempt to translate it to a key enum and call the key
|
||||
// callback. First try plain ASCII.
|
||||
@@ -1414,12 +1426,6 @@ fn keyEvent(
|
||||
}
|
||||
}
|
||||
|
||||
// Before using the physical key, try to convert the keyval
|
||||
// directly to a key. This allows the use of key remapping.
|
||||
if (gtk_key.keyFromKeyval(keyval)) |key| {
|
||||
break :key key;
|
||||
}
|
||||
|
||||
// If we have im text then this is invalid. This means that
|
||||
// the keypress generated some character that we don't know about
|
||||
// in our key enum. We don't want to use the physical key because
|
||||
|
||||
@@ -190,16 +190,18 @@ const keymap: []const RawEntry = &.{
|
||||
.{ c.GDK_KEY_KP_Enter, .kp_enter },
|
||||
.{ c.GDK_KEY_KP_Equal, .kp_equal },
|
||||
|
||||
// These are all just aliases to the non-kp variants because Ghostty
|
||||
// core doesn't distinguish between them currently.
|
||||
.{ c.GDK_KEY_KP_Home, .home },
|
||||
.{ c.GDK_KEY_KP_End, .end },
|
||||
.{ c.GDK_KEY_KP_Page_Up, .page_up },
|
||||
.{ c.GDK_KEY_KP_Page_Down, .page_down },
|
||||
.{ c.GDK_KEY_KP_Up, .up },
|
||||
.{ c.GDK_KEY_KP_Down, .down },
|
||||
.{ c.GDK_KEY_KP_Right, .right },
|
||||
.{ c.GDK_KEY_KP_Left, .left },
|
||||
.{ c.GDK_KEY_KP_Separator, .kp_separator },
|
||||
.{ c.GDK_KEY_KP_Left, .kp_left },
|
||||
.{ c.GDK_KEY_KP_Right, .kp_right },
|
||||
.{ c.GDK_KEY_KP_Up, .kp_up },
|
||||
.{ c.GDK_KEY_KP_Down, .kp_down },
|
||||
.{ c.GDK_KEY_KP_Page_Up, .kp_page_up },
|
||||
.{ c.GDK_KEY_KP_Page_Down, .kp_page_down },
|
||||
.{ c.GDK_KEY_KP_Home, .kp_home },
|
||||
.{ c.GDK_KEY_KP_End, .kp_end },
|
||||
.{ c.GDK_KEY_KP_Insert, .kp_insert },
|
||||
.{ c.GDK_KEY_KP_Delete, .kp_delete },
|
||||
.{ c.GDK_KEY_KP_Begin, .kp_begin },
|
||||
|
||||
.{ c.GDK_KEY_Shift_L, .left_shift },
|
||||
.{ c.GDK_KEY_Control_L, .left_control },
|
||||
@@ -209,4 +211,6 @@ const keymap: []const RawEntry = &.{
|
||||
.{ c.GDK_KEY_Control_R, .right_control },
|
||||
.{ c.GDK_KEY_Alt_R, .right_alt },
|
||||
.{ c.GDK_KEY_Super_R, .right_super },
|
||||
|
||||
// TODO: media keys
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user