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



commit 0a8e108f1053609a234247ad821b61d39882f968
Author: Jonas Ådahl <jadahl gmail com>
Date:   Wed Jun 14 12:17:31 2017 +0800

    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

 src/backends/meta-monitor-manager.c    |   16 +++++++++++-----
 src/org.gnome.Mutter.DisplayConfig.xml |    8 +++++---
 2 files changed, 16 insertions(+), 8 deletions(-)
---
diff --git a/src/backends/meta-monitor-manager.c b/src/backends/meta-monitor-manager.c
index 1cccebc..cf01096 100644
--- a/src/backends/meta-monitor-manager.c
+++ b/src/backends/meta-monitor-manager.c
@@ -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_CURRENT (1 << 1)
 
-#define MODE_FORMAT "(siiddadu)"
+#define MODE_FORMAT "(siiddada{sv})"
 #define MODES_FORMAT "a" MODE_FORMAT
 #define MONITOR_SPEC_FORMAT "(ssss)"
 #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 *supported_scales;
           int n_supported_scales;
-          uint32_t flags = 0;
+          GVariantBuilder mode_properties_builder;
 
           mode_id = meta_monitor_mode_get_id (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]);
           g_free (supported_scales);
 
+          g_variant_builder_init (&mode_properties_builder,
+                                  G_VARIANT_TYPE ("a{sv}"));
           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)
-            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,
                                  mode_id,
@@ -1592,7 +1598,7 @@ meta_monitor_manager_handle_get_current_state (MetaDBusDisplayConfig *skeleton,
                                  refresh_rate,
                                  (double) preferred_scale,
                                  &supported_scales_builder,
-                                 flags);
+                                 &mode_properties_builder);
         }
 
       g_variant_builder_init (&monitor_properties_builder,
diff --git a/src/org.gnome.Mutter.DisplayConfig.xml b/src/org.gnome.Mutter.DisplayConfig.xml
index befd685..30a8e97 100644
--- a/src/org.gnome.Mutter.DisplayConfig.xml
+++ b/src/org.gnome.Mutter.DisplayConfig.xml
@@ -315,14 +315,16 @@
        * s vendor: vendor name
        * s product: product name
        * s serial: product serial
-       * a(siiddad) modes: available modes
+       * a(siiddada{sv}) modes: available modes
            * s id: mode ID
            * i width: width in physical pixels
            * i height: height in physical pixels
            * d refresh rate: refresh rate
            * d preferred scale: scale preferred as per calculations
            * 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:
            - "width-mm" (i): physical width of monitor in millimeters
            - "height-mm" (i): physical height of monitor in millimeters
@@ -405,7 +407,7 @@
     -->
     <method name="GetCurrentState">
       <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="properties" direction="out" type="a{sv}" />
     </method>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]