[mutter] default: Use a consistent rand() for monitor backgrounds



commit 91770d0477c549aa5e23b429418ec6ec6dbfcaf8
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Mon Feb 17 13:47:58 2014 -0500

    default: Use a consistent rand() for monitor backgrounds
    
    g_random_int() is seeded with /dev/urandom, so it's not consistent.

 src/compositor/plugins/default.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/src/compositor/plugins/default.c b/src/compositor/plugins/default.c
index 1c8d741..edfb24b 100644
--- a/src/compositor/plugins/default.c
+++ b/src/compositor/plugins/default.c
@@ -295,6 +295,7 @@ on_monitors_changed (MetaScreen *screen,
 {
   MetaDefaultPlugin *self = META_DEFAULT_PLUGIN (plugin);
   int i, n;
+  GRand *rand = g_rand_new_with_seed (12345);
 
   clutter_actor_destroy_all_children (self->priv->background_group);
 
@@ -317,14 +318,16 @@ on_monitors_changed (MetaScreen *screen,
          reproducible.
       */
       clutter_color_init (&color,
-                          g_random_int () % 255,
-                          g_random_int () % 255,
-                          g_random_int () % 255,
+                          g_rand_int_range (rand, 0, 255),
+                          g_rand_int_range (rand, 0, 255),
+                          g_rand_int_range (rand, 0, 255),
                           255);
       clutter_actor_set_background_color (background, &color);
 
       clutter_actor_add_child (self->priv->background_group, background);
     }
+
+  g_rand_free (rand);
 }
 
 static void


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