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
This commit is contained in:
fwsmit 2020-12-22 16:47:37 +01:00
parent 5a20d463b5
commit bb12727bc0
8 changed files with 60 additions and 6 deletions

View File

@ -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

View File

@ -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=<PATH>`: Set the destination directory of the installation. (Default: `/`)
- `PREFIX=<PATH>`: Set the prefix of the installation. (Default: `/usr/local`)
- `BINDIR=<PATH>`: Set the `dunst` executable's path (Default: `${PREFIX}/bin`)
- `DATADIR=<PATH>`: Set the path for shared files. (Default: `${PREFIX}/share`)
- `MANDIR=<PATH>`: 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=<PATH>`: The path to put the systemd user service file. Unused, if `SYSTEMD=0`. (Default: detected via `pkg-config`)
- `SERVICEDIR_DBUS=<PATH>`: The path to put the dbus service file. (Default: detected via `pkg-config`)

View File

@ -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

View File

@ -9,7 +9,6 @@
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <wayland-client.h>
#include "dbus.h"
#include "draw.h"

View File

@ -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: */

View File

@ -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: */

View File

@ -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 */

View File

@ -4,7 +4,9 @@
#include <stdbool.h>
#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;