summaryrefslogtreecommitdiff
path: root/gnome-settings-daemon/gnome-settings-bus.c
diff options
context:
space:
mode:
authorRui Matos <tiagomatos@gmail.com>2014-10-06 15:31:42 +0200
committerRui Matos <tiagomatos@gmail.com>2014-10-10 18:25:24 +0200
commit6c2bbfced34eed8048374411cfaa2589e7c2914b (patch)
treed9e57034ad3c52a74bd347341bfb0206d95cdf02 /gnome-settings-daemon/gnome-settings-bus.c
parente6e81aea689c03206ec0c6125adc1461c7eba133 (diff)
downloadgnome-settings-daemon-6c2bbfced34eed8048374411cfaa2589e7c2914b.tar.gz
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
Diffstat (limited to 'gnome-settings-daemon/gnome-settings-bus.c')
-rw-r--r--gnome-settings-daemon/gnome-settings-bus.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/gnome-settings-daemon/gnome-settings-bus.c b/gnome-settings-daemon/gnome-settings-bus.c
index 1eb5dfc5..c4d14f81 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;
+}