diff options
author | Mike Gorse <mgorse@suse.com> | 2021-05-12 15:46:05 -0500 |
---|---|---|
committer | Mike Gorse <mgorse@suse.com> | 2021-05-12 15:46:05 -0500 |
commit | 1a7d59f174a66d2b46a7774c1f09154a94ea151c (patch) | |
tree | 424570b55d5ce0dd02934a9943f687cc1b241b1e /atspi/atspi-device.c | |
parent | 89c6d6051957025d57bc32c3b82dabab76eab3b3 (diff) | |
download | at-spi2-core-1a7d59f174a66d2b46a7774c1f09154a94ea151c.tar.gz |
AtspiDevice key grab fixes
Diffstat (limited to 'atspi/atspi-device.c')
-rw-r--r-- | atspi/atspi-device.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/atspi/atspi-device.c b/atspi/atspi-device.c index 5f62dc3c..e4a564c7 100644 --- a/atspi/atspi-device.c +++ b/atspi/atspi-device.c @@ -107,6 +107,19 @@ atspi_device_new () return ATSPI_DEVICE (atspi_device_legacy_new ()); } +static gboolean +key_matches_modifiers (guint key_mods, guint grab_mods) +{ + /* The presence or lack thereof of locking modifiers should make no + difference when testing, but other modifiers should match. If the + keypress has modifiers that (a) the grab does not check for and (b) are + not lock modifiers, then we reject the match. Alt + left arrow should not + match a grab on left arrow, for instance, but whether numlock is on or + off would be irrelevant. */ + key_mods &= ~((1 << ATSPI_MODIFIER_SHIFTLOCK) | (1 << ATSPI_MODIFIER_NUMLOCK)); + return (key_mods == grab_mods); +} + gboolean atspi_device_notify_key (AtspiDevice *device, gboolean pressed, int keycode, int keysym, gint state, gchar *text) { @@ -123,8 +136,7 @@ atspi_device_notify_key (AtspiDevice *device, gboolean pressed, int keycode, int for (l = priv->keygrabs; l; l = l->next) { AtspiKeyGrab *grab = l->data; - //if (keycode == grab->keycode && (grab->modifiers & state) == grab->modifiers) - if (keycode == grab->keycode && grab->modifiers == state) + if (keycode == grab->keycode && key_matches_modifiers (state, grab->modifiers)) { if (grab->callback) grab->callback (device, pressed, keycode, keysym, state, text, grab->callback_data); |