mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-13 05:50:10 +00:00
gdk: Redo key events
Add all of the keyboard translation results in the key event, so we can translate the keyboard state at the time the event is created, and avoid doing state translation at match time. We actually need to carry two sets of translation results, since we ignore CapsLock when matching accelerators, in gdk_event_matches(). At the same time, drop the scancode field - it is only ever set on win32, and is basically unused in GTK. Update all callers.
This commit is contained in:
parent
5071367794
commit
0a96a483c6
@ -545,8 +545,9 @@ gdk_scroll_event_get_deltas
|
|||||||
gdk_scroll_event_is_stop
|
gdk_scroll_event_is_stop
|
||||||
gdk_key_event_get_keyval
|
gdk_key_event_get_keyval
|
||||||
gdk_key_event_get_keycode
|
gdk_key_event_get_keycode
|
||||||
gdk_key_event_get_scancode
|
gdk_key_event_get_consumed_modifiers
|
||||||
gdk_key_event_get_group
|
gdk_key_event_get_layout
|
||||||
|
gdk_key_event_get_level
|
||||||
gdk_key_event_is_modifier
|
gdk_key_event_is_modifier
|
||||||
gdk_focus_event_get_in
|
gdk_focus_event_get_in
|
||||||
gdk_touch_event_get_emulating_pointer
|
gdk_touch_event_get_emulating_pointer
|
||||||
|
@ -266,6 +266,11 @@ _gdk_broadway_events_got_input (GdkDisplay *display,
|
|||||||
GINT_TO_POINTER (message->key.surface_id));
|
GINT_TO_POINTER (message->key.surface_id));
|
||||||
if (surface)
|
if (surface)
|
||||||
{
|
{
|
||||||
|
GdkTranslatedKey translated;
|
||||||
|
translated.keyval = message->key.key;
|
||||||
|
translated.consumed = 0;
|
||||||
|
translated.layout = 0;
|
||||||
|
translated.level = 0;
|
||||||
event = gdk_event_key_new (message->base.type == BROADWAY_EVENT_KEY_PRESS
|
event = gdk_event_key_new (message->base.type == BROADWAY_EVENT_KEY_PRESS
|
||||||
? GDK_KEY_PRESS
|
? GDK_KEY_PRESS
|
||||||
: GDK_KEY_RELEASE,
|
: GDK_KEY_RELEASE,
|
||||||
@ -273,12 +278,11 @@ _gdk_broadway_events_got_input (GdkDisplay *display,
|
|||||||
gdk_seat_get_keyboard (seat),
|
gdk_seat_get_keyboard (seat),
|
||||||
gdk_seat_get_keyboard (seat),
|
gdk_seat_get_keyboard (seat),
|
||||||
message->base.time,
|
message->base.time,
|
||||||
|
message->key.key,
|
||||||
message->key.state,
|
message->key.state,
|
||||||
message->key.key,
|
FALSE,
|
||||||
message->key.key,
|
&translated,
|
||||||
message->key.key,
|
&translated);
|
||||||
0,
|
|
||||||
FALSE);
|
|
||||||
|
|
||||||
node = _gdk_event_queue_append (display, event);
|
node = _gdk_event_queue_append (display, event);
|
||||||
_gdk_windowing_got_event (display, node, event, message->base.serial);
|
_gdk_windowing_got_event (display, node, event, message->base.serial);
|
||||||
|
222
gdk/gdkevents.c
222
gdk/gdkevents.c
@ -931,17 +931,16 @@ gdk_event_proximity_new (GdkEventType type,
|
|||||||
}
|
}
|
||||||
|
|
||||||
GdkEvent *
|
GdkEvent *
|
||||||
gdk_event_key_new (GdkEventType type,
|
gdk_event_key_new (GdkEventType type,
|
||||||
GdkSurface *surface,
|
GdkSurface *surface,
|
||||||
GdkDevice *device,
|
GdkDevice *device,
|
||||||
GdkDevice *source_device,
|
GdkDevice *source_device,
|
||||||
guint32 time,
|
guint32 time,
|
||||||
GdkModifierType state,
|
guint keycode,
|
||||||
guint keyval,
|
GdkModifierType state,
|
||||||
guint16 keycode,
|
gboolean is_modifier,
|
||||||
guint16 scancode,
|
GdkTranslatedKey *translated,
|
||||||
guint8 group,
|
GdkTranslatedKey *no_lock)
|
||||||
gboolean is_modifier)
|
|
||||||
{
|
{
|
||||||
GdkEventKey *event;
|
GdkEventKey *event;
|
||||||
|
|
||||||
@ -956,12 +955,11 @@ gdk_event_key_new (GdkEventType type,
|
|||||||
event->any.surface = g_object_ref (surface);
|
event->any.surface = g_object_ref (surface);
|
||||||
event->any.device = g_object_ref (device);
|
event->any.device = g_object_ref (device);
|
||||||
event->any.source_device = g_object_ref (source_device);
|
event->any.source_device = g_object_ref (source_device);
|
||||||
|
event->keycode = keycode;
|
||||||
event->state = state;
|
event->state = state;
|
||||||
event->keyval = keyval;
|
|
||||||
event->hardware_keycode = keycode;
|
|
||||||
event->key_scancode = scancode;
|
|
||||||
event->group = group;
|
|
||||||
event->any.key_is_modifier = is_modifier;
|
event->any.key_is_modifier = is_modifier;
|
||||||
|
event->translated[0] = *translated;
|
||||||
|
event->translated[1] = *no_lock;
|
||||||
|
|
||||||
return (GdkEvent *)event;
|
return (GdkEvent *)event;
|
||||||
}
|
}
|
||||||
@ -1669,7 +1667,7 @@ gdk_key_event_get_keyval (GdkEvent *event)
|
|||||||
g_return_val_if_fail (event->any.type == GDK_KEY_PRESS ||
|
g_return_val_if_fail (event->any.type == GDK_KEY_PRESS ||
|
||||||
event->any.type == GDK_KEY_RELEASE, 0);
|
event->any.type == GDK_KEY_RELEASE, 0);
|
||||||
|
|
||||||
return event->key.keyval;
|
return event->key.translated[0].keyval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1686,41 +1684,58 @@ gdk_key_event_get_keycode (GdkEvent *event)
|
|||||||
g_return_val_if_fail (event->any.type == GDK_KEY_PRESS ||
|
g_return_val_if_fail (event->any.type == GDK_KEY_PRESS ||
|
||||||
event->any.type == GDK_KEY_RELEASE, 0);
|
event->any.type == GDK_KEY_RELEASE, 0);
|
||||||
|
|
||||||
return event->key.hardware_keycode;
|
return event->key.keycode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gdk_key_event_get_scancode:
|
* gdk_key_event_get_level:
|
||||||
* @event: a key event
|
* @event: a key event
|
||||||
*
|
*
|
||||||
* Extracts the scancode from a key event.
|
* Extracts the shift level from a key event.
|
||||||
*
|
*
|
||||||
* Returns: the scancode of @event
|
* Returns: the shift level of @event
|
||||||
*/
|
*/
|
||||||
guint
|
guint
|
||||||
gdk_key_event_get_scancode (GdkEvent *event)
|
gdk_key_event_get_level (GdkEvent *event)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (event->any.type == GDK_KEY_PRESS ||
|
g_return_val_if_fail (event->any.type == GDK_KEY_PRESS ||
|
||||||
event->any.type == GDK_KEY_RELEASE, 0);
|
event->any.type == GDK_KEY_RELEASE, 0);
|
||||||
|
|
||||||
return event->key.key_scancode;
|
return event->key.translated[0].level;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gdk_key_event_get_group:
|
* gdk_key_event_get_layout:
|
||||||
* @event: a key event
|
* @event: a key event
|
||||||
*
|
*
|
||||||
* Extracts the group from a key event.
|
* Extracts the layout from a key event.
|
||||||
*
|
*
|
||||||
* Returns: the group of @event
|
* Returns: the layout of @event
|
||||||
*/
|
*/
|
||||||
guint
|
guint
|
||||||
gdk_key_event_get_group (GdkEvent *event)
|
gdk_key_event_get_layout (GdkEvent *event)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (event->any.type == GDK_KEY_PRESS ||
|
g_return_val_if_fail (event->any.type == GDK_KEY_PRESS ||
|
||||||
event->any.type == GDK_KEY_RELEASE, 0);
|
event->any.type == GDK_KEY_RELEASE, 0);
|
||||||
|
|
||||||
return event->key.group;
|
return event->key.translated[0].layout;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gdk_key_event_get_consumed_modifiers:
|
||||||
|
* @event: a key event
|
||||||
|
*
|
||||||
|
* Extracts the consumed modifiers from a key event.
|
||||||
|
*
|
||||||
|
* Returns: the consumed modifiers or @event
|
||||||
|
*/
|
||||||
|
GdkModifierType
|
||||||
|
gdk_key_event_get_consumed_modifiers (GdkEvent *event)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (event->any.type == GDK_KEY_PRESS ||
|
||||||
|
event->any.type == GDK_KEY_RELEASE, 0);
|
||||||
|
|
||||||
|
return event->key.translated[0].consumed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2111,108 +2126,48 @@ gdk_grab_broken_event_get_grab_surface (GdkEvent *event)
|
|||||||
return event->grab_broken.grab_surface;
|
return event->grab_broken.grab_surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
translate_keyboard_accel_state (GdkKeymap *keymap,
|
|
||||||
guint hardware_keycode,
|
|
||||||
GdkModifierType state,
|
|
||||||
gint group,
|
|
||||||
guint *keyval,
|
|
||||||
gint *effective_group,
|
|
||||||
gint *level,
|
|
||||||
GdkModifierType *consumed_modifiers)
|
|
||||||
{
|
|
||||||
GdkModifierType mask;
|
|
||||||
GdkModifierType shift_group_mask;
|
|
||||||
gboolean group_mask_disabled = FALSE;
|
|
||||||
gboolean retval;
|
|
||||||
|
|
||||||
mask = gdk_keymap_get_modifier_mask (keymap,
|
|
||||||
GDK_MODIFIER_INTENT_DEFAULT_MOD_MASK);
|
|
||||||
|
|
||||||
/* if the group-toggling modifier is part of the accel mod mask, and
|
|
||||||
* it is active, disable it for matching
|
|
||||||
*/
|
|
||||||
shift_group_mask = gdk_keymap_get_modifier_mask (keymap,
|
|
||||||
GDK_MODIFIER_INTENT_SHIFT_GROUP);
|
|
||||||
if (mask & state & shift_group_mask)
|
|
||||||
{
|
|
||||||
state &= ~shift_group_mask;
|
|
||||||
group = 0;
|
|
||||||
group_mask_disabled = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
retval = gdk_keymap_translate_keyboard_state (keymap,
|
|
||||||
hardware_keycode, state, group,
|
|
||||||
keyval,
|
|
||||||
effective_group, level,
|
|
||||||
consumed_modifiers);
|
|
||||||
|
|
||||||
/* add back the group mask, we want to match against the modifier,
|
|
||||||
* but not against the keyval from its group
|
|
||||||
*/
|
|
||||||
if (group_mask_disabled)
|
|
||||||
{
|
|
||||||
if (effective_group)
|
|
||||||
*effective_group = 1;
|
|
||||||
|
|
||||||
if (consumed_modifiers)
|
|
||||||
*consumed_modifiers &= ~shift_group_mask;
|
|
||||||
}
|
|
||||||
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gdk_event_matches:
|
* gdk_key_event_matches:
|
||||||
* @event: the #GdkEvent
|
* @event: a key #GdkEvent
|
||||||
* @keyval: the keyval to match
|
* @keyval: the keyval to match
|
||||||
* @modifiers: the modifiers to match
|
* @modifiers: the modifiers to match
|
||||||
*
|
*
|
||||||
* Matches an event against a keyboard shortcut that is specified
|
* Matches a key event against a keyboard shortcut that is specified
|
||||||
* as a keyval and modifiers. Note that partial matches are possible
|
* as a keyval and modifiers. Partial matches are possible where the
|
||||||
* where the combination matches if the currently active group is
|
* combination matches if the currently active group is ignored.
|
||||||
* ignored.
|
|
||||||
*
|
*
|
||||||
* Returns: a GdkEventMatch value describing whether @event matches
|
* Note that we ignore Caps Lock for matching.
|
||||||
|
*
|
||||||
|
* Returns: a GdkKeyMatch value describing whether @event matches
|
||||||
*/
|
*/
|
||||||
GdkEventMatch
|
GdkKeyMatch
|
||||||
gdk_event_matches (GdkEvent *event,
|
gdk_key_event_matches (GdkEvent *event,
|
||||||
guint keyval,
|
guint keyval,
|
||||||
GdkModifierType modifiers)
|
GdkModifierType modifiers)
|
||||||
{
|
{
|
||||||
guint keycode;
|
guint keycode;
|
||||||
GdkModifierType state;
|
GdkModifierType state;
|
||||||
GdkModifierType mask;
|
GdkModifierType mask;
|
||||||
int group;
|
|
||||||
GdkKeymap *keymap;
|
|
||||||
guint ev_keyval;
|
guint ev_keyval;
|
||||||
int effective_group;
|
int layout;
|
||||||
int level;
|
int level;
|
||||||
GdkModifierType consumed_modifiers;
|
GdkModifierType consumed_modifiers;
|
||||||
GdkModifierType shift_group_mask;
|
GdkModifierType shift_group_mask;
|
||||||
gboolean group_mod_is_accel_mod = FALSE;
|
gboolean group_mod_is_accel_mod = FALSE;
|
||||||
|
|
||||||
if (gdk_event_get_event_type (event) != GDK_KEY_PRESS)
|
g_return_val_if_fail (event->any.type == GDK_KEY_PRESS ||
|
||||||
return GDK_EVENT_MATCH_NONE;
|
event->any.type == GDK_KEY_RELEASE, GDK_KEY_MATCH_NONE);
|
||||||
|
|
||||||
keycode = gdk_key_event_get_keycode (event);
|
keycode = event->key.keycode;
|
||||||
state = gdk_event_get_modifier_state (event);
|
state = event->key.state & ~GDK_LOCK_MASK;
|
||||||
group = gdk_key_event_get_group (event);
|
ev_keyval = event->key.translated[1].keyval;
|
||||||
keymap = gdk_display_get_keymap (gdk_event_get_display (event));
|
layout = event->key.translated[1].layout;
|
||||||
|
level = event->key.translated[1].level;
|
||||||
|
consumed_modifiers = event->key.translated[1].consumed;
|
||||||
|
|
||||||
mask = gdk_keymap_get_modifier_mask (keymap,
|
mask = gdk_keymap_get_modifier_mask (keymap,
|
||||||
GDK_MODIFIER_INTENT_DEFAULT_MOD_MASK);
|
GDK_MODIFIER_INTENT_DEFAULT_MOD_MASK);
|
||||||
|
|
||||||
/* We don't want Caps_Lock to affect keybinding lookups.
|
|
||||||
*/
|
|
||||||
state &= ~GDK_LOCK_MASK;
|
|
||||||
|
|
||||||
translate_keyboard_accel_state (keymap,
|
|
||||||
keycode, state, group,
|
|
||||||
&ev_keyval,
|
|
||||||
&effective_group, &level,
|
|
||||||
&consumed_modifiers);
|
|
||||||
|
|
||||||
/* if the group-toggling modifier is part of the default accel mod
|
/* if the group-toggling modifier is part of the default accel mod
|
||||||
* mask, and it is active, disable it for matching
|
* mask, and it is active, disable it for matching
|
||||||
*/
|
*/
|
||||||
@ -2244,22 +2199,23 @@ gdk_event_matches (GdkEvent *event,
|
|||||||
if (ev_keyval == key && /* exact match */
|
if (ev_keyval == key && /* exact match */
|
||||||
(!group_mod_is_accel_mod ||
|
(!group_mod_is_accel_mod ||
|
||||||
(state & shift_group_mask) == (modifiers & shift_group_mask)))
|
(state & shift_group_mask) == (modifiers & shift_group_mask)))
|
||||||
return GDK_EVENT_MATCH_EXACT;
|
{
|
||||||
|
return GDK_KEY_MATCH_EXACT;
|
||||||
|
}
|
||||||
|
|
||||||
gdk_keymap_get_entries_for_keyval (keymap, keyval, &keys, &n_keys);
|
gdk_display_map_keyval (gdk_event_get_display (event), keyval, &keys, &n_keys);
|
||||||
|
|
||||||
for (i = 0; i < n_keys; i++)
|
for (i = 0; i < n_keys; i++)
|
||||||
{
|
{
|
||||||
if (keys[i].keycode == keycode &&
|
if (keys[i].keycode == keycode &&
|
||||||
keys[i].level == level &&
|
keys[i].level == level &&
|
||||||
/* Only match for group if it's an accel mod */
|
/* Only match for group if it's an accel mod */
|
||||||
(!group_mod_is_accel_mod ||
|
(!group_mod_is_accel_mod || keys[i].group == layout))
|
||||||
keys[i].group == effective_group))
|
|
||||||
{
|
{
|
||||||
/* partial match */
|
/* partial match */
|
||||||
g_free (keys);
|
g_free (keys);
|
||||||
|
|
||||||
return GDK_EVENT_MATCH_PARTIAL;
|
return GDK_KEY_MATCH_PARTIAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2267,12 +2223,12 @@ gdk_event_matches (GdkEvent *event,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return GDK_EVENT_MATCH_NONE;
|
return GDK_KEY_MATCH_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gdk_event_get_match:
|
* gdk_key_event_get_match:
|
||||||
* @event: a #GdkEvent
|
* @event: a key #GdkEvent
|
||||||
* @keyval: (out): return location for a keyval
|
* @keyval: (out): return location for a keyval
|
||||||
* @modifiers: (out): return location for modifiers
|
* @modifiers: (out): return location for modifiers
|
||||||
*
|
*
|
||||||
@ -2282,31 +2238,28 @@ gdk_event_matches (GdkEvent *event,
|
|||||||
* Returns: %TRUE on success
|
* Returns: %TRUE on success
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
gdk_event_get_match (GdkEvent *event,
|
gdk_key_event_get_match (GdkEvent *event,
|
||||||
guint *keyval,
|
guint *keyval,
|
||||||
GdkModifierType *modifiers)
|
GdkModifierType *modifiers)
|
||||||
{
|
{
|
||||||
GdkKeymap *keymap;
|
GdkKeymap *keymap;
|
||||||
GdkModifierType mask;
|
GdkModifierType mask;
|
||||||
guint keycode;
|
|
||||||
guint group;
|
|
||||||
guint key;
|
guint key;
|
||||||
guint accel_key;
|
guint accel_key;
|
||||||
GdkModifierType accel_mods;
|
GdkModifierType accel_mods;
|
||||||
GdkModifierType consumed_modifiers;
|
GdkModifierType consumed_modifiers;
|
||||||
|
|
||||||
if (gdk_event_get_event_type (event) != GDK_KEY_PRESS)
|
g_return_val_if_fail (event->any.type == GDK_KEY_PRESS ||
|
||||||
return FALSE;
|
event->any.type == GDK_KEY_RELEASE, FALSE);
|
||||||
|
|
||||||
keymap = gdk_display_get_keymap (gdk_event_get_display (event));
|
keymap = gdk_display_get_keymap (gdk_event_get_display (event));
|
||||||
|
|
||||||
mask = gdk_keymap_get_modifier_mask (keymap,
|
mask = gdk_keymap_get_modifier_mask (keymap,
|
||||||
GDK_MODIFIER_INTENT_DEFAULT_MOD_MASK);
|
GDK_MODIFIER_INTENT_DEFAULT_MOD_MASK);
|
||||||
|
|
||||||
keycode = gdk_key_event_get_keycode (event);
|
accel_key = event->key.translated[1].keyval;
|
||||||
group = gdk_key_event_get_group (event);
|
accel_mods = event->key.state;
|
||||||
accel_key = gdk_key_event_get_keyval (event);
|
consumed_modifiers = event->key.translated[1].consumed;
|
||||||
accel_mods = gdk_event_get_modifier_state (event);
|
|
||||||
|
|
||||||
if (accel_key == GDK_KEY_Sys_Req &&
|
if (accel_key == GDK_KEY_Sys_Req &&
|
||||||
(accel_mods & GDK_ALT_MASK) != 0)
|
(accel_mods & GDK_ALT_MASK) != 0)
|
||||||
@ -2319,24 +2272,17 @@ gdk_event_get_match (GdkEvent *event,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
translate_keyboard_accel_state (keymap,
|
key = gdk_keyval_to_lower (accel_key);
|
||||||
keycode,
|
|
||||||
accel_mods,
|
|
||||||
group,
|
|
||||||
&key, NULL, NULL, &consumed_modifiers);
|
|
||||||
|
|
||||||
accel_key = gdk_keyval_to_lower (key);
|
if (key == GDK_KEY_ISO_Left_Tab)
|
||||||
|
key = GDK_KEY_Tab;
|
||||||
if (accel_key == GDK_KEY_ISO_Left_Tab)
|
|
||||||
accel_key = GDK_KEY_Tab;
|
|
||||||
|
|
||||||
accel_mods &= mask & ~consumed_modifiers;
|
accel_mods &= mask & ~consumed_modifiers;
|
||||||
|
|
||||||
/* Put shift back if it changed the case of the key, not otherwise. */
|
|
||||||
if (accel_key != key)
|
if (accel_key != key)
|
||||||
accel_mods |= GDK_SHIFT_MASK;
|
accel_mods |= GDK_SHIFT_MASK;
|
||||||
|
|
||||||
*keyval = accel_key;
|
*keyval = key;
|
||||||
*modifiers = accel_mods;
|
*modifiers = accel_mods;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -363,9 +363,11 @@ guint gdk_key_event_get_keyval (GdkEvent *event);
|
|||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
guint gdk_key_event_get_keycode (GdkEvent *event);
|
guint gdk_key_event_get_keycode (GdkEvent *event);
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
guint gdk_key_event_get_scancode (GdkEvent *event);
|
GdkModifierType gdk_key_event_get_consumed_modifiers (GdkEvent *event);
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
guint gdk_key_event_get_group (GdkEvent *event);
|
guint gdk_key_event_get_layout (GdkEvent *event);
|
||||||
|
GDK_AVAILABLE_IN_ALL
|
||||||
|
guint gdk_key_event_get_level (GdkEvent *event);
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
gboolean gdk_key_event_is_modifier (GdkEvent *event);
|
gboolean gdk_key_event_is_modifier (GdkEvent *event);
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
@ -429,30 +431,30 @@ gboolean gdk_events_get_center (GdkEvent *event1,
|
|||||||
double *y);
|
double *y);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GdkEventMatch:
|
* GdkKeyMatch:
|
||||||
* @GDK_EVENT_MATCH_NONE: The key event does not match
|
* @GDK_KEY_MATCH_NONE: The key event does not match
|
||||||
* @GDK_EVENT_MATCH_PARTIAL: The key event matches if keyboard state
|
* @GDK_KEY_MATCH_PARTIAL: The key event matches if keyboard state
|
||||||
* (specifically, the currently active group) is ignored
|
* (specifically, the currently active group) is ignored
|
||||||
* @GDK_EVENT_MATCH_EXACT: The key event matches
|
* @GDK_KEY_MATCH_EXACT: The key event matches
|
||||||
*
|
*
|
||||||
* The possible return values from gdk_event_matches()
|
* The possible return values from gdk_key_event_matches()
|
||||||
* describe how well an event matches a given keyval and modifiers.
|
* describe how well an event matches a given keyval and modifiers.
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
GDK_EVENT_MATCH_NONE,
|
GDK_KEY_MATCH_NONE,
|
||||||
GDK_EVENT_MATCH_PARTIAL,
|
GDK_KEY_MATCH_PARTIAL,
|
||||||
GDK_EVENT_MATCH_EXACT
|
GDK_KEY_MATCH_EXACT
|
||||||
} GdkEventMatch;
|
} GdkKeyMatch;
|
||||||
|
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
GdkEventMatch gdk_event_matches (GdkEvent *event,
|
GdkKeyMatch gdk_key_event_matches (GdkEvent *event,
|
||||||
guint keyval,
|
guint keyval,
|
||||||
GdkModifierType modifiers);
|
GdkModifierType modifiers);
|
||||||
|
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
gboolean gdk_event_get_match (GdkEvent *event,
|
gboolean gdk_key_event_get_match (GdkEvent *event,
|
||||||
guint *keyval,
|
guint *keyval,
|
||||||
GdkModifierType *modifiers);
|
GdkModifierType *modifiers);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
@ -223,6 +223,13 @@ struct _GdkEventScroll
|
|||||||
GdkDeviceTool *tool;
|
GdkDeviceTool *tool;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
guint keyval;
|
||||||
|
GdkModifierType consumed;
|
||||||
|
guint layout;
|
||||||
|
guint level;
|
||||||
|
} GdkTranslatedKey;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GdkEventKey:
|
* GdkEventKey:
|
||||||
* @type: the type of the event (%GDK_KEY_PRESS or %GDK_KEY_RELEASE).
|
* @type: the type of the event (%GDK_KEY_PRESS or %GDK_KEY_RELEASE).
|
||||||
@ -232,13 +239,9 @@ struct _GdkEventScroll
|
|||||||
* @state: (type GdkModifierType): a bit-mask representing the state of
|
* @state: (type GdkModifierType): a bit-mask representing the state of
|
||||||
* the modifier keys (e.g. Control, Shift and Alt) and the pointer
|
* the modifier keys (e.g. Control, Shift and Alt) and the pointer
|
||||||
* buttons. See #GdkModifierType.
|
* buttons. See #GdkModifierType.
|
||||||
* @keyval: the key that was pressed or released. See the
|
* @keycode: the raw code of the key that was pressed or released.
|
||||||
* `gdk/gdkkeysyms.h` header file for a
|
* @translated: the result of translating @keycode. First with the full
|
||||||
* complete list of GDK key codes.
|
* @state, then while ignoring Caps Lock.
|
||||||
* @hardware_keycode: the raw code of the key that was pressed or released.
|
|
||||||
* @group: the keyboard group.
|
|
||||||
* @is_modifier: a flag that indicates if @hardware_keycode is mapped to a
|
|
||||||
* modifier
|
|
||||||
*
|
*
|
||||||
* Describes a key press or key release event.
|
* Describes a key press or key release event.
|
||||||
*/
|
*/
|
||||||
@ -246,10 +249,8 @@ struct _GdkEventKey
|
|||||||
{
|
{
|
||||||
GdkEventAny any;
|
GdkEventAny any;
|
||||||
GdkModifierType state;
|
GdkModifierType state;
|
||||||
guint keyval;
|
guint32 keycode;
|
||||||
guint16 hardware_keycode;
|
GdkTranslatedKey translated[2];
|
||||||
guint16 key_scancode;
|
|
||||||
guint8 group;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -594,17 +595,16 @@ GdkEvent * gdk_event_proximity_new (GdkEventType type,
|
|||||||
GdkDeviceTool *tool,
|
GdkDeviceTool *tool,
|
||||||
guint32 time);
|
guint32 time);
|
||||||
|
|
||||||
GdkEvent * gdk_event_key_new (GdkEventType type,
|
GdkEvent * gdk_event_key_new (GdkEventType type,
|
||||||
GdkSurface *surface,
|
GdkSurface *surface,
|
||||||
GdkDevice *device,
|
GdkDevice *device,
|
||||||
GdkDevice *source_device,
|
GdkDevice *source_device,
|
||||||
guint32 time,
|
guint32 time,
|
||||||
GdkModifierType state,
|
guint keycode,
|
||||||
guint keyval,
|
GdkModifierType modifiers,
|
||||||
guint16 keycode,
|
gboolean is_modifier,
|
||||||
guint16 scancode,
|
GdkTranslatedKey *translated,
|
||||||
guint8 group,
|
GdkTranslatedKey *no_lock);
|
||||||
gboolean is_modifier);
|
|
||||||
|
|
||||||
GdkEvent * gdk_event_focus_new (GdkSurface *surface,
|
GdkEvent * gdk_event_focus_new (GdkSurface *surface,
|
||||||
GdkDevice *device,
|
GdkDevice *device,
|
||||||
|
@ -2815,17 +2815,18 @@ rewrite_event_for_toplevel (GdkEvent *event)
|
|||||||
gdk_event_get_source_device (event),
|
gdk_event_get_source_device (event),
|
||||||
gdk_focus_event_get_in (event));
|
gdk_focus_event_get_in (event));
|
||||||
else
|
else
|
||||||
return gdk_event_key_new (gdk_event_get_event_type (event),
|
{
|
||||||
surface,
|
return gdk_event_key_new (gdk_event_get_event_type (event),
|
||||||
gdk_event_get_device (event),
|
surface,
|
||||||
gdk_event_get_source_device (event),
|
gdk_event_get_device (event),
|
||||||
gdk_event_get_time (event),
|
gdk_event_get_source_device (event),
|
||||||
gdk_event_get_modifier_state (event),
|
gdk_event_get_time (event),
|
||||||
gdk_key_event_get_keyval (event),
|
gdk_key_event_get_keycode (event),
|
||||||
gdk_key_event_get_keycode (event),
|
gdk_event_get_modifier_state (event),
|
||||||
gdk_key_event_get_scancode (event),
|
gdk_key_event_is_modifier (event),
|
||||||
gdk_key_event_get_group (event),
|
&event->key.translated[0],
|
||||||
gdk_key_event_is_modifier (event));
|
&event->key.translated[1]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -2874,13 +2875,13 @@ add_event_mark (GdkEvent *event,
|
|||||||
case GDK_KEY_PRESS:
|
case GDK_KEY_PRESS:
|
||||||
case GDK_KEY_RELEASE:
|
case GDK_KEY_RELEASE:
|
||||||
{
|
{
|
||||||
message = g_strdup_printf ("%s {keyval=%u, state=0x%x, hardware_keycode=%u key_scancode=%u group=%u is_modifier=%u}",
|
message = g_strdup_printf ("%s {keyval=%u, state=0x%x, keycode=%u layout=%u level=%u is_modifier=%u}",
|
||||||
kind,
|
kind,
|
||||||
gdk_key_event_get_keyval (event),
|
gdk_key_event_get_keyval (event),
|
||||||
gdk_event_get_modifier_state (event),
|
gdk_event_get_modifier_state (event),
|
||||||
gdk_key_event_get_keycode (event),
|
gdk_key_event_get_keycode (event),
|
||||||
gdk_key_event_get_scancode (event),
|
gdk_key_event_get_layout (event),
|
||||||
gdk_key_event_get_group (event),
|
gdk_key_event_get_level (event),
|
||||||
gdk_key_event_is_modifier (event));
|
gdk_key_event_is_modifier (event));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2020,9 +2020,13 @@ deliver_key_event (GdkWaylandSeat *seat,
|
|||||||
struct xkb_state *xkb_state;
|
struct xkb_state *xkb_state;
|
||||||
struct xkb_keymap *xkb_keymap;
|
struct xkb_keymap *xkb_keymap;
|
||||||
GdkKeymap *keymap;
|
GdkKeymap *keymap;
|
||||||
xkb_keysym_t sym;
|
|
||||||
guint delay, interval, timeout;
|
guint delay, interval, timeout;
|
||||||
gint64 begin_time, now;
|
gint64 begin_time, now;
|
||||||
|
xkb_mod_mask_t consumed;
|
||||||
|
GdkTranslatedKey translated;
|
||||||
|
GdkTranslatedKey no_lock;
|
||||||
|
xkb_mod_mask_t modifiers;
|
||||||
|
xkb_mod_index_t caps_lock;
|
||||||
|
|
||||||
begin_time = g_get_monotonic_time ();
|
begin_time = g_get_monotonic_time ();
|
||||||
|
|
||||||
@ -2032,36 +2036,69 @@ deliver_key_event (GdkWaylandSeat *seat,
|
|||||||
xkb_state = _gdk_wayland_keymap_get_xkb_state (keymap);
|
xkb_state = _gdk_wayland_keymap_get_xkb_state (keymap);
|
||||||
xkb_keymap = _gdk_wayland_keymap_get_xkb_keymap (keymap);
|
xkb_keymap = _gdk_wayland_keymap_get_xkb_keymap (keymap);
|
||||||
|
|
||||||
sym = xkb_state_key_get_one_sym (xkb_state, key);
|
translated.keyval = xkb_state_key_get_one_sym (xkb_state, key);
|
||||||
if (sym == XKB_KEY_NoSymbol)
|
modifiers = xkb_state_serialize_mods (xkb_state, XKB_STATE_MODS_EFFECTIVE);
|
||||||
|
consumed = modifiers & ~xkb_state_mod_mask_remove_consumed (xkb_state, key, modifiers);
|
||||||
|
translated.consumed = gdk_wayland_keymap_get_gdk_modifiers (keymap, consumed);
|
||||||
|
translated.layout = xkb_state_key_get_layout (xkb_state, key);
|
||||||
|
translated.level = xkb_state_key_get_level (xkb_state, key, translated.layout);
|
||||||
|
|
||||||
|
if (translated.keyval == XKB_KEY_NoSymbol)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
seat->pointer_info.time = time_;
|
seat->pointer_info.time = time_;
|
||||||
seat->key_modifiers = gdk_keymap_get_modifier_state (keymap);
|
seat->key_modifiers = gdk_keymap_get_modifier_state (keymap);
|
||||||
|
|
||||||
|
|
||||||
|
modifiers = xkb_state_serialize_mods (xkb_state, XKB_STATE_MODS_EFFECTIVE);
|
||||||
|
caps_lock = xkb_keymap_mod_get_index (xkb_keymap, XKB_MOD_NAME_CAPS);
|
||||||
|
if (modifiers & (1 << caps_lock))
|
||||||
|
{
|
||||||
|
struct xkb_state *tmp_state = xkb_state_new (xkb_keymap);
|
||||||
|
xkb_layout_index_t layout;
|
||||||
|
|
||||||
|
modifiers &= ~(1 << caps_lock);
|
||||||
|
layout = xkb_state_serialize_layout (xkb_state, XKB_STATE_LAYOUT_EFFECTIVE);
|
||||||
|
xkb_state_update_mask (tmp_state, modifiers, 0, 0, layout, 0, 0);
|
||||||
|
|
||||||
|
no_lock.keyval = xkb_state_key_get_one_sym (tmp_state, key);
|
||||||
|
consumed = modifiers & ~xkb_state_mod_mask_remove_consumed (tmp_state, key, modifiers);
|
||||||
|
no_lock.consumed = gdk_wayland_keymap_get_gdk_modifiers (keymap, consumed);
|
||||||
|
no_lock.layout = xkb_state_key_get_layout (tmp_state, key);
|
||||||
|
no_lock.level = xkb_state_key_get_level (tmp_state, key, no_lock.layout);
|
||||||
|
|
||||||
|
xkb_state_unref (tmp_state);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
no_lock = translated;
|
||||||
|
}
|
||||||
|
|
||||||
event = gdk_event_key_new (state ? GDK_KEY_PRESS : GDK_KEY_RELEASE,
|
event = gdk_event_key_new (state ? GDK_KEY_PRESS : GDK_KEY_RELEASE,
|
||||||
seat->keyboard_focus,
|
seat->keyboard_focus,
|
||||||
seat->master_keyboard,
|
seat->master_keyboard,
|
||||||
seat->keyboard,
|
seat->keyboard,
|
||||||
time_,
|
time_,
|
||||||
|
key,
|
||||||
device_get_modifiers (seat->master_pointer),
|
device_get_modifiers (seat->master_pointer),
|
||||||
sym,
|
_gdk_wayland_keymap_key_is_modifier (keymap, key),
|
||||||
key,
|
&translated,
|
||||||
key,
|
&no_lock);
|
||||||
0,
|
|
||||||
_gdk_wayland_keymap_key_is_modifier (keymap, key));
|
|
||||||
|
|
||||||
_gdk_wayland_display_deliver_event (seat->display, event);
|
_gdk_wayland_display_deliver_event (seat->display, event);
|
||||||
|
|
||||||
GDK_SEAT_NOTE (seat, EVENTS,
|
GDK_SEAT_NOTE (seat, EVENTS,
|
||||||
g_message ("keyboard %s event%s, surface %p, code %d, sym %d, "
|
g_message ("keyboard %s event%s, surface %p, code %d, sym %d, "
|
||||||
"mods 0x%x",
|
"mods 0x%x, consumed 0x%x, layout %d level %d",
|
||||||
(state ? "press" : "release"),
|
(state ? "press" : "release"),
|
||||||
(from_key_repeat ? " (repeat)" : ""),
|
(from_key_repeat ? " (repeat)" : ""),
|
||||||
gdk_event_get_surface (event),
|
gdk_event_get_surface (event),
|
||||||
gdk_key_event_get_keycode (event),
|
gdk_key_event_get_keycode (event),
|
||||||
gdk_key_event_get_keyval (event),
|
gdk_key_event_get_keyval (event),
|
||||||
gdk_event_get_modifier_state (event)));
|
gdk_event_get_modifier_state (event),
|
||||||
|
gdk_key_event_get_consumed_modifiers (event),
|
||||||
|
gdk_key_event_get_layout (event),
|
||||||
|
gdk_key_event_get_level (event)));
|
||||||
|
|
||||||
if (!xkb_keymap_key_repeats (xkb_keymap, key))
|
if (!xkb_keymap_key_repeats (xkb_keymap, key))
|
||||||
return;
|
return;
|
||||||
|
@ -300,6 +300,15 @@ get_gdk_modifiers (struct xkb_keymap *xkb_keymap,
|
|||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GdkModifierType
|
||||||
|
gdk_wayland_keymap_get_gdk_modifiers (GdkKeymap *keymap,
|
||||||
|
guint32 mods)
|
||||||
|
{
|
||||||
|
struct xkb_keymap *xkb_keymap = GDK_WAYLAND_KEYMAP (keymap)->xkb_keymap;
|
||||||
|
|
||||||
|
return get_gdk_modifiers (xkb_keymap, mods);
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gdk_wayland_keymap_translate_keyboard_state (GdkKeymap *keymap,
|
gdk_wayland_keymap_translate_keyboard_state (GdkKeymap *keymap,
|
||||||
guint hardware_keycode,
|
guint hardware_keycode,
|
||||||
|
@ -201,5 +201,7 @@ void gdk_wayland_surface_update_scale (GdkSurface *surface);
|
|||||||
|
|
||||||
GdkSurface * create_dnd_surface (GdkDisplay *display);
|
GdkSurface * create_dnd_surface (GdkDisplay *display);
|
||||||
|
|
||||||
|
GdkModifierType gdk_wayland_keymap_get_gdk_modifiers (GdkKeymap *keymap,
|
||||||
|
guint32 mods);
|
||||||
|
|
||||||
#endif /* __GDK_PRIVATE_WAYLAND_H__ */
|
#endif /* __GDK_PRIVATE_WAYLAND_H__ */
|
||||||
|
@ -809,7 +809,7 @@ _gdk_win32_print_event (GdkEvent *event)
|
|||||||
kvname = gdk_keyval_name (gdk_key_event_get_keyval (event));
|
kvname = gdk_keyval_name (gdk_key_event_get_keyval (event));
|
||||||
g_print ("%#.02x group:%d %s",
|
g_print ("%#.02x group:%d %s",
|
||||||
gdk_key_event_get_keycode (event),
|
gdk_key_event_get_keycode (event),
|
||||||
gdk_key_event_get_group (event),
|
gdk_key_event_get_layout (event),
|
||||||
(kvname ? kvname : "??"));
|
(kvname ? kvname : "??"));
|
||||||
print_event_state (gdk_event_get_modifier_state (event));
|
print_event_state (gdk_event_get_modifier_state (event));
|
||||||
break;
|
break;
|
||||||
@ -2050,12 +2050,12 @@ gdk_event_translate (MSG *msg,
|
|||||||
GdkModifierType state;
|
GdkModifierType state;
|
||||||
guint keyval;
|
guint keyval;
|
||||||
guint16 keycode;
|
guint16 keycode;
|
||||||
guint16 scancode;
|
|
||||||
guint8 group;
|
guint8 group;
|
||||||
gboolean is_modifier;
|
gboolean is_modifier;
|
||||||
|
|
||||||
double delta_x, delta_y;
|
double delta_x, delta_y;
|
||||||
GdkScrollDirection direction;
|
GdkScrollDirection direction;
|
||||||
|
GdkTranslatedKey translated;
|
||||||
|
|
||||||
display = gdk_display_get_default ();
|
display = gdk_display_get_default ();
|
||||||
win32_display = GDK_WIN32_DISPLAY (display);
|
win32_display = GDK_WIN32_DISPLAY (display);
|
||||||
@ -2129,17 +2129,20 @@ gdk_event_translate (MSG *msg,
|
|||||||
gdk_display_setting_changed (display, "gtk-im-module");
|
gdk_display_setting_changed (display, "gtk-im-module");
|
||||||
|
|
||||||
/* Generate a dummy key event to "nudge" IMContext */
|
/* Generate a dummy key event to "nudge" IMContext */
|
||||||
|
translated.keyval = GDK_KEY_VoidSymbol;
|
||||||
|
translated.consumed = 0;
|
||||||
|
translated.layout = 0;
|
||||||
|
translated.level = 0;
|
||||||
event = gdk_event_key_new (GDK_KEY_PRESS,
|
event = gdk_event_key_new (GDK_KEY_PRESS,
|
||||||
window,
|
window,
|
||||||
device_manager_win32->core_keyboard,
|
device_manager_win32->core_keyboard,
|
||||||
device_manager_win32->system_keyboard,
|
device_manager_win32->system_keyboard,
|
||||||
_gdk_win32_get_next_tick (msg->time),
|
_gdk_win32_get_next_tick (msg->time),
|
||||||
0,
|
0,
|
||||||
GDK_KEY_VoidSymbol,
|
|
||||||
0,
|
0,
|
||||||
0,
|
FALSE,
|
||||||
0,
|
&translated,
|
||||||
FALSE);
|
&translated);
|
||||||
_gdk_win32_append_event (event);
|
_gdk_win32_append_event (event);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -2225,7 +2228,6 @@ gdk_event_translate (MSG *msg,
|
|||||||
|
|
||||||
keyval = GDK_KEY_VoidSymbol;
|
keyval = GDK_KEY_VoidSymbol;
|
||||||
keycode = msg->wParam;
|
keycode = msg->wParam;
|
||||||
scancode = msg->lParam >> 16;
|
|
||||||
|
|
||||||
if (HIWORD (msg->lParam) & KF_EXTENDED)
|
if (HIWORD (msg->lParam) & KF_EXTENDED)
|
||||||
{
|
{
|
||||||
@ -2329,6 +2331,11 @@ gdk_event_translate (MSG *msg,
|
|||||||
if (msg->wParam == VK_MENU)
|
if (msg->wParam == VK_MENU)
|
||||||
state &= ~GDK_ALT_MASK;
|
state &= ~GDK_ALT_MASK;
|
||||||
|
|
||||||
|
/* FIXME do proper translation */
|
||||||
|
translated.keyval = keyval;
|
||||||
|
translated.consumed = 0;
|
||||||
|
translated.layout = group;
|
||||||
|
translated.level = 0;
|
||||||
event = gdk_event_key_new ((msg->message == WM_KEYDOWN || msg->message == WM_SYSKEYDOWN)
|
event = gdk_event_key_new ((msg->message == WM_KEYDOWN || msg->message == WM_SYSKEYDOWN)
|
||||||
? GDK_KEY_PRESS
|
? GDK_KEY_PRESS
|
||||||
: GDK_KEY_RELEASE,
|
: GDK_KEY_RELEASE,
|
||||||
@ -2337,11 +2344,10 @@ gdk_event_translate (MSG *msg,
|
|||||||
device_manager_win32->system_keyboard,
|
device_manager_win32->system_keyboard,
|
||||||
_gdk_win32_get_next_tick (msg->time),
|
_gdk_win32_get_next_tick (msg->time),
|
||||||
state,
|
state,
|
||||||
keyval,
|
|
||||||
keycode,
|
keycode,
|
||||||
scancode,
|
is_modifier,
|
||||||
group,
|
&translated,
|
||||||
is_modifier);
|
&translated);
|
||||||
|
|
||||||
_gdk_win32_append_event (event);
|
_gdk_win32_append_event (event);
|
||||||
|
|
||||||
@ -2403,17 +2409,20 @@ gdk_event_translate (MSG *msg,
|
|||||||
for (i = 0; i < ccount; i++)
|
for (i = 0; i < ccount; i++)
|
||||||
{
|
{
|
||||||
/* Build a key press event */
|
/* Build a key press event */
|
||||||
|
translated.keyval = gdk_unicode_to_keyval (wbuf[i]);
|
||||||
|
translated.consumed = 0;
|
||||||
|
translated.layout = get_active_group ();
|
||||||
|
translated.level = 0;
|
||||||
event = gdk_event_key_new (GDK_KEY_PRESS,
|
event = gdk_event_key_new (GDK_KEY_PRESS,
|
||||||
window,
|
window,
|
||||||
device_manager_win32->core_keyboard,
|
device_manager_win32->core_keyboard,
|
||||||
device_manager_win32->system_keyboard,
|
device_manager_win32->system_keyboard,
|
||||||
_gdk_win32_get_next_tick (msg->time),
|
_gdk_win32_get_next_tick (msg->time),
|
||||||
build_key_event_state (key_state),
|
build_key_event_state (key_state),
|
||||||
gdk_unicode_to_keyval (wbuf[i]),
|
|
||||||
0,
|
0,
|
||||||
0,
|
FALSE,
|
||||||
get_active_group (),
|
&translated,
|
||||||
FALSE);
|
&translated);
|
||||||
|
|
||||||
_gdk_win32_append_event (event);
|
_gdk_win32_append_event (event);
|
||||||
|
|
||||||
@ -2424,11 +2433,10 @@ gdk_event_translate (MSG *msg,
|
|||||||
device_manager_win32->system_keyboard,
|
device_manager_win32->system_keyboard,
|
||||||
_gdk_win32_get_next_tick (msg->time),
|
_gdk_win32_get_next_tick (msg->time),
|
||||||
build_key_event_state (key_state),
|
build_key_event_state (key_state),
|
||||||
gdk_unicode_to_keyval (wbuf[i]),
|
|
||||||
0,
|
0,
|
||||||
0,
|
FALSE,
|
||||||
get_active_group (),
|
&translated,
|
||||||
FALSE);
|
&translated);
|
||||||
|
|
||||||
_gdk_win32_append_event (event);
|
_gdk_win32_append_event (event);
|
||||||
}
|
}
|
||||||
|
@ -1521,7 +1521,10 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
|
|||||||
XIDeviceEvent *xev = (XIDeviceEvent *) ev;
|
XIDeviceEvent *xev = (XIDeviceEvent *) ev;
|
||||||
GdkKeymap *keymap = gdk_display_get_keymap (display);
|
GdkKeymap *keymap = gdk_display_get_keymap (display);
|
||||||
GdkModifierType consumed, state, orig_state;
|
GdkModifierType consumed, state, orig_state;
|
||||||
|
int layout, level;
|
||||||
guint keyval;
|
guint keyval;
|
||||||
|
GdkTranslatedKey translated;
|
||||||
|
GdkTranslatedKey no_lock;
|
||||||
|
|
||||||
GDK_DISPLAY_NOTE (display, EVENTS,
|
GDK_DISPLAY_NOTE (display, EVENTS,
|
||||||
g_message ("key %s:\twindow %ld\n"
|
g_message ("key %s:\twindow %ld\n"
|
||||||
@ -1549,12 +1552,37 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
|
|||||||
state,
|
state,
|
||||||
xev->group.effective,
|
xev->group.effective,
|
||||||
&keyval,
|
&keyval,
|
||||||
NULL, NULL, &consumed);
|
&layout, &level, &consumed);
|
||||||
orig_state = state;
|
orig_state = state;
|
||||||
state &= ~consumed;
|
state &= ~consumed;
|
||||||
_gdk_x11_keymap_add_virt_mods (keymap, &state);
|
_gdk_x11_keymap_add_virt_mods (keymap, &state);
|
||||||
state |= orig_state;
|
state |= orig_state;
|
||||||
|
|
||||||
|
translated.keyval = keyval;
|
||||||
|
translated.consumed = consumed;
|
||||||
|
translated.layout = layout;
|
||||||
|
translated.level = level;
|
||||||
|
|
||||||
|
if (orig_state & GDK_LOCK_MASK)
|
||||||
|
{
|
||||||
|
orig_state &= ~GDK_LOCK_MASK;
|
||||||
|
|
||||||
|
gdk_keymap_translate_keyboard_state (keymap,
|
||||||
|
xev->detail,
|
||||||
|
orig_state,
|
||||||
|
xev->group.effective,
|
||||||
|
&keyval,
|
||||||
|
&layout, &level, &consumed);
|
||||||
|
|
||||||
|
no_lock.keyval = keyval;
|
||||||
|
no_lock.consumed = consumed;
|
||||||
|
no_lock.layout = layout;
|
||||||
|
no_lock.level = level;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
no_lock = translated;
|
||||||
|
}
|
||||||
event = gdk_event_key_new (xev->evtype == XI_KeyPress
|
event = gdk_event_key_new (xev->evtype == XI_KeyPress
|
||||||
? GDK_KEY_PRESS
|
? GDK_KEY_PRESS
|
||||||
: GDK_KEY_RELEASE,
|
: GDK_KEY_RELEASE,
|
||||||
@ -1562,12 +1590,11 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
|
|||||||
device,
|
device,
|
||||||
source_device,
|
source_device,
|
||||||
xev->time,
|
xev->time,
|
||||||
|
xev->detail,
|
||||||
state,
|
state,
|
||||||
keyval,
|
gdk_x11_keymap_key_is_modifier (keymap, xev->detail),
|
||||||
xev->detail,
|
&translated,
|
||||||
xev->detail,
|
&no_lock);
|
||||||
xev->group.effective,
|
|
||||||
gdk_x11_keymap_key_is_modifier (keymap, xev->detail));
|
|
||||||
|
|
||||||
if (ev->evtype == XI_KeyPress)
|
if (ev->evtype == XI_KeyPress)
|
||||||
set_user_time (event);
|
set_user_time (event);
|
||||||
|
@ -2214,7 +2214,7 @@ gdk_dnd_handle_key_event (GdkDrag *drag,
|
|||||||
|
|
||||||
if (event->any.type == GDK_KEY_PRESS)
|
if (event->any.type == GDK_KEY_PRESS)
|
||||||
{
|
{
|
||||||
switch (event->keyval)
|
switch (event->translated[0].keyval)
|
||||||
{
|
{
|
||||||
case GDK_KEY_Escape:
|
case GDK_KEY_Escape:
|
||||||
gdk_drag_cancel (drag, GDK_DRAG_CANCEL_USER_CANCELLED);
|
gdk_drag_cancel (drag, GDK_DRAG_CANCEL_USER_CANCELLED);
|
||||||
|
@ -540,7 +540,7 @@ key_controller_key_pressed (GtkEventControllerKey *key,
|
|||||||
GdkModifierType accel_mods = 0;
|
GdkModifierType accel_mods = 0;
|
||||||
guint accel_key;
|
guint accel_key;
|
||||||
|
|
||||||
if (!gdk_event_get_match (gtk_get_current_event (), &accel_key, &accel_mods))
|
if (!gdk_key_event_get_match (gtk_get_current_event (), &accel_key, &accel_mods))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (accel_mods == 0)
|
if (accel_mods == 0)
|
||||||
|
@ -385,5 +385,5 @@ gtk_event_controller_key_get_group (GtkEventControllerKey *controller)
|
|||||||
g_return_val_if_fail (GTK_IS_EVENT_CONTROLLER_KEY (controller), FALSE);
|
g_return_val_if_fail (GTK_IS_EVENT_CONTROLLER_KEY (controller), FALSE);
|
||||||
g_return_val_if_fail (controller->current_event != NULL, FALSE);
|
g_return_val_if_fail (controller->current_event != NULL, FALSE);
|
||||||
|
|
||||||
return gdk_key_event_get_group (controller->current_event);
|
return gdk_key_event_get_layout (controller->current_event);
|
||||||
}
|
}
|
||||||
|
@ -929,18 +929,21 @@ no_sequence_matches (GtkIMContextSimple *context_simple,
|
|||||||
|
|
||||||
for (i = 0; i < n_compose - len - 1; i++)
|
for (i = 0; i < n_compose - len - 1; i++)
|
||||||
{
|
{
|
||||||
guint tmp_keyval = priv->compose_buffer[len + i];
|
GdkTranslatedKey translated;
|
||||||
|
translated.keyval = priv->compose_buffer[len + i];
|
||||||
|
translated.consumed = 0;
|
||||||
|
translated.layout = 0;
|
||||||
|
translated.level = 0;
|
||||||
GdkEvent *tmp_event = gdk_event_key_new (GDK_KEY_PRESS,
|
GdkEvent *tmp_event = gdk_event_key_new (GDK_KEY_PRESS,
|
||||||
gdk_event_get_surface (event),
|
gdk_event_get_surface (event),
|
||||||
gdk_event_get_device (event),
|
gdk_event_get_device (event),
|
||||||
gdk_event_get_source_device (event),
|
gdk_event_get_source_device (event),
|
||||||
gdk_event_get_time (event),
|
gdk_event_get_time (event),
|
||||||
|
priv->compose_buffer[len + i],
|
||||||
gdk_event_get_modifier_state (event),
|
gdk_event_get_modifier_state (event),
|
||||||
tmp_keyval,
|
FALSE,
|
||||||
tmp_keyval,
|
&translated,
|
||||||
tmp_keyval,
|
&translated);
|
||||||
0,
|
|
||||||
0);
|
|
||||||
|
|
||||||
gtk_im_context_filter_keypress (context, tmp_event);
|
gtk_im_context_filter_keypress (context, tmp_event);
|
||||||
gdk_event_unref (tmp_event);
|
gdk_event_unref (tmp_event);
|
||||||
@ -997,7 +1000,7 @@ canonical_hex_keyval (GdkEvent *event)
|
|||||||
* any other state, and return that hex keyval if so
|
* any other state, and return that hex keyval if so
|
||||||
*/
|
*/
|
||||||
gdk_display_map_keycode (gdk_event_get_display (event),
|
gdk_display_map_keycode (gdk_event_get_display (event),
|
||||||
gdk_key_event_get_scancode (event),
|
gdk_key_event_get_keycode (event),
|
||||||
NULL,
|
NULL,
|
||||||
&keyvals, &n_vals);
|
&keyvals, &n_vals);
|
||||||
|
|
||||||
|
@ -313,16 +313,16 @@ gtk_shortcut_controller_run_controllers (GtkEventController *controller,
|
|||||||
|
|
||||||
switch (gtk_shortcut_trigger_trigger (gtk_shortcut_get_trigger (shortcut), event, enable_mnemonics))
|
switch (gtk_shortcut_trigger_trigger (gtk_shortcut_get_trigger (shortcut), event, enable_mnemonics))
|
||||||
{
|
{
|
||||||
case GDK_EVENT_MATCH_PARTIAL:
|
case GDK_KEY_MATCH_PARTIAL:
|
||||||
if (!has_exact)
|
if (!has_exact)
|
||||||
break;
|
break;
|
||||||
G_GNUC_FALLTHROUGH;
|
G_GNUC_FALLTHROUGH;
|
||||||
|
|
||||||
case GDK_EVENT_MATCH_NONE:
|
case GDK_KEY_MATCH_NONE:
|
||||||
g_object_unref (shortcut);
|
g_object_unref (shortcut);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case GDK_EVENT_MATCH_EXACT:
|
case GDK_KEY_MATCH_EXACT:
|
||||||
if (!has_exact)
|
if (!has_exact)
|
||||||
{
|
{
|
||||||
g_slist_free_full (shortcuts, shortcut_data_free);
|
g_slist_free_full (shortcuts, shortcut_data_free);
|
||||||
|
@ -59,7 +59,7 @@ struct _GtkShortcutTriggerClass
|
|||||||
{
|
{
|
||||||
GObjectClass parent_class;
|
GObjectClass parent_class;
|
||||||
|
|
||||||
GdkEventMatch (* trigger) (GtkShortcutTrigger *trigger,
|
GdkKeyMatch (* trigger) (GtkShortcutTrigger *trigger,
|
||||||
GdkEvent *event,
|
GdkEvent *event,
|
||||||
gboolean enable_mnemonics);
|
gboolean enable_mnemonics);
|
||||||
guint (* hash) (GtkShortcutTrigger *trigger);
|
guint (* hash) (GtkShortcutTrigger *trigger);
|
||||||
@ -96,12 +96,12 @@ gtk_shortcut_trigger_init (GtkShortcutTrigger *self)
|
|||||||
*
|
*
|
||||||
* Returns: Whether the event triggered the shortcut
|
* Returns: Whether the event triggered the shortcut
|
||||||
**/
|
**/
|
||||||
GdkEventMatch
|
GdkKeyMatch
|
||||||
gtk_shortcut_trigger_trigger (GtkShortcutTrigger *self,
|
gtk_shortcut_trigger_trigger (GtkShortcutTrigger *self,
|
||||||
GdkEvent *event,
|
GdkEvent *event,
|
||||||
gboolean enable_mnemonics)
|
gboolean enable_mnemonics)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (GTK_IS_SHORTCUT_TRIGGER (self), GDK_EVENT_MATCH_NONE);
|
g_return_val_if_fail (GTK_IS_SHORTCUT_TRIGGER (self), GDK_KEY_MATCH_NONE);
|
||||||
|
|
||||||
return GTK_SHORTCUT_TRIGGER_GET_CLASS (self)->trigger (self, event, enable_mnemonics);
|
return GTK_SHORTCUT_TRIGGER_GET_CLASS (self)->trigger (self, event, enable_mnemonics);
|
||||||
}
|
}
|
||||||
@ -409,12 +409,12 @@ gtk_never_trigger_finalize (GObject *gobject)
|
|||||||
G_OBJECT_CLASS (gtk_never_trigger_parent_class)->finalize (gobject);
|
G_OBJECT_CLASS (gtk_never_trigger_parent_class)->finalize (gobject);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GdkEventMatch
|
static GdkKeyMatch
|
||||||
gtk_never_trigger_trigger (GtkShortcutTrigger *trigger,
|
gtk_never_trigger_trigger (GtkShortcutTrigger *trigger,
|
||||||
GdkEvent *event,
|
GdkEvent *event,
|
||||||
gboolean enable_mnemonics)
|
gboolean enable_mnemonics)
|
||||||
{
|
{
|
||||||
return GDK_EVENT_MATCH_NONE;
|
return GDK_KEY_MATCH_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static guint
|
static guint
|
||||||
@ -509,14 +509,14 @@ enum
|
|||||||
|
|
||||||
static GParamSpec *keyval_props[KEYVAL_N_PROPS];
|
static GParamSpec *keyval_props[KEYVAL_N_PROPS];
|
||||||
|
|
||||||
static GdkEventMatch
|
static GdkKeyMatch
|
||||||
gtk_keyval_trigger_trigger (GtkShortcutTrigger *trigger,
|
gtk_keyval_trigger_trigger (GtkShortcutTrigger *trigger,
|
||||||
GdkEvent *event,
|
GdkEvent *event,
|
||||||
gboolean enable_mnemonics)
|
gboolean enable_mnemonics)
|
||||||
{
|
{
|
||||||
GtkKeyvalTrigger *self = GTK_KEYVAL_TRIGGER (trigger);
|
GtkKeyvalTrigger *self = GTK_KEYVAL_TRIGGER (trigger);
|
||||||
|
|
||||||
return gdk_event_matches (event, self->keyval, self->modifiers);
|
return gdk_key_event_matches (event, self->keyval, self->modifiers);
|
||||||
}
|
}
|
||||||
|
|
||||||
static guint
|
static guint
|
||||||
@ -752,7 +752,7 @@ enum
|
|||||||
|
|
||||||
static GParamSpec *mnemonic_props[MNEMONIC_N_PROPS];
|
static GParamSpec *mnemonic_props[MNEMONIC_N_PROPS];
|
||||||
|
|
||||||
static GdkEventMatch
|
static GdkKeyMatch
|
||||||
gtk_mnemonic_trigger_trigger (GtkShortcutTrigger *trigger,
|
gtk_mnemonic_trigger_trigger (GtkShortcutTrigger *trigger,
|
||||||
GdkEvent *event,
|
GdkEvent *event,
|
||||||
gboolean enable_mnemonics)
|
gboolean enable_mnemonics)
|
||||||
@ -761,10 +761,10 @@ gtk_mnemonic_trigger_trigger (GtkShortcutTrigger *trigger,
|
|||||||
guint keyval;
|
guint keyval;
|
||||||
|
|
||||||
if (!enable_mnemonics)
|
if (!enable_mnemonics)
|
||||||
return GDK_EVENT_MATCH_NONE;
|
return GDK_KEY_MATCH_NONE;
|
||||||
|
|
||||||
if (gdk_event_get_event_type (event) != GDK_KEY_PRESS)
|
if (gdk_event_get_event_type (event) != GDK_KEY_PRESS)
|
||||||
return GDK_EVENT_MATCH_NONE;
|
return GDK_KEY_MATCH_NONE;
|
||||||
|
|
||||||
/* XXX: This needs to deal with groups */
|
/* XXX: This needs to deal with groups */
|
||||||
keyval = gdk_key_event_get_keyval (event);
|
keyval = gdk_key_event_get_keyval (event);
|
||||||
@ -775,9 +775,9 @@ gtk_mnemonic_trigger_trigger (GtkShortcutTrigger *trigger,
|
|||||||
keyval = gdk_keyval_to_lower (keyval);
|
keyval = gdk_keyval_to_lower (keyval);
|
||||||
|
|
||||||
if (keyval != self->keyval)
|
if (keyval != self->keyval)
|
||||||
return GDK_EVENT_MATCH_NONE;
|
return GDK_KEY_MATCH_NONE;
|
||||||
|
|
||||||
return GDK_EVENT_MATCH_EXACT;
|
return GDK_KEY_MATCH_EXACT;
|
||||||
}
|
}
|
||||||
|
|
||||||
static guint
|
static guint
|
||||||
@ -988,7 +988,7 @@ gtk_alternative_trigger_dispose (GObject *gobject)
|
|||||||
G_OBJECT_CLASS (gtk_alternative_trigger_parent_class)->dispose (gobject);
|
G_OBJECT_CLASS (gtk_alternative_trigger_parent_class)->dispose (gobject);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GdkEventMatch
|
static GdkKeyMatch
|
||||||
gtk_alternative_trigger_trigger (GtkShortcutTrigger *trigger,
|
gtk_alternative_trigger_trigger (GtkShortcutTrigger *trigger,
|
||||||
GdkEvent *event,
|
GdkEvent *event,
|
||||||
gboolean enable_mnemonics)
|
gboolean enable_mnemonics)
|
||||||
|
@ -65,7 +65,7 @@ gint gtk_shortcut_trigger_compare (gconstpointer
|
|||||||
gconstpointer trigger2);
|
gconstpointer trigger2);
|
||||||
|
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
GdkEventMatch gtk_shortcut_trigger_trigger (GtkShortcutTrigger *self,
|
GdkKeyMatch gtk_shortcut_trigger_trigger (GtkShortcutTrigger *self,
|
||||||
GdkEvent *event,
|
GdkEvent *event,
|
||||||
gboolean enable_mnemonics);
|
gboolean enable_mnemonics);
|
||||||
|
|
||||||
|
@ -19,27 +19,21 @@ struct _GdkEventAny
|
|||||||
GdkDevice *source_device;
|
GdkDevice *source_device;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
guint keyval;
|
||||||
|
GdkModifierType consumed;
|
||||||
|
guint layout;
|
||||||
|
guint level;
|
||||||
|
} GdkTranslatedKey;
|
||||||
|
|
||||||
struct _GdkEventKey
|
struct _GdkEventKey
|
||||||
{
|
{
|
||||||
GdkEventAny any;
|
GdkEventAny any;
|
||||||
GdkModifierType state;
|
GdkModifierType state;
|
||||||
guint keyval;
|
guint32 keycode;
|
||||||
guint16 hardware_keycode;
|
GdkTranslatedKey translated[2];
|
||||||
guint16 key_scancode;
|
|
||||||
guint8 group;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static GdkEvent * gdk_event_key_new (GdkEventType type,
|
|
||||||
GdkSurface *surface,
|
|
||||||
GdkDevice *device,
|
|
||||||
GdkDevice *source_device,
|
|
||||||
guint32 time,
|
|
||||||
GdkModifierType state,
|
|
||||||
guint keyval,
|
|
||||||
guint16 keycode,
|
|
||||||
guint16 scancode,
|
|
||||||
guint8 group,
|
|
||||||
gboolean is_modifier);
|
|
||||||
|
|
||||||
static GdkEvent *
|
static GdkEvent *
|
||||||
gdk_event_key_new (GdkEventType type,
|
gdk_event_key_new (GdkEventType type,
|
||||||
@ -47,12 +41,23 @@ gdk_event_key_new (GdkEventType type,
|
|||||||
GdkDevice *device,
|
GdkDevice *device,
|
||||||
GdkDevice *source_device,
|
GdkDevice *source_device,
|
||||||
guint32 time,
|
guint32 time,
|
||||||
|
guint keycode,
|
||||||
GdkModifierType state,
|
GdkModifierType state,
|
||||||
guint keyval,
|
gboolean is_modifier,
|
||||||
guint16 keycode,
|
GdkTranslatedKey *translated,
|
||||||
guint16 scancode,
|
GdkTranslatedKey *no_lock);
|
||||||
guint8 group,
|
|
||||||
gboolean is_modifier)
|
static GdkEvent *
|
||||||
|
gdk_event_key_new (GdkEventType type,
|
||||||
|
GdkSurface *surface,
|
||||||
|
GdkDevice *device,
|
||||||
|
GdkDevice *source_device,
|
||||||
|
guint32 time,
|
||||||
|
guint keycode,
|
||||||
|
GdkModifierType state,
|
||||||
|
gboolean is_modifier,
|
||||||
|
GdkTranslatedKey *translated,
|
||||||
|
GdkTranslatedKey *no_lock)
|
||||||
{
|
{
|
||||||
GdkEventKey *event;
|
GdkEventKey *event;
|
||||||
|
|
||||||
@ -67,12 +72,11 @@ gdk_event_key_new (GdkEventType type,
|
|||||||
event->any.surface = g_object_ref (surface);
|
event->any.surface = g_object_ref (surface);
|
||||||
event->any.device = g_object_ref (device);
|
event->any.device = g_object_ref (device);
|
||||||
event->any.source_device = g_object_ref (source_device);
|
event->any.source_device = g_object_ref (source_device);
|
||||||
|
event->keycode = keycode;
|
||||||
event->state = state;
|
event->state = state;
|
||||||
event->keyval = keyval;
|
|
||||||
event->hardware_keycode = keycode;
|
|
||||||
event->key_scancode = scancode;
|
|
||||||
event->group = group;
|
|
||||||
event->any.key_is_modifier = is_modifier;
|
event->any.key_is_modifier = is_modifier;
|
||||||
|
event->translated[0] = *translated;
|
||||||
|
event->translated[1] = *no_lock;
|
||||||
|
|
||||||
return (GdkEvent *)event;
|
return (GdkEvent *)event;
|
||||||
}
|
}
|
||||||
@ -340,14 +344,14 @@ test_trigger_trigger (void)
|
|||||||
guint keyval;
|
guint keyval;
|
||||||
GdkModifierType state;
|
GdkModifierType state;
|
||||||
gboolean mnemonic;
|
gboolean mnemonic;
|
||||||
GdkEventMatch result[4];
|
GdkKeyMatch result[4];
|
||||||
} tests[] = {
|
} tests[] = {
|
||||||
{ GDK_KEY_a, GDK_CONTROL_MASK, FALSE, { GDK_EVENT_MATCH_NONE, GDK_EVENT_MATCH_EXACT, GDK_EVENT_MATCH_NONE, GDK_EVENT_MATCH_EXACT } },
|
{ GDK_KEY_a, GDK_CONTROL_MASK, FALSE, { GDK_KEY_MATCH_NONE, GDK_KEY_MATCH_EXACT, GDK_KEY_MATCH_NONE, GDK_KEY_MATCH_EXACT } },
|
||||||
{ GDK_KEY_a, GDK_CONTROL_MASK, TRUE, { GDK_EVENT_MATCH_NONE, GDK_EVENT_MATCH_EXACT, GDK_EVENT_MATCH_NONE, GDK_EVENT_MATCH_EXACT } },
|
{ GDK_KEY_a, GDK_CONTROL_MASK, TRUE, { GDK_KEY_MATCH_NONE, GDK_KEY_MATCH_EXACT, GDK_KEY_MATCH_NONE, GDK_KEY_MATCH_EXACT } },
|
||||||
{ GDK_KEY_a, GDK_SHIFT_MASK, FALSE, { GDK_EVENT_MATCH_NONE, GDK_EVENT_MATCH_NONE, GDK_EVENT_MATCH_NONE, GDK_EVENT_MATCH_NONE } },
|
{ GDK_KEY_a, GDK_SHIFT_MASK, FALSE, { GDK_KEY_MATCH_NONE, GDK_KEY_MATCH_NONE, GDK_KEY_MATCH_NONE, GDK_KEY_MATCH_NONE } },
|
||||||
{ GDK_KEY_a, GDK_SHIFT_MASK, TRUE, { GDK_EVENT_MATCH_NONE, GDK_EVENT_MATCH_NONE, GDK_EVENT_MATCH_NONE, GDK_EVENT_MATCH_NONE } },
|
{ GDK_KEY_a, GDK_SHIFT_MASK, TRUE, { GDK_KEY_MATCH_NONE, GDK_KEY_MATCH_NONE, GDK_KEY_MATCH_NONE, GDK_KEY_MATCH_NONE } },
|
||||||
{ GDK_KEY_u, GDK_SHIFT_MASK, FALSE, { GDK_EVENT_MATCH_NONE, GDK_EVENT_MATCH_NONE, GDK_EVENT_MATCH_NONE, GDK_EVENT_MATCH_NONE } },
|
{ GDK_KEY_u, GDK_SHIFT_MASK, FALSE, { GDK_KEY_MATCH_NONE, GDK_KEY_MATCH_NONE, GDK_KEY_MATCH_NONE, GDK_KEY_MATCH_NONE } },
|
||||||
{ GDK_KEY_u, GDK_SHIFT_MASK, TRUE, { GDK_EVENT_MATCH_NONE, GDK_EVENT_MATCH_NONE, GDK_EVENT_MATCH_EXACT, GDK_EVENT_MATCH_EXACT } },
|
{ GDK_KEY_u, GDK_SHIFT_MASK, TRUE, { GDK_KEY_MATCH_NONE, GDK_KEY_MATCH_NONE, GDK_KEY_MATCH_EXACT, GDK_KEY_MATCH_EXACT } },
|
||||||
};
|
};
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
@ -365,23 +369,29 @@ test_trigger_trigger (void)
|
|||||||
{
|
{
|
||||||
GdkKeymapKey *keys;
|
GdkKeymapKey *keys;
|
||||||
int n_keys;
|
int n_keys;
|
||||||
|
GdkTranslatedKey translated;
|
||||||
|
|
||||||
if (!gdk_display_map_keyval (display, tests[i].keyval, &keys, &n_keys))
|
if (!gdk_display_map_keyval (display, tests[i].keyval, &keys, &n_keys))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
translated.keyval = tests[i].keyval;
|
||||||
|
translated.consumed = 0;
|
||||||
|
translated.layout = keys[0].group;
|
||||||
|
translated.level = keys[0].level;
|
||||||
event = gdk_event_key_new (GDK_KEY_PRESS,
|
event = gdk_event_key_new (GDK_KEY_PRESS,
|
||||||
surface,
|
surface,
|
||||||
device,
|
device,
|
||||||
device,
|
device,
|
||||||
GDK_CURRENT_TIME,
|
GDK_CURRENT_TIME,
|
||||||
|
keys[0].keycode,
|
||||||
tests[i].state,
|
tests[i].state,
|
||||||
tests[i].keyval,
|
FALSE,
|
||||||
keys[0].keycode,
|
&translated,
|
||||||
keys[0].keycode,
|
&translated);
|
||||||
keys[0].group,
|
|
||||||
FALSE);
|
|
||||||
for (j = 0; j < 4; j++)
|
for (j = 0; j < 4; j++)
|
||||||
g_assert_cmpint (gtk_shortcut_trigger_trigger (trigger[j], event, tests[i].mnemonic), ==, tests[i].result[j]);
|
{
|
||||||
|
g_assert_cmpint (gtk_shortcut_trigger_trigger (trigger[j], event, tests[i].mnemonic), ==, tests[i].result[j]);
|
||||||
|
}
|
||||||
|
|
||||||
gdk_event_unref (event);
|
gdk_event_unref (event);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user