From 4e419a1223fa4a44c02e76fa4972db3d6518c839 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Fri, 18 May 2012 15:27:03 +0200 Subject: [PATCH] Reset grab-sequence on match 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; }