[Spice-devel] [RFC/POC PATCH spice-gtk 11/16] Add output_id to the monitors_config

Lukáš Hrázký lhrazky at redhat.com
Tue Jun 5 15:30:37 UTC 2018


Use the new output_id field in the message from the client, store it in
the monitor_configs array in the session and pass it to the server and
subsequently vd_agent in the VDAgentMonitorsConfigV2 message.

Signed-off-by: Lukáš Hrázký <lhrazky at redhat.com>
---
 src/channel-display.c | 14 ++++++++------
 src/channel-main.c    |  8 +++++---
 src/spice-session.c   | 16 +++++++++-------
 src/spice-session.h   |  5 +++--
 4 files changed, 25 insertions(+), 18 deletions(-)

diff --git a/src/channel-display.c b/src/channel-display.c
index 9e83e43..942b0fd 100644
--- a/src/channel-display.c
+++ b/src/channel-display.c
@@ -1900,8 +1900,8 @@ static void display_handle_monitors_config(SpiceChannel *channel, SpiceMsgIn *in
     for (i = 0; i < config->count; i++) {
         SpiceDisplayMonitorConfig *mc = &g_array_index(c->monitors, SpiceDisplayMonitorConfig, i);
         SpiceHead *head = &config->heads[i];
-        CHANNEL_DEBUG(channel, "monitor id: %u, surface id: %u, +%u+%u-%ux%u",
-                    head->id, head->surface_id,
+        CHANNEL_DEBUG(channel, "monitor id: %u, surface id: %u, output id: %u, +%u+%u-%ux%u",
+                    head->id, head->surface_id, head->output_id,
                     head->x, head->y, head->width, head->height);
         mc->id = head->id;
         mc->surface_id = head->surface_id;
@@ -1912,18 +1912,20 @@ static void display_handle_monitors_config(SpiceChannel *channel, SpiceMsgIn *in
 
         if (spice_session_find_monitor_config(session, channel->priv->channel_id, i)) {
             spice_session_update_monitor_config(session, channel->priv->channel_id, i,
-                                                head->x, head->y, head->width, head->height);
+                                                head->x, head->y, head->width, head->height,
+                                                head->output_id);
         } else {
             spice_session_add_monitor_config(session, channel->priv->channel_id, i,
-                                             head->x, head->y, head->width, head->height);
+                                             head->x, head->y, head->width, head->height,
+                                             head->output_id);
         }
     }
 
     // On top of the above, create disabled configs for all monitors up to max_allowed
-    // if they don't exist.
+    // if they don't exist. The output_id for those is 0 (we have no other information).
     for (i = config->count; i < config->max_allowed; i++) {
         if (!spice_session_find_monitor_config(session, channel->priv->channel_id, i)) {
-            spice_session_add_monitor_config(session, channel->priv->channel_id, i, 0, 0, 0, 0);
+            spice_session_add_monitor_config(session, channel->priv->channel_id, i, 0, 0, 0, 0, 0);
         }
     }
 
diff --git a/src/channel-main.c b/src/channel-main.c
index 8b2c031..77870a0 100644
--- a/src/channel-main.c
+++ b/src/channel-main.c
@@ -1132,12 +1132,14 @@ gboolean spice_main_channel_send_monitor_config(SpiceMainChannel *channel)
                 j++;
             continue;
         }
+        mon->monitors[j].output_id  = mc->output_id;
         mon->monitors[j].depth  = c->display_color_depth ? c->display_color_depth : 32;
         mon->monitors[j].width  = mc->width;
         mon->monitors[j].height = mc->height;
         mon->monitors[j].x = mc->x;
         mon->monitors[j].y = mc->y;
-        CHANNEL_DEBUG(channel, "monitor #%d: %ux%u+%d+%d @ %u bpp", j,
+        CHANNEL_DEBUG(channel, "monitor #%d output id %u: %ux%u+%d+%d @ %u bpp", j,
+                      mon->monitors[j].output_id,
                       mon->monitors[j].width, mon->monitors[j].height,
                       mon->monitors[j].x, mon->monitors[j].y,
                       mon->monitors[j].depth);
@@ -2681,8 +2683,8 @@ void spice_main_channel_update_display(SpiceMainChannel *channel, int id, int x,
     }
 
     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);
+        "Update display (monitor config) id: %d (channel_id: %u, monitor_id: %u), output_id: %u, +%d+%d-%dx%d",
+        id, mc->channel_id, mc->monitor_id, mc->output_id, x, y, width, height);
 
     mc->x = x;
     mc->y = y;
diff --git a/src/spice-session.c b/src/spice-session.c
index 73da32b..b6c4300 100644
--- a/src/spice-session.c
+++ b/src/spice-session.c
@@ -2860,7 +2860,7 @@ SpiceMonitorConfig *spice_session_find_monitor_config(SpiceSession *session,
  * Since: 0.36
  **/
 void spice_session_add_monitor_config(SpiceSession *session, uint32_t channel_id, uint32_t monitor_id,
-                                      int x, int y, int width, int height)
+                                      int x, int y, int width, int height, uint32_t output_id)
 {
     GArray *monitor_configs = spice_session_get_monitor_configs(session);
     g_assert(monitor_configs != NULL);
@@ -2877,11 +2877,12 @@ void spice_session_add_monitor_config(SpiceSession *session, uint32_t channel_id
         .y = y,
         .width = width,
         .height = height,
-        .enabled = 0
+        .enabled = 0,
+        .output_id = output_id
     };
 
-    SPICE_DEBUG("Adding new monitor_config idx=%u +%d+%d:%dx%d",
-                monitor_configs->len, x, y, width, height);
+    SPICE_DEBUG("Adding new monitor_config idx=%u +%d+%d:%dx%d output_id: %u",
+                monitor_configs->len, x, y, width, height, output_id);
 
     g_array_append_val(monitor_configs, mc);
 }
@@ -2903,19 +2904,20 @@ void spice_session_add_monitor_config(SpiceSession *session, uint32_t channel_id
  * Since: 0.36
  **/
 void spice_session_update_monitor_config(SpiceSession *session, uint32_t  channel_id, uint32_t monitor_id,
-                                         int x, int y, int width, int height)
+                                         int x, int y, int width, int height, uint32_t output_id)
 {
     SpiceMonitorConfig *mc = spice_session_find_monitor_config(session, channel_id, monitor_id);
 
     g_return_if_fail(mc != NULL);
 
-    SPICE_DEBUG("Updating monitor config channel_id: %u, monitor_id: %u, +%d+%d-%dx%d",
-                channel_id, monitor_id, x, y, width, height);
+    SPICE_DEBUG("Updating monitor config channel_id: %u, monitor_id: %u, output_id: %u (-> %u), +%d+%d-%dx%d",
+                channel_id, monitor_id, mc->output_id, output_id, x, y, width, height);
 
     mc->x = x;
     mc->y = y;
     mc->width = width;
     mc->height = height;
+    mc->output_id = output_id;
 }
 
 G_GNUC_INTERNAL
diff --git a/src/spice-session.h b/src/spice-session.h
index ed997d3..8aa2794 100644
--- a/src/spice-session.h
+++ b/src/spice-session.h
@@ -113,6 +113,7 @@ typedef struct {
     int                     width;
     int                     height;
     int                     enabled;
+    uint32_t                output_id;
 } SpiceMonitorConfig;
 
 GType spice_session_get_type(void);
@@ -134,10 +135,10 @@ SpiceMonitorConfig *spice_session_find_monitor_config(SpiceSession *session,
                                                       uint32_t monitor_id);
 
 void spice_session_add_monitor_config(SpiceSession *session, uint32_t channel_id, uint32_t display_id,
-                                      int x, int y, int width, int height);
+                                      int x, int y, int width, int height, uint32_t output_id);
 
 void spice_session_update_monitor_config(SpiceSession *session, uint32_t  channel_id, uint32_t monitor_id,
-                                         int x, int y, int width, int height);
+                                         int x, int y, int width, int height, uint32_t output_id);
 
 G_END_DECLS
 
-- 
2.17.1



More information about the Spice-devel mailing list