[Spice-devel] [RFC PATCH spice-gtk v2 14/20] Deprecate the old monitors_config API

Lukáš Hrázký lhrazky at redhat.com
Thu Aug 16 16:26:43 UTC 2018


Signed-off-by: Lukáš Hrázký <lhrazky at redhat.com>
---
 src/channel-main.c | 204 ++++++++++++++++++++++++---------------------
 src/channel-main.h |  18 ++--
 2 files changed, 120 insertions(+), 102 deletions(-)

diff --git a/src/channel-main.c b/src/channel-main.c
index a23bc64..085990c 100644
--- a/src/channel-main.c
+++ b/src/channel-main.c
@@ -2623,6 +2623,55 @@ gboolean spice_main_channel_agent_test_capability(SpiceMainChannel *channel, gui
     return test_agent_cap(channel, cap);
 }
 
+static void spice_main_channel_update_display_deprecated(SpiceMainChannel *channel,
+                                                         int id, int x, int y, int width,
+                                                         int height, gboolean update)
+{
+    g_return_if_fail(channel != NULL);
+    g_return_if_fail(SPICE_IS_MAIN_CHANNEL(channel));
+    g_return_if_fail(x >= 0);
+    g_return_if_fail(y >= 0);
+    g_return_if_fail(width >= 0);
+    g_return_if_fail(height >= 0);
+
+    GArray *monitor_configs = spice_session_get_monitor_configs(
+        spice_channel_get_session(SPICE_CHANNEL(channel)));
+
+    bool found = false;
+    SpiceMonitorConfig *mc = NULL;
+    for (size_t i = 0; i < monitor_configs->len; ++i) {
+        mc = &g_array_index(monitor_configs, SpiceMonitorConfig, i);
+        if (mc->channel_id + mc->monitor_id == id) {
+            found = true;
+            break;
+        }
+    }
+
+    if (!found) {
+        g_warning("Display ID %d not found while trying to update the display (monitor config).", id);
+        return;
+    }
+
+    if (mc->x == x &&
+        mc->y == y &&
+        mc->width == width &&
+        mc->height == height) {
+        return;
+    }
+
+    CHANNEL_DEBUG(channel,
+        "Update display (monitor config) id: %d (channel_id: %u, monitor_id: %u), +%d+%d-%dx%d",
+        id, mc->channel_id, mc->monitor_id, x, y, width, height);
+
+    mc->x = x;
+    mc->y = y;
+    mc->width = width;
+    mc->height = height;
+
+    if (update)
+        spice_main_channel_update_display_timer(channel, 1);
+}
+
 /**
  * spice_main_update_display:
  * @channel: a #SpiceMainChannel
@@ -2640,13 +2689,13 @@ gboolean spice_main_channel_agent_test_capability(SpiceMainChannel *channel, gui
  * without delay the new configuration to the remote with
  * spice_main_send_monitor_config()
  *
- * Deprecated: 0.35: use spice_main_channel_update_display() instead.
+ * Deprecated: 0.36: use spice_session_update_monitor_config_dimensions() instead.
  **/
 void spice_main_update_display(SpiceMainChannel *channel, int id,
                                int x, int y, int width, int height,
                                gboolean update)
 {
-    spice_main_channel_update_display(channel, id, x, y, width, height, update);
+    spice_main_channel_update_display_deprecated(channel, id, x, y, width, height, update);
 }
 
 /**
@@ -2667,53 +2716,12 @@ void spice_main_update_display(SpiceMainChannel *channel, int id,
  * spice_main_send_monitor_config()
  *
  * Since: 0.35
+ * Deprecated: 0.36: use spice_session_update_monitor_config_dimensions() instead.
  **/
 void spice_main_channel_update_display(SpiceMainChannel *channel, int id, int x, int y, int width,
                                int height, gboolean update)
 {
-    g_return_if_fail(channel != NULL);
-    g_return_if_fail(SPICE_IS_MAIN_CHANNEL(channel));
-    g_return_if_fail(x >= 0);
-    g_return_if_fail(y >= 0);
-    g_return_if_fail(width >= 0);
-    g_return_if_fail(height >= 0);
-
-    GArray *monitor_configs = spice_session_get_monitor_configs(
-        spice_channel_get_session(SPICE_CHANNEL(channel)));
-
-    bool found = false;
-    SpiceMonitorConfig *mc = NULL;
-    for (size_t i = 0; i < monitor_configs->len; ++i) {
-        mc = &g_array_index(monitor_configs, SpiceMonitorConfig, i);
-        if (mc->channel_id + mc->monitor_id == id) {
-            found = true;
-            break;
-        }
-    }
-
-    if (!found) {
-        g_warning("Display ID %d not found while trying to update the display (monitor config).", id);
-        return;
-    }
-
-    if (mc->x == x &&
-        mc->y == y &&
-        mc->width == width &&
-        mc->height == height) {
-        return;
-    }
-
-    CHANNEL_DEBUG(channel,
-        "Update display (monitor config) id: %d (channel_id: %u, monitor_id: %u), +%d+%d-%dx%d",
-        id, mc->channel_id, mc->monitor_id, x, y, width, height);
-
-    mc->x = x;
-    mc->y = y;
-    mc->width = width;
-    mc->height = height;
-
-    if (update)
-        spice_main_channel_update_display_timer(channel, 1);
+    spice_main_channel_update_display_deprecated(channel, id, x, y, width, height, update);
 }
 
 /**
@@ -2728,12 +2736,12 @@ void spice_main_channel_update_display(SpiceMainChannel *channel, int id, int x,
  * Notify the guest of screen resolution change. The notification is
  * sent 1 second later, if no further changes happen.
  *
- * Deprecated: 0.35: use spice_main_channel_update_display() instead.
+ * Deprecated: 0.36: use spice_session_update_monitor_config_dimensions() instead.
  **/
 void spice_main_set_display(SpiceMainChannel *channel, int id,
                             int x, int y, int width, int height)
 {
-    spice_main_channel_update_display(channel, id, x, y, width, height, TRUE);
+    spice_main_channel_update_display_deprecated(channel, id, x, y, width, height, TRUE);
 }
 
 /**
@@ -2958,51 +2966,9 @@ void spice_main_channel_clipboard_selection_request(SpiceMainChannel *channel, g
     spice_channel_wakeup(SPICE_CHANNEL(channel), FALSE);
 }
 
-/**
- * spice_main_update_display_enabled:
- * @channel: a #SpiceMainChannel
- * @id: the display ID - assumed to be channel_id + monitor_id
- * @enabled: wether display @id is enabled
- * @update: if %TRUE, update guest display state after 1sec.
- *
- * When sending monitor configuration to agent guest, if @enabled is %FALSE,
- * don't set display @id, which the agent translates to disabling the display
- * id. If @enabled is %TRUE, the monitor will be included in the next monitor
- * update. Note: this will take effect next time the monitor configuration is
- * sent.
- *
- * If @update is %FALSE, no server update will be triggered by this call, but
- * the value will be saved and used in the next configuration update.
- *
- * Since: 0.30
- * Deprecated: 0.35: use spice_main_channel_update_display_enabled() instead.
- **/
-void spice_main_update_display_enabled(SpiceMainChannel *channel, int id, gboolean enabled,
-                                       gboolean update)
-{
-    spice_main_channel_update_display_enabled(channel, id, enabled, update);
-}
-
-/**
- * spice_main_channel_update_display_enabled:
- * @channel: a #SpiceMainChannel
- * @id: the display ID - assumed to be channel_id + monitor_id
- * @enabled: wether display @id is enabled
- * @update: if %TRUE, update guest display state after 1sec.
- *
- * When sending monitor configuration to agent guest, if @enabled is %FALSE,
- * don't set display @id, which the agent translates to disabling the display
- * id. If @enabled is %TRUE, the monitor will be included in the next monitor
- * update. Note: this will take effect next time the monitor configuration is
- * sent.
- *
- * If @update is %FALSE, no server update will be triggered by this call, but
- * the value will be saved and used in the next configuration update.
- *
- * Since: 0.35
- **/
-void spice_main_channel_update_display_enabled(SpiceMainChannel *channel, int id, gboolean enabled,
-                                               gboolean update)
+static void spice_main_channel_update_display_enabled_deprecated(SpiceMainChannel *channel,
+                                                                 int id, gboolean enabled,
+                                                                 gboolean update)
 {
     g_return_if_fail(channel != NULL);
     g_return_if_fail(SPICE_IS_MAIN_CHANNEL(channel));
@@ -3051,6 +3017,56 @@ void spice_main_channel_update_display_enabled(SpiceMainChannel *channel, int id
         spice_main_channel_update_display_timer(channel, 1);
 }
 
+/**
+ * spice_main_update_display_enabled:
+ * @channel: a #SpiceMainChannel
+ * @id: the display ID - assumed to be channel_id + monitor_id
+ * @enabled: wether display @id is enabled
+ * @update: if %TRUE, update guest display state after 1sec.
+ *
+ * When sending monitor configuration to agent guest, if @enabled is %FALSE,
+ * don't set display @id, which the agent translates to disabling the display
+ * id. If @enabled is %TRUE, the monitor will be included in the next monitor
+ * update. Note: this will take effect next time the monitor configuration is
+ * sent.
+ *
+ * If @update is %FALSE, no server update will be triggered by this call, but
+ * the value will be saved and used in the next configuration update.
+ *
+ * Since: 0.30
+ * Deprecated: 0.36: use spice_session_update_monitor_config_enabled() instead.
+ **/
+void spice_main_update_display_enabled(SpiceMainChannel *channel, int id, gboolean enabled,
+                                       gboolean update)
+{
+    spice_main_channel_update_display_enabled_deprecated(channel, id, enabled, update);
+}
+
+/**
+ * spice_main_channel_update_display_enabled:
+ * @channel: a #SpiceMainChannel
+ * @id: the display ID - assumed to be channel_id + monitor_id
+ * @enabled: wether display @id is enabled
+ * @update: if %TRUE, update guest display state after 1sec.
+ *
+ * When sending monitor configuration to agent guest, if @enabled is %FALSE,
+ * don't set display @id, which the agent translates to disabling the display
+ * id. If @enabled is %TRUE, the monitor will be included in the next monitor
+ * update. Note: this will take effect next time the monitor configuration is
+ * sent.
+ *
+ * If @update is %FALSE, no server update will be triggered by this call, but
+ * the value will be saved and used in the next configuration update.
+ *
+ * Since: 0.35
+ * Deprecated: 0.36: use spice_session_update_monitor_config_enabled() instead.
+ **/
+void spice_main_channel_update_display_enabled(SpiceMainChannel *channel, int id, gboolean enabled,
+                                               gboolean update)
+{
+    spice_main_channel_update_display_enabled_deprecated(channel, id, enabled, update);
+}
+
 /**
  * spice_main_set_display_enabled:
  * @channel: a #SpiceMainChannel
@@ -3063,11 +3079,11 @@ void spice_main_channel_update_display_enabled(SpiceMainChannel *channel, int id
  * configuration is sent.
  *
  * Since: 0.6
- * Deprecated: 0.35: use spice_main_channel_update_display_enabled() instead.
+ * Deprecated: 0.36: use spice_session_update_monitor_config_enabled() instead.
  **/
 void spice_main_set_display_enabled(SpiceMainChannel *channel, int id, gboolean enabled)
 {
-    spice_main_channel_update_display_enabled(channel, id, enabled, TRUE);
+    spice_main_channel_update_display_enabled_deprecated(channel, id, enabled, TRUE);
 }
 
 static void file_xfer_init_task_async_cb(GObject *obj, GAsyncResult *res, gpointer data)
diff --git a/src/channel-main.h b/src/channel-main.h
index 0495bb2..aee9577 100644
--- a/src/channel-main.h
+++ b/src/channel-main.h
@@ -71,10 +71,6 @@ struct _SpiceMainChannelClass {
 
 GType spice_main_channel_get_type(void);
 
-void spice_main_channel_update_display(SpiceMainChannel *channel, int id, int x, int y, int width,
-                                       int height, gboolean update);
-void spice_main_channel_update_display_enabled(SpiceMainChannel *channel, int id, gboolean enabled,
-                                               gboolean update);
 gboolean spice_main_channel_send_monitor_config(SpiceMainChannel *channel);
 
 void spice_main_channel_clipboard_selection_grab(SpiceMainChannel *channel, guint selection,
@@ -114,14 +110,20 @@ void spice_main_clipboard_notify(SpiceMainChannel *channel, guint32 type, const
 G_DEPRECATED_FOR(spice_main_channel_clipboard_selection_request)
 void spice_main_clipboard_request(SpiceMainChannel *channel, guint32 type);
 
-G_DEPRECATED_FOR(spice_main_channel_update_display)
+G_DEPRECATED_FOR(spice_session_update_monitor_config_dimensions)
+void spice_main_channel_update_display(SpiceMainChannel *channel, int id, int x, int y, int width,
+                                       int height, gboolean update);
+G_DEPRECATED_FOR(spice_session_update_monitor_config_dimensions)
 void spice_main_set_display(SpiceMainChannel *channel, int id,int x, int y, int width, int height);
-G_DEPRECATED_FOR(spice_main_channel_update_display)
+G_DEPRECATED_FOR(spice_session_update_monitor_config_dimensions)
 void spice_main_update_display(SpiceMainChannel *channel, int id, int x, int y, int width,
                                int height, gboolean update);
-G_DEPRECATED_FOR(spice_main_channel_update_display_enabled)
+G_DEPRECATED_FOR(spice_session_update_monitor_config_enabled)
+void spice_main_channel_update_display_enabled(SpiceMainChannel *channel, int id, gboolean enabled,
+                                               gboolean update);
+G_DEPRECATED_FOR(spice_session_update_monitor_config_enabled)
 void spice_main_set_display_enabled(SpiceMainChannel *channel, int id, gboolean enabled);
-G_DEPRECATED_FOR(spice_main_channel_update_display_enabled)
+G_DEPRECATED_FOR(spice_session_update_monitor_config_enabled)
 void spice_main_update_display_enabled(SpiceMainChannel *channel, int id, gboolean enabled,
                                        gboolean update);
 G_DEPRECATED_FOR(spice_main_channel_send_monitor_config)
-- 
2.18.0



More information about the Spice-devel mailing list