From 70d4dc2c01729d164c077fd166a0ea93050a817f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberts=20Muktup=C4=81vels?= Date: Sat, 10 Oct 2020 18:02:00 +0300 Subject: compositor-xrender: use GRand to generate random numbers --- src/compositor/meta-compositor-xrender.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/compositor/meta-compositor-xrender.c b/src/compositor/meta-compositor-xrender.c index 77aca305..4c7ea2b4 100644 --- a/src/compositor/meta-compositor-xrender.c +++ b/src/compositor/meta-compositor-xrender.c @@ -100,6 +100,7 @@ typedef struct gboolean prefs_listener_added; guint show_redraw : 1; + GRand *rand; } MetaCompositorXRenderPrivate; G_DEFINE_TYPE_WITH_PRIVATE (MetaCompositorXRender, @@ -865,6 +866,9 @@ timeout_debug (MetaCompositorXRender *self) priv->show_redraw = (g_getenv ("METACITY_DEBUG_REDRAWS") != NULL); + if (priv->show_redraw) + priv->rand = g_rand_new (); + return FALSE; } @@ -948,6 +952,8 @@ meta_compositor_xrender_finalize (GObject *object) } } + g_clear_pointer (&priv->rand, g_rand_free); + G_OBJECT_CLASS (meta_compositor_xrender_parent_class)->finalize (object); } @@ -1371,9 +1377,9 @@ meta_compositor_xrender_draw (MetaCompositorXRender *self, /* Make a random colour overlay */ overlay = solid_picture (xdisplay, TRUE, 1, /* 0.3, alpha */ - ((double) (rand () % 100)) / 100.0, - ((double) (rand () % 100)) / 100.0, - ((double) (rand () % 100)) / 100.0); + g_rand_double (priv->rand), + g_rand_double (priv->rand), + g_rand_double (priv->rand)); XRenderComposite (xdisplay, PictOpOver, overlay, None, priv->root_picture, 0, 0, 0, 0, 0, 0, screen_width, screen_height); -- cgit v1.2.1