diff options
-rw-r--r-- | gdk/broadway/gdkeventsource.c | 1 | ||||
-rw-r--r-- | gdk/gdkevents.c | 34 | ||||
-rw-r--r-- | gdk/gdkevents.h | 3 | ||||
-rw-r--r-- | gdk/gdkinternals.h | 4 | ||||
-rw-r--r-- | gdk/mir/gdkmireventsource.c | 1 | ||||
-rw-r--r-- | gdk/quartz/gdkevents-quartz.c | 1 | ||||
-rw-r--r-- | gdk/wayland/gdkdevice-wayland.c | 1 | ||||
-rw-r--r-- | gdk/win32/gdkevents-win32.c | 2 | ||||
-rw-r--r-- | gdk/x11/gdkdevicemanager-core-x11.c | 1 | ||||
-rw-r--r-- | gdk/x11/gdkdevicemanager-xi2.c | 1 |
10 files changed, 49 insertions, 0 deletions
diff --git a/gdk/broadway/gdkeventsource.c b/gdk/broadway/gdkeventsource.c index ae5b41e979..9d795c4caa 100644 --- a/gdk/broadway/gdkeventsource.c +++ b/gdk/broadway/gdkeventsource.c @@ -295,6 +295,7 @@ _gdk_broadway_events_got_input (BroadwayInputMsg *message) event->key.keyval = message->key.key; event->key.state = message->key.state; event->key.hardware_keycode = message->key.key; + _gdk_event_set_scancode (event, message->key.key); event->key.length = 0; gdk_event_set_device (event, device_manager->core_keyboard); gdk_event_set_seat (event, gdk_device_get_seat (device_manager->core_keyboard)); diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c index 4a051f25ef..d508dc3541 100644 --- a/gdk/gdkevents.c +++ b/gdk/gdkevents.c @@ -2464,3 +2464,37 @@ gdk_event_set_device_tool (GdkEvent *event, private = (GdkEventPrivate *) event; private->tool = tool; } + +void +_gdk_event_set_scancode (GdkEvent *event, + guint16 scancode) +{ + GdkEventPrivate *private = (GdkEventPrivate *) event; + + private->key_scancode = scancode; +} + +/** + * gdk_event_get_scancode: + * @event: a #GdkEvent + * + * Gets the keyboard low-level scancode. + * This is usually hardware_keycode. + * On Windows this is the high word of WM_KEY{DOWN,UP} lParam + * which contains the scancode and some extended flags. + * + * Returns: The associated keyboard scancode or 0 + * + * Since: 3.22 + **/ +int +gdk_event_get_scancode (GdkEvent *event) +{ + GdkEventPrivate *private; + + if (!gdk_event_is_allocated (event)) + return 0; + + private = (GdkEventPrivate *) event; + return private->key_scancode; +} diff --git a/gdk/gdkevents.h b/gdk/gdkevents.h index 3e7824f5cc..0fea302736 100644 --- a/gdk/gdkevents.h +++ b/gdk/gdkevents.h @@ -1451,6 +1451,9 @@ GDK_AVAILABLE_IN_3_22 void gdk_event_set_device_tool (GdkEvent *event, GdkDeviceTool *tool); +GDK_AVAILABLE_IN_3_22 +int gdk_event_get_scancode (GdkEvent *event); + G_END_DECLS #endif /* __GDK_EVENTS_H__ */ diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h index f68cd99700..9f7a0ab869 100644 --- a/gdk/gdkinternals.h +++ b/gdk/gdkinternals.h @@ -190,6 +190,7 @@ struct _GdkEventPrivate GdkDevice *source_device; GdkSeat *seat; GdkDeviceTool *tool; + guint16 key_scancode; }; typedef struct _GdkWindowPaint GdkWindowPaint; @@ -396,6 +397,9 @@ void _gdk_event_set_pointer_emulated (GdkEvent *event, gboolean emulated); gboolean _gdk_event_get_pointer_emulated (GdkEvent *event); +void _gdk_event_set_scancode (GdkEvent *event, + guint16 scancode); + void gdk_event_set_seat (GdkEvent *event, GdkSeat *seat); diff --git a/gdk/mir/gdkmireventsource.c b/gdk/mir/gdkmireventsource.c index a288cb798d..c8e7a48531 100644 --- a/gdk/mir/gdkmireventsource.c +++ b/gdk/mir/gdkmireventsource.c @@ -133,6 +133,7 @@ generate_key_event (GdkWindow *window, GdkEventType type, guint state, guint key event->key.state = state; event->key.keyval = keyval; event->key.hardware_keycode = keycode + 8; + _gdk_event_set_scancode (event, keycode + 8); event->key.is_modifier = is_modifier; event->key.time = event_time; set_key_event_string (&event->key); diff --git a/gdk/quartz/gdkevents-quartz.c b/gdk/quartz/gdkevents-quartz.c index 62094a8fc9..856c946de9 100644 --- a/gdk/quartz/gdkevents-quartz.c +++ b/gdk/quartz/gdkevents-quartz.c @@ -1134,6 +1134,7 @@ fill_key_event (GdkWindow *window, event->key.time = get_time_from_ns_event (nsevent); event->key.state = get_keyboard_modifiers_from_ns_event (nsevent); event->key.hardware_keycode = [nsevent keyCode]; + _gdk_event_set_scancode (event, [nsevent keyCode]); event->key.group = ([nsevent modifierFlags] & NSAlternateKeyMask) ? 1 : 0; event->key.keyval = GDK_KEY_VoidSymbol; diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c index 96e5fb6bea..856437df51 100644 --- a/gdk/wayland/gdkdevice-wayland.c +++ b/gdk/wayland/gdkdevice-wayland.c @@ -1836,6 +1836,7 @@ deliver_key_event (GdkWaylandSeat *seat, event->key.state = device_get_modifiers (seat->master_pointer); event->key.group = 0; event->key.hardware_keycode = key; + _gdk_event_set_scancode (event, key); event->key.keyval = sym; event->key.is_modifier = _gdk_wayland_keymap_key_is_modifier (keymap, key); diff --git a/gdk/win32/gdkevents-win32.c b/gdk/win32/gdkevents-win32.c index c6f6a243cd..2c8f0fab14 100644 --- a/gdk/win32/gdkevents-win32.c +++ b/gdk/win32/gdkevents-win32.c @@ -2339,6 +2339,8 @@ gdk_event_translate (MSG *msg, event->key.string = NULL; event->key.length = 0; event->key.hardware_keycode = msg->wParam; + /* save original scancode */ + _gdk_event_set_scancode (event, msg->lParam >> 16); gdk_event_set_device (event, device_manager_win32->core_keyboard); gdk_event_set_source_device (event, device_manager_win32->system_keyboard); gdk_event_set_seat (event, gdk_device_get_seat (device_manager_win32->core_keyboard)); diff --git a/gdk/x11/gdkdevicemanager-core-x11.c b/gdk/x11/gdkdevicemanager-core-x11.c index 994d359903..84f964116b 100644 --- a/gdk/x11/gdkdevicemanager-core-x11.c +++ b/gdk/x11/gdkdevicemanager-core-x11.c @@ -160,6 +160,7 @@ translate_key_event (GdkDisplay *display, event->key.state = (GdkModifierType) xevent->xkey.state; event->key.group = gdk_x11_keymap_get_group_for_state (keymap, xevent->xkey.state); event->key.hardware_keycode = xevent->xkey.keycode; + _gdk_event_set_scancode (event, xevent->xkey.keycode); event->key.keyval = GDK_KEY_VoidSymbol; diff --git a/gdk/x11/gdkdevicemanager-xi2.c b/gdk/x11/gdkdevicemanager-xi2.c index 836f455abb..1e5e77ae8b 100644 --- a/gdk/x11/gdkdevicemanager-xi2.c +++ b/gdk/x11/gdkdevicemanager-xi2.c @@ -1469,6 +1469,7 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator, event->key.group = xev->group.effective; event->key.hardware_keycode = xev->detail; + _gdk_event_set_scancode (event, xev->detail); event->key.is_modifier = gdk_x11_keymap_key_is_modifier (keymap, event->key.hardware_keycode); device = g_hash_table_lookup (device_manager->id_table, |