commit 7325a3ee4762f5aea70c9f3168825a9d2bc710a7 Author: Harrison DiAmbrosio Date: Thu Oct 16 10:39:24 2025 -0400 batman diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1dfcbd2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.zig-cache/ diff --git a/build.zig b/build.zig new file mode 100644 index 0000000..ce96a72 --- /dev/null +++ b/build.zig @@ -0,0 +1,71 @@ +const std = @import("std"); + +const Scanner = @import("wayland").Scanner; + +pub fn build(b: *std.Build) void { + const target = b.standardTargetOptions(.{}); + const optimize = b.standardOptimizeOption(.{}); + + // If instead your goal is to create an executable, consider if users might + // be interested in also being able to embed the core functionality of your + // program in their own executable in order to avoid the overhead involved in + // subprocessing your CLI tool. + + // The below is copied from tinywl + // TODO: Ensure versioning is correct + // TODO: Ensure paths for system protocols are correct + + const scanner = Scanner.create(b, .{}); + scanner.addSystemProtocol("stable/xdg-shell/xdg-shell.xml"); + scanner.addSystemProtocol("stable/tablet/tablet-v2.xml"); + + scanner.generate("wl_compositor", 4); + scanner.generate("wl_subcompositor", 1); + scanner.generate("wl_shm", 1); + scanner.generate("wl_output", 4); + scanner.generate("wl_seat", 7); + scanner.generate("wl_data_device_manager", 3); + scanner.generate("xdg_wm_base", 2); + scanner.generate("zwp_tablet_manager_v2", 1); + + const wayland = b.createModule(.{ .root_source_file = scanner.result }); + const xkbcommon = b.dependency("xkbcommon", .{}).module("xkbcommon"); + const pixman = b.dependency("pixman", .{}).module("pixman"); + const wlroots = b.dependency("wlroots", .{}).module("wlroots"); + + wlroots.addImport("wayland", wayland); + wlroots.addImport("xkbcommon", xkbcommon); + wlroots.addImport("pixman", pixman); + + wlroots.resolved_target = target; + wlroots.linkSystemLibrary("wlroots-0.19", .{}); + + const wwm = b.addExecutable(.{ + .name = "wwm", + .root_module = b.createModule(.{ + .root_source_file = b.path("src/main.zig"), + .target = target, + .optimize = optimize, + }), + }); + + wwm.linkLibC(); + + wwm.root_module.addImport("wayland", wayland); + wwm.root_module.addImport("xkbcommon", xkbcommon); + wwm.root_module.addImport("wlroots", wlroots); + + wwm.linkSystemLibrary("wayland-server"); + wwm.linkSystemLibrary("xkbcommon"); + wwm.linkSystemLibrary("pixman-1"); + + b.installArtifact(wwm); + + const run_step = b.step("run", "Run the app"); + const run_cmd = b.addRunArtifact(wwm); + run_step.dependOn(&run_cmd.step); + run_cmd.step.dependOn(b.getInstallStep()); + if (b.args) |args| { + run_cmd.addArgs(args); + } +} diff --git a/build.zig.zon b/build.zig.zon new file mode 100644 index 0000000..c39a27a --- /dev/null +++ b/build.zig.zon @@ -0,0 +1,29 @@ +.{ + .name = .wwm, + .version = "0.0.1", + .fingerprint = 0xfd825513ca495f0b, // Changing this has security and trust implications. + .minimum_zig_version = "0.15.2", + .dependencies = .{ + .wayland = .{ + .url = "https://codeberg.org/ifreund/zig-wayland/archive/v0.4.0.tar.gz", + .hash = "wayland-0.4.0-lQa1khbMAQAsLS2eBR7M5lofyEGPIbu2iFDmoz8lPC27", + }, + .pixman = .{ + .url = "https://codeberg.org/ifreund/zig-pixman/archive/v0.3.0.tar.gz", + .hash = "pixman-0.3.0-LClMnz2VAAAs7QSCGwLimV5VUYx0JFnX5xWU6HwtMuDX", + }, + .xkbcommon = .{ + .url = "https://codeberg.org/ifreund/zig-xkbcommon/archive/v0.3.0.tar.gz", + .hash = "xkbcommon-0.3.0-VDqIe3K9AQB2fG5ZeRcMC9i7kfrp5m2rWgLrmdNn9azr", + }, + .wlroots = .{ + .url = "https://codeberg.org/ifreund/zig-wlroots/archive/v0.19.3.tar.gz", + .hash = "wlroots-0.19.3-jmOlcuL_AwBHhLCwpFsXbTizE3q9BugFmGX-XIxqcPMc", + }, + }, + .paths = .{ + "build.zig", + "build.zig.zon", + "src", + }, +} diff --git a/ideation.md b/ideation.md new file mode 100644 index 0000000..d00b276 --- /dev/null +++ b/ideation.md @@ -0,0 +1,23 @@ +# {NAME GOES HERE} +1. Not strictly dynamic tiling, calls to a lua script (a standard stack/master by default) to know where to + * Tile windows + * Follow window rules, (GIMP should be floating) + * If this is the case, a default config should exist somewhere +2. A very transparent API for lua to interact with is important + * I love the idea of the autocommands, wm should hold a callback list for each autocommand (maybe look at how nvim does this) +3. Is it better to use the zig-wlroots bindings, "translate-c" wlroots, or compile the C in with wlroots + * It seems like Isaac started with translate-c and then created the wlroots bindings. Depends if we want latest for wlroots and zig + * Not using the bindings is most likey a LOT of extra work + +# Names +* Selene +* Chandra - wtf +* Phoeb - Horrible to write in code +* Mezzaluna (mez) +* Gibbous (gib) +* Monzonite (monz) +* Slasagna + +# Style Guide + +Perhaps we do what river does for organization? Checkout river/Server.zig:17's use of @This(); diff --git a/src/main.zig b/src/main.zig new file mode 100644 index 0000000..a7031e5 --- /dev/null +++ b/src/main.zig @@ -0,0 +1,7 @@ +const std = @import("std"); + +const Server = @import("server.zig").Server; + +pub fn main() !void { + std.debug.print("Starting wwm"); +} diff --git a/src/server.zig b/src/server.zig new file mode 100644 index 0000000..437b386 --- /dev/null +++ b/src/server.zig @@ -0,0 +1,39 @@ +const wl = @import("wayland").server.wl; +const wlr = @import("wlroots"); + +pub const Server = struct { + allocator: *wlr.Allocator, + + server: *wl.Server, + event_loop: *wl.EventLoop, + + session: *wlr.Session, + backend: *wlr.Backend, + renderer: *wlr.Renderer, + + compositor: *wlr.Compositor, + + pub fn init() !Server { + const server = try wl.Server.create(); + const event_loop = server.getEventLoop(); + + var session: ?*wlr.Session = undefined; + const backend = try wlr.Backend.autocreate(event_loop, &session); + const renderer = try wlr.Renderer.autocreate(backend); + + // Do we need to fail if session is NULL + + return .{ + .server = server, + .event_loop = event_loop, + + .session = session, + .backend = backend, + .renderer = renderer, + + .allocator = try wlr.Allocator.autocreate(backend, renderer), + + .compositor = try wlr.Compositor.create(server, 6, renderer), + }; + } +}; diff --git a/zig-out/bin/wwm b/zig-out/bin/wwm new file mode 100755 index 0000000..1294713 Binary files /dev/null and b/zig-out/bin/wwm differ