summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColomban Wendling <[email protected]>2020-06-11 12:20:22 +0200
committerRobert Antoni Buj Gelonch <[email protected]>2020-08-08 23:24:58 +0200
commit7c0d9fa87266156e3bb88a2f89386da17ea47a47 (patch)
treed6a19a897e3ab7325344c897657c6ea06bac79fd
parent36ed52d622557ddf75466d6963b64db24dcd90e3 (diff)
downloadmate-settings-daemon-7c0d9fa87266156e3bb88a2f89386da17ea47a47.tar.bz2
mate-settings-daemon-7c0d9fa87266156e3bb88a2f89386da17ea47a47.tar.xz
a11y-keyboard: capslock-beep: Don't ring on CapsLock itself
Ringing when a locking modifier gets enabled/disabled is already taken care of by the `togglekeys` settings, so don't provide redundant functionality and allow better settings granularity.
-rw-r--r--plugins/a11y-keyboard/msd-a11y-keyboard-atspi.c34
1 files changed, 8 insertions, 26 deletions
diff --git a/plugins/a11y-keyboard/msd-a11y-keyboard-atspi.c b/plugins/a11y-keyboard/msd-a11y-keyboard-atspi.c
index c9343a6..a1d7c9c 100644
--- a/plugins/a11y-keyboard/msd-a11y-keyboard-atspi.c
+++ b/plugins/a11y-keyboard/msd-a11y-keyboard-atspi.c
@@ -62,9 +62,9 @@ static gboolean
on_key_press_event (const AtspiDeviceEvent *event,
void *user_data G_GNUC_UNUSED)
{
- /* don't ring when disabling capslock */
- if (event->id == GDK_KEY_Caps_Lock &&
- event->modifiers & (1 << ATSPI_MODIFIER_SHIFTLOCK))
+ /* don't ring on capslock itself, that's taken care of by togglekeys
+ * if the user want it. */
+ if (event->id == GDK_KEY_Caps_Lock)
return FALSE;
gdk_display_beep (gdk_display_get_default ());
@@ -96,47 +96,29 @@ static void
register_deregister_events (MsdA11yKeyboardAtspi *self,
gboolean do_register)
{
- AtspiKeyDefinition shiftlock_key;
- GArray *shiftlock_key_set;
-
g_return_if_fail (MSD_IS_A11Y_KEYBOARD_ATSPI (self));
g_return_if_fail (ATSPI_IS_DEVICE_LISTENER (self->priv->listener));
- /* register listeners for CAPS_LOCK with any modifier but CAPS_LOCK,
- * and all keys with CAPS_LOCK modifier, so we grab when CAPS_LOCK is
- * active or gets activated */
- shiftlock_key.keycode = 0;
- shiftlock_key.keysym = GDK_KEY_Caps_Lock;
- shiftlock_key.keystring = NULL;
-
- shiftlock_key_set = g_array_new (FALSE, FALSE, sizeof shiftlock_key);
- g_array_append_val (shiftlock_key_set, shiftlock_key);
-
+ /* register listeners for all keys with CAPS_LOCK modifier */
for (AtspiKeyMaskType mod_mask = 0; mod_mask < 256; mod_mask++)
{
- GArray *key_set;
-
- if (mod_mask & (1 << ATSPI_MODIFIER_SHIFTLOCK))
- key_set = NULL;
- else
- key_set = shiftlock_key_set;
+ if (! (mod_mask & (1 << ATSPI_MODIFIER_SHIFTLOCK)))
+ continue;
if (do_register)
atspi_register_keystroke_listener (self->priv->listener,
- key_set,
+ NULL,
mod_mask,
1 << ATSPI_KEY_PRESSED_EVENT,
ATSPI_KEYLISTENER_NOSYNC,
NULL);
else
atspi_deregister_keystroke_listener (self->priv->listener,
- key_set,
+ NULL,
mod_mask,
1 << ATSPI_KEY_PRESSED_EVENT,
NULL);
}
-
- g_array_unref (shiftlock_key_set);
}
void