A library for using the Layer Shell Wayland protocol with GTK4. With this library you can build desktop shell components such as panels, notifications and wallpapers. You can use it to anchor your windows to a corner or edge of the output, or stretch them across the entire output. This Library is compatible with C, C++ and any language that supports GObject introspection files (Python, Vala, etc).
To report a crash or other problem using this library open a new issue on Github. Try to include a minimum reproducer if possible (ideally in C). DO NOT REPORT GTK4 LAYER SHELL BUGS TO UPSTREAM GTK. If you can reproduce the problem without including or linking to the gtk4-layer-shell library at all then and only then report it to GTK instead of here.
This library only works on Wayland, and only on Wayland compositors that support the Layer Shell protocol. Layer shell is supported on:
- wlroots based compositors (such as Sway)
- Smithay based compositors (such as COSMIC)
- Mir based compositors (some may not enable the protocol by default. It can be enabled with
--add-wayland-extension zwlr_layer_shell_v1
) - KDE Plasma on wayland
Layer shell is not supported on:
- Gnome-on-Wayland
- Any X11 desktop
gtk4-layer-demo
is built if examples are enabled. It's useful for testing layer shell support in compositors. Its code can be found in examples/demo/.
The easiest way to build against GTK Layer Shell is to use the gtk-layer-shell-0
pkg-config package. Refer to your build system or the pkg-config docs for further instructions. examples/simple-example.c is a minimal complete app written in C. If you link against libwayland, you must link libwayland after gtk4-layer-shell. See linking.md for details.
examples/simple-example.py contains sample Python code.
examples/simple-example.vala contains a minimal working Vala app.
@pentamassiv maintains safe Rust bindings and the crates.io crate. Rust examples can be found here.
mswiger maintains Ruby bindings which are published to RubyGems.
- Clone this repo
- Install build dependencies (see below)
$ meson setup -Dexamples=true -Ddocs=true -Dtests=true build
(NOTE:--prefix=/usr
may be needed on Arch Linux)$ ninja -C build
$ sudo ninja -C build install
$ sudo ldconfig
- Meson (>=0.45.1)
- Ninja (>=1.8.2)
- libwayland (>=1.10.0)
- wayland-protocols (>=1.16.0)
- GTK4
- If
introspection
enabled: GObject introspection - If
docs
enabled: GTK Doc - If
tests
enabled: Python3 - If
vapi
enabled: Vala
To install these dependencies on Ubuntu 18.04 and later:
sudo apt install meson ninja-build libwayland-dev libgtk-4-dev gobject-introspection libgirepository1.0-dev gtk-doc-tools python3 valac
To install on Arch Linux:
pacman -S --needed meson ninja gtk4 wayland gobject-introspection libgirepository gtk-doc python vala
-Dexamples
(defaultfalse
): If to build the example C apps; gtk4-layer-demo is installed if examples are built; The Vala example is never built with the rest of the project-Ddocs
(defaultfalse
): If to generate the docs-Dtests
(defaultfalse
): If to build the tests-Dsmoke-tests
(default:true
): If to test that all examples can run (disable if you don't want to install the various languages and dependencies required)-Dintrospection
(default:true
): If to build GObject Introspection data (used for bindings to languages other than C/C++)-Dvapi
(default:true
): If to build VAPI data and Vala example. The VAPI file allows this library to be used in Vala. Requires-Dintrospection=true
ninja -C build test
- Or, to run a specific test and print the complete output
meson test <testname> --verbose -C build
100% MIT (unlike the GTK3 version of this library which contained GPL code copied from GTK)