[Spice-devel] [PATCH spice-gtk 4/4] spice-widget: Don't change usbredir/automount settings while redirecting

Hans de Goede hdegoede at redhat.com
Thu Jun 21 13:09:16 PDT 2012


The keyboard focus may change while usb-device-manager is in the process of
redirecting a usb-device (as this may show a policykit dialog). Making
autoredir/automount setting changes while this is happening is not a good idea!

Since usb-device-manager already sets keyboard_grab_inhibit when it is
redirecting to allow the policykit dialog to show, we can use that to
inhibit usb-autoredir setting changes.

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

diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
index 9397750..a013237 100644
--- a/gtk/spice-widget.c
+++ b/gtk/spice-widget.c
@@ -213,6 +213,14 @@ static void update_usb_autoredir(SpiceDisplay *display)
 {
     SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
     guint toplevel_window_id = 0;
+
+    /* keyboard grab gets inhibited by usb-device-manager when it is
+       in the process of redirecting a usb-device (as this may show a
+       policykit dialog). Making autoredir/automount setting changes while
+       this is happening is not a good idea! */
+    if (d->keyboard_grab_inhibit)
+        return;
+
 #ifdef GDK_WINDOWING_X11
     {
         GtkWidget *toplevel = gtk_widget_get_toplevel(GTK_WIDGET(display));
@@ -298,6 +306,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_usb_autoredir(display);
 }
 
 static void spice_display_dispose(GObject *obj)
-- 
1.7.10.4



More information about the Spice-devel mailing list