[Spice-commits] 2 commits - gtk/spice-widget.c

Marc-André Lureau elmarco at kemper.freedesktop.org
Tue Apr 2 10:21:08 PDT 2013

 gtk/spice-widget.c |   23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

New commits:
commit c68f74b02e3747ec4919693c8ef81ee36a335ee8
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Tue Apr 2 18:12:17 2013 +0200

    win32: do not handle win keys when the keyboard is not grabbed
    Special-case on win32, filter out the win keys when not having the
    keyboard grab. This is to avoid the win keys to be received both by
    the guest and the client, which can be undesirable in general.

diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
index 73b964d..6936ceb 100644
--- a/gtk/spice-widget.c
+++ b/gtk/spice-widget.c
@@ -1278,6 +1278,14 @@ static gboolean key_event(GtkWidget *widget, GdkEventKey *key)
     /* on windows, we ought to ignore the reserved key event? */
     if (key->hardware_keycode == 0xff)
         return false;
+    if (!d->keyboard_grab_active) {
+        if (key->hardware_keycode == VK_LWIN ||
+            key->hardware_keycode == VK_RWIN ||
+            key->hardware_keycode == VK_APPS)
+            return false;
+    }
     SPICE_DEBUG("%s %s: keycode: %d  state: %d  group %d modifier %d",
             __FUNCTION__, key->type == GDK_KEY_PRESS ? "press" : "release",
commit 9b9c06a7d27d0261dff6cdd10f7edd4beb6ffb4f
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Tue Mar 26 21:00:48 2013 +0100

    Release pointer grab on grab-broken
    On windows, the client receives a WM_KILLFOCUS event which generates
    solely a keyboard grab-broken event.
    This event is received when pressing ctrl-alt-del (to show up the task
    manager), and we need to release the pointer grab and clip region in
    this case for the client to be usable.
    This also clear the clipping region when the client pops-up a dialog.
    Since keyboard focus is a pre-requisite for pointer grab, it sounds
    logical to release the pointer grab if losing keyboard focus, but for
    now, we just release it in grab-broken, as a result of discussion on
    the ML.

diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
index fb8094e..73b964d 100644
--- a/gtk/spice-widget.c
+++ b/gtk/spice-widget.c
@@ -477,17 +477,18 @@ static GdkCursor* get_blank_cursor(void)
 static gboolean grab_broken(SpiceDisplay *self, GdkEventGrabBroken *event,
                             gpointer user_data G_GNUC_UNUSED)
-    SpiceDisplayPrivate *d = self->priv;
+    SPICE_DEBUG("%s (implicit: %d, keyboard: %d)", __FUNCTION__,
+                event->implicit, event->keyboard);
-    SPICE_DEBUG("%s (%d)", __FUNCTION__, event->implicit);
     if (event->keyboard) {
-        d->keyboard_grab_active = false;
-        g_signal_emit(self, signals[SPICE_DISPLAY_KEYBOARD_GRAB], 0, false);
-    } else {
-        d->mouse_grab_active = false;
-        g_signal_emit(self, signals[SPICE_DISPLAY_MOUSE_GRAB], 0, false);
+        try_keyboard_ungrab(self);
+    /* always release mouse when grab broken, this could be more
+       generally placed in keyboard_ungrab(), but one might worry of
+       breaking someone else code. */
+    try_mouse_ungrab(self);
     return false;

More information about the Spice-commits mailing list