Skip to content

Commit

Permalink
Support drawing the desktop on wayland using gtk-layer-shell.
Browse files Browse the repository at this point in the history
  • Loading branch information
lcolitti committed Jan 18, 2024
1 parent b51ed7b commit caacd15
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 1 deletion.
2 changes: 2 additions & 0 deletions config.h.meson.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#mesondefine HAVE_SELINUX
// Define to enable pango-1.44 fixes
#mesondefine HAVE_PANGO_144
// Define to use gtk-layer-shell
#mesondefine HAVE_GTK_LAYER_SHELL



Expand Down
6 changes: 6 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ if libselinux_enabled
endif
conf.set('HAVE_SELINUX', libselinux_enabled)

gtk_layer_shell_enabled = get_option('gtk_layer_shell')
if gtk_layer_shell_enabled
gtk_layer_shell = dependency('gtk-layer-shell-0', version: '>=0.8')
endif
conf.set('HAVE_GTK_LAYER_SHELL', gtk_layer_shell_enabled)

# make sure pango development files are installed
pango = dependency('pango', version: '>=1.40.0')
# check for newer pango for necessary workarounds
Expand Down
2 changes: 2 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ option('empty_view', type : 'boolean', value : false,
description: 'Enable empty view')
option('tracker',type : 'combo', choices : ['true', 'false', 'auto'], value : 'false',
description: 'Tracker support')
option('gtk_layer_shell', type : 'boolean', value : false,
description: 'Use gtk-layer-shell to draw desktop on wayland')
4 changes: 4 additions & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ if libexif_enabled
nemo_deps += libexif
endif

if gtk_layer_shell_enabled
nemo_deps += gtk_layer_shell
endif

nemo = executable('nemo',
nemoCommon_sources + nemoWindow_sources,
include_directories: [ rootInclude ],
Expand Down
8 changes: 7 additions & 1 deletion src/nemo-desktop-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,13 @@ main (int argc, char *argv[])

g_set_prgname ("nemo-desktop");

gdk_set_allowed_backends ("x11");
#ifdef HAVE_GTK_LAYER_SHELL
if (gtk_layer_is_supported())
gdk_set_allowed_backends ("wayland");
else
#else
gdk_set_allowed_backends ("x11");
#endif

#ifdef HAVE_EXEMPI
xmp_init();
Expand Down
16 changes: 16 additions & 0 deletions src/nemo-window.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@
#include <math.h>
#include <sys/time.h>

#ifdef HAVE_GTK_LAYER_SHELL
#include <gtk-layer-shell/gtk-layer-shell.h>
#endif

#define MAX_TITLE_LENGTH 180

/* Forward and back buttons on the mouse */
Expand Down Expand Up @@ -619,6 +623,18 @@ nemo_window_constructed (GObject *self)
window = NEMO_WINDOW (self);
application = nemo_application_get_singleton ();

#ifdef HAVE_GTK_LAYER_SHELL
if (gtk_layer_is_supported() && window->details->disable_chrome) {
gtk_layer_init_for_window(GTK_WINDOW(window));
gtk_layer_set_namespace(GTK_WINDOW(window), _("Nemo"));
gtk_layer_set_layer(GTK_WINDOW(window), GTK_LAYER_SHELL_LAYER_BOTTOM);
gtk_layer_set_margin(GTK_WINDOW(window), GTK_LAYER_SHELL_EDGE_TOP, 0);
for (int anchor = 0; anchor < 4; anchor++) {
gtk_layer_set_anchor(GTK_WINDOW(window), anchor, 1);
}
}
#endif

G_OBJECT_CLASS (nemo_window_parent_class)->constructed (self);
gtk_window_set_application (GTK_WINDOW (window), GTK_APPLICATION (application));

Expand Down

0 comments on commit caacd15

Please sign in to comment.