[gnome-settings-daemon] daemon: Use GOnce to check for Wayland



commit 9c1ed01d676e4515e4aa81375a08c65ea37f0df2
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Jan 27 17:10:34 2015 +0100

    daemon: Use GOnce to check for Wayland
    
    https://bugzilla.gnome.org/show_bug.cgi?id=743588

 gnome-settings-daemon/gnome-settings-bus.c |   21 +++++++++------------
 1 files changed, 9 insertions(+), 12 deletions(-)
---
diff --git a/gnome-settings-daemon/gnome-settings-bus.c b/gnome-settings-daemon/gnome-settings-bus.c
index c4d14f8..9e884a6 100644
--- a/gnome-settings-daemon/gnome-settings-bus.c
+++ b/gnome-settings-daemon/gnome-settings-bus.c
@@ -122,31 +122,28 @@ gnome_settings_bus_get_shell_proxy (void)
         return shell_proxy;
 }
 
-static gboolean
-is_wayland_session (void)
+static gpointer
+is_wayland_session (gpointer user_data)
 {
 #if HAVE_WAYLAND
         struct wl_display *display;
 
         display = wl_display_connect (NULL);
         if (!display)
-                return FALSE;
+                return GUINT_TO_POINTER(FALSE);
         wl_display_disconnect (display);
-        return TRUE;
+        return GUINT_TO_POINTER(TRUE);
 #else
-        return FALSE;
+        return GUINT_TO_POINTER(FALSE);
 #endif
 }
 
 gboolean
 gnome_settings_is_wayland (void)
 {
-        static gboolean checked = FALSE;
-        static gboolean wayland = FALSE;
+        static GOnce wayland_once = G_ONCE_INIT;
 
-        if (!checked) {
-                wayland = is_wayland_session ();
-                checked = TRUE;
-        }
-        return wayland;
+        g_once (&wayland_once, is_wayland_session, NULL);
+
+        return GPOINTER_TO_UINT(wayland_once.retval);
 }


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