[mutter] plugins/default: Initialize background color in a predictable manner



commit ba3805706795c90db436f6a1572ecf9f5ca5cf2b
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Sun Feb 14 00:17:36 2021 +0100

    plugins/default: Initialize background color in a predictable manner
    
    The order of which function argument expressions are executed is
    undefined, so don't rely on this for setting the background colors, as
    it results in different colors on different architectures.
    
    For example, it has been observed that the order of execution is
    reversed comparing x86_64 and aarch64, making these two architectures
    having different background color.
    
    Fix this confusion, and also reproduceability in future reference tests,
    by making the order of execution predictable.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>

 src/compositor/plugins/default.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
---
diff --git a/src/compositor/plugins/default.c b/src/compositor/plugins/default.c
index 1c73174d2f..c89c84121f 100644
--- a/src/compositor/plugins/default.c
+++ b/src/compositor/plugins/default.c
@@ -338,6 +338,9 @@ on_monitors_changed (MetaMonitorManager *monitor_manager,
       MetaRectangle rect;
       ClutterActor *background_actor;
       MetaBackground *background;
+      uint8_t red;
+      uint8_t green;
+      uint8_t blue;
       ClutterColor color;
 
       meta_display_get_monitor_geometry (display, i, &rect);
@@ -353,11 +356,11 @@ on_monitors_changed (MetaMonitorManager *monitor_manager,
          parsing the driconf XML, but it's nice if the colors are
          reproducible.
       */
-      clutter_color_init (&color,
-                          g_rand_int_range (rand, 0, 255),
-                          g_rand_int_range (rand, 0, 255),
-                          g_rand_int_range (rand, 0, 255),
-                          255);
+
+      blue = g_rand_int_range (rand, 0, 255);
+      green = g_rand_int_range (rand, 0, 255);
+      red = g_rand_int_range (rand, 0, 255);
+      clutter_color_init (&color, red, green, blue, 255);
 
       background = meta_background_new (display);
       meta_background_set_color (background, &color);


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