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

Submitted by Hans de Goede on June 21, 2012, 8:09 p.m.

Details

Message ID 1340309356-28960-5-git-send-email-hdegoede@redhat.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Hans de Goede June 21, 2012, 8:09 p.m.
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@redhat.com>
---
 gtk/spice-widget.c |    9 +++++++++
 1 file changed, 9 insertions(+)

Patch hide | download patch | download mbox

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)