[libdazzle] shortcuts: allow basic modifier chords



commit 9b448d8cf59c755312a4fb5e083aa9e1f63ec0cc
Author: Christian Hergert <chergert redhat com>
Date:   Thu Mar 28 13:29:29 2019 -0700

    shortcuts: allow basic modifier chords
    
    This allows events to be delivered for modifier keys such as plain Control
    (which can be useful for widgets). We squash the last modifier-only key
    press as part of this.

 src/shortcuts/dzl-shortcut-chord.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/src/shortcuts/dzl-shortcut-chord.c b/src/shortcuts/dzl-shortcut-chord.c
index a77c0c3..5f16fbc 100644
--- a/src/shortcuts/dzl-shortcut-chord.c
+++ b/src/shortcuts/dzl-shortcut-chord.c
@@ -91,7 +91,7 @@ dzl_shortcut_chord_is_valid (const DzlShortcutChord *self)
   g_assert (IS_SHORTCUT_CHORD (self));
 
   /* Ensure we got a valid first key at least */
-  if (self->keys[0].keyval == 0)
+  if (self->keys[0].keyval == 0 && self->keys[0].modifier == 0)
     return FALSE;
 
   return TRUE;
@@ -104,10 +104,6 @@ dzl_shortcut_chord_new_from_event (const GdkEventKey *key)
 
   g_return_val_if_fail (key != NULL, NULL);
 
-  /* Ignore modifier keypresses */
-  if (key->is_modifier)
-    return NULL;
-
   self = g_slice_new0 (DzlShortcutChord);
   self->magic = CHORD_MAGIC;
 
@@ -168,6 +164,10 @@ dzl_shortcut_chord_append_event (DzlShortcutChord  *self,
 
   for (i = 0; i < G_N_ELEMENTS (self->keys); i++)
     {
+      /* We might have just a state (control, etc), and we want
+       * to consume that if we've gotten another key here. So we
+       * only check against key.keyval.
+       */
       if (self->keys[i].keyval == 0)
         {
           self->keys[i].keyval = gdk_keyval_to_lower (key->keyval);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]