diff options
author | Rui Matos <tiagomatos@gmail.com> | 2014-10-06 15:31:42 +0200 |
---|---|---|
committer | Rui Matos <tiagomatos@gmail.com> | 2014-10-10 18:25:24 +0200 |
commit | 6c2bbfced34eed8048374411cfaa2589e7c2914b (patch) | |
tree | d9e57034ad3c52a74bd347341bfb0206d95cdf02 /gnome-settings-daemon | |
parent | e6e81aea689c03206ec0c6125adc1461c7eba133 (diff) | |
download | gnome-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')
-rw-r--r-- | gnome-settings-daemon/Makefile.am | 2 | ||||
-rw-r--r-- | gnome-settings-daemon/gnome-settings-bus.c | 33 | ||||
-rw-r--r-- | gnome-settings-daemon/gnome-settings-bus.h | 1 |
3 files changed, 36 insertions, 0 deletions
diff --git a/gnome-settings-daemon/Makefile.am b/gnome-settings-daemon/Makefile.am index e5f12183..dd901c7d 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 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; +} diff --git a/gnome-settings-daemon/gnome-settings-bus.h b/gnome-settings-daemon/gnome-settings-bus.h index 22711b63..845a3694 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 |