From bb12727bc063ce9b5ef4a9eb0df78a506b67b2a0 Mon Sep 17 00:00:00 2001 From: fwsmit Date: Tue, 22 Dec 2020 16:47:37 +0100 Subject: [PATCH] Make compiling for wayland optional This can be changed in config.mk or by using the command make WAYLAND=0 Also removed using_xwayland function definition as it isn't defined anymore --- Makefile | 13 ++++++++++++- README.md | 4 ++++ config.mk | 16 ++++++++++++++-- src/dunst.c | 1 - src/output.c | 9 +++++++++ src/output.h | 2 -- src/settings.c | 9 +++++++++ src/settings.h | 12 ++++++++++++ 8 files changed, 60 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 41e10be..f170efc 100644 --- a/Makefile +++ b/Makefile @@ -33,9 +33,11 @@ $(error "Failed to query $(PKG_CONFIG) for package 'systemd'!") endif endif +ifneq (0,${WAYLAND}) DATA_DIR_WAYLAND_PROTOCOLS ?= $(shell $(PKG_CONFIG) wayland-protocols --variable=pkgdatadir) ifeq (,${DATA_DIR_WAYLAND_PROTOCOLS}) - $(error "Failed to query $(PKG_CONFIG) for package 'wayland-protocols'!") + $(warning "Failed to query $(PKG_CONFIG) for package 'wayland-protocols'!") +endif endif LIBS := $(shell $(PKG_CONFIG) --libs ${pkg_config_packs}) @@ -50,7 +52,14 @@ endif CFLAGS := ${DEFAULT_CPPFLAGS} ${CPPFLAGS} ${DEFAULT_CFLAGS} ${CFLAGS} ${INCS} -MMD -MP LDFLAGS := ${DEFAULT_LDFLAGS} ${LDFLAGS} ${LIBS} + +ifeq (0,${WAYLAND}) +# without wayland support +SRC := $(sort $(shell ${FIND} src/ -not \( -path src/wayland -prune \) -name '*.c')) +else +# with Wayland support SRC := $(sort $(shell ${FIND} src/ -name '*.c')) +endif OBJ := ${SRC:.c=.o} TEST_SRC := $(sort $(shell ${FIND} test/ -name '*.c')) TEST_OBJ := $(TEST_SRC:.c=.o) @@ -133,6 +142,7 @@ service-systemd: @${SED} "s|##PREFIX##|$(PREFIX)|" dunst.systemd.service.in > dunst.systemd.service endif +ifneq (0,${WAYLAND}) wayland-protocols: src/wayland/protocols/wlr-layer-shell-unstable-v1.xml mkdir -p src/wayland/protocols wayland-scanner private-code ${DATA_DIR_WAYLAND_PROTOCOLS}/stable/xdg-shell/xdg-shell.xml src/wayland/protocols/xdg-shell.h @@ -143,6 +153,7 @@ wayland-protocols: src/wayland/protocols/wlr-layer-shell-unstable-v1.xml wayland-scanner private-code src/wayland/protocols/wlr-layer-shell-unstable-v1.xml src/wayland/protocols/wlr-layer-shell-unstable-v1.h wayland-scanner client-header src/wayland/protocols/idle.xml src/wayland/protocols/idle-client-header.h wayland-scanner private-code src/wayland/protocols/idle.xml src/wayland/protocols/idle.h +endif .PHONY: clean clean-dunst clean-dunstify clean-doc clean-tests clean-coverage clean-coverage-run clean-wayland-protocols clean: clean-dunst clean-dunstify clean-doc clean-tests clean-coverage clean-coverage-run diff --git a/README.md b/README.md index 785ab9b..c5bd791 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,8 @@ Dunst has a number of build dependencies that must be present before attempting - pango/cairo - libgtk-3-dev - libnotify (for dunstify only) +- wayland-client (can build without, see [make parameters](#make-parameters)) +- wayland-protocols (optional, for recompiling protocols) ### Building @@ -38,11 +40,13 @@ sudo make install ### Make parameters +- `DESTDIR=`: Set the destination directory of the installation. (Default: `/`) - `PREFIX=`: Set the prefix of the installation. (Default: `/usr/local`) - `BINDIR=`: Set the `dunst` executable's path (Default: `${PREFIX}/bin`) - `DATADIR=`: Set the path for shared files. (Default: `${PREFIX}/share`) - `MANDIR=`: Set the prefix of the manpage. (Default: `${DATADIR}/man`) - `SYSTEMD=(0|1)`: Enable/Disable the systemd unit. (Default: detected via `pkg-config`) +- `WAYLAND=(0|1)`: Enable/Disable wayland support. (Default: 1) - `SERVICEDIR_SYSTEMD=`: The path to put the systemd user service file. Unused, if `SYSTEMD=0`. (Default: detected via `pkg-config`) - `SERVICEDIR_DBUS=`: The path to put the dbus service file. (Default: detected via `pkg-config`) diff --git a/config.mk b/config.mk index 4d1f659..f71d49f 100644 --- a/config.mk +++ b/config.mk @@ -20,13 +20,22 @@ VALGRIND ?= valgrind # if you don't want to use systemd albeit installed #SYSTEMD ?= 0 +# Disable dependency on wayland. This will force dunst to use +# xwayland on wayland compositors +# You can also use "make WAYLAND=0" to build without wayland +# WAYLAND ?= 0 + +ifneq (0, ${WAYLAND}) +ENABLE_WAYLAND= -DENABLE_WAYLAND +endif + # uncomment to disable parsing of dunstrc # or use "CFLAGS=-DSTATIC_CONFIG make" to build #STATIC= -DSTATIC_CONFIG # Warning: This is deprecated behavior # flags DEFAULT_CPPFLAGS = -D_DEFAULT_SOURCE -DVERSION=\"${VERSION}\" -DEFAULT_CFLAGS = -g --std=gnu99 -pedantic -Wall -Wno-overlength-strings -Os ${STATIC} +DEFAULT_CFLAGS = -g --std=gnu99 -pedantic -Wall -Wno-overlength-strings -Os ${STATIC} ${ENABLE_WAYLAND} DEFAULT_LDFLAGS = -lm -lrt CPPFLAGS_DEBUG := -DDEBUG_BUILD @@ -42,12 +51,15 @@ pkg_config_packs := gio-2.0 \ xext \ "xrandr >= 1.5" \ xscrnsaver \ - wayland-client \ # dunstify also needs libnotify pkg_config_packs += libnotify +ifneq (0,${WAYLAND}) +pkg_config_packs += wayland-client +endif + ifneq (,$(findstring STATIC_CONFIG,$(CFLAGS))) $(warning STATIC_CONFIG is deprecated behavior. It will get removed in future releases) endif diff --git a/src/dunst.c b/src/dunst.c index 0d68a84..7fffa21 100644 --- a/src/dunst.c +++ b/src/dunst.c @@ -9,7 +9,6 @@ #include #include #include -#include #include "dbus.h" #include "draw.h" diff --git a/src/output.c b/src/output.c index 6f6f6e6..238e32d 100644 --- a/src/output.c +++ b/src/output.c @@ -3,7 +3,10 @@ #include "log.h" #include "x11/x.h" #include "x11/screen.h" + +#ifdef ENABLE_WAYLAND #include "wayland/wl.h" +#endif const bool is_running_wayland(void) { char* wayland_display = getenv("WAYLAND_DISPLAY"); @@ -30,6 +33,7 @@ const struct output output_x11 = { have_fullscreen_window }; +#ifdef ENABLE_WAYLAND const struct output output_wl = { wl_init, wl_deinit, @@ -49,9 +53,11 @@ const struct output output_wl = { wl_is_idle, wl_have_fullscreen_window }; +#endif const struct output* output_create(bool force_xwayland) { +#ifdef ENABLE_WAYLAND if (!force_xwayland && is_running_wayland()) { LOG_I("Using Wayland output"); return &output_wl; @@ -59,5 +65,8 @@ const struct output* output_create(bool force_xwayland) LOG_I("Using X11 output"); return &output_x11; } +#else + return &output_x11; +#endif } /* vim: set ft=c tabstop=8 shiftwidth=8 expandtab textwidth=0: */ diff --git a/src/output.h b/src/output.h index 5cd7d50..6ebb436 100644 --- a/src/output.h +++ b/src/output.h @@ -51,7 +51,5 @@ const struct output* output_create(bool force_xwayland); const bool is_running_wayland(void); -const bool is_running_xwayland(void); - #endif /* vim: set ft=c tabstop=8 shiftwidth=8 expandtab textwidth=0: */ diff --git a/src/settings.c b/src/settings.c index 2d25916..9fdb6f7 100644 --- a/src/settings.c +++ b/src/settings.c @@ -13,6 +13,7 @@ #include "rules.h" #include "utils.h" #include "x11/x.h" +#include "output.h" #include "../config.h" @@ -215,6 +216,14 @@ void load_settings(char *cmdline_config_path) "Don't timeout notifications if user is longer idle than threshold" ); +#ifndef ENABLE_WAYLAND + if (is_running_wayland()){ + /* We are using xwayland now. Setting force_xwayland to make sure + * the idle workaround below is activated */ + settings.force_xwayland = true; + } +#endif + if (settings.force_xwayland) { /* There is no way to detect if the user is idle * on xwayland, so turn this feature off */ diff --git a/src/settings.h b/src/settings.h index 3aab1ac..61f6178 100644 --- a/src/settings.h +++ b/src/settings.h @@ -4,7 +4,9 @@ #include +#ifdef ENABLE_WAYLAND #include "wayland/protocols/wlr-layer-shell-unstable-v1-client-header.h" +#endif #include "markup.h" #include "notification.h" @@ -17,6 +19,16 @@ enum vertical_alignment { VERTICAL_TOP, VERTICAL_CENTER, VERTICAL_BOTTOM }; enum separator_color { SEP_FOREGROUND, SEP_AUTO, SEP_FRAME, SEP_CUSTOM }; enum follow_mode { FOLLOW_NONE, FOLLOW_MOUSE, FOLLOW_KEYBOARD }; enum mouse_action { MOUSE_NONE, MOUSE_DO_ACTION, MOUSE_CLOSE_CURRENT, MOUSE_CLOSE_ALL }; +#ifndef ZWLR_LAYER_SHELL_V1_LAYER_ENUM +#define ZWLR_LAYER_SHELL_V1_LAYER_ENUM +// Needed for compiling without wayland dependency +enum zwlr_layer_shell_v1_layer { + ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND = 0, + ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM = 1, + ZWLR_LAYER_SHELL_V1_LAYER_TOP = 2, + ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY = 3, +}; +#endif /* ZWLR_LAYER_SHELL_V1_LAYER_ENUM */ struct separator_color_data { enum separator_color type;