[Spice-commits] 2 commits - doc/reference gtk/channel-main.c gtk/channel-main.h gtk/map-file gtk/spice-gtk-session.c gtk/spice-widget.c

Marc-André Lureau elmarco at kemper.freedesktop.org
Wed Feb 1 02:27:08 PST 2012


 doc/reference/spice-gtk-sections.txt |    1 +
 gtk/channel-main.c                   |   22 ++++++++++++++++++++++
 gtk/channel-main.h                   |    2 ++
 gtk/map-file                         |    1 +
 gtk/spice-gtk-session.c              |    7 +++++--
 gtk/spice-widget.c                   |    2 +-
 6 files changed, 32 insertions(+), 3 deletions(-)

New commits:
commit 364e34b4a05ebcee881afbfe13a845aa49adf488
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Tue Jan 31 23:22:35 2012 +0100

    Report the scaling is 1.0 if the widget isn't realized yet
    
    To avoid a few warnings in some corner cases.

diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
index 86001be..e574274 100644
--- a/gtk/spice-widget.c
+++ b/gtk/spice-widget.c
@@ -1632,7 +1632,7 @@ void spice_display_get_scaling(SpiceDisplay *display, double *sx, double *sy)
     int fbw = d->width, fbh = d->height;
     int ww, wh;
 
-    if (!spicex_is_scaled(display)) {
+    if (!spicex_is_scaled(display) || !gtk_widget_get_window(GTK_WIDGET(display))) {
         *sx = 1.0;
         *sy = 1.0;
         return;
commit 5f39af6b88407752984dbf6f8943408e790d2f21
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Tue Jan 31 23:03:22 2012 +0100

    Do not grab/release the clipboard on guest without clipboard support
    
    Add an agent capability check before calling those functions from
    gtk-session. Avoid extra warnings.

diff --git a/doc/reference/spice-gtk-sections.txt b/doc/reference/spice-gtk-sections.txt
index 5e3af99..3e5ce0b 100644
--- a/doc/reference/spice-gtk-sections.txt
+++ b/doc/reference/spice-gtk-sections.txt
@@ -50,6 +50,7 @@ SpiceMainChannelClass
 <SUBSECTION>
 spice_main_channel
 spice_main_set_display
+spice_main_agent_test_capability
 spice_main_clipboard_selection_grab
 spice_main_clipboard_selection_notify
 spice_main_clipboard_selection_release
diff --git a/gtk/channel-main.c b/gtk/channel-main.c
index b2df547..0689368 100644
--- a/gtk/channel-main.c
+++ b/gtk/channel-main.c
@@ -736,6 +736,7 @@ static void do_emit_main_context(GObject *object, int signum, gpointer params)
 
 /* ------------------------------------------------------------------ */
 
+
 static void agent_free_msg_queue(SpiceMainChannel *channel)
 {
     SpiceMainChannelPrivate *c = channel->priv;
@@ -1716,6 +1717,27 @@ static gboolean timer_set_display(gpointer data)
 }
 
 /**
+ * spice_main_agent_test_capability:
+ * @channel:
+ * @cap: an agent capability identifier
+ *
+ * Test capability of a remote agent.
+ *
+ * Returns: %TRUE if @cap (channel kind capability) is available.
+ **/
+gboolean spice_main_agent_test_capability(SpiceMainChannel *channel, guint32 cap)
+{
+    g_return_val_if_fail(SPICE_IS_MAIN_CHANNEL(channel), FALSE);
+
+    SpiceMainChannelPrivate *c = channel->priv;
+
+    if (!c->agent_caps_received)
+        return FALSE;
+
+    return VD_AGENT_HAS_CAPABILITY(c->agent_caps, sizeof(c->agent_caps), cap);
+}
+
+/**
  * spice_main_set_display:
  * @channel:
  * @id: display channel ID
diff --git a/gtk/channel-main.h b/gtk/channel-main.h
index f1ab6ae..ae3f241 100644
--- a/gtk/channel-main.h
+++ b/gtk/channel-main.h
@@ -83,6 +83,8 @@ void spice_main_clipboard_selection_release(SpiceMainChannel *channel, guint sel
 void spice_main_clipboard_selection_notify(SpiceMainChannel *channel, guint selection, guint32 type, const guchar *data, size_t size);
 void spice_main_clipboard_selection_request(SpiceMainChannel *channel, guint selection, guint32 type);
 
+gboolean spice_main_agent_test_capability(SpiceMainChannel *channel, guint32 cap);
+
 G_END_DECLS
 
 #endif /* __SPICE_CLIENT_MAIN_CHANNEL_H__ */
diff --git a/gtk/map-file b/gtk/map-file
index 38f7c26..320dae3 100644
--- a/gtk/map-file
+++ b/gtk/map-file
@@ -48,6 +48,7 @@ spice_inputs_lock_get_type;
 spice_inputs_motion;
 spice_inputs_position;
 spice_inputs_set_key_locks;
+spice_main_agent_test_capability;
 spice_main_channel_get_type;
 spice_main_clipboard_grab;
 spice_main_clipboard_notify;
diff --git a/gtk/spice-gtk-session.c b/gtk/spice-gtk-session.c
index e4a36d1..f77296d 100644
--- a/gtk/spice-gtk-session.c
+++ b/gtk/spice-gtk-session.c
@@ -478,7 +478,9 @@ static void clipboard_get_targets(GtkClipboard *clipboard,
     }
     if (!s->clip_grabbed[selection] && t > 0) {
         s->clip_grabbed[selection] = TRUE;
-        spice_main_clipboard_selection_grab(s->main, selection, types, t);
+
+        if (spice_main_agent_test_capability(s->main, VD_AGENT_CAP_CLIPBOARD_BY_DEMAND))
+            spice_main_clipboard_selection_grab(s->main, selection, types, t);
         /* Sending a grab causes the agent to do an impicit release */
         s->nclip_targets[selection] = 0;
     }
@@ -502,7 +504,8 @@ static void clipboard_owner_change(GtkClipboard        *clipboard,
 
     if (s->clip_grabbed[selection]) {
         s->clip_grabbed[selection] = FALSE;
-        spice_main_clipboard_selection_release(s->main, selection);
+        if (spice_main_agent_test_capability(s->main, VD_AGENT_CAP_CLIPBOARD_BY_DEMAND))
+            spice_main_clipboard_selection_release(s->main, selection);
     }
 
     switch (event->reason) {


More information about the Spice-commits mailing list