commit e99d13a

sewn  ·  2026-03-01 00:41:13 +0000 UTC
parent d7a9eda
switch to meson

convert_font: print debugging lines on debug mode only
example: fix API usage
evdev: assume devices are always set
19 files changed,  +252, -634
+0, -323
  1@@ -1,323 +0,0 @@
  2-# bmake-compatible build for swc (avoids GNU make-specific functions/macros).
  3-
  4-.include "config.mk"
  5-
  6-.MAIN: build
  7-
  8-.if !defined(PREFIX)
  9-PREFIX=/usr/local
 10-.endif
 11-.if !defined(BINDIR)
 12-BINDIR=${PREFIX}/bin
 13-.endif
 14-.if !defined(LIBDIR)
 15-LIBDIR=${PREFIX}/lib
 16-.endif
 17-.if !defined(INCLUDEDIR)
 18-INCLUDEDIR=${PREFIX}/include
 19-.endif
 20-.if !defined(DATADIR)
 21-DATADIR=${PREFIX}/share
 22-.endif
 23-.if !defined(PKGCONFIGDIR)
 24-PKGCONFIGDIR=${LIBDIR}/pkgconfig
 25-.endif
 26-
 27-.if !defined(OBJCOPY)
 28-OBJCOPY=objcopy
 29-.endif
 30-.if !defined(PKG_CONFIG)
 31-PKG_CONFIG=pkg-config
 32-.endif
 33-.if !defined(WAYLAND_SCANNER)
 34-WAYLAND_SCANNER=wayland-scanner
 35-.endif
 36-.if !defined(CC)
 37-CC=cc
 38-.endif
 39-.if !defined(AR)
 40-AR=ar
 41-.endif
 42-
 43-UNAME!= uname
 44-
 45-.if !defined(INPUT_BACKEND)
 46-. if ${UNAME} == "NetBSD"
 47-INPUT_BACKEND=wscons
 48-. else
 49-INPUT_BACKEND=libinput
 50-. endif
 51-.endif
 52-
 53-VERSION_MAJOR=0
 54-VERSION_MINOR=0
 55-VERSION=${VERSION_MAJOR}.${VERSION_MINOR}
 56-
 57-PACKAGES=libdrm pixman-1 wayland-server wayland-protocols wld xkbcommon
 58-
 59-.if ${INPUT_BACKEND} == "libinput"
 60-PACKAGES+= libinput
 61-.if defined(ENABLE_LIBUDEV) && ${ENABLE_LIBUDEV} == 1
 62-PACKAGES+= libudev
 63-.endif
 64-.endif
 65-
 66-.if defined(ENABLE_XWAYLAND) && ${ENABLE_XWAYLAND} == 1
 67-PACKAGES+= xcb xcb-composite xcb-ewmh xcb-icccm
 68-.endif
 69-
 70-PKG_CFLAGS!= ${PKG_CONFIG} --cflags ${PACKAGES}
 71-PKG_LIBS!= ${PKG_CONFIG} --libs ${PACKAGES}
 72-WAYLAND_CLIENT_CFLAGS!= ${PKG_CONFIG} --cflags wayland-client
 73-WAYLAND_CLIENT_LIBS!= ${PKG_CONFIG} --libs wayland-client
 74-WAYLAND_PROTOCOLS_DATADIR!= ${PKG_CONFIG} --variable=pkgdatadir wayland-protocols
 75-
 76-CPPFLAGS+= -D_GNU_SOURCE
 77-CFLAGS+= -fvisibility=hidden -std=c11 ${PKG_CFLAGS}
 78-CFLAGS+= -Werror=implicit-function-declaration -Werror=implicit-int -Werror=pointer-sign -Werror=pointer-arith -Wall -Wno-missing-braces
 79-
 80-.if defined(ENABLE_DEBUG) && ${ENABLE_DEBUG} == 1
 81-CPPFLAGS+= -DENABLE_DEBUG=1
 82-CFLAGS+= -g
 83-.endif
 84-
 85-.if defined(ENABLE_LIBUDEV) && ${ENABLE_LIBUDEV} == 1
 86-CPPFLAGS+= -DENABLE_LIBUDEV
 87-.endif
 88-.if defined(ENABLE_XWAYLAND) && ${ENABLE_XWAYLAND} == 1
 89-CPPFLAGS+= -DENABLE_XWAYLAND
 90-.endif
 91-
 92-.if defined(EVDEV_KBD_DEVICE)
 93-CPPFLAGS+= -DEVDEV_KBD_DEVICE=\\\"${EVDEV_KBD_DEVICE}\\\"
 94-.endif
 95-.if defined(EVDEV_POINTER_DEVICE)
 96-CPPFLAGS+= -DEVDEV_POINTER_DEVICE=\\\"${EVDEV_POINTER_DEVICE}\\\"
 97-.endif
 98-
 99-PROTO_EXTENSIONS= \
100-	protocol/server-decoration.xml \
101-	protocol/swc.xml \
102-	protocol/swc_snap.xml \
103-	protocol/swc_select.xml \
104-	protocol/swc_wallpaper.xml \
105-	protocol/wayland-drm.xml \
106-	${WAYLAND_PROTOCOLS_DATADIR}/stable/xdg-shell/xdg-shell.xml \
107-	${WAYLAND_PROTOCOLS_DATADIR}/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml \
108-	${WAYLAND_PROTOCOLS_DATADIR}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml
109-
110-.for xml in ${PROTO_EXTENSIONS}
111-_base=${xml:T:R}
112-protocol/${_base}-protocol.c: ${xml} \
113-    protocol/${_base}-server-protocol.h \
114-    protocol/${_base}-client-protocol.h
115-	@echo "  GEN $@"
116-	@${WAYLAND_SCANNER} code ${xml} ${.TARGET}
117-
118-protocol/${_base}-server-protocol.h: ${xml}
119-	@echo "  GEN $@"
120-	@${WAYLAND_SCANNER} server-header ${xml} ${.TARGET}
121-
122-protocol/${_base}-client-protocol.h: ${xml}
123-	@echo "  GEN $@"
124-	@${WAYLAND_SCANNER} client-header ${xml} ${.TARGET}
125-.endfor
126-
127-PROTO_GEN_C= \
128-	protocol/linux-dmabuf-unstable-v1-protocol.c \
129-	protocol/server-decoration-protocol.c \
130-	protocol/swc-protocol.c \
131-	protocol/swc_snap-protocol.c \
132-	protocol/swc_select-protocol.c \
133-	protocol/swc_wallpaper-protocol.c \
134-	protocol/wayland-drm-protocol.c \
135-	protocol/xdg-decoration-unstable-v1-protocol.c \
136-	protocol/xdg-shell-protocol.c
137-
138-PROTO_GEN_H= \
139-	protocol/linux-dmabuf-unstable-v1-server-protocol.h \
140-	protocol/linux-dmabuf-unstable-v1-client-protocol.h \
141-	protocol/server-decoration-server-protocol.h \
142-	protocol/server-decoration-client-protocol.h \
143-	protocol/swc-server-protocol.h \
144-	protocol/swc-client-protocol.h \
145-	protocol/swc_snap-server-protocol.h \
146-	protocol/swc_snap-client-protocol.h \
147-	protocol/swc_select-server-protocol.h \
148-	protocol/swc_select-client-protocol.h \
149-	protocol/swc_wallpaper-server-protocol.h \
150-	protocol/swc_wallpaper-client-protocol.h \
151-	protocol/wayland-drm-server-protocol.h \
152-	protocol/wayland-drm-client-protocol.h \
153-	protocol/xdg-decoration-unstable-v1-server-protocol.h \
154-	protocol/xdg-decoration-unstable-v1-client-protocol.h \
155-	protocol/xdg-shell-server-protocol.h \
156-	protocol/xdg-shell-client-protocol.h
157-
158-cursor/cursor_data.h: cursor/cursor.pcf cursor/convert_font
159-	@echo "  GEN $@"
160-	@cursor/convert_font cursor/cursor.pcf ${.TARGET} 2>/dev/null
161-
162-cursor/convert_font: cursor/convert_font.o
163-	@echo "  CCLD $@"
164-	@${CC} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
165-
166-cursor/convert_font.o: cursor/convert_font.c
167-	@echo "  CC $@"
168-	@${CC} ${CPPFLAGS} ${CFLAGS} -I . -c -o ${.TARGET} ${.ALLSRC}
169-
170-LAUNCH_DEVMAJOR=launch/devmajor-linux.c
171-.if ${UNAME} == "NetBSD"
172-LAUNCH_DEVMAJOR=launch/devmajor-netbsd.c
173-.elif ${UNAME} == "OpenBSD"
174-LAUNCH_DEVMAJOR=launch/devmajor-openbsd.c
175-.endif
176-
177-launch/swc-launch: launch/launch.o launch/protocol.o launch/${LAUNCH_DEVMAJOR:T:R}.o
178-	@echo "  CCLD $@"
179-	@${CC} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} ${PKG_LIBS}
180-
181-.for f in launch/launch.c launch/protocol.c ${LAUNCH_DEVMAJOR}
182-launch/${f:T:R}.o: ${f}
183-	@echo "  CC $@"
184-	@${CC} ${CPPFLAGS} ${CFLAGS} -I . -c -o ${.TARGET} ${.ALLSRC}
185-.endfor
186-
187-SWC_SOURCES= \
188-	libswc/bindings.c \
189-	libswc/compositor.c \
190-	libswc/data.c \
191-	libswc/data_device.c \
192-	libswc/data_device_manager.c \
193-	libswc/dmabuf.c \
194-	libswc/drm.c \
195-	libswc/input.c \
196-	libswc/kde_decoration.c \
197-	libswc/keyboard.c \
198-	libswc/launch.c \
199-	libswc/mode.c \
200-	libswc/output.c \
201-	libswc/panel.c \
202-	libswc/panel_manager.c \
203-	libswc/plane.c \
204-	libswc/pointer.c \
205-	libswc/primary_plane.c \
206-	libswc/region.c \
207-	libswc/screen.c \
208-	libswc/shell.c \
209-	libswc/shell_surface.c \
210-	libswc/shm.c \
211-	libswc/snap.c \
212-	libswc/subcompositor.c \
213-	libswc/subsurface.c \
214-	libswc/surface.c \
215-	libswc/select.c \
216-	libswc/swc.c \
217-	libswc/util.c \
218-	libswc/view.c \
219-	libswc/wallpaper.c \
220-	libswc/wayland_buffer.c \
221-	libswc/window.c \
222-	libswc/xdg_decoration.c \
223-	libswc/xdg_shell.c \
224-	protocol/linux-dmabuf-unstable-v1-protocol.c \
225-	protocol/server-decoration-protocol.c \
226-	protocol/swc-protocol.c \
227-	protocol/swc_snap-protocol.c \
228-	protocol/swc_select-protocol.c \
229-	protocol/swc_wallpaper-protocol.c \
230-	protocol/wayland-drm-protocol.c \
231-	protocol/xdg-decoration-unstable-v1-protocol.c \
232-	protocol/xdg-shell-protocol.c
233-
234-.if ${INPUT_BACKEND} == "wscons"
235-SWC_SOURCES+= libswc/seat-ws.c
236-.elif ${INPUT_BACKEND} == "evdev"
237-SWC_SOURCES+= libswc/seat-evdev.c
238-.elif ${INPUT_BACKEND} == "libinput"
239-SWC_SOURCES+= libswc/seat.c
240-.else
241-.error Unknown INPUT_BACKEND '${INPUT_BACKEND}'. Use libinput, evdev, or wscons.
242-.endif
243-
244-.if defined(ENABLE_XWAYLAND) && ${ENABLE_XWAYLAND} == 1
245-SWC_SOURCES+= libswc/xserver.c libswc/xwm.c
246-.endif
247-
248-SWC_OBJECTS=${SWC_SOURCES:S/.c/.o/}
249-SWC_OBJECTS+= launch/protocol.o
250-
251-.for src in ${SWC_SOURCES}
252-${src:R}.o: ${src} ${PROTO_GEN_H} cursor/cursor_data.h
253-	@echo "  CC $@"
254-	@${CC} ${CPPFLAGS} ${CFLAGS} -I . -I protocol -c -o ${.TARGET} ${.IMPSRC}
255-.endfor
256-
257-libswc/libswc-internal.o: ${SWC_OBJECTS}
258-	@echo "  CCLD $@"
259-	@${CC} -nostdlib -r -o ${.TARGET} ${.ALLSRC}
260-
261-libswc/libswc.o: libswc/libswc-internal.o
262-	@echo "  OBJCOPY $@"
263-.if ${UNAME} == "OpenBSD"
264-	@cp ${.ALLSRC} ${.TARGET}
265-.else
266-	@${OBJCOPY} --localize-hidden ${.ALLSRC} ${.TARGET}
267-.endif
268-
269-libswc/libswc.a: libswc/libswc.o
270-	@echo "  AR $@"
271-	@${AR} cru ${.TARGET} ${.ALLSRC}
272-
273-EXTRA_CAPTURE_TOOLS= \
274-	extra/swcsnap
275-
276-.for ex in ${EXTRA_CAPTURE_TOOLS}
277-${ex:R}.o: ${ex}.c protocol/swc_snap-client-protocol.h
278-	@echo "  CC $@"
279-	@${CC} ${CPPFLAGS} ${CFLAGS} ${WAYLAND_CLIENT_CFLAGS} -I . -I protocol \
280-	    -c -o ${.TARGET} ${.IMPSRC}
281-.endfor
282-
283-extra/swcsnap: extra/swcsnap.o protocol/swc_snap-protocol.o
284-	@echo "  CCLD $@"
285-	@${CC} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} ${WAYLAND_CLIENT_LIBS}
286-
287-swc.pc: swc.pc.in
288-	@echo "  GEN $@"
289-	@sed -e 's:@VERSION@:${VERSION}:' \
290-	     -e 's:@PREFIX@:${PREFIX}:' \
291-	     -e 's:@LIBDIR@:${LIBDIR}:' \
292-	     -e 's:@INCLUDEDIR@:${INCLUDEDIR}:' \
293-	     -e 's:@DATADIR@:${DATADIR}:' \
294-	     -e 's:@REQUIRES@:wayland-server:' \
295-	     -e 's:@REQUIRES_PRIVATE@::' \
296-	     ${.ALLSRC} > ${.TARGET}
297-
298-.PHONY: all build clean install
299-all: build
300-build: libswc/libswc.a launch/swc-launch cursor/cursor_data.h swc.pc
301-build: ${EXTRA_CAPTURE_TOOLS}
302-
303-install: build
304-	install -d ${DESTDIR}${BINDIR}
305-	install -d ${DESTDIR}${LIBDIR}
306-	install -d ${DESTDIR}${INCLUDEDIR}
307-	install -d ${DESTDIR}${DATADIR}/swc
308-	install -d ${DESTDIR}${PKGCONFIGDIR}
309-	install -m 4755 launch/swc-launch ${DESTDIR}${BINDIR}/
310-	install -m 755 extra/swcsnap ${DESTDIR}${BINDIR}/
311-	install -m 644 libswc/libswc.a ${DESTDIR}${LIBDIR}/
312-	install -m 644 libswc/swc.h ${DESTDIR}${INCLUDEDIR}/
313-	install -m 644 ${PROTO_GEN_H} ${DESTDIR}${INCLUDEDIR}/
314-	install -m 644 protocol/swc.xml protocol/swc_snap.xml protocol/swc_wallpaper.xml ${DESTDIR}${DATADIR}/swc/
315-	install -m 644 swc.pc ${DESTDIR}${PKGCONFIGDIR}/
316-
317-clean:
318-	rm -f swc.pc \
319-	      ${PROTO_GEN_C} ${PROTO_GEN_H} \
320-	      cursor/cursor_data.h cursor/convert_font cursor/convert_font.o \
321-	      launch/*.o launch/swc-launch \
322-	      libswc/*.o libswc/libswc-internal.o libswc/libswc.o libswc/libswc.a \
323-	      protocol/*.o \
324-	      extra/swcsnap.o extra/swcsnap
+0, -28
 1@@ -1,28 +0,0 @@
 2-# swc: common.mk
 3-
 4-.PHONY: build-$(dir)
 5-build-$(dir): $($(dir)_TARGETS)
 6-
 7-.PHONY: install-$(dir)
 8-install-$(dir):
 9-
10-.deps/$(dir):
11-	@mkdir -p "$@"
12-
13-$(dir)/%: dir := $(dir)
14-
15-$(dir)/%.o: $(dir)/%.c | .deps/$(dir)
16-	$(compile) $($(dir)_CFLAGS) $($(dir)_PACKAGE_CFLAGS)
17-
18-$(dir)/%.lo: $(dir)/%.c | .deps/$(dir)
19-	$(compile) -fPIC $($(dir)_CFLAGS) $($(dir)_PACKAGE_CFLAGS)
20-
21-ifeq ($(origin $(dir)_PACKAGE_CFLAGS),undefined)
22-    $(dir)_PACKAGE_CFLAGS := $(call pkgconfig,$($(dir)_PACKAGES),cflags,CFLAGS)
23-endif
24-ifeq ($(origin $(dir)_PACKAGE_LIBS),undefined)
25-    $(dir)_PACKAGE_LIBS := $(call pkgconfig,$($(dir)_PACKAGES),libs,LIBS)
26-endif
27-
28-CLEAN_FILES += $($(dir)_TARGETS)
29-
+0, -24
 1@@ -1,24 +0,0 @@
 2-# swc: config.mk
 3-
 4-# The commented out options are defaults
 5-
 6-PREFIX          = /usr
 7-# BINDIR          = $(PREFIX)/bin
 8-# LIBDIR          = $(PREFIX)/lib
 9-# INCLUDEDIR      = $(PREFIX)/include
10-# DATADIR         = $(PREFIX)/share
11-# PKGCONFIGDIR    = $(LIBDIR)/pkgconfig
12-
13-# OBJCOPY         = objcopy
14-# PKG_CONFIG      = pkg-config
15-# WAYLAND_SCANNER = wayland-scanner
16-
17-ENABLE_DEBUG    = 1
18-ENABLE_STATIC   = 1
19-ENABLE_SHARED   = 0
20-ENABLE_LIBUDEV  = 1
21-ENABLE_XWAYLAND = 1
22-
23-#INPUT_BACKEND  = libinput
24-#   available: libinput, evdev, wscons
25-#   default: libinput on linux, wscons on NetBSD
+28, -1
  1@@ -129,7 +129,9 @@ struct bitmaps {
  2 static void
  3 handle_compressed_metrics(int32_t count, struct compressed_metrics *m)
  4 {
  5+#if ENABLE_DEBUG
  6 	fprintf(stderr, "metrics count: %d\n", count);
  7+#endif
  8 	extracted_font.count = count;
  9 	extracted_font.glyphs = calloc(count, sizeof(struct glyph));
 10 
 11@@ -154,15 +156,21 @@ static void
 12 handle_metrics(void *metricbuf)
 13 {
 14 	struct metrics *metrics = metricbuf;
 15+#if ENABLE_DEBUG
 16 	fprintf(stderr, "metric format: %x\n", metrics->format);
 17+#endif
 18 
 19 	if ((metrics->format & PCF_FORMAT_MASK) == PCF_DEFAULT_FORMAT) {
 20+#if ENABLE_DEBUG
 21 		fprintf(stderr, "todo...\n");
 22+#endif
 23 	} else if ((metrics->format & PCF_FORMAT_MASK) == PCF_COMPRESSED_METRICS) {
 24 		handle_compressed_metrics(metrics->compressed.count,
 25 		                          &metrics->compressed.compressed_metrics[0]);
 26 	} else {
 27+#if ENABLE_DEBUG
 28 		fprintf(stderr, "incompatible format\n");
 29+#endif
 30 		abort();
 31 	}
 32 }
 33@@ -170,13 +178,17 @@ handle_metrics(void *metricbuf)
 34 static void
 35 handle_glyph_names(struct glyph_names *names)
 36 {
 37+#if ENABLE_DEBUG
 38 	fprintf(stderr, "glyph count %d\n", names->glyph_count);
 39+#endif
 40 
 41 	if (names->glyph_count != extracted_font.count) {
 42 		abort();
 43 	}
 44 
 45+#if ENABLE_DEBUG
 46 	fprintf(stderr, "glyph names format %x\n", names->format);
 47+#endif
 48 
 49 	char *names_start = ((char *)names) + sizeof(struct glyph_names) +
 50 	                    (names->glyph_count + 1) * sizeof(int32_t);
 51@@ -194,16 +206,21 @@ handle_glyph_names(struct glyph_names *names)
 52 static void
 53 handle_bitmaps(struct bitmaps *bitmaps)
 54 {
 55+#if ENABLE_DEBUG
 56 	fprintf(stderr, "bitmaps count %d\n", bitmaps->glyph_count);
 57+#endif
 58 
 59 	if (bitmaps->glyph_count != extracted_font.count) {
 60 		abort();
 61 	}
 62-
 63+#if ENABLE_DEBUG
 64 	fprintf(stderr, "format %x\n", bitmaps->format);
 65+#endif
 66 
 67 	if (bitmaps->format != 2) {
 68+#if ENABLE_DEBUG
 69 		fprintf(stderr, "format not yet supported\n");
 70+#endif
 71 		abort();
 72 	}
 73 
 74@@ -223,11 +240,15 @@ static void
 75 handle_pcf(void *fontbuf)
 76 {
 77 	struct pcf_header *header = fontbuf;
 78+#if ENABLE_DEBUG
 79 	fprintf(stderr, "tablecount %d\n", header->table_count);
 80+#endif
 81 
 82 	for (unsigned i = 0; i < header->table_count; ++i) {
 83 		struct toc_entry *entry = &header->tables[i];
 84+#if ENABLE_DEBUG
 85 		fprintf(stderr, "type: %d\n", entry->type);
 86+#endif
 87 		if (entry->type == PCF_METRICS) {
 88 			handle_metrics((void *)((uintptr_t)fontbuf + entry->offset));
 89 		} else if (entry->type == PCF_GLYPH_NAMES) {
 90@@ -472,13 +493,17 @@ output_interesting_cursors(FILE *file)
 91 		find_cursor_and_mask(interesting_cursors[i].source_name, &cursor,
 92 		                     &mask);
 93 		if (!cursor) {
 94+#if ENABLE_DEBUG
 95 			fprintf(stderr, "no cursor for %s\n",
 96 			        interesting_cursors[i].source_name);
 97+#endif
 98 			abort();
 99 		}
100 		if (!mask) {
101+#if ENABLE_DEBUG
102 			fprintf(stderr, "no mask for %s\n",
103 			        interesting_cursors[i].source_name);
104+#endif
105 			abort();
106 		}
107 		reconstruct_glyph(cursor, mask, interesting_cursors[i].target_name,
108@@ -492,7 +517,9 @@ int
109 main(int argc, char *argv[])
110 {
111 	if (argc != 3) {
112+#if ENABLE_DEBUG
113 		fprintf(stderr, "Usage: %s input.pcf output.h\n", argv[0]);
114+#endif
115 		return EXIT_FAILURE;
116 	}
117 
+0, -15
 1@@ -1,15 +0,0 @@
 2-# swc: cursor/local.mk
 3-
 4-dir := cursor
 5-
 6-$(dir)_TARGETS := $(dir)/convert_font $(dir)/cursor_data.h
 7-
 8-$(dir)/convert_font: $(dir)/convert_font.o
 9-	$(link)
10-
11-$(dir)/cursor_data.h: $(dir)/cursor.pcf $(dir)/convert_font
12-	$(Q_GEN)cursor/convert_font $< $@ 2>/dev/null
13-
14-CLEAN_FILES += $(dir)/convert_font.o
15-
16-include common.mk
+7, -0
1@@ -0,0 +1,7 @@
2+tool = executable('convert_cont', 'convert_font.c')
3+
4+cursor = custom_target('cursor_data_h',
5+  input: 'cursor.pcf',
6+  output: 'cursor_data.h',
7+  command: [tool, '@INPUT@', '@OUTPUT@']
8+)
+0, -16
 1@@ -1,16 +0,0 @@
 2-# swc: example/local.mk
 3-
 4-dir := example
 5-
 6-$(dir)_PACKAGES = wayland-server xkbcommon
 7-$(dir)_CFLAGS = -Ilibswc
 8-
 9-$(dir): $(dir)/wm
10-
11-$(dir)/wm: $(dir)/wm.o libswc/libswc.a
12-	$(link) $(example_PACKAGE_LIBS) $(libswc_PACKAGE_LIBS) -lm
13-
14-CLEAN_FILES += $(dir)/wm.o $(dir)/wm
15-
16-include common.mk
17-
+4, -0
1@@ -0,0 +1,4 @@
2+executable('wm',
3+  'wm.c',
4+  dependencies: libswc,
5+)
+2, -2
 1@@ -115,11 +115,11 @@ focus(struct window *window)
 2 {
 3 	if (focused_window) {
 4 		swc_window_set_border(focused_window->swc, border_color_normal,
 5-		                      border_width);
 6+		                      border_width, 0, 0);
 7 	}
 8 
 9 	if (window) {
10-		swc_window_set_border(window->swc, border_color_active, border_width);
11+		swc_window_set_border(window->swc, border_color_active, border_width, 0, 0);
12 		swc_window_focus(window->swc);
13 	} else {
14 		swc_window_focus(NULL);
+5, -0
1@@ -0,0 +1,5 @@
2+executable('swcsnap',
3+  ['swcsnap.c', protos.get('swc_snap') ],
4+  dependencies: libswc,
5+  install: true,
6+)
+0, -24
 1@@ -1,24 +0,0 @@
 2-# swc: launch/local.mk
 3-
 4-dir := launch
 5-
 6-$(dir)_TARGETS  := $(dir)/swc-launch
 7-$(dir)_PACKAGES := libdrm
 8-
 9-ifeq ($(shell uname),NetBSD)
10-	DEVMAJOR_OBJ=devmajor-netbsd.o
11-else
12-	DEVMAJOR_OBJ=devmajor-linux.o
13-endif
14-
15-$(dir)/swc-launch: $(dir)/$(DEVMAJOR_OBJ) $(dir)/launch.o $(dir)/protocol.o
16-	$(link) $(launch_PACKAGE_LIBS)
17-
18-install-$(dir): $(dir)/swc-launch | $(DESTDIR)$(BINDIR)
19-	install -m 4755 launch/swc-launch $(DESTDIR)$(BINDIR)
20-
21-CLEAN_FILES += $(dir)/launch.o
22-CLEAN_FILES += $(dir)/$(DEVMAJOR_OBJ)
23-
24-include common.mk
25-
+7, -0
1@@ -0,0 +1,7 @@
2+launch_protocol = files('protocol.c')
3+executable('swc-launch',
4+  ['launch.c', launch_protocol, 'devmajor-@0@.c'.format(os)],
5+  dependencies: requires_private[0], # libdrm
6+  install: true,
7+  install_mode: 'rwsr-xr-x',
8+)
+0, -157
  1@@ -1,157 +0,0 @@
  2-# swc: libswc/local.mk
  3-
  4-dir := libswc
  5-
  6-LIBSWC_LINK := libswc.so
  7-LIBSWC_SO   := $(LIBSWC_LINK).$(VERSION_MAJOR)
  8-LIBSWC_LIB  := $(LIBSWC_SO).$(VERSION_MINOR)
  9-
 10-ifneq ($(ENABLE_STATIC), 0)
 11-$(dir)_TARGETS += $(dir)/libswc.a
 12-endif
 13-
 14-ifneq ($(ENABLE_SHARED), 0)
 15-$(dir)_TARGETS +=                   \
 16-    $(dir)/$(LIBSWC_LIB)            \
 17-    $(dir)/$(LIBSWC_SO)             \
 18-    $(dir)/$(LIBSWC_LINK)
 19-endif
 20-
 21-$(dir)_PACKAGES := libdrm pixman-1 wayland-server wld xkbcommon
 22-$(dir)_CFLAGS += -Iprotocol
 23-
 24-SWC_SOURCES =                       \
 25-    launch/protocol.c               \
 26-    libswc/bindings.c               \
 27-    libswc/compositor.c             \
 28-    libswc/data.c                   \
 29-    libswc/data_device.c            \
 30-    libswc/data_device_manager.c    \
 31-    libswc/dmabuf.c                 \
 32-    libswc/drm.c                    \
 33-    libswc/input.c                  \
 34-    libswc/kde_decoration.c         \
 35-    libswc/keyboard.c               \
 36-    libswc/launch.c                 \
 37-    libswc/mode.c                   \
 38-    libswc/output.c                 \
 39-    libswc/panel.c                  \
 40-    libswc/panel_manager.c          \
 41-    libswc/plane.c                  \
 42-    libswc/pointer.c                \
 43-    libswc/primary_plane.c          \
 44-    libswc/region.c                 \
 45-    libswc/screen.c                 \
 46-    libswc/shell.c                  \
 47-    libswc/shell_surface.c          \
 48-    libswc/shm.c                    \
 49-    libswc/snap.c                   \
 50-    libswc/subcompositor.c          \
 51-    libswc/subsurface.c             \
 52-    libswc/surface.c                \
 53-    libswc/swc.c                    \
 54-    libswc/util.c                   \
 55-    libswc/view.c                   \
 56-    libswc/wallpaper.c              \
 57-    libswc/wayland_buffer.c         \
 58-    libswc/window.c                 \
 59-    libswc/xdg_decoration.c         \
 60-    libswc/xdg_shell.c              \
 61-    protocol/linux-dmabuf-unstable-v1-protocol.c \
 62-    protocol/server-decoration-protocol.c \
 63-    protocol/swc-protocol.c         \
 64-    protocol/swc_snap-protocol.c    \
 65-    protocol/swc_wallpaper-protocol.c \
 66-    protocol/wayland-drm-protocol.c \
 67-    protocol/xdg-decoration-unstable-v1-protocol.c \
 68-    protocol/xdg-shell-protocol.c
 69-
 70-ifeq ($(strip $(INPUT_BACKEND)),)
 71-    ifeq ($(shell uname),NetBSD)
 72-        INPUT_BACKEND = wscons
 73-    else
 74-        INPUT_BACKEND = libinput
 75-    endif
 76-endif
 77-
 78-ifeq ($(INPUT_BACKEND),wscons)
 79-    SWC_SOURCES += libswc/seat-ws.c
 80-else ifeq ($(INPUT_BACKEND),evdev)
 81-    SWC_SOURCES += libswc/seat-evdev.c
 82-    ifneq ($(EVDEV_KBD_DEVICE),)
 83-        $(dir)_CFLAGS += -DEVDEV_KBD_DEVICE=\"$(EVDEV_KBD_DEVICE)\"
 84-    endif
 85-    ifneq ($(EVDEV_POINTER_DEVICE),)
 86-        $(dir)_CFLAGS += -DEVDEV_POINTER_DEVICE=\"$(EVDEV_POINTER_DEVICE)\"
 87-    endif
 88-else ifeq ($(INPUT_BACKEND),libinput)
 89-    SWC_SOURCES += libswc/seat.c
 90-    $(dir)_PACKAGES += libinput
 91-    ifeq ($(ENABLE_LIBUDEV),1)
 92-        $(dir)_CFLAGS += -DENABLE_LIBUDEV
 93-        $(dir)_PACKAGES += libudev
 94-    endif
 95-else
 96-    $(error Unknown INPUT_BACKEND '$(INPUT_BACKEND)'. Use libinput, evdev, or wscons.)
 97-endif
 98-
 99-ifeq ($(ENABLE_XWAYLAND),1)
100-$(dir)_CFLAGS += -DENABLE_XWAYLAND
101-$(dir)_PACKAGES += xcb xcb-composite xcb-ewmh xcb-icccm
102-
103-SWC_SOURCES +=                      \
104-    libswc/xserver.c                \
105-    libswc/xwm.c
106-endif
107-
108-SWC_STATIC_OBJECTS = $(SWC_SOURCES:%.c=%.o)
109-SWC_SHARED_OBJECTS = $(SWC_SOURCES:%.c=%.lo)
110-
111-# Explicitly state dependencies on generated files
112-objects = $(foreach obj,$(1),$(dir)/$(obj).o $(dir)/$(obj).lo)
113-$(call objects,compositor panel_manager panel screen): protocol/swc-server-protocol.h
114-$(call objects,dmabuf): protocol/linux-dmabuf-unstable-v1-server-protocol.h
115-$(call objects,drm drm_buffer): protocol/wayland-drm-server-protocol.h
116-$(call objects,kde_decoration): protocol/server-decoration-server-protocol.h
117-$(call objects,snap): protocol/swc_snap-server-protocol.h
118-$(call objects,wallpaper): protocol/swc_wallpaper-server-protocol.h
119-$(call objects,xdg_decoration): protocol/xdg-decoration-unstable-v1-server-protocol.h
120-$(call objects,xdg_shell): protocol/xdg-shell-server-protocol.h
121-$(call objects,pointer): cursor/cursor_data.h
122-
123-$(dir)/libswc-internal.o: $(SWC_STATIC_OBJECTS)
124-	$(link) -nostdlib -r
125-
126-$(dir)/libswc.o: $(dir)/libswc-internal.o
127-	$(Q_OBJCOPY)$(OBJCOPY) --localize-hidden $< $@
128-
129-$(dir)/libswc.a: $(dir)/libswc.o
130-	$(Q_AR)$(AR) cru $@ $^
131-
132-$(dir)/$(LIBSWC_LIB): $(SWC_SHARED_OBJECTS)
133-	$(link) -shared -Wl,-soname,$(LIBSWC_SO) -Wl,-no-undefined $(libswc_PACKAGE_LIBS)
134-
135-$(dir)/$(LIBSWC_SO): $(dir)/$(LIBSWC_LIB)
136-	$(Q_SYM)ln -sf $(notdir $<) $@
137-
138-$(dir)/$(LIBSWC_LINK): $(dir)/$(LIBSWC_SO)
139-	$(Q_SYM)ln -sf $(notdir $<) $@
140-
141-.PHONY: install-libswc.a
142-install-libswc.a: $(dir)/libswc.a | $(DESTDIR)$(LIBDIR)
143-	install -m 644 $< $(DESTDIR)$(LIBDIR)
144-
145-.PHONY: install-$(LIBSWC_LIB)
146-install-$(LIBSWC_LIB): $(dir)/$(LIBSWC_LIB) | $(DESTDIR)$(LIBDIR)
147-	install -m 755 $< $(DESTDIR)$(LIBDIR)
148-
149-.PHONY: install-$(LIBSWC_SO) install-$(LIBSWC_LINK)
150-install-$(LIBSWC_SO) install-$(LIBSWC_LINK): install-$(LIBSWC_LIB)
151-	ln -sf $(LIBSWC_LIB) $(DESTDIR)$(LIBDIR)/${@:install-%=%}
152-
153-install-$(dir): $($(dir)_TARGETS:$(dir)/%=install-%) | $(DESTDIR)$(INCLUDEDIR)
154-	install -m 644 libswc/swc.h $(DESTDIR)$(INCLUDEDIR)
155-
156-CLEAN_FILES += $(SWC_SHARED_OBJECTS) $(SWC_STATIC_OBJECTS)
157-
158-include common.mk
+73, -0
 1@@ -0,0 +1,73 @@
 2+install_headers('swc.h')
 3+
 4+libswc_src = files(
 5+  'bindings.c',
 6+  'compositor.c',
 7+  'data.c',
 8+  'data_device.c',
 9+  'data_device_manager.c',
10+  'dmabuf.c',
11+  'drm.c',
12+  'input.c',
13+  'kde_decoration.c',
14+  'keyboard.c',
15+  'launch.c',
16+  'mode.c',
17+  'output.c',
18+  'panel.c',
19+  'panel_manager.c',
20+  'plane.c',
21+  'pointer.c',
22+  'primary_plane.c',
23+  'region.c',
24+  'screen.c',
25+  'select.c',
26+  'snap.c',
27+  'shell.c',
28+  'shell_surface.c',
29+  'shm.c',
30+  'subcompositor.c',
31+  'subsurface.c',
32+  'surface.c',
33+  'swc.c',
34+  'util.c',
35+  'view.c',
36+  'wallpaper.c',
37+  'wayland_buffer.c',
38+  'window.c',
39+  'xdg_decoration.c',
40+  'xdg_shell.c',
41+
42+  input_backend == 'libinput' ? 'seat.c' : [],
43+  input_backend == 'wscons' ? 'seat-ws.c' : [],
44+  input_backend == 'evdev' ? 'seat-evdev.c' : [],
45+
46+  xwayland.found() ? ['xserver.c', 'xwm.c'] : [],  
47+)
48+libswc_src += [cursor, launch_protocol]
49+
50+foreach proto, proto_src : protos
51+	libswc_src += proto_src
52+endforeach
53+
54+libswc_lib = library(
55+	'swc',
56+	libswc_src,
57+	dependencies: requires + requires_private,
58+	install: true,
59+	include_directories: include_directories('..'),
60+)
61+
62+# Allows other meson projects to use libswc
63+libswc = declare_dependency(
64+	link_with: libswc_lib,
65+	dependencies: requires + requires_private,
66+)
67+
68+pkg.generate(
69+  libswc_lib,
70+  name: 'swc',
71+  description: 'A library for making a simple Wayland compositor',
72+  requires: requires,
73+  requires_private: requires_private,
74+)
+0, -8
 1@@ -25,14 +25,6 @@
 2 
 3 #include <linux/input.h>
 4 
 5-#ifndef EVDEV_KBD_DEVICE
 6-#define EVDEV_KBD_DEVICE "/dev/input/event0"
 7-#endif
 8-
 9-#ifndef EVDEV_POINTER_DEVICE
10-#define EVDEV_POINTER_DEVICE "/dev/input/event1"
11-#endif
12-
13 struct seat {
14 	struct swc_seat base;
15 
+98, -0
 1@@ -0,0 +1,98 @@
 2+project('swc', 'c',
 3+  version: '0.0',
 4+  meson_version: '>=1.1',
 5+  license: 'MIT',
 6+  default_options: [
 7+    'c_std=c11',
 8+    'warning_level=1',
 9+    'default_library=both',
10+  ],
11+)
12+
13+cc = meson.get_compiler('c')
14+os = host_machine.system()
15+pkg = import('pkgconfig')
16+wl = import('wayland')
17+
18+add_project_arguments(cc.get_supported_arguments([
19+  '-fvisibility=hidden',
20+
21+  '-Werror=implicit-function-declaration',
22+  '-Werror=implicit-int',
23+  '-Werror=pointer-sign',
24+  '-Werror=pointer-arith',
25+  '-Wno-missing-braces',
26+]) + [
27+  '-D_GNU_SOURCE', # Required for mkostemp
28+  get_option('buildtype').startswith('debug') ? '-DENABLE_DEBUG=1' : [],
29+], language: 'c')
30+
31+requires = [
32+  dependency('wayland-server', version: '>=1.6.0'),
33+]
34+requires_private = [
35+  dependency('libdrm'),
36+  dependency('pixman-1'),
37+  dependency('wayland-protocols'),
38+  dependency('wld'),
39+  dependency('xkbcommon'),
40+]
41+
42+xwayland = dependency('xwayland', required: get_option('xwayland'))
43+xwayland_deps = [
44+  'xcb',
45+  'xcb-composite',
46+  'xcb-ewmh',
47+  'xcb-icccm',
48+]
49+if xwayland.found()
50+  add_project_arguments('-DENABLE_XWAYLAND', language: 'c')
51+  requires_private += xwayland
52+  foreach dep : xwayland_deps
53+    requires_private += dependency(dep, required: xwayland.found())
54+	endforeach
55+endif
56+
57+input_backend = get_option('input')
58+libinput = dependency('libinput', version: '>=0.4', required: input_backend == 'libinput')
59+
60+if input_backend == 'auto'
61+  if os == 'linux'
62+    input_backend = libinput.found() ? 'libinput' : 'evdev'
63+  elif os == 'netbsd'
64+    input_backend = 'wscons'
65+  else
66+    error('Failed to determine input backend for ' + os)
67+  endif
68+endif  
69+
70+if input_backend == 'libinput'
71+  udev = dependency('libudev', required: get_option('udev'))
72+  if udev.found()
73+    add_project_arguments('-DENABLE_LIBUDEV', language: 'c')
74+  endif
75+  requires_private += [libinput, udev]
76+elif input_backend == 'evdev'
77+  add_project_arguments([
78+    '-DEVDEV_KBD_DEVICE="@0@"'.format(get_option('evdev-keyboard')),
79+    '-DEVDEV_POINTER_DEVICE="@0@"'.format(get_option('evdev-pointer')),
80+  ], language: 'c')
81+endif
82+
83+subdir('protocol')
84+subdir('cursor')
85+subdir('launch')
86+subdir('libswc')
87+
88+if get_option('extra')
89+  subdir('extra')
90+endif
91+
92+if get_option('example')
93+  subdir('example')
94+endif
95+
96+summary({
97+  'Xwayland support': xwayland.found(),
98+  'Input backend': input_backend,
99+}, bool_yn: true)
+7, -0
1@@ -0,0 +1,7 @@
2+option('xwayland', type: 'feature', value: 'auto', description: 'Automatic Xwayland handling')
3+option('input', type: 'combo', value: 'auto', choices: ['auto', 'libinput', 'evdev', 'wscons'], description: 'Input backend to use')
4+option('udev', type: 'feature', value: 'auto', description: 'libinput libudev support')
5+option('evdev-keyboard', type: 'string', value: '/dev/input/event0', description: 'evdev keyboard device to use')
6+option('evdev-pointer', type: 'string', value: '/dev/input/event1', description: 'evdev pointer device to use')
7+option('extra', type: 'boolean', value: true, description: 'Build swc utility applications')
8+option('example', type: 'boolean', value: false, description: 'Build swc example compositor')
+0, -36
 1@@ -1,36 +0,0 @@
 2-# swc: protocol/local.mk
 3-
 4-dir := protocol
 5-wayland_protocols := $(call pkgconfig,wayland-protocols,variable=pkgdatadir,DATADIR)
 6-
 7-PROTOCOL_EXTENSIONS =           \
 8-    $(dir)/server-decoration.xml\
 9-    $(dir)/swc.xml              \
10-    $(dir)/swc_snap.xml         \
11-    $(dir)/swc_wallpaper.xml    \
12-    $(dir)/wayland-drm.xml      \
13-    $(wayland_protocols)/stable/xdg-shell/xdg-shell.xml \
14-    $(wayland_protocols)/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml \
15-    $(wayland_protocols)/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml
16-
17-$(dir)_PACKAGES := wayland-server
18-
19-.for ext in ${PROTOCOL_EXTENSIONS}
20-proto_base := ${ext:T:R}
21-
22-${dir}/${proto_base}-protocol.c: ${ext}
23-	${Q_GEN}${WAYLAND_SCANNER} server-header ${ext} ${dir}/${proto_base}-server-protocol.h
24-	${Q_GEN}${WAYLAND_SCANNER} client-header ${ext} ${dir}/${proto_base}-client-protocol.h
25-	${Q_GEN}${WAYLAND_SCANNER} code ${ext} ${.TARGET}
26-
27-CLEAN_FILES += ${dir}/${proto_base}-protocol.c \
28-    ${dir}/${proto_base}-server-protocol.h \
29-    ${dir}/${proto_base}-client-protocol.h
30-.endfor
31-
32-install-$(dir): | $(DESTDIR)$(DATADIR)/swc
33-	install -m 644 protocol/swc.xml $(DESTDIR)$(DATADIR)/swc
34-	install -m 644 protocol/swc_snap.xml $(DESTDIR)$(DATADIR)/swc
35-	install -m 644 protocol/swc_wallpaper.xml $(DESTDIR)$(DATADIR)/swc
36-
37-include common.mk
+21, -0
 1@@ -0,0 +1,21 @@
 2+fs = import('fs')
 3+
 4+# Allow easy lookup for protocol for utility applications
 5+protos = {}
 6+foreach proto : [
 7+  'server-decoration.xml',
 8+  'swc.xml',
 9+  'swc_snap.xml',
10+  'swc_select.xml',
11+  'swc_wallpaper.xml',
12+  'wayland-drm.xml',
13+  wl.find_protocol('xdg-shell', state: 'stable'),
14+  wl.find_protocol('linux-dmabuf', state: 'unstable', version: 1),
15+  wl.find_protocol('xdg-decoration', state: 'unstable', version: 1),
16+]
17+  protocols = wl.scan_xml(proto,
18+    public: true,
19+    client: true,
20+    server: true)
21+  protos += {fs.stem(fs.name(proto)): protocols}
22+endforeach