[Spice-commits] 3 commits - gtk/spice-gtk-session-priv.h gtk/spice-gtk-session.c gtk/spice-widget.c gtk/usb-device-manager.c
Hans de Goede
jwrdegoede at kemper.freedesktop.org
Tue Jun 26 05:31:45 PDT 2012
gtk/spice-gtk-session-priv.h | 2 +-
gtk/spice-gtk-session.c | 38 ++++++++++++++++++++++++++++----------
gtk/spice-widget.c | 4 ++--
gtk/usb-device-manager.c | 5 +++++
4 files changed, 36 insertions(+), 13 deletions(-)
New commits:
commit b5d4cc27c483cb47960c410705d6163cfb75b587
Author: Hans de Goede <hdegoede at redhat.com>
Date: Mon Jun 25 16:36:32 2012 +0200
spice-gtk-session: rename update_keyboard_focus to request_auto_usbredir
To better reflect what then function does, also rename the tracking variable
inside spice-gtk-session to match.
Signed-off-by: Hans de Goede <hdegoede at redhat.com>
diff --git a/gtk/spice-gtk-session-priv.h b/gtk/spice-gtk-session-priv.h
index 21a4251..aba6fe9 100644
--- a/gtk/spice-gtk-session-priv.h
+++ b/gtk/spice-gtk-session-priv.h
@@ -22,7 +22,7 @@
G_BEGIN_DECLS
-void spice_gtk_session_update_keyboard_focus(SpiceGtkSession *self,
+void spice_gtk_session_request_auto_usbredir(SpiceGtkSession *self,
gboolean state);
gboolean spice_gtk_session_get_read_only(SpiceGtkSession *self);
diff --git a/gtk/spice-gtk-session.c b/gtk/spice-gtk-session.c
index 1d8c888..1df63f5 100644
--- a/gtk/spice-gtk-session.c
+++ b/gtk/spice-gtk-session.c
@@ -39,7 +39,7 @@ struct _SpiceGtkSessionPrivate {
gboolean clipboard_by_guest[CLIPBOARD_LAST];
/* auto-usbredir related */
gboolean auto_usbredir_enable;
- int keyboard_focus;
+ int auto_usbredir_reqs;
};
/**
@@ -235,7 +235,7 @@ static void spice_gtk_session_set_property(GObject *gobject,
break;
case PROP_AUTO_USBREDIR:
s->auto_usbredir_enable = g_value_get_boolean(value);
- if (s->keyboard_focus) {
+ if (s->auto_usbredir_reqs) {
SpiceUsbDeviceManager *manager =
spice_usb_device_manager_get(s->session, NULL);
@@ -837,7 +837,7 @@ static gboolean read_only(SpiceGtkSession *self)
/* ---------------------------------------------------------------- */
/* private functions (usbredir related) */
G_GNUC_INTERNAL
-void spice_gtk_session_update_keyboard_focus(SpiceGtkSession *self,
+void spice_gtk_session_request_auto_usbredir(SpiceGtkSession *self,
gboolean state)
{
g_return_if_fail(SPICE_IS_GTK_SESSION(self));
@@ -846,13 +846,13 @@ void spice_gtk_session_update_keyboard_focus(SpiceGtkSession *self,
SpiceUsbDeviceManager *manager;
if (state) {
- s->keyboard_focus++;
- if (s->keyboard_focus != 1)
+ s->auto_usbredir_reqs++;
+ if (s->auto_usbredir_reqs != 1)
return;
} else {
- g_return_if_fail(s->keyboard_focus > 0);
- s->keyboard_focus--;
- if (s->keyboard_focus != 0)
+ g_return_if_fail(s->auto_usbredir_reqs > 0);
+ s->auto_usbredir_reqs--;
+ if (s->auto_usbredir_reqs != 0)
return;
}
diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
index d559273..2ce8b1a 100644
--- a/gtk/spice-widget.c
+++ b/gtk/spice-widget.c
@@ -1097,7 +1097,7 @@ static gboolean focus_in_event(GtkWidget *widget, GdkEventFocus *focus G_GNUC_UN
sync_keyboard_lock_modifiers(display);
d->keyboard_have_focus = true;
try_keyboard_grab(display);
- spice_gtk_session_update_keyboard_focus(d->gtk_session,
+ spice_gtk_session_request_auto_usbredir(d->gtk_session,
d->keyboard_have_focus);
#ifdef WIN32
focus_window = GDK_WINDOW_HWND(gtk_widget_get_window(widget));
@@ -1122,7 +1122,7 @@ static gboolean focus_out_event(GtkWidget *widget, GdkEventFocus *focus G_GNUC_U
release_keys(display);
d->keyboard_have_focus = false;
- spice_gtk_session_update_keyboard_focus(d->gtk_session,
+ spice_gtk_session_request_auto_usbredir(d->gtk_session,
d->keyboard_have_focus);
return true;
}
commit 567b41fdc37dd184506aac7a92f815a212c85daa
Author: Hans de Goede <hdegoede at redhat.com>
Date: Thu Jun 21 16:22:29 2012 +0200
spice-gtk-session: Fix keyboard focus tracking
This patch changes the "do we have focus?" tracking, to keeping a counter with
how many widgets have focus. The reason for this is that sometimes multiple
spice-widgets can have focus at the same time, yes really! Sometimes (rarely,
hard to reproduce) the focus in event for one window arrives before the
focus out of the other window.
Signed-off-by: Hans de Goede <hdegoede at redhat.com>
diff --git a/gtk/spice-gtk-session.c b/gtk/spice-gtk-session.c
index 130cbc9..1d8c888 100644
--- a/gtk/spice-gtk-session.c
+++ b/gtk/spice-gtk-session.c
@@ -39,7 +39,7 @@ struct _SpiceGtkSessionPrivate {
gboolean clipboard_by_guest[CLIPBOARD_LAST];
/* auto-usbredir related */
gboolean auto_usbredir_enable;
- gboolean keyboard_focus;
+ int keyboard_focus;
};
/**
@@ -845,7 +845,16 @@ void spice_gtk_session_update_keyboard_focus(SpiceGtkSession *self,
SpiceGtkSessionPrivate *s = self->priv;
SpiceUsbDeviceManager *manager;
- s->keyboard_focus = state;
+ if (state) {
+ s->keyboard_focus++;
+ if (s->keyboard_focus != 1)
+ return;
+ } else {
+ g_return_if_fail(s->keyboard_focus > 0);
+ s->keyboard_focus--;
+ if (s->keyboard_focus != 0)
+ return;
+ }
if (!s->auto_usbredir_enable)
return;
commit cf168467becc342489a954c5fef5b1e9c646e520
Author: Hans de Goede <hdegoede at redhat.com>
Date: Wed Jun 13 15:54:44 2012 +0200
spice-gtk-session: Only update usb "auto-connect" when doing "auto-usb-redir"
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 at redhat.com>
diff --git a/gtk/spice-gtk-session.c b/gtk/spice-gtk-session.c
index 3d2483d..130cbc9 100644
--- a/gtk/spice-gtk-session.c
+++ b/gtk/spice-gtk-session.c
@@ -235,7 +235,16 @@ 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)
+ break;
+
+ g_object_set(manager, "auto-connect", s->auto_usbredir_enable,
+ NULL);
+ }
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, pspec);
@@ -835,17 +844,17 @@ 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);
- }
+ if (!manager)
+ return;
+
+ g_object_set(manager, "auto-connect", state, NULL);
}
/* ------------------------------------------------------------------ */
diff --git a/gtk/usb-device-manager.c b/gtk/usb-device-manager.c
index 25cb14a..b39c2d4 100644
--- a/gtk/usb-device-manager.c
+++ b/gtk/usb-device-manager.c
@@ -341,6 +341,11 @@ static void spice_usb_device_manager_class_init(SpiceUsbDeviceManagerClass *klas
/**
* SpiceUsbDeviceManager:auto-connect:
+ *
+ * Set this to TRUE to automatically redirect newly plugged in device.
+ *
+ * Note when #SpiceGtkSession's auto-usbredir property is TRUE, this
+ * property is controlled by #SpiceGtkSession.
*/
pspec = g_param_spec_boolean("auto-connect", "Auto Connect",
"Auto connect plugged in USB devices",
More information about the Spice-commits
mailing list