[Spice-devel] [RFC/POC PATCH spice-gtk 09/16] Use an 'enabled' flag instead of status enum in monitors_config

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


The 3-state SpiceDisplayState enum is no longer needed, as there are no
items in the UNDEFINED state in the list of monitor_configs anymore.
---
 src/channel-main.c      | 10 ++++------
 src/map-file            |  1 -
 src/spice-glib-sym-file |  1 -
 src/spice-session.c     |  2 +-
 src/spice-session.h     |  8 +-------
 5 files changed, 6 insertions(+), 16 deletions(-)

diff --git a/src/channel-main.c b/src/channel-main.c
index 549b4f5..72cc070 100644
--- a/src/channel-main.c
+++ b/src/channel-main.c
@@ -1108,7 +1108,7 @@ gboolean spice_main_channel_send_monitor_config(SpiceMainChannel *channel)
     } else {
         monitors = 0;
         for (i = 0; i < monitor_configs->len; i++) {
-            if (g_array_index(monitor_configs, SpiceMonitorConfig, i).display_state == DISPLAY_ENABLED) {
+            if (g_array_index(monitor_configs, SpiceMonitorConfig, i).enabled) {
                 monitors += 1;
             }
         }
@@ -1126,7 +1126,7 @@ gboolean spice_main_channel_send_monitor_config(SpiceMainChannel *channel)
     j = 0;
     for (i = 0; i < monitor_configs->len; i++) {
         SpiceMonitorConfig *mc = &g_array_index(monitor_configs, SpiceMonitorConfig, i);
-        if (mc->display_state != DISPLAY_ENABLED) {
+        if (!mc->enabled) {
             if (spice_main_channel_agent_test_capability(channel,
                                                          VD_AGENT_CAP_SPARSE_MONITORS_CONFIG))
                 j++;
@@ -2988,14 +2988,12 @@ void spice_main_channel_update_display_enabled(SpiceMainChannel *channel, int id
     GArray *monitor_configs = spice_session_get_monitor_configs(
         spice_channel_get_session(SPICE_CHANNEL(channel)));
 
-    SpiceDisplayState display_state = enabled ? DISPLAY_ENABLED : DISPLAY_DISABLED;
-
     if (id == -1) {
         SPICE_DEBUG("Updating all monitor configs' state to %s", enabled ? "enabled" : "disabled");
 
         gint i;
         for (i = 0; i < monitor_configs->len; i++) {
-            g_array_index(monitor_configs, SpiceMonitorConfig, i).display_state = display_state;
+            g_array_index(monitor_configs, SpiceMonitorConfig, i).enabled = enabled;
         }
     } else {
         int found = 0;
@@ -3017,7 +3015,7 @@ void spice_main_channel_update_display_enabled(SpiceMainChannel *channel, int id
         SPICE_DEBUG("Updating monitor config id: %d (channel_id: %u, monitor_id: %u) state to %s",
                     id, mc->channel_id, mc->monitor_id, enabled ? "enabled" : "disabled");
 
-        mc->display_state = display_state;
+        mc->enabled = enabled;
     }
 
     if (update)
diff --git a/src/map-file b/src/map-file
index 72ee2f3..18d9a2d 100644
--- a/src/map-file
+++ b/src/map-file
@@ -123,7 +123,6 @@ spice_record_send_data;
 spice_session_add_monitor_config;
 spice_session_connect;
 spice_session_disconnect;
-spice_display_state_get_type;
 spice_session_find_monitor_config;
 spice_session_get_channels;
 spice_session_get_monitor_configs;
diff --git a/src/spice-glib-sym-file b/src/spice-glib-sym-file
index c186624..b75d3e0 100644
--- a/src/spice-glib-sym-file
+++ b/src/spice-glib-sym-file
@@ -102,7 +102,6 @@ spice_record_send_data
 spice_session_add_monitor_config
 spice_session_connect
 spice_session_disconnect
-spice_display_state_get_type
 spice_session_find_monitor_config
 spice_session_get_channels
 spice_session_get_monitor_configs
diff --git a/src/spice-session.c b/src/spice-session.c
index 4d60c3f..73da32b 100644
--- a/src/spice-session.c
+++ b/src/spice-session.c
@@ -2877,7 +2877,7 @@ void spice_session_add_monitor_config(SpiceSession *session, uint32_t channel_id
         .y = y,
         .width = width,
         .height = height,
-        .display_state = DISPLAY_DISABLED
+        .enabled = 0
     };
 
     SPICE_DEBUG("Adding new monitor_config idx=%u +%d+%d:%dx%d",
diff --git a/src/spice-session.h b/src/spice-session.h
index 6d97ab2..ed997d3 100644
--- a/src/spice-session.h
+++ b/src/spice-session.h
@@ -105,12 +105,6 @@ struct _SpiceSessionClass
     gchar _spice_reserved[SPICE_RESERVED_PADDING];
 };
 
-typedef enum {
-    DISPLAY_UNDEFINED,
-    DISPLAY_DISABLED,
-    DISPLAY_ENABLED,
-} SpiceDisplayState;
-
 typedef struct {
     uint32_t                channel_id;
     uint32_t                monitor_id;
@@ -118,7 +112,7 @@ typedef struct {
     int                     y;
     int                     width;
     int                     height;
-    SpiceDisplayState       display_state;
+    int                     enabled;
 } SpiceMonitorConfig;
 
 GType spice_session_get_type(void);
-- 
2.17.1



More information about the Spice-devel mailing list