[virt-tools-list] [virt-viewer 2/4] spice: Stop using deprecated SpiceMainChannel API

Christophe Fergeau cfergeau at redhat.com
Thu Jun 14 16:01:41 UTC 2018


spice_main_set_display and spice_main_set_display_enabled have been
superseded by spice_main_channel_update_display and
spice_main_channel_update_display_enabled

Signed-off-by: Christophe Fergeau <cfergeau at redhat.com>
---
 src/virt-viewer-display-spice.c |  7 ++++++-
 src/virt-viewer-session-spice.c | 27 ++++++++++++++++++---------
 2 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/src/virt-viewer-display-spice.c b/src/virt-viewer-display-spice.c
index a604230..6cec79f 100644
--- a/src/virt-viewer-display-spice.c
+++ b/src/virt-viewer-display-spice.c
@@ -49,6 +49,11 @@ struct _VirtViewerDisplaySpicePrivate {
     guint y;
 };
 
+#if !SPICE_GTK_CHECK_VERSION(0, 34, 21)
+#define spice_main_channel_update_display_enabled(channel, id, enabled, update) \
+                spice_main_update_display_enabled((channel), (id), (enabled), (update))
+#endif
+
 #define VIRT_VIEWER_DISPLAY_SPICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), VIRT_VIEWER_TYPE_DISPLAY_SPICE, VirtViewerDisplaySpicePrivate))
 
 static void virt_viewer_display_spice_send_keys(VirtViewerDisplay *display,
@@ -103,7 +108,7 @@ static void update_enabled(VirtViewerDisplay *self, gboolean enabled, gboolean s
         return;
 
     g_object_get(self, "nth-display", &nth, NULL);
-    spice_main_update_display_enabled(main_channel, nth, enabled, send);
+    spice_main_channel_update_display_enabled(main_channel, nth, enabled, send);
 }
 
 static void
diff --git a/src/virt-viewer-session-spice.c b/src/virt-viewer-session-spice.c
index f43ed65..526c637 100644
--- a/src/virt-viewer-session-spice.c
+++ b/src/virt-viewer-session-spice.c
@@ -64,6 +64,14 @@ enum {
 };
 
 
+#if !SPICE_GTK_CHECK_VERSION(0, 34, 21)
+#define spice_main_channel_update_display(channel, id, x, y, width, height, update) \
+                spice_main_update_display((channel), (id), (x), (y), (width), (height), (update))
+#define spice_main_channel_update_display_enabled(channel, id, enabled, update) \
+                spice_main_update_display_enabled((channel), (id), (enabled), (update))
+#define spice_main_channel_send_monitor_config spice_main_send_monitor_config
+#endif
+
 static void virt_viewer_session_spice_close(VirtViewerSession *session);
 static gboolean virt_viewer_session_spice_open_fd(VirtViewerSession *session, int fd);
 static gboolean virt_viewer_session_spice_open_host(VirtViewerSession *session, const gchar *host, const gchar *port, const gchar *tlsport);
@@ -921,9 +929,9 @@ virt_viewer_session_spice_display_monitors(SpiceChannel *channel,
             !display_is_in_fullscreen_mode(self, VIRT_VIEWER_DISPLAY(display))) {
             g_debug("display %d should not be enabled, disabling",
                     virt_viewer_display_get_nth(VIRT_VIEWER_DISPLAY(display)) + 1);
-            spice_main_set_display_enabled(virt_viewer_session_spice_get_main_channel(self),
-                                           virt_viewer_display_get_nth(VIRT_VIEWER_DISPLAY(display)),
-                                           FALSE);
+            spice_main_channel_update_display_enabled(virt_viewer_session_spice_get_main_channel(self),
+                                                      virt_viewer_display_get_nth(VIRT_VIEWER_DISPLAY(display)),
+                                                      FALSE, TRUE);
             disabled = TRUE;
         }
 
@@ -1055,7 +1063,7 @@ virt_viewer_session_spice_fullscreen_auto_conf(VirtViewerSessionSpice *self)
         return FALSE;
     }
 
-    spice_main_set_display_enabled(cmain, -1, FALSE);
+    spice_main_channel_update_display_enabled(cmain, -1, FALSE, TRUE);
 
     initial_displays = virt_viewer_app_get_initial_displays(app);
     ndisplays = g_list_length(initial_displays);
@@ -1079,15 +1087,15 @@ virt_viewer_session_spice_fullscreen_auto_conf(VirtViewerSessionSpice *self)
         GdkRectangle *rect = value;
         gint j = GPOINTER_TO_INT(key);
 
-        spice_main_set_display(cmain, j, rect->x, rect->y, rect->width, rect->height);
-        spice_main_set_display_enabled(cmain, j, TRUE);
+        spice_main_channel_update_display(cmain, j, rect->x, rect->y, rect->width, rect->height, TRUE);
+        spice_main_channel_update_display_enabled(cmain, j, TRUE, TRUE);
         g_debug("Set SPICE display %d to (%d,%d)-(%dx%d)",
                   j, rect->x, rect->y, rect->width, rect->height);
     }
     g_list_free(initial_displays);
     g_hash_table_unref(displays);
 
-    spice_main_send_monitor_config(cmain);
+    spice_main_channel_send_monitor_config(cmain);
     self->priv->did_auto_conf = TRUE;
     return TRUE;
 }
@@ -1180,8 +1188,9 @@ virt_viewer_session_spice_apply_monitor_geometry(VirtViewerSession *session, GHa
         gint i = GPOINTER_TO_INT(key);
         GdkRectangle* rect = value;
 
-        spice_main_set_display(self->priv->main_channel, i, rect->x,
-                               rect->y, rect->width, rect->height);
+        spice_main_channel_update_display(self->priv->main_channel, i, rect->x,
+                                          rect->y, rect->width, rect->height,
+                                          TRUE);
     }
 }
 
-- 
2.17.1




More information about the virt-tools-list mailing list