[Spice-devel,spice-gtk,1/3] spice-gtk-session: Only update usb "auto-connect" when doing "auto-usb-redir"

Submitted by Hans de Goede on June 13, 2012, 5:07 p.m.

Details

Message ID 1339607243-2344-1-git-send-email-hdegoede@redhat.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Hans de Goede June 13, 2012, 5:07 p.m.
Only update the UsbDeviceManager's "auto-connect" property when
"auto-usb-redir" is set, otherwise leave it as is. This allows apps to
control UsbDeviceManager's "auto-connect" directly, without it getting reset
on every keyboard focus change.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 gtk/spice-gtk-session.c |   16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

Patch hide | download patch | download mbox

diff --git a/gtk/spice-gtk-session.c b/gtk/spice-gtk-session.c
index 3d2483d..af30b4f 100644
--- a/gtk/spice-gtk-session.c
+++ b/gtk/spice-gtk-session.c
@@ -235,7 +235,14 @@  static void spice_gtk_session_set_property(GObject      *gobject,
         break;
     case PROP_AUTO_USBREDIR:
         s->auto_usbredir_enable = g_value_get_boolean(value);
-        spice_gtk_session_update_keyboard_focus(self, s->keyboard_focus);
+        if (s->keyboard_focus) {
+            SpiceUsbDeviceManager *manager =
+                spice_usb_device_manager_get(s->session, NULL);
+            if (manager) {
+                g_object_set(manager, "auto-connect", s->auto_usbredir_enable,
+                             NULL);
+            }
+        }
         break;
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, pspec);
@@ -835,16 +842,15 @@  void spice_gtk_session_update_keyboard_focus(SpiceGtkSession *self,
 
     SpiceGtkSessionPrivate *s = self->priv;
     SpiceUsbDeviceManager *manager;
-    gboolean auto_connect = FALSE;
 
     s->keyboard_focus = state;
 
-    if (s->auto_usbredir_enable && s->keyboard_focus)
-        auto_connect = TRUE;
+    if (!s->auto_usbredir_enable)
+        return;
 
     manager = spice_usb_device_manager_get(s->session, NULL);
     if (manager) {
-        g_object_set(manager, "auto-connect", auto_connect, NULL);
+        g_object_set(manager, "auto-connect", s->keyboard_focus, NULL);
     }
 }
 

Comments

ack

On Wed, Jun 13, 2012 at 7:07 PM, Hans de Goede <hdegoede@redhat.com> wrote:
> Only update the UsbDeviceManager's "auto-connect" property when
> "auto-usb-redir" is set, otherwise leave it as is. This allows apps to
> control UsbDeviceManager's "auto-connect" directly, without it getting reset
> on every keyboard focus change.
>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
>  gtk/spice-gtk-session.c |   16 +++++++++++-----
>  1 file changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/gtk/spice-gtk-session.c b/gtk/spice-gtk-session.c
> index 3d2483d..af30b4f 100644
> --- a/gtk/spice-gtk-session.c
> +++ b/gtk/spice-gtk-session.c
> @@ -235,7 +235,14 @@ static void spice_gtk_session_set_property(GObject      *gobject,
>         break;
>     case PROP_AUTO_USBREDIR:
>         s->auto_usbredir_enable = g_value_get_boolean(value);
> -        spice_gtk_session_update_keyboard_focus(self, s->keyboard_focus);
> +        if (s->keyboard_focus) {
> +            SpiceUsbDeviceManager *manager =
> +                spice_usb_device_manager_get(s->session, NULL);
> +            if (manager) {
> +                g_object_set(manager, "auto-connect", s->auto_usbredir_enable,
> +                             NULL);
> +            }
> +        }
>         break;
>     default:
>         G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, pspec);
> @@ -835,16 +842,15 @@ void spice_gtk_session_update_keyboard_focus(SpiceGtkSession *self,
>
>     SpiceGtkSessionPrivate *s = self->priv;
>     SpiceUsbDeviceManager *manager;
> -    gboolean auto_connect = FALSE;
>
>     s->keyboard_focus = state;
>
> -    if (s->auto_usbredir_enable && s->keyboard_focus)
> -        auto_connect = TRUE;
> +    if (!s->auto_usbredir_enable)
> +        return;
>
>     manager = spice_usb_device_manager_get(s->session, NULL);
>     if (manager) {
> -        g_object_set(manager, "auto-connect", auto_connect, NULL);
> +        g_object_set(manager, "auto-connect", s->keyboard_focus, NULL);
>     }
>  }
>
> --
> 1.7.10.2
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
On Wed, Jun 13, 2012 at 07:07:21PM +0200, Hans de Goede wrote:
> Only update the UsbDeviceManager's "auto-connect" property when
> "auto-usb-redir" is set, otherwise leave it as is. This allows apps to
> control UsbDeviceManager's "auto-connect" directly, without it getting reset
> on every keyboard focus change.

Ah nice, I got caught by that when adding usb controller support ;)
http://git.fedorahosted.org/git/?p=virt-viewer.git;a=commit;h=37171c465fd762da6c398003340855cc7df062ac

Christophe