[Spice-devel] [PATCH spice-gtk 14/25] Use monitor_id to compute display_id

Marc-André Lureau marcandre.lureau at gmail.com
Thu Jul 12 15:29:11 PDT 2012


---
 gtk/channel-main.c |    4 ++--
 gtk/spice-widget.c |   17 +++++++++++++++--
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/gtk/channel-main.c b/gtk/channel-main.c
index 9e97b8b..3c173c6 100644
--- a/gtk/channel-main.c
+++ b/gtk/channel-main.c
@@ -1829,7 +1829,7 @@ gboolean spice_main_agent_test_capability(SpiceMainChannel *channel, guint32 cap
 /**
  * spice_main_set_display:
  * @channel:
- * @id: display channel ID
+ * @id: display ID
  * @x: x position
  * @y: y position
  * @width: display width
@@ -2013,7 +2013,7 @@ void spice_main_clipboard_selection_request(SpiceMainChannel *channel, guint sel
 /**
  * spice_main_set_display_enabled:
  * @channel: a #SpiceMainChannel
- * @id: display channel ID (if -1: set all displays)
+ * @id: display ID (if -1: set all displays)
  * @enabled: wether display @id is enabled
  *
  * When sending monitor configuration to agent guest, don't set
diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
index f640fae..0ab00fe 100644
--- a/gtk/spice-widget.c
+++ b/gtk/spice-widget.c
@@ -779,6 +779,19 @@ static void update_mouse_grab(SpiceDisplay *display)
         try_mouse_ungrab(display);
 }
 
+static gint get_display_id(SpiceDisplay *display)
+{
+    SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+
+    /* supported monitor_id only with display channel #0 */
+    if (d->channel_id == 0 && d->monitor_id >= 0)
+        return d->monitor_id;
+
+    g_return_val_if_fail(d->monitor_id <= 0, -1);
+
+    return d->channel_id;
+}
+
 static void recalc_geometry(GtkWidget *widget)
 {
     SpiceDisplay *display = SPICE_DISPLAY(widget);
@@ -800,7 +813,7 @@ static void recalc_geometry(GtkWidget *widget)
                 d->ww, d->wh, zoom, d->mx, d->my);
 
     if (d->resize_guest_enable)
-        spice_main_set_display(d->main, d->channel_id,
+        spice_main_set_display(d->main, get_display_id(display),
                                0, 0, d->ww / zoom, d->wh / zoom);
 }
 
@@ -1687,7 +1700,7 @@ static void mark(SpiceChannel *channel, gint mark, gpointer data)
 
     SPICE_DEBUG("widget mark: %d, channel %d", mark, d->channel_id);
     d->mark = mark;
-    spice_main_set_display_enabled(d->main, d->channel_id, d->mark != 0);
+    spice_main_set_display_enabled(d->main, get_display_id(display), d->mark != 0);
     if (mark != 0 && gtk_widget_get_window(GTK_WIDGET(display)))
         gtk_widget_queue_draw(GTK_WIDGET(display));
 }
-- 
1.7.10.4



More information about the Spice-devel mailing list