[PATCH spice-gtk 2/2] Reset grab-sequence on match

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

 



This avoids triggering the grab event on consecutive
matches, such as ctrl+alt (match) then ctrl+alt+foo
(match again) that would prevent the longer combination
from being sent.
---
 gtk/spice-widget.c |   18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
index 86d5f3e..0abd4c6 100644
--- a/gtk/spice-widget.c
+++ b/gtk/spice-widget.c
@@ -941,11 +941,7 @@ static gboolean check_for_grab_key(SpiceDisplay *display, int type, int keyval)
     if (!d->grabseq->nkeysyms)
         return FALSE;
 
-    if (type == GDK_KEY_RELEASE) {
-        /* Any key release resets the whole grab sequence */
-        memset(d->activeseq, 0, sizeof(gboolean) * d->grabseq->nkeysyms);
-        return FALSE;
-    } else {
+    if (type == GDK_KEY_PRESS) {
         /* Record the new key press */
         for (i = 0 ; i < d->grabseq->nkeysyms ; i++)
             if (d->grabseq->keysyms[i] == keyval)
@@ -956,8 +952,17 @@ static gboolean check_for_grab_key(SpiceDisplay *display, int type, int keyval)
             if (d->activeseq[i] == FALSE)
                 return FALSE;
 
+        /* resets the whole grab sequence on success */
+        memset(d->activeseq, 0, sizeof(gboolean) * d->grabseq->nkeysyms);
         return TRUE;
-    }
+    } else if (type == GDK_KEY_RELEASE) {
+        /* Any key release resets the whole grab sequence */
+        memset(d->activeseq, 0, sizeof(gboolean) * d->grabseq->nkeysyms);
+        return FALSE;
+    } else
+        g_warn_if_reached();
+
+    return FALSE;
 }
 
 static gboolean key_event(GtkWidget *widget, GdkEventKey *key)
@@ -999,6 +1004,7 @@ static gboolean key_event(GtkWidget *widget, GdkEventKey *key)
         send_key(display, scancode, 0);
         break;
     default:
+        g_warn_if_reached();
         break;
     }
 
-- 
1.7.10.1

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]