This commit is contained in:
Harrison DiAmbrosio 2025-10-16 10:39:24 -04:00
commit 7325a3ee47
7 changed files with 170 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
.zig-cache/

71
build.zig Normal file
View file

@ -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);
}
}

29
build.zig.zon Normal file
View file

@ -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",
},
}

23
ideation.md Normal file
View file

@ -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();

7
src/main.zig Normal file
View file

@ -0,0 +1,7 @@
const std = @import("std");
const Server = @import("server.zig").Server;
pub fn main() !void {
std.debug.print("Starting wwm");
}

39
src/server.zig Normal file
View file

@ -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),
};
}
};

BIN
zig-out/bin/wwm Executable file

Binary file not shown.