DisplayConfig: Replace mode 'u' flags with 'a{sv}' property bag

To be more flexible without having to change any D-Bus type signatures
in the future, replace the 'uint' flags value (currently determining
whether a mode is current and/or preferred) with a variant lookup table.

The keys 'is-current' (b) and 'is-preferred' (b) replace the existing
flags.

https://bugzilla.gnome.org/show_bug.cgi?id=765011
This commit is contained in:
Jonas Ådahl 2017-06-14 12:17:31 +08:00
parent 859b01fc39
commit 0a8e108f10
2 changed files with 16 additions and 8 deletions

View File

@ -1492,7 +1492,7 @@ meta_monitor_manager_legacy_handle_apply_configuration (MetaDBusDisplayConfig *
#define META_DISPLAY_CONFIG_MODE_FLAGS_PREFERRED (1 << 0) #define META_DISPLAY_CONFIG_MODE_FLAGS_PREFERRED (1 << 0)
#define META_DISPLAY_CONFIG_MODE_FLAGS_CURRENT (1 << 1) #define META_DISPLAY_CONFIG_MODE_FLAGS_CURRENT (1 << 1)
#define MODE_FORMAT "(siiddadu)" #define MODE_FORMAT "(siiddada{sv})"
#define MODES_FORMAT "a" MODE_FORMAT #define MODES_FORMAT "a" MODE_FORMAT
#define MONITOR_SPEC_FORMAT "(ssss)" #define MONITOR_SPEC_FORMAT "(ssss)"
#define MONITOR_FORMAT "(" MONITOR_SPEC_FORMAT MODES_FORMAT "a{sv})" #define MONITOR_FORMAT "(" MONITOR_SPEC_FORMAT MODES_FORMAT "a{sv})"
@ -1555,7 +1555,7 @@ meta_monitor_manager_handle_get_current_state (MetaDBusDisplayConfig *skeleton,
float preferred_scale; float preferred_scale;
float *supported_scales; float *supported_scales;
int n_supported_scales; int n_supported_scales;
uint32_t flags = 0; GVariantBuilder mode_properties_builder;
mode_id = meta_monitor_mode_get_id (monitor_mode); mode_id = meta_monitor_mode_get_id (monitor_mode);
meta_monitor_mode_get_resolution (monitor_mode, meta_monitor_mode_get_resolution (monitor_mode,
@ -1580,10 +1580,16 @@ meta_monitor_manager_handle_get_current_state (MetaDBusDisplayConfig *skeleton,
(double) supported_scales[i]); (double) supported_scales[i]);
g_free (supported_scales); g_free (supported_scales);
g_variant_builder_init (&mode_properties_builder,
G_VARIANT_TYPE ("a{sv}"));
if (monitor_mode == current_mode) if (monitor_mode == current_mode)
flags |= META_DISPLAY_CONFIG_MODE_FLAGS_CURRENT; g_variant_builder_add (&mode_properties_builder, "{sv}",
"is-current",
g_variant_new_boolean (TRUE));
if (monitor_mode == preferred_mode) if (monitor_mode == preferred_mode)
flags |= META_DISPLAY_CONFIG_MODE_FLAGS_PREFERRED; g_variant_builder_add (&mode_properties_builder, "{sv}",
"is-preferred",
g_variant_new_boolean (TRUE));
g_variant_builder_add (&modes_builder, MODE_FORMAT, g_variant_builder_add (&modes_builder, MODE_FORMAT,
mode_id, mode_id,
@ -1592,7 +1598,7 @@ meta_monitor_manager_handle_get_current_state (MetaDBusDisplayConfig *skeleton,
refresh_rate, refresh_rate,
(double) preferred_scale, (double) preferred_scale,
&supported_scales_builder, &supported_scales_builder,
flags); &mode_properties_builder);
} }
g_variant_builder_init (&monitor_properties_builder, g_variant_builder_init (&monitor_properties_builder,

View File

@ -315,14 +315,16 @@
* s vendor: vendor name * s vendor: vendor name
* s product: product name * s product: product name
* s serial: product serial * s serial: product serial
* a(siiddad) modes: available modes * a(siiddada{sv}) modes: available modes
* s id: mode ID * s id: mode ID
* i width: width in physical pixels * i width: width in physical pixels
* i height: height in physical pixels * i height: height in physical pixels
* d refresh rate: refresh rate * d refresh rate: refresh rate
* d preferred scale: scale preferred as per calculations * d preferred scale: scale preferred as per calculations
* ad supported scales: scales supported by this mode * ad supported scales: scales supported by this mode
* u flags: mode flags (see below) * a{sv} properties: optional properties, including:
- "is-current" (b): the mode is currently active mode
- "is-preferred" (b): the mode is the preferred mode
* a{sv} properties: optional properties, including: * a{sv} properties: optional properties, including:
- "width-mm" (i): physical width of monitor in millimeters - "width-mm" (i): physical width of monitor in millimeters
- "height-mm" (i): physical height of monitor in millimeters - "height-mm" (i): physical height of monitor in millimeters
@ -405,7 +407,7 @@
--> -->
<method name="GetCurrentState"> <method name="GetCurrentState">
<arg name="serial" direction="out" type="u" /> <arg name="serial" direction="out" type="u" />
<arg name="monitors" direction="out" type="a((ssss)a(siiddadu)a{sv})" /> <arg name="monitors" direction="out" type="a((ssss)a(siiddada{sv})a{sv})" />
<arg name="logical_monitors" direction="out" type="a(iiduba(ssss)a{sv})" /> <arg name="logical_monitors" direction="out" type="a(iiduba(ssss)a{sv})" />
<arg name="properties" direction="out" type="a{sv}" /> <arg name="properties" direction="out" type="a{sv}" />
</method> </method>