Skip to content

Commit 8dc27b3

Browse files
committed
nemo-desktop: Force the x11 backend if gtk-layer-shell isn't
supported. If nemo-desktop is run as a Wayland client without layer-shell support, the desktop window will be treated a normal window, above other windows, and with a window-list/taskbar entry. We can't call gtk_layer_is_supported before gtk_main(), so we need to manually connect to the wayland display and check ourselves.
1 parent 24bff62 commit 8dc27b3

4 files changed

Lines changed: 56 additions & 2 deletions

File tree

debian/control

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Build-Depends:
2828
libxapp-dev (>= 2.0.0),
2929
libxext-dev,
3030
libxrender-dev,
31+
libwayland-dev,
3132
meson,
3233
python3,
3334
python3-gi,

meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ endif
134134
conf.set('HAVE_SELINUX', libselinux_enabled)
135135

136136
gtk_layer_shell_enabled = get_option('gtk_layer_shell')
137-
gtk_layer_shell = dependency('', required: false)
138137
if gtk_layer_shell_enabled
139138
gtk_layer_shell = dependency('gtk-layer-shell-0', version: '>=0.8', required: true)
139+
wayland_client = dependency('wayland-client', required: true)
140140
conf.set('HAVE_GTK_LAYER_SHELL', gtk_layer_shell.found())
141141
endif
142142

src/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ endif
115115

116116
if gtk_layer_shell_enabled
117117
nemo_deps += gtk_layer_shell
118+
nemo_deps += wayland_client
118119
endif
119120

120121
nemo = executable('nemo',

src/nemo-desktop-main.c

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,47 @@
5555

5656
#ifdef HAVE_GTK_LAYER_SHELL
5757
#include <gtk-layer-shell/gtk-layer-shell.h>
58+
#include <wayland-client.h>
59+
60+
static gboolean layer_shell_available = FALSE;
61+
62+
static void
63+
registry_handle_global (void *data, struct wl_registry *registry,
64+
uint32_t name, const char *interface, uint32_t version)
65+
{
66+
if (g_strcmp0 (interface, "zwlr_layer_shell_v1") == 0)
67+
layer_shell_available = TRUE;
68+
}
69+
70+
static void
71+
registry_handle_global_remove (void *data, struct wl_registry *registry, uint32_t name)
72+
{
73+
}
74+
75+
static const struct wl_registry_listener registry_listener = {
76+
registry_handle_global,
77+
registry_handle_global_remove,
78+
};
79+
80+
static gboolean
81+
check_layer_shell_support (void)
82+
{
83+
struct wl_display *display;
84+
struct wl_registry *registry;
85+
86+
display = wl_display_connect (NULL);
87+
if (!display)
88+
return FALSE;
89+
90+
registry = wl_display_get_registry (display);
91+
wl_registry_add_listener (registry, &registry_listener, NULL);
92+
wl_display_roundtrip (display);
93+
94+
wl_registry_destroy (registry);
95+
wl_display_disconnect (display);
96+
97+
return layer_shell_available;
98+
}
5899
#endif
59100

60101
int
@@ -91,7 +132,18 @@ main (int argc, char *argv[])
91132

92133
g_set_prgname ("nemo-desktop");
93134

94-
#ifndef HAVE_GTK_LAYER_SHELL
135+
#ifdef HAVE_GTK_LAYER_SHELL
136+
if (check_layer_shell_support ())
137+
{
138+
g_message ("nemo-desktop: using Wayland backend, gtk-layer-shell supported");
139+
}
140+
else
141+
{
142+
g_message ("nemo-desktop: Not a Wayland session, or wlr-layer-shell protocol not supported, using X11 backend");
143+
gdk_set_allowed_backends ("x11");
144+
}
145+
#else
146+
g_message ("nemo-desktop: using X11");
95147
gdk_set_allowed_backends ("x11");
96148
#endif
97149

0 commit comments

Comments
 (0)