[Spice-devel] [RFC PATCH spice-gtk v2 16/20] Use an 'enabled' flag instead of status enum in monitors_config
Lukáš Hrázký
lhrazky at redhat.com
Thu Aug 16 16:26:45 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.
Signed-off-by: Lukáš Hrázký <lhrazky at redhat.com>
---
src/channel-main.c | 12 +++++-------
src/map-file | 1 -
src/spice-glib-sym-file | 1 -
src/spice-session.c | 6 +++---
src/spice-session.h | 8 +-------
5 files changed, 9 insertions(+), 19 deletions(-)
diff --git a/src/channel-main.c b/src/channel-main.c
index 040f4a8..44137b9 100644
--- a/src/channel-main.c
+++ b/src/channel-main.c
@@ -1104,7 +1104,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;
}
}
@@ -1122,7 +1122,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++;
@@ -2957,14 +2957,12 @@ static void spice_main_channel_update_display_enabled_deprecated(SpiceMainChanne
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 {
bool found = false;
@@ -2983,14 +2981,14 @@ static void spice_main_channel_update_display_enabled_deprecated(SpiceMainChanne
return;
}
- if (mc->display_state == display_state) {
+ if (mc->enabled == enabled) {
return;
}
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 0e4c375..d0163d4 100644
--- a/src/map-file
+++ b/src/map-file
@@ -122,7 +122,6 @@ spice_record_channel_send_data;
spice_record_send_data;
spice_session_connect;
spice_session_disconnect;
-spice_display_state_get_type;
spice_session_get_monitor_config;
spice_session_get_channels;
spice_session_get_proxy_uri;
diff --git a/src/spice-glib-sym-file b/src/spice-glib-sym-file
index 897a303..202588e 100644
--- a/src/spice-glib-sym-file
+++ b/src/spice-glib-sym-file
@@ -101,7 +101,6 @@ spice_record_channel_send_data
spice_record_send_data
spice_session_connect
spice_session_disconnect
-spice_display_state_get_type
spice_session_get_monitor_config
spice_session_get_channels
spice_session_get_proxy_uri
diff --git a/src/spice-session.c b/src/spice-session.c
index cea8fdf..56829ea 100644
--- a/src/spice-session.c
+++ b/src/spice-session.c
@@ -2834,7 +2834,7 @@ void spice_session_add_monitor_config(SpiceSession *session, uint32_t channel_id
.y = y,
.width = width,
.height = height,
- .display_state = DISPLAY_DISABLED
+ .enabled = FALSE
};
SPICE_DEBUG("Adding new monitor_config channel_id: %u, monitor_id: %u, +%u+%u:%ux%u",
@@ -2950,14 +2950,14 @@ void spice_session_update_monitor_config_enabled(SpiceSession *session,
g_return_if_fail(mc != NULL);
- if (mc->display_state == (enabled ? DISPLAY_ENABLED : DISPLAY_DISABLED)) {
+ if (mc->enabled == enabled) {
return;
}
SPICE_DEBUG("%s monitor config channel_id: %u, monitor_id: %u",
enabled ? "Enabling" : "Disabling", channel_id, monitor_id);
- mc->display_state = enabled ? DISPLAY_ENABLED : DISPLAY_DISABLED;
+ mc->enabled = enabled;
if (update) {
spice_main_channel_update_display_timer((SpiceMainChannel *) session->priv->cmain, 1);
diff --git a/src/spice-session.h b/src/spice-session.h
index 16523bb..54e79b2 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 {
uint32_t y;
uint32_t width;
uint32_t height;
- SpiceDisplayState display_state;
+ gboolean enabled;
} SpiceMonitorConfig;
GType spice_session_get_type(void);
--
2.18.0
More information about the Spice-devel
mailing list