From 6b049debf0134bfbdab849976db82a9a48127482 Mon Sep 17 00:00:00 2001 From: Andrew Hamilton Date: Sun, 9 Aug 2026 12:46:14 +1000 Subject: [PATCH] Build with meson; portable wlroots fallback (pinned wrap) + README --- .gitignore | 5 ++++ Makefile | 24 --------------- README.md | 65 ++++++++++++++++++++++++++++++++++++++++ meson.build | 43 ++++++++++++++++++++++++++ subprojects/wlroots.wrap | 5 ++++ 5 files changed, 118 insertions(+), 24 deletions(-) delete mode 100644 Makefile create mode 100644 README.md create mode 100644 meson.build create mode 100644 subprojects/wlroots.wrap diff --git a/.gitignore b/.gitignore index 4e23c1f..68737eb 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,8 @@ tabbed-wayland tabbed-windows tabbed-wlroots core.* + +/build/ +/build-*/ +/subprojects/packagecache/ +/subprojects/wlroots-0.19.1/ diff --git a/Makefile b/Makefile deleted file mode 100644 index b7c9a4e..0000000 --- a/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -SAN ?= -CFLAGS = -Wall -Wextra -std=c11 -g $(SAN) - -.PHONY: all clean - -all: tabbed-wlroots - -xdg-shell-protocol.o: xdg-shell-protocol.c xdg-shell-server.h - $(CC) $(CFLAGS) -c -o $@ $< - -xdg-decoration-protocol.o: xdg-decoration-protocol.c xdg-decoration-client.h - $(CC) $(CFLAGS) -c -o $@ $< - -WLR_CFLAGS = $(CFLAGS) -Iwlr-protocols $(shell pkg-config --cflags wlroots-0.19 wayland-server wayland-client wayland-egl xkbcommon egl) -DWLR_USE_UNSTABLE -WLR_LIBS = $(shell pkg-config --libs wlroots-0.19 wayland-server wayland-client wayland-egl xkbcommon) -lEGL -lGLESv2 $(SAN) - -tabbed-wlroots.o: tabbed-wlroots.c - $(CC) $(WLR_CFLAGS) -c -o $@ $< - -tabbed-wlroots: tabbed-wlroots.o xdg-shell-protocol.o xdg-decoration-protocol.o - $(CC) -o $@ $^ $(WLR_LIBS) - -clean: - rm -f *.o tabbed-wlroots diff --git a/README.md b/README.md new file mode 100644 index 0000000..d66a222 --- /dev/null +++ b/README.md @@ -0,0 +1,65 @@ +# tabbed-wlroots + +A nested Wayland compositor (built on wlroots) that presents several +client apps as tabs in a single window on the host Wayland compositor. +Each command-line argument launches one tab. + +## Building + +The project builds with [Meson](https://mesonbuild.com/) + Ninja. On most +distributions the non-wlroots dependencies are available in the standard +repositories; `wlroots` is used from the system where one is installed, and +otherwise is fetched and built automatically from a pinned source tarball +(`subprojects/wlroots.wrap`). + +```sh +meson setup build +meson compile -C build +``` + +The resulting binary is `build/tabbed-wlroots`. + +### Debian / Ubuntu + +```sh +sudo apt install build-essential meson ninja-build pkg-config \ + libwayland-dev libwayland-bin wayland-protocols \ + libwlroots-dev libxkbcommon-dev \ + libegl1-mesa-dev libgles2-mesa-dev \ + libpixman-1-dev libdisplay-info-dev libliftoff-dev libseat-dev +``` + +`libwlroots-dev` already satisfies the wlroots dependency on this platform. + +### Arch + +```sh +sudo pacman -S base-devel meson ninja pkgconf wayland wayland-protocols \ + wlroots xkbcommon mesa pixman +``` + +### Fedora + +```sh +sudo dnf install gcc meson ninja-build pkgconf-pkg-config \ + wayland-devel wayland-protocols-devel wlroots-devel \ + libxkbcommon-devel mesa-libEGL-devel mesa-libGLES-devel pixman-devel +``` + +### When the system wlroots dep is missing / the fallback can't find one + +The Meson setup searches for `wlroots-0.19` then `wlroots`; if neither is +installed it builds the pinned 0.19.1 from `subprojects/wlroots.wrap`, which +only needs the wayland, wayland-protocols, xkbcommon and EGL/GLES2 dev +packages listed above. Optional wlroots features (Vulkan, X11, libinput, +etc.) are auto-detected and skipped when their build deps aren't present, so +a minimal install works too. + +## Usage + +``` +tabbed-wlroots [prog...] +``` + +Each `` is one shell command; quote it when it takes arguments, e.g. +`tabbed-wlroots "foot -e htop" "firefox -no-remote"`. \ No newline at end of file diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..610fea2 --- /dev/null +++ b/meson.build @@ -0,0 +1,43 @@ +project('tabbed-wlroots', 'c', + version: '0.1.0', + meson_version: '>=1.0', + default_options: ['c_std=c11', 'warning_level=2']) + +wlroots_ver = '>=0.19,<0.20' + +# wlroots' pkg-config name varies between distributions (wlroots-0.19 on +# Debian/Ubuntu, plain wlroots on Arch/Fedora). Prefer the system copy, and +# fall back to a pinned source build from subprojects/wlroots.wrap when no +# matching system library is found. +wlroots = dependency('wlroots-0.19', version: wlroots_ver, required: false) +if not wlroots.found() + wlroots = dependency('wlroots', version: wlroots_ver, required: false) +endif +if not wlroots.found() + wlroots_subproj = subproject('wlroots', default_options: ['examples=false']) + wlroots = wlroots_subproj.get_variable('wlroots') +endif + +deps = [ + wlroots, + dependency('wayland-server'), + dependency('wayland-client'), + dependency('wayland-egl'), + dependency('xkbcommon'), + dependency('egl'), + dependency('glesv2'), +] + +cc = meson.get_compiler('c') +libm = cc.find_library('m', required: false) +if libm.found() + deps += libm +endif + +executable('tabbed-wlroots', + 'tabbed-wlroots.c', + 'xdg-shell-protocol.c', + 'xdg-decoration-protocol.c', + dependencies: deps, + include_directories: include_directories('wlr-protocols'), + c_args: ['-DWLR_USE_UNSTABLE']) diff --git a/subprojects/wlroots.wrap b/subprojects/wlroots.wrap new file mode 100644 index 0000000..9052c67 --- /dev/null +++ b/subprojects/wlroots.wrap @@ -0,0 +1,5 @@ +[wrap-file] +directory = wlroots-0.19.1 +source_url = https://gitlab.freedesktop.org/wlroots/wlroots/-/archive/0.19.1/wlroots-0.19.1.tar.bz2 +source_filename = wlroots-0.19.1.tar.bz2 +source_hash = 73e150569c42bdfe36dcb5751e7ec96e9bbd72f8bc6fcbfdd45c4d3cd98ce093 \ No newline at end of file