From bd1137acd76cb01e6e7298f98ef360a9efb4ed79 Mon Sep 17 00:00:00 2001 From: sewn Date: Fri, 30 Aug 2024 17:45:16 +0300 Subject: [PATCH] Revert "Added zig build system only" This reverts commit 8f48f398625ce198377b56d61972973655d53c32. --- .gitignore | 5 +-- Makefile | 61 +++++++++++++++++++++++++++++++++++ build.zig | 94 ------------------------------------------------------ dam.c | 18 +++++------ 4 files changed, 73 insertions(+), 105 deletions(-) create mode 100644 Makefile delete mode 100644 build.zig diff --git a/.gitignore b/.gitignore index d8c8979..d577a31 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ -.zig-cache -zig-out +dam +*.o +*-protocol.* diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5484260 --- /dev/null +++ b/Makefile @@ -0,0 +1,61 @@ +.POSIX: + +PREFIX = /usr/local + +PKG_CONFIG = pkg-config + +PKGS = wayland-client fcft pixman-1 +INCS = `$(PKG_CONFIG) --cflags $(PKGS)` +LIBS = `$(PKG_CONFIG) --libs $(PKGS)` + +FPCFLAGS = -pedantic -Wall $(INCS) $(CPPFLAGS) $(CFLAGS) +LDLIBS = $(LIBS) + +SRC = dam.o xdg-shell-protocol.o wlr-layer-shell-unstable-v1-protocol.o \ + river-control-unstable-v1-protocol.o river-status-unstable-v1-protocol.o +OBJ = $(SRC:.c=.o) + +all: dam + +.c.o: + $(CC) -o $@ -c $(FPCFLAGS) -c $< + +dam.o: wlr-layer-shell-unstable-v1-protocol.h \ + river-control-unstable-v1-protocol.h river-status-unstable-v1-protocol.h + +dam: $(OBJ) + $(CC) $(LDFLAGS) -o $@ $(OBJ) $(LDLIBS) + +WAYLAND_PROTOCOLS = `$(PKG_CONFIG) --variable=pkgdatadir wayland-protocols` +WAYLAND_SCANNER = `$(PKG_CONFIG) --variable=wayland_scanner wayland-scanner` + +xdg-shell-protocol.c: + $(WAYLAND_SCANNER) private-code $(WAYLAND_PROTOCOLS)/stable/xdg-shell/xdg-shell.xml $@ +xdg-shell-protocol.h: + $(WAYLAND_SCANNER) client-header $(WAYLAND_PROTOCOLS)/stable/xdg-shell/xdg-shell.xml $@ +wlr-layer-shell-unstable-v1-protocol.c: + $(WAYLAND_SCANNER) private-code wlr-layer-shell-unstable-v1.xml $@ +wlr-layer-shell-unstable-v1-protocol.h: + $(WAYLAND_SCANNER) client-header wlr-layer-shell-unstable-v1.xml $@ +wlr-layer-shell-unstable-v1-protocol.o: xdg-shell-protocol.o +river-control-unstable-v1-protocol.c: + $(WAYLAND_SCANNER) private-code river-control-unstable-v1.xml $@ +river-control-unstable-v1-protocol.h: + $(WAYLAND_SCANNER) client-header river-control-unstable-v1.xml $@ +river-status-unstable-v1-protocol.c: + $(WAYLAND_SCANNER) private-code river-status-unstable-v1.xml $@ +river-status-unstable-v1-protocol.h: + $(WAYLAND_SCANNER) client-header river-status-unstable-v1.xml $@ + +clean: + rm -f dam *.o *-protocol.* + +install: all + mkdir -p $(DESTDIR)$(PREFIX)/bin + cp -f dam $(DESTDIR)$(PREFIX)/bin + chmod 755 $(DESTDIR)$(PREFIX)/bin/dam + +uninstall: + rm -f $(DESTDIR)$(PREFIX)/bin/dam + +.PHONY: all clean install uninstall diff --git a/build.zig b/build.zig deleted file mode 100644 index 2bb656b..0000000 --- a/build.zig +++ /dev/null @@ -1,94 +0,0 @@ -const std = @import("std"); -const Build = std.Build; -const fs = std.fs; -const mem = std.mem; - -pub fn build(b: *Build) void { - const target = b.standardTargetOptions(.{}); - const optimize = b.standardOptimizeOption(.{}); - - const dam = b.addExecutable(.{ - .name = "dam", - .target = target, - .optimize = optimize, - }); - dam.addIncludePath(b.path("")); - dam.addCSourceFile(.{ - .file = b.path("dam.c"), - .flags = &.{"-D_GNU_SOURCE"}, - }); - - dam.linkLibC(); - dam.linkSystemLibrary("wayland-client"); - dam.linkSystemLibrary("fcft"); - dam.linkSystemLibrary("pixman-1"); - - const scanner = Scanner.create(b, .{}, dam); - scanner.addSystemProtocol("/stable/xdg-shell/xdg-shell.xml"); - scanner.addCustomProtocol("wlr-layer-shell-unstable-v1.xml"); - scanner.addCustomProtocol("river-control-unstable-v1.xml"); - scanner.addCustomProtocol("river-status-unstable-v1.xml"); - - b.installArtifact(dam); -} - -pub const Scanner = struct { - build: *Build, - wayland_protocols_path: []const u8, - wayland_scanner_path: []const u8, - compile: *Build.Step.Compile, - - const opts = struct { - wayland_protocols_path: ?[]const u8 = null, - wayland_scanner_path: ?[]const u8 = null, - }; - - pub fn create(b: *Build, opt: opts, c: *Build.Step.Compile) *Scanner { - const wayland_protocols_path = opt.wayland_protocols_path orelse blk: { - const pathr = b.run(&.{ "pkg-config", "--variable=pkgdatadir", "wayland-protocols" }); - break :blk mem.trim(u8, pathr, &std.ascii.whitespace); - }; - const scanner_path = opt.wayland_scanner_path orelse blk: { - const pathr = b.run(&.{ "pkg-config", "--variable=wayland_scanner", "wayland-scanner" }); - break :blk mem.trim(u8, pathr, &std.ascii.whitespace); - }; - - const scanner = b.allocator.create(Scanner) catch @panic("OOM"); - scanner.* = .{ - .wayland_protocols_path = wayland_protocols_path, - .wayland_scanner_path = scanner_path, - .build = b, - .compile = c, - }; - - return scanner; - } - - pub fn addSystemProtocol(scanner: *Scanner, relative_path: []const u8) void { - const full_path = scanner.build.pathJoin(&.{ scanner.wayland_protocols_path, relative_path }); - scanner.addCustomProtocol(full_path); - } - - pub fn addCustomProtocol(scanner: *Scanner, path: []const u8) void { - scanner.generateCHeader(path); - scanner.generateCode(path); - } - - fn generateCHeader(scanner: *Scanner, protocol: []const u8) void { - const cmd = scanner.build.addSystemCommand(&.{ "wayland-scanner", "client-header", protocol }); - const out_name = mem.concat(scanner.build.allocator, u8, &.{ fs.path.stem(protocol), "-protocol.h" }) catch @panic("OOM"); - - const c_header = cmd.addOutputFileArg(out_name); - scanner.compile.addIncludePath(c_header.dirname()); - } - - fn generateCode(scanner: *Scanner, protocol: []const u8) void { - const cmd = scanner.build.addSystemCommand(&.{ "wayland-scanner", "private-code", protocol }); - const out_name = mem.concat(scanner.build.allocator, u8, &.{ fs.path.stem(protocol), "-protocol.c" }) catch @panic("OOM"); - - const c_file = cmd.addOutputFileArg(out_name); - scanner.compile.addCSourceFile(.{ - .file = c_file, - }); - } -}; diff --git a/dam.c b/dam.c index 5e01c05..0d635f4 100644 --- a/dam.c +++ b/dam.c @@ -155,20 +155,20 @@ bar_draw(Bar *bar) x += w; } - wl_list_for_each(seat, &seats, link) { - if (seat->bar != bar) - continue; - w = TEXTW(bar, seat->mode); - drwl_setscheme(bar->drw, colors[SchemeSel]); - x = drwl_text(bar->drw, x, 0, w, bar->height, bar->lrpad / 2, seat->mode, 0); - } - if (bar->layout) { w = TEXTW(bar, bar->layout); drwl_setscheme(bar->drw, colors[SchemeNorm]); x = drwl_text(bar->drw, x, 0, w, bar->height, bar->lrpad / 2, bar->layout, 0); } - + + wl_list_for_each(seat, &seats, link) { + if (seat->bar != bar) + continue; + w = TEXTW(bar, seat->mode); + drwl_setscheme(bar->drw, colors[SchemeNorm]); + x = drwl_text(bar->drw, x, 0, w, bar->height, bar->lrpad / 2, seat->mode, 1); + } + if ((w = bar->width - tw - x) > bar->height) { if (bar->title && *bar->title != '\0') { drwl_setscheme(bar->drw, colors[bar->selected ? SchemeSel : SchemeNorm]);