commit 1fc0fbe5e605daa91f4ea8462fdf267b48e99404
parent 0789db751deae22ea02ec9c20880038e3a4d97dc
Author: Stacy Harper <contact@stacyharper.net>
Date: Sun, 22 Aug 2021 23:14:47 +0200
Make the layout switchable
Diffstat:
4 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/Makefile b/Makefile
@@ -1,5 +1,7 @@
include config.mk
+NAME=wvkbd
+BIN=${NAME}-${LAYOUT}
SRC=.
WLDSRC=wld
@@ -8,7 +10,7 @@ PKGS = fontconfig wayland-client xkbcommon pixman-1
WVKBD_SOURCES += $(wildcard $(SRC)/*.c)
WVKBD_HEADERS += $(wildcard $(SRC)/*.h)
-CFLAGS += -std=gnu99 -Wall -g -DWITH_WAYLAND_SHM
+CFLAGS += -std=gnu99 -Wall -g -DWITH_WAYLAND_SHM -DLAYOUT=\"layout.${LAYOUT}.h\"
CFLAGS += $(shell pkg-config --cflags $(PKGS))
LDFLAGS =wld/libwld.a $(shell pkg-config --libs $(PKGS)) -lm -lutil
@@ -20,7 +22,7 @@ SOURCES = $(WVKBD_SOURCES) $(WAYLAND_SRC)
OBJECTS = $(SOURCES:.c=.o)
-all: wld wvkbd
+all: wld ${BIN}
proto/%-client-protocol.c: proto/%.xml
wayland-scanner code < $? > $@
@@ -30,8 +32,8 @@ proto/%-client-protocol.h: proto/%.xml
$(OBJECTS): $(HDRS) $(WVKBD_HEADERS)
-wvkbd: $(OBJECTS)
- $(CC) -o wvkbd $(OBJECTS) $(LDFLAGS)
+wvkbd-${LAYOUT}: $(OBJECTS) layout.${LAYOUT}.h
+ $(CC) -o wvkbd-${LAYOUT} $(OBJECTS) $(LDFLAGS)
wld: wld/libwld.a
@@ -39,7 +41,7 @@ wld/libwld.a:
$(MAKE) -C wld ENABLE_DRM=0
clean:
- rm -f $(OBJECTS) $(HDRS) $(WAYLAND_SRC) wvkbd
+ rm -f $(OBJECTS) $(HDRS) $(WAYLAND_SRC) ${BIN}
$(MAKE) -C wld clean
format:
diff --git a/config.mk b/config.mk
@@ -1,2 +1,3 @@
VERSION = 0.0.1
CFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=700
+LAYOUT = mobile
diff --git a/config.h b/layout.mobile.h
diff --git a/main.c b/main.c
@@ -126,7 +126,11 @@ static const struct zwlr_layer_surface_v1_listener layer_surface_listener = {
.closed = layer_surface_closed,
};
-#include "config.h"
+/* configuration, allows nested code to access above variables */
+#ifndef LAYOUT
+#error "make sure to define LAYOUT"
+#endif
+#include LAYOUT
void
wl_touch_down(void *data, struct wl_touch *wl_touch, uint32_t serial,