[gnome-settings-daemon] daemon: Add a check for wayland sessions



commit 6c2bbfced34eed8048374411cfaa2589e7c2914b
Author: Rui Matos <tiagomatos gmail com>
Date:   Mon Oct 6 15:31:42 2014 +0200

    daemon: Add a check for wayland sessions
    
    We want to do some things differently, or disable some features
    entirely, when running under a wayland session.
    
    Adding a global function which tries to connect to a wayland
    compositor using the same method as a regular wayland client allows us
    to achieve that.
    
    For now, since we don't need to do anything else with the wayland
    connection we tear it down immediately after checking. Note that g-s-d
    uses the X11 GDK backend exclusively so there's no danger of this
    being a duplicated wayland connection.
    
    This commit introduces an optional build time dependency on
    libwayland-client which is, by default, enabled or disabled
    automatically depending on the pc file existence.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=738009

 configure.ac                               |   17 ++++++++++++++
 gnome-settings-daemon/Makefile.am          |    2 +
 gnome-settings-daemon/gnome-settings-bus.c |   33 ++++++++++++++++++++++++++++
 gnome-settings-daemon/gnome-settings-bus.h |    1 +
 4 files changed, 53 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index c42ea8b..dfcfc2d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -144,6 +144,23 @@ fi
 AM_CONDITIONAL(HAVE_GUDEV, test x$have_gudev = xyes)
 
 dnl ---------------------------------------------------------------------------
+dnl - Check for libwayland-client
+dnl ---------------------------------------------------------------------------
+AC_ARG_ENABLE(wayland,
+        AC_HELP_STRING([--disable-wayland], [Disable wayland support (default: auto)]),
+        enable_wayland=$enableval, enable_wayland=auto)
+if test x$enable_wayland != xno; then
+        PKG_CHECK_MODULES(WAYLAND, wayland-client, have_wayland=yes, have_wayland=no)
+        if test x$have_wayland = xyes; then
+                AC_DEFINE(HAVE_WAYLAND, 1, [Define if libwayland-client is available])
+        else
+                if test x$enable_wayland = xyes; then
+                        AC_MSG_ERROR([Wayland enabled but not found])
+                fi
+        fi
+fi
+
+dnl ---------------------------------------------------------------------------
 dnl - common
 dnl ---------------------------------------------------------------------------
 
diff --git a/gnome-settings-daemon/Makefile.am b/gnome-settings-daemon/Makefile.am
index e5f1218..dd901c7 100644
--- a/gnome-settings-daemon/Makefile.am
+++ b/gnome-settings-daemon/Makefile.am
@@ -11,6 +11,7 @@ AM_CPPFLAGS = \
        $(SETTINGS_DAEMON_CFLAGS)                               \
        $(LIBNOTIFY_CFLAGS)                                     \
        $(GNOME_DESKTOP_CFLAGS)                                 \
+       $(WAYLAND_CFLAGS)                                       \
        $(NULL)
 
 privlibdir = $(pkglibdir)-$(GSD_API_VERSION)
@@ -78,6 +79,7 @@ libgsd_la_CFLAGS =            \
 libgsd_la_LIBADD =             \
        $(SETTINGS_DAEMON_LIBS)         \
        $(GIOUNIX_LIBS)         \
+       $(WAYLAND_LIBS)         \
        $(NULL)
 
 libgsd_la_LDFLAGS =            \
diff --git a/gnome-settings-daemon/gnome-settings-bus.c b/gnome-settings-daemon/gnome-settings-bus.c
index 1eb5dfc..c4d14f8 100644
--- a/gnome-settings-daemon/gnome-settings-bus.c
+++ b/gnome-settings-daemon/gnome-settings-bus.c
@@ -27,6 +27,10 @@
 #include <glib.h>
 #include <gio/gio.h>
 
+#if HAVE_WAYLAND
+#include <wayland-client.h>
+#endif
+
 #include "gnome-settings-bus.h"
 
 #define GNOME_SESSION_DBUS_NAME      "org.gnome.SessionManager"
@@ -117,3 +121,32 @@ gnome_settings_bus_get_shell_proxy (void)
 
         return shell_proxy;
 }
+
+static gboolean
+is_wayland_session (void)
+{
+#if HAVE_WAYLAND
+        struct wl_display *display;
+
+        display = wl_display_connect (NULL);
+        if (!display)
+                return FALSE;
+        wl_display_disconnect (display);
+        return TRUE;
+#else
+        return FALSE;
+#endif
+}
+
+gboolean
+gnome_settings_is_wayland (void)
+{
+        static gboolean checked = FALSE;
+        static gboolean wayland = FALSE;
+
+        if (!checked) {
+                wayland = is_wayland_session ();
+                checked = TRUE;
+        }
+        return wayland;
+}
diff --git a/gnome-settings-daemon/gnome-settings-bus.h b/gnome-settings-daemon/gnome-settings-bus.h
index 22711b6..845a369 100644
--- a/gnome-settings-daemon/gnome-settings-bus.h
+++ b/gnome-settings-daemon/gnome-settings-bus.h
@@ -32,6 +32,7 @@ G_BEGIN_DECLS
 GsdSessionManager        *gnome_settings_bus_get_session_proxy       (void);
 GsdScreenSaver           *gnome_settings_bus_get_screen_saver_proxy  (void);
 GsdShell                 *gnome_settings_bus_get_shell_proxy         (void);
+gboolean                  gnome_settings_is_wayland                  (void);
 
 G_END_DECLS
 


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