summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile96
-rw-r--r--client.h18
-rw-r--r--config.def.h9
-rw-r--r--config.mk11
-rw-r--r--dwl.c29
5 files changed, 93 insertions, 70 deletions
diff --git a/Makefile b/Makefile
index 0c2b78d..ac24ae7 100644
--- a/Makefile
+++ b/Makefile
@@ -1,73 +1,69 @@
-include config.mk
-
-CFLAGS += -I. -DWLR_USE_UNSTABLE -std=c99 -pedantic -DVERSION=\"$(VERSION)\"
-
-WAYLAND_PROTOCOLS=$(shell pkg-config --variable=pkgdatadir wayland-protocols)
-WAYLAND_SCANNER=$(shell pkg-config --variable=wayland_scanner wayland-scanner)
-
-PKGS = wlroots wayland-server xcb xkbcommon libinput
-CFLAGS += $(foreach p,$(PKGS),$(shell pkg-config --cflags $(p)))
-LDLIBS += $(foreach p,$(PKGS),$(shell pkg-config --libs $(p)))
-
-all: dwl
+.POSIX:
+.SUFFIXES:
-clean:
- rm -f dwl *.o *-protocol.h *-protocol.c
+include config.mk
-dist: clean
- mkdir -p dwl-$(VERSION)
- cp -R LICENSE* Makefile README.md generate-version.sh client.h\
- config.def.h config.mk protocols dwl.1 dwl.c util.c util.h\
- dwl-$(VERSION)
- echo "echo $(VERSION)" > dwl-$(VERSION)/generate-version.sh
- tar -caf dwl-$(VERSION).tar.gz dwl-$(VERSION)
- rm -rf dwl-$(VERSION)
+# flags for compiling
+DWLCPPFLAGS = -I. -DWLR_USE_UNSTABLE -DVERSION=\"$(VERSION)\"
-install: dwl
- install -Dm755 dwl $(DESTDIR)$(PREFIX)/bin/dwl
- install -Dm644 dwl.1 $(DESTDIR)$(MANDIR)/man1/dwl.1
+# Wayland utils
+WAYLAND_PROTOCOLS = `pkg-config --variable=pkgdatadir wayland-protocols`
+WAYLAND_SCANNER = `pkg-config --variable=wayland_scanner wayland-scanner`
-uninstall:
- rm -f $(DESTDIR)$(PREFIX)/bin/dwl $(DESTDIR)$(MANDIR)/man1/dwl.1
+# CFLAGS / LDFLAGS
+PKGS = wlroots wayland-server xkbcommon libinput $(XLIBS)
+DWLCFLAGS = `pkg-config --cflags $(PKGS)` $(DWLCPPFLAGS) $(CFLAGS) $(XWAYLAND)
+LDLIBS = `pkg-config --libs $(PKGS)` $(LIBS)
-.PHONY: all clean dist install uninstall
+# build rules
# wayland-scanner is a tool which generates C headers and rigging for Wayland
# protocols, which are specified in XML. wlroots requires you to rig these up
# to your build system yourself and provide them in the include path.
+all: dwl
+dwl: dwl.o util.o
+ $(CC) dwl.o util.o $(LDLIBS) $(LDFLAGS) -o $@
+dwl.o: dwl.c config.mk config.h client.h xdg-shell-protocol.h wlr-layer-shell-unstable-v1-protocol.h idle-protocol.h
+util.o: util.c util.h
+
+# wayland scanner rules to generate .h / .c files
xdg-shell-protocol.h:
$(WAYLAND_SCANNER) server-header \
$(WAYLAND_PROTOCOLS)/stable/xdg-shell/xdg-shell.xml $@
-
-xdg-shell-protocol.c:
- $(WAYLAND_SCANNER) private-code \
- $(WAYLAND_PROTOCOLS)/stable/xdg-shell/xdg-shell.xml $@
-
-xdg-shell-protocol.o: xdg-shell-protocol.h
-
wlr-layer-shell-unstable-v1-protocol.h:
$(WAYLAND_SCANNER) server-header \
protocols/wlr-layer-shell-unstable-v1.xml $@
-
-wlr-layer-shell-unstable-v1-protocol.c:
- $(WAYLAND_SCANNER) private-code \
- protocols/wlr-layer-shell-unstable-v1.xml $@
-
-wlr-layer-shell-unstable-v1-protocol.o: wlr-layer-shell-unstable-v1-protocol.h
-
idle-protocol.h:
$(WAYLAND_SCANNER) server-header \
protocols/idle.xml $@
-idle-protocol.c:
- $(WAYLAND_SCANNER) private-code \
- protocols/idle.xml $@
+config.h:
+ cp config.def.h $@
+clean:
+ rm -f dwl *.o *-protocol.h
-idle-protocol.o: idle-protocol.h
+# distribution archive
+dist: clean
+ mkdir -p dwl-$(VERSION)
+ cp -R LICENSE* Makefile README.md generate-version.sh client.h\
+ config.def.h config.mk protocols dwl.1 dwl.c util.c util.h\
+ dwl-$(VERSION)
+ echo "echo $(VERSION)" > dwl-$(VERSION)/generate-version.sh
+ tar -caf dwl-$(VERSION).tar.gz dwl-$(VERSION)
+ rm -rf dwl-$(VERSION)
-config.h: | config.def.h
- cp config.def.h $@
+# install rules
-dwl.o: config.mk config.h client.h xdg-shell-protocol.h wlr-layer-shell-unstable-v1-protocol.h idle-protocol.h util.h
+install: dwl
+ mkdir -p $(DESTDIR)$(PREFIX)/bin
+ cp dwl $(DESTDIR)$(PREFIX)/bin
+ chmod 755 $(DESTDIR)$(PREFIX)/bin/dwl
+ mkdir -p $(DESTDIR)$(MANDIR)/man1
+ cp dwl.1 $(DESTDIR)$(MANDIR)/man1
+ chmod 644 $(DESTDIR)$(MANDIR)/man1/dwl.1
+uninstall:
+ rm -f $(DESTDIR)$(PREFIX)/bin/dwl $(DESTDIR)$(MANDIR)/man1/dwl.1
-dwl: xdg-shell-protocol.o wlr-layer-shell-unstable-v1-protocol.o idle-protocol.o util.o
+.SUFFIXES: .c .o
+.c.o:
+ $(CC) $(CPPFLAGS) $(DWLCFLAGS) -c $<
diff --git a/client.h b/client.h
index ec760ec..6791a4d 100644
--- a/client.h
+++ b/client.h
@@ -232,10 +232,22 @@ client_min_size(Client *c, int *width, int *height)
}
static inline Client *
-client_from_wlr_surface(struct wlr_surface *surface)
+client_from_wlr_surface(struct wlr_surface *s)
{
- struct wlr_scene_node *n = surface->data;
- return n ? n->data : NULL;
+ struct wlr_xdg_surface *surface;
+
+#ifdef XWAYLAND
+ struct wlr_xwayland_surface *xsurface;
+ if (s->role_data && wlr_surface_is_xwayland_surface(s)
+ && (xsurface = wlr_xwayland_surface_from_wlr_surface(s)))
+ return xsurface->data;
+#endif
+ if (s->role_data && wlr_surface_is_xdg_surface(s)
+ && (surface = wlr_xdg_surface_from_wlr_surface(s))
+ && surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL)
+ return surface->data;
+
+ return NULL;
}
static inline Client *
diff --git a/config.def.h b/config.def.h
index 8c27380..43f35cd 100644
--- a/config.def.h
+++ b/config.def.h
@@ -62,12 +62,21 @@ LIBINPUT_CONFIG_SCROLL_EDGE
LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN
*/
static const enum libinput_config_scroll_method scroll_method = LIBINPUT_CONFIG_SCROLL_2FG;
+
+/* You can choose between:
+LIBINPUT_CONFIG_CLICK_METHOD_NONE
+LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS
+LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER
+*/
+static const enum libinput_config_click_method click_method = LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS;
+
/* You can choose between:
LIBINPUT_CONFIG_SEND_EVENTS_ENABLED
LIBINPUT_CONFIG_SEND_EVENTS_DISABLED
LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE
*/
static const uint32_t send_events_mode = LIBINPUT_CONFIG_SEND_EVENTS_ENABLED;
+
/* You can choose between:
LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT
LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE
diff --git a/config.mk b/config.mk
index 37b4114..ba24bb8 100644
--- a/config.mk
+++ b/config.mk
@@ -1,12 +1,15 @@
_VERSION = 0.3.1
-VERSION = $(shell ./generate-version.sh $(_VERSION))
+VERSION = `./generate-version.sh $(_VERSION)`
# paths
PREFIX = /usr/local
MANDIR = $(PREFIX)/share/man
-# Default compile flags (overridable by environment)
-CFLAGS ?= -g -Wall -Wextra -Werror -Wno-unused-parameter -Wno-sign-compare -Wno-unused-function -Wno-unused-variable -Wno-unused-result -Wdeclaration-after-statement
+# Compile flags that can be used
+#CFLAGS = -pedantic -Wall -Wextra -Werror -Wno-unused-parameter -Wno-sign-compare -Wno-unused-function -Wno-unused-variable -Wno-unused-result -Wdeclaration-after-statement
+XWAYLAND =
+XLIBS =
# Uncomment to build XWayland support
-#CFLAGS += -DXWAYLAND
+#XWAYLAND = -DXWAYLAND
+#XLIBS = xcb
diff --git a/dwl.c b/dwl.c
index f061ebe..8a85c79 100644
--- a/dwl.c
+++ b/dwl.c
@@ -297,6 +297,7 @@ static void zoom(const Arg *arg);
/* variables */
static const char broken[] = "broken";
+static pid_t child_pid = -1;
static struct wl_display *dpy;
static struct wlr_backend *backend;
static struct wlr_scene *scene;
@@ -687,7 +688,10 @@ cleanup(void)
wlr_xwayland_destroy(xwayland);
#endif
wl_display_destroy_clients(dpy);
-
+ if (child_pid > 0) {
+ kill(child_pid, SIGTERM);
+ waitpid(child_pid, NULL, 0);
+ }
wlr_backend_destroy(backend);
wlr_xcursor_manager_destroy(cursor_mgr);
wlr_cursor_destroy(cursor);
@@ -1003,6 +1007,9 @@ createpointer(struct wlr_input_device *device)
if (libinput_device_config_scroll_get_methods(libinput_device) != LIBINPUT_CONFIG_SCROLL_NO_SCROLL)
libinput_device_config_scroll_set_method (libinput_device, scroll_method);
+
+ if (libinput_device_config_click_get_methods(libinput_device) != LIBINPUT_CONFIG_CLICK_METHOD_NONE)
+ libinput_device_config_click_set_method (libinput_device, click_method);
if (libinput_device_config_send_events_get_modes(libinput_device))
libinput_device_config_send_events_set_mode(libinput_device, send_events_mode);
@@ -1750,8 +1757,6 @@ resize(Client *c, int x, int y, int w, int h, int interact)
void
run(char *startup_cmd)
{
- pid_t startup_pid = -1;
-
/* Add a Unix socket to the Wayland display. */
const char *socket = wl_display_add_socket_auto(dpy);
if (!socket)
@@ -1763,9 +1768,9 @@ run(char *startup_cmd)
int piperw[2];
if (pipe(piperw) < 0)
die("startup: pipe:");
- if ((startup_pid = fork()) < 0)
+ if ((child_pid = fork()) < 0)
die("startup: fork:");
- if (startup_pid == 0) {
+ if (child_pid == 0) {
dup2(piperw[0], STDIN_FILENO);
close(piperw[0]);
close(piperw[1]);
@@ -1801,11 +1806,6 @@ run(char *startup_cmd)
* loop configuration to listen to libinput events, DRM events, generate
* frame events at the refresh rate, and so on. */
wl_display_run(dpy);
-
- if (startup_cmd) {
- kill(startup_pid, SIGTERM);
- waitpid(startup_pid, NULL, 0);
- }
}
Client *
@@ -2117,10 +2117,12 @@ sigchld(int unused)
* but the Xwayland implementation in wlroots currently prevents us from
* setting our own disposition for SIGCHLD.
*/
+ pid_t pid;
if (signal(SIGCHLD, sigchld) == SIG_ERR)
die("can't install SIGCHLD handler:");
- while (0 < waitpid(-1, NULL, WNOHANG))
- ;
+ while (0 < (pid = waitpid(-1, NULL, WNOHANG)))
+ if (pid == child_pid)
+ child_pid = -1;
}
void
@@ -2250,7 +2252,8 @@ toggleview(const Arg *arg)
void
unmaplayersurface(LayerSurface *layersurface)
{
- layersurface->layer_surface->mapped = 0;
+ layersurface->layer_surface->mapped = (layersurface->mapped = 0);
+ wlr_scene_node_set_enabled(layersurface->scene, 0);
if (layersurface->layer_surface->surface ==
seat->keyboard_state.focused_surface)
focusclient(selclient(), 1);