[Spice-devel] [PATCH spice-gtk] spice-widget: release mouse grab on keyboard-grab-inhibit

Hans de Goede hdegoede at redhat.com
Wed Jul 4 00:07:41 PDT 2012


The purpose of the keyboard-grab-inihbit mechanism is to allow other apps
to grab the input while the spice-widget has the focus, mainly when we're
going to invoke policykit for usb-redirection, as that the policy-kit
agent may want to grab the input.

Before this patch we were only inhibitting the keyboard grab, which works fine
for vms which are in client mouse mode, but is not enough for vms which are
in server mouse mode.

This patch also releases the mouse grab on keyboard-grab-inhibit, fixing
the policykit dialog not showing (and thus usb redir not working) when
running with server mouse mode. Note that this makes the inhibit-keyboard-grab
name of the property no longer really cover what it does, but allas it is
part of our ABI...

Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
 gtk/spice-widget.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
index e892591..14f1fba 100644
--- a/gtk/spice-widget.c
+++ b/gtk/spice-widget.c
@@ -297,6 +297,7 @@ static void session_inhibit_keyboard_grab_changed(GObject    *gobject,
     g_object_get(d->session, "inhibit-keyboard-grab",
                  &d->keyboard_grab_inhibit, NULL);
     update_keyboard_grab(display);
+    update_mouse_grab(display);
 }
 
 static void spice_display_dispose(GObject *obj)
@@ -774,7 +775,9 @@ static void update_mouse_grab(SpiceDisplay *display)
 {
     SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
 
-    if (d->mouse_grab_enable && !d->disable_inputs)
+    if (d->mouse_grab_enable &&
+        !d->keyboard_grab_inhibit &&
+        !d->disable_inputs)
         try_mouse_grab(display);
     else
         try_mouse_ungrab(display);
-- 
1.7.10.4



More information about the Spice-devel mailing list