build: update to zig version 0.9.0

This commit is contained in:
Isaac Freund 2021-10-11 12:44:46 +02:00
parent 1edaa5ad21
commit c1d985ac29
No known key found for this signature in database
GPG Key ID: 86DED400DDFD7A11
62 changed files with 349 additions and 383 deletions

View File

@ -10,7 +10,7 @@ name: voidlinux glibc
jobs: jobs:
default_build: default_build:
name: default build name: build/test/fmt
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: voidlinux/voidlinux:latest container: voidlinux/voidlinux:latest
@ -25,7 +25,7 @@ jobs:
libffi-devel wayland-protocols xcb-util-errors-devel xcb-util-wm-devel \ libffi-devel wayland-protocols xcb-util-errors-devel xcb-util-wm-devel \
xcb-util-renderutil-devel libxcb-devel xcb-util-cursor-devel xcb-util-devel \ xcb-util-renderutil-devel libxcb-devel xcb-util-cursor-devel xcb-util-devel \
xcb-util-image-devel xcb-util-keysyms-devel xcb-util-xrm-devel \ xcb-util-image-devel xcb-util-keysyms-devel xcb-util-xrm-devel \
xorg-server-xwayland pkg-config meson git gcc zig pkgconf scdoc xorg-server-xwayland pkg-config meson git gcc pkgconf scdoc wget tar xz
git clone https://gitlab.freedesktop.org/wayland/wayland.git git clone https://gitlab.freedesktop.org/wayland/wayland.git
cd wayland cd wayland
@ -40,6 +40,13 @@ jobs:
meson build --auto-features=enabled -Drenderers=gles2 -Dexamples=false \ meson build --auto-features=enabled -Drenderers=gles2 -Dexamples=false \
-Dwerror=false -Db_ndebug=false --prefix /usr -Dwerror=false -Db_ndebug=false --prefix /usr
ninja -C build install ninja -C build install
wget https://ziglang.org/download/0.9.0/zig-linux-x86_64-0.9.0.tar.xz
tar -xvf zig-linux-x86_64-0.9.0.tar.xz
mv zig-linux-x86_64-0.9.0/zig /usr/bin/
mv zig-linux-x86_64-0.9.0/lib /usr/lib/zig
zig env
- name: checkout - name: checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
with: with:
@ -53,65 +60,13 @@ jobs:
run: | run: |
zig build test zig build test
xwayland_build: - name: xwayland build
name: xwayland build
runs-on: ubuntu-latest
container: voidlinux/voidlinux:latest
steps:
- name: install deps
run: | run: |
xbps-install -Sy xbps zig build -Dxwayland
xbps-install -uy
# wayland/wlroots dependencies as well as we build from source
xbps-install -y MesaLib-devel libseat-devel eudev-libudev-devel libdrm-devel \
libinput-devel libxkbcommon-devel pixman-devel expat-devel libxml2-devel \
libffi-devel wayland-protocols xcb-util-errors-devel xcb-util-wm-devel \
xcb-util-renderutil-devel libxcb-devel xcb-util-cursor-devel xcb-util-devel \
xcb-util-image-devel xcb-util-keysyms-devel xcb-util-xrm-devel \
xorg-server-xwayland pkg-config meson git gcc zig pkgconf scdoc
git clone https://gitlab.freedesktop.org/wayland/wayland.git - name: xwayland test
cd wayland
git checkout 1.20.0
meson build -Ddocumentation=false -Dtests=false --prefix /usr
ninja -C build install
cd ..
git clone https://gitlab.freedesktop.org/wlroots/wlroots.git
cd wlroots
git checkout 0.15.0
meson build --auto-features=enabled -Drenderers=gles2 -Dexamples=false \
-Dwerror=false -Db_ndebug=false --prefix /usr
ninja -C build install
- name: checkout
uses: actions/checkout@v2
with:
submodules: true
- name: build
run: | run: |
zig build -Dxwayland=true zig build -Dxwayland test
- name: test
run: |
zig build -Dxwayland=true test
zig_fmt:
name: zig fmt
runs-on: ubuntu-latest
container: voidlinux/voidlinux:latest
steps:
- name: install deps
run: |
xbps-install -Sy xbps
xbps-install -uy zig git
- name: checkout
uses: actions/checkout@v2
with:
submodules: true
- name: fmt - name: fmt
run: | run: |

View File

@ -16,12 +16,6 @@ pub fn build(b: *zbs.Builder) !void {
const target = b.standardTargetOptions(.{}); const target = b.standardTargetOptions(.{});
const mode = b.standardReleaseOptions(); const mode = b.standardReleaseOptions();
const xwayland = b.option(
bool,
"xwayland",
"Set to true to enable xwayland support",
) orelse false;
const man_pages = b.option( const man_pages = b.option(
bool, bool,
"man-pages", "man-pages",
@ -52,6 +46,12 @@ pub fn build(b: *zbs.Builder) !void {
"Set to true to install fish completion for riverctl. Defaults to true.", "Set to true to install fish completion for riverctl. Defaults to true.",
) orelse true; ) orelse true;
const xwayland = b.option(
bool,
"xwayland",
"Set to true to enable xwayland support",
) orelse false;
const full_version = blk: { const full_version = blk: {
if (mem.endsWith(u8, version, "-dev")) { if (mem.endsWith(u8, version, "-dev")) {
var ret: u8 = undefined; var ret: u8 = undefined;
@ -70,6 +70,10 @@ pub fn build(b: *zbs.Builder) !void {
} }
}; };
const options = b.addOptions();
options.addOption(bool, "xwayland", xwayland);
options.addOption([]const u8, "version", full_version);
const scanner = ScanProtocolsStep.create(b); const scanner = ScanProtocolsStep.create(b);
scanner.addSystemProtocol("stable/xdg-shell/xdg-shell.xml"); scanner.addSystemProtocol("stable/xdg-shell/xdg-shell.xml");
scanner.addSystemProtocol("unstable/pointer-gestures/pointer-gestures-unstable-v1.xml"); scanner.addSystemProtocol("unstable/pointer-gestures/pointer-gestures-unstable-v1.xml");
@ -85,8 +89,7 @@ pub fn build(b: *zbs.Builder) !void {
const river = b.addExecutable("river", "river/main.zig"); const river = b.addExecutable("river", "river/main.zig");
river.setTarget(target); river.setTarget(target);
river.setBuildMode(mode); river.setBuildMode(mode);
river.addBuildOption(bool, "xwayland", xwayland); river.addOptions("build_options", options);
river.addBuildOption([:0]const u8, "version", full_version);
addServerDeps(river, scanner); addServerDeps(river, scanner);
@ -97,11 +100,14 @@ pub fn build(b: *zbs.Builder) !void {
const riverctl = b.addExecutable("riverctl", "riverctl/main.zig"); const riverctl = b.addExecutable("riverctl", "riverctl/main.zig");
riverctl.setTarget(target); riverctl.setTarget(target);
riverctl.setBuildMode(mode); riverctl.setBuildMode(mode);
riverctl.addBuildOption([:0]const u8, "version", full_version); riverctl.addOptions("build_options", options);
riverctl.step.dependOn(&scanner.step); riverctl.step.dependOn(&scanner.step);
riverctl.addPackage(scanner.getPkg());
riverctl.addPackagePath("flags", "common/flags.zig"); riverctl.addPackagePath("flags", "common/flags.zig");
riverctl.addPackage(.{
.name = "wayland",
.path = .{ .generated = &scanner.result },
});
riverctl.linkLibC(); riverctl.linkLibC();
riverctl.linkSystemLibrary("wayland-client"); riverctl.linkSystemLibrary("wayland-client");
@ -114,11 +120,14 @@ pub fn build(b: *zbs.Builder) !void {
const rivertile = b.addExecutable("rivertile", "rivertile/main.zig"); const rivertile = b.addExecutable("rivertile", "rivertile/main.zig");
rivertile.setTarget(target); rivertile.setTarget(target);
rivertile.setBuildMode(mode); rivertile.setBuildMode(mode);
rivertile.addBuildOption([:0]const u8, "version", full_version); rivertile.addOptions("build_options", options);
rivertile.step.dependOn(&scanner.step); rivertile.step.dependOn(&scanner.step);
rivertile.addPackage(scanner.getPkg());
rivertile.addPackagePath("flags", "common/flags.zig"); rivertile.addPackagePath("flags", "common/flags.zig");
rivertile.addPackage(.{
.name = "wayland",
.path = .{ .generated = &scanner.result },
});
rivertile.linkLibC(); rivertile.linkLibC();
rivertile.linkSystemLibrary("wayland-client"); rivertile.linkSystemLibrary("wayland-client");
@ -169,7 +178,7 @@ pub fn build(b: *zbs.Builder) !void {
const river_test = b.addTest("river/test_main.zig"); const river_test = b.addTest("river/test_main.zig");
river_test.setTarget(target); river_test.setTarget(target);
river_test.setBuildMode(mode); river_test.setBuildMode(mode);
river_test.addBuildOption(bool, "xwayland", xwayland); river_test.addOptions("build_options", options);
addServerDeps(river_test, scanner); addServerDeps(river_test, scanner);
@ -179,12 +188,21 @@ pub fn build(b: *zbs.Builder) !void {
} }
fn addServerDeps(exe: *zbs.LibExeObjStep, scanner: *ScanProtocolsStep) void { fn addServerDeps(exe: *zbs.LibExeObjStep, scanner: *ScanProtocolsStep) void {
const wayland = scanner.getPkg(); const wayland = zbs.Pkg{
const xkbcommon = zbs.Pkg{ .name = "xkbcommon", .path = "deps/zig-xkbcommon/src/xkbcommon.zig" }; .name = "wayland",
const pixman = zbs.Pkg{ .name = "pixman", .path = "deps/zig-pixman/pixman.zig" }; .path = .{ .generated = &scanner.result },
};
const xkbcommon = zbs.Pkg{
.name = "xkbcommon",
.path = .{ .path = "deps/zig-xkbcommon/src/xkbcommon.zig" },
};
const pixman = zbs.Pkg{
.name = "pixman",
.path = .{ .path = "deps/zig-pixman/pixman.zig" },
};
const wlroots = zbs.Pkg{ const wlroots = zbs.Pkg{
.name = "wlroots", .name = "wlroots",
.path = "deps/zig-wlroots/src/wlroots.zig", .path = .{ .path = "deps/zig-wlroots/src/wlroots.zig" },
.dependencies = &[_]zbs.Pkg{ wayland, xkbcommon, pixman }, .dependencies = &[_]zbs.Pkg{ wayland, xkbcommon, pixman },
}; };
@ -232,7 +250,7 @@ const ScdocStep = struct {
fn init(builder: *zbs.Builder) ScdocStep { fn init(builder: *zbs.Builder) ScdocStep {
return ScdocStep{ return ScdocStep{
.builder = builder, .builder = builder,
.step = zbs.Step.init(.Custom, "Generate man pages", builder.allocator, make), .step = zbs.Step.init(.custom, "Generate man pages", builder.allocator, make),
}; };
} }

2
deps/zig-pixman vendored

@ -1 +1 @@
Subproject commit 88520f264cd65153fe77ad2e5a17d22eee5e1af4 Subproject commit d381567de9b6e40dd7f4c6e0b5740f94ebd8c9d7

2
deps/zig-wayland vendored

@ -1 +1 @@
Subproject commit 38b5de89b3e3de670bb2496de56e5173d626fad5 Subproject commit 80166ba1d5b4f94c7972d6922587ba769be93f8a

2
deps/zig-wlroots vendored

@ -1 +1 @@
Subproject commit 0bb32072a435561cd2310901f8ee0c8e41b150db Subproject commit 417c10339e253a978135f48d5573932a340a6992

2
deps/zig-xkbcommon vendored

@ -1 +1 @@
Subproject commit 10cdca686dacb91d6cfe37f1839b6aedfb53cc4c Subproject commit 60dde0523907df672ec9ca8b9efb25a1c7ca4d82

View File

@ -94,16 +94,16 @@ pub fn init() !Self {
errdefer self.deinit(); errdefer self.deinit();
// Start with two empty modes, "normal" and "locked" // Start with two empty modes, "normal" and "locked"
try self.modes.ensureCapacity(2); try self.modes.ensureTotalCapacity(2);
{ {
// Normal mode, id 0 // Normal mode, id 0
const owned_slice = try std.mem.dupe(util.gpa, u8, "normal"); const owned_slice = try util.gpa.dupe(u8, "normal");
try self.mode_to_id.putNoClobber(owned_slice, 0); try self.mode_to_id.putNoClobber(owned_slice, 0);
self.modes.appendAssumeCapacity(Mode.init()); self.modes.appendAssumeCapacity(Mode.init());
} }
{ {
// Locked mode, id 1 // Locked mode, id 1
const owned_slice = try std.mem.dupe(util.gpa, u8, "locked"); const owned_slice = try util.gpa.dupe(u8, "locked");
try self.mode_to_id.putNoClobber(owned_slice, 1); try self.mode_to_id.putNoClobber(owned_slice, 1);
self.modes.appendAssumeCapacity(Mode.init()); self.modes.appendAssumeCapacity(Mode.init());
} }

View File

@ -48,7 +48,7 @@ pub fn init(self: *Self) !void {
server.wl_server.addDestroyListener(&self.server_destroy); server.wl_server.addDestroyListener(&self.server_destroy);
} }
fn handleServerDestroy(listener: *wl.Listener(*wl.Server), wl_server: *wl.Server) void { fn handleServerDestroy(listener: *wl.Listener(*wl.Server), _: *wl.Server) void {
const self = @fieldParentPtr(Self, "server_destroy", listener); const self = @fieldParentPtr(Self, "server_destroy", listener);
self.global.destroy(); self.global.destroy();
self.args_map.deinit(); self.args_map.deinit();

View File

@ -178,7 +178,7 @@ pub fn setTheme(self: *Self, theme: ?[*:0]const u8, _size: ?u32) !void {
// If this cursor belongs to the default seat, set the xcursor environment // If this cursor belongs to the default seat, set the xcursor environment
// variables and the xwayland cursor theme. // variables and the xwayland cursor theme.
if (self.seat == server.input_manager.defaultSeat()) { if (self.seat == server.input_manager.defaultSeat()) {
const size_str = try std.fmt.allocPrint0(util.gpa, "{}", .{size}); const size_str = try std.fmt.allocPrintZ(util.gpa, "{}", .{size});
defer util.gpa.free(size_str); defer util.gpa.free(size_str);
if (c.setenv("XCURSOR_SIZE", size_str, 1) < 0) return error.OutOfMemory; if (c.setenv("XCURSOR_SIZE", size_str, 1) < 0) return error.OutOfMemory;
if (theme) |t| if (c.setenv("XCURSOR_THEME", t, 1) < 0) return error.OutOfMemory; if (theme) |t| if (c.setenv("XCURSOR_THEME", t, 1) < 0) return error.OutOfMemory;
@ -400,7 +400,7 @@ fn handlePointerMapping(self: *Self, event: *wlr.Pointer.event.Button, view: *Vi
/// Frame events are sent after regular pointer events to group multiple /// Frame events are sent after regular pointer events to group multiple
/// events together. For instance, two axis events may happen at the same /// events together. For instance, two axis events may happen at the same
/// time, in which case a frame event won't be sent in between. /// time, in which case a frame event won't be sent in between.
fn handleFrame(listener: *wl.Listener(*wlr.Cursor), wlr_cursor: *wlr.Cursor) void { fn handleFrame(listener: *wl.Listener(*wlr.Cursor), _: *wlr.Cursor) void {
const self = @fieldParentPtr(Self, "frame", listener); const self = @fieldParentPtr(Self, "frame", listener);
self.seat.wlr_seat.pointerNotifyFrame(); self.seat.wlr_seat.pointerNotifyFrame();
} }
@ -867,7 +867,7 @@ pub fn updateState(self: *Self) void {
if (self.shouldPassthrough()) { if (self.shouldPassthrough()) {
self.mode = .passthrough; self.mode = .passthrough;
var now: os.timespec = undefined; var now: os.timespec = undefined;
os.clock_gettime(os.CLOCK_MONOTONIC, &now) catch @panic("CLOCK_MONOTONIC not supported"); os.clock_gettime(os.CLOCK.MONOTONIC, &now) catch @panic("CLOCK_MONOTONIC not supported");
const msec = @intCast(u32, now.tv_sec * std.time.ms_per_s + const msec = @intCast(u32, now.tv_sec * std.time.ms_per_s +
@divFloor(now.tv_nsec, std.time.ns_per_ms)); @divFloor(now.tv_nsec, std.time.ns_per_ms));
self.passthrough(msec); self.passthrough(msec);

View File

@ -46,7 +46,7 @@ pub fn init(self: *Self, xdg_toplevel_decoration: *wlr.XdgToplevelDecorationV1)
fn handleDestroy( fn handleDestroy(
listener: *wl.Listener(*wlr.XdgToplevelDecorationV1), listener: *wl.Listener(*wlr.XdgToplevelDecorationV1),
xdg_toplevel_decoration: *wlr.XdgToplevelDecorationV1, _: *wlr.XdgToplevelDecorationV1,
) void { ) void {
const self = @fieldParentPtr(Self, "destroy", listener); const self = @fieldParentPtr(Self, "destroy", listener);
self.destroy.link.remove(); self.destroy.link.remove();
@ -59,7 +59,7 @@ fn handleDestroy(
fn handleRequestMode( fn handleRequestMode(
listener: *wl.Listener(*wlr.XdgToplevelDecorationV1), listener: *wl.Listener(*wlr.XdgToplevelDecorationV1),
xdg_toplevel_decoration: *wlr.XdgToplevelDecorationV1, _: *wlr.XdgToplevelDecorationV1,
) void { ) void {
const self = @fieldParentPtr(Self, "request_mode", listener); const self = @fieldParentPtr(Self, "request_mode", listener);

View File

@ -74,16 +74,15 @@ fn handleMap(listener: *wl.Listener(*wlr.Drag.Icon), wlr_drag_icon: *wlr.Drag.Ic
while (it) |node| : (it = node.next) node.data.damage.addWhole(); while (it) |node| : (it = node.next) node.data.damage.addWhole();
} }
fn handleUnmap(listener: *wl.Listener(*wlr.Drag.Icon), wlr_drag_icon: *wlr.Drag.Icon) void { fn handleUnmap(listener: *wl.Listener(*wlr.Drag.Icon), _: *wlr.Drag.Icon) void {
const drag_icon = @fieldParentPtr(DragIcon, "unmap", listener); const drag_icon = @fieldParentPtr(DragIcon, "unmap", listener);
drag_icon.commit.link.remove(); drag_icon.commit.link.remove();
var it = server.root.outputs.first; var it = server.root.outputs.first;
while (it) |node| : (it = node.next) node.data.damage.addWhole(); while (it) |node| : (it = node.next) node.data.damage.addWhole();
} }
fn handleCommit(listener: *wl.Listener(*wlr.Surface), surface: *wlr.Surface) void {
const drag_icon = @fieldParentPtr(DragIcon, "commit", listener);
fn handleCommit(_: *wl.Listener(*wlr.Surface), _: *wlr.Surface) void {
var it = server.root.outputs.first; var it = server.root.outputs.first;
while (it) |node| : (it = node.next) node.data.damage.addWhole(); while (it) |node| : (it = node.next) node.data.damage.addWhole();
} }

View File

@ -59,7 +59,7 @@ pub const AccelProfile = enum {
adaptive, adaptive,
pub fn apply(accel_profile: AccelProfile, device: *c.libinput_device) void { pub fn apply(accel_profile: AccelProfile, device: *c.libinput_device) void {
const want = @intToEnum(c.libinput_config_accel_profile, switch (accel_profile) { const want = @as(c_uint, switch (accel_profile) {
.none => c.LIBINPUT_CONFIG_ACCEL_PROFILE_NONE, .none => c.LIBINPUT_CONFIG_ACCEL_PROFILE_NONE,
.flat => c.LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT, .flat => c.LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT,
.adaptive => c.LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE, .adaptive => c.LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE,
@ -78,13 +78,13 @@ pub const ClickMethod = enum {
clickfinger, clickfinger,
pub fn apply(click_method: ClickMethod, device: *c.libinput_device) void { pub fn apply(click_method: ClickMethod, device: *c.libinput_device) void {
const want = @intToEnum(c.libinput_config_click_method, switch (click_method) { const want = @as(c_uint, switch (click_method) {
.none => c.LIBINPUT_CONFIG_CLICK_METHOD_NONE, .none => c.LIBINPUT_CONFIG_CLICK_METHOD_NONE,
.@"button-areas" => c.LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS, .@"button-areas" => c.LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS,
.clickfinger => c.LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER, .clickfinger => c.LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER,
}); });
const supports = c.libinput_device_config_click_get_methods(device); const supports = c.libinput_device_config_click_get_methods(device);
if (supports & @intCast(u32, @enumToInt(want)) == 0) return; if (supports & want == 0) return;
_ = c.libinput_device_config_click_set_method(device, want); _ = c.libinput_device_config_click_set_method(device, want);
} }
}; };
@ -94,7 +94,7 @@ pub const DragState = enum {
enabled, enabled,
pub fn apply(drag_state: DragState, device: *c.libinput_device) void { pub fn apply(drag_state: DragState, device: *c.libinput_device) void {
const want = @intToEnum(c.libinput_config_drag_state, switch (drag_state) { const want = @as(c_uint, switch (drag_state) {
.disabled => c.LIBINPUT_CONFIG_DRAG_DISABLED, .disabled => c.LIBINPUT_CONFIG_DRAG_DISABLED,
.enabled => c.LIBINPUT_CONFIG_DRAG_ENABLED, .enabled => c.LIBINPUT_CONFIG_DRAG_ENABLED,
}); });
@ -111,7 +111,7 @@ pub const DragLock = enum {
enabled, enabled,
pub fn apply(drag_lock: DragLock, device: *c.libinput_device) void { pub fn apply(drag_lock: DragLock, device: *c.libinput_device) void {
const want = @intToEnum(c.libinput_config_drag_lock_state, switch (drag_lock) { const want = @as(c_uint, switch (drag_lock) {
.disabled => c.LIBINPUT_CONFIG_DRAG_LOCK_DISABLED, .disabled => c.LIBINPUT_CONFIG_DRAG_LOCK_DISABLED,
.enabled => c.LIBINPUT_CONFIG_DRAG_LOCK_ENABLED, .enabled => c.LIBINPUT_CONFIG_DRAG_LOCK_ENABLED,
}); });
@ -128,7 +128,7 @@ pub const DwtState = enum {
enabled, enabled,
pub fn apply(dwt_state: DwtState, device: *c.libinput_device) void { pub fn apply(dwt_state: DwtState, device: *c.libinput_device) void {
const want = @intToEnum(c.libinput_config_dwt_state, switch (dwt_state) { const want = @as(c_uint, switch (dwt_state) {
.disabled => c.LIBINPUT_CONFIG_DWT_DISABLED, .disabled => c.LIBINPUT_CONFIG_DWT_DISABLED,
.enabled => c.LIBINPUT_CONFIG_DWT_ENABLED, .enabled => c.LIBINPUT_CONFIG_DWT_ENABLED,
}); });
@ -145,7 +145,7 @@ pub const MiddleEmulation = enum {
enabled, enabled,
pub fn apply(middle_emulation: MiddleEmulation, device: *c.libinput_device) void { pub fn apply(middle_emulation: MiddleEmulation, device: *c.libinput_device) void {
const want = @intToEnum(c.libinput_config_middle_emulation_state, switch (middle_emulation) { const want = @as(c_uint, switch (middle_emulation) {
.disabled => c.LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED, .disabled => c.LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED,
.enabled => c.LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED, .enabled => c.LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED,
}); });
@ -196,7 +196,7 @@ pub const TapState = enum {
enabled, enabled,
pub fn apply(tap_state: TapState, device: *c.libinput_device) void { pub fn apply(tap_state: TapState, device: *c.libinput_device) void {
const want = @intToEnum(c.libinput_config_tap_state, switch (tap_state) { const want = @as(c_uint, switch (tap_state) {
.disabled => c.LIBINPUT_CONFIG_TAP_DISABLED, .disabled => c.LIBINPUT_CONFIG_TAP_DISABLED,
.enabled => c.LIBINPUT_CONFIG_TAP_ENABLED, .enabled => c.LIBINPUT_CONFIG_TAP_ENABLED,
}); });
@ -213,7 +213,7 @@ pub const TapButtonMap = enum {
@"left-right-middle", @"left-right-middle",
pub fn apply(tap_button_map: TapButtonMap, device: *c.libinput_device) void { pub fn apply(tap_button_map: TapButtonMap, device: *c.libinput_device) void {
const want = @intToEnum(c.libinput_config_tap_button_map, switch (tap_button_map) { const want = @as(c_uint, switch (tap_button_map) {
.@"left-right-middle" => c.LIBINPUT_CONFIG_TAP_MAP_LRM, .@"left-right-middle" => c.LIBINPUT_CONFIG_TAP_MAP_LRM,
.@"left-middle-right" => c.LIBINPUT_CONFIG_TAP_MAP_LMR, .@"left-middle-right" => c.LIBINPUT_CONFIG_TAP_MAP_LMR,
}); });
@ -243,14 +243,14 @@ pub const ScrollMethod = enum {
button, button,
pub fn apply(scroll_method: ScrollMethod, device: *c.libinput_device) void { pub fn apply(scroll_method: ScrollMethod, device: *c.libinput_device) void {
const want = @intToEnum(c.libinput_config_scroll_method, switch (scroll_method) { const want = @as(c_uint, switch (scroll_method) {
.none => c.LIBINPUT_CONFIG_SCROLL_NO_SCROLL, .none => c.LIBINPUT_CONFIG_SCROLL_NO_SCROLL,
.@"two-finger" => c.LIBINPUT_CONFIG_SCROLL_2FG, .@"two-finger" => c.LIBINPUT_CONFIG_SCROLL_2FG,
.edge => c.LIBINPUT_CONFIG_SCROLL_EDGE, .edge => c.LIBINPUT_CONFIG_SCROLL_EDGE,
.button => c.LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN, .button => c.LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN,
}); });
const supports = c.libinput_device_config_scroll_get_methods(device); const supports = c.libinput_device_config_scroll_get_methods(device);
if (supports & @intCast(u32, @enumToInt(want)) == 0) return; if (supports & want == 0) return;
_ = c.libinput_device_config_scroll_set_method(device, want); _ = c.libinput_device_config_scroll_set_method(device, want);
} }
}; };

View File

@ -71,7 +71,7 @@ pub const InputDevice = struct {
self.destroy.link.remove(); self.destroy.link.remove();
} }
fn handleDestroy(listener: *wl.Listener(*wlr.InputDevice), device: *wlr.InputDevice) void { fn handleDestroy(listener: *wl.Listener(*wlr.InputDevice), _: *wlr.InputDevice) void {
const self = @fieldParentPtr(InputDevice, "destroy", listener); const self = @fieldParentPtr(InputDevice, "destroy", listener);
log.debug("removed input device: {s}", .{self.identifier}); log.debug("removed input device: {s}", .{self.identifier});
self.deinit(); self.deinit();
@ -172,7 +172,7 @@ pub fn updateCursorState(self: Self) void {
fn handleInhibitActivate( fn handleInhibitActivate(
listener: *wl.Listener(*wlr.InputInhibitManager), listener: *wl.Listener(*wlr.InputInhibitManager),
input_inhibit_manager: *wlr.InputInhibitManager, _: *wlr.InputInhibitManager,
) void { ) void {
const self = @fieldParentPtr(Self, "inhibit_activate", listener); const self = @fieldParentPtr(Self, "inhibit_activate", listener);
@ -193,7 +193,7 @@ fn handleInhibitActivate(
fn handleInhibitDeactivate( fn handleInhibitDeactivate(
listener: *wl.Listener(*wlr.InputInhibitManager), listener: *wl.Listener(*wlr.InputInhibitManager),
input_inhibit_manager: *wlr.InputInhibitManager, _: *wlr.InputInhibitManager,
) void { ) void {
const self = @fieldParentPtr(Self, "inhibit_deactivate", listener); const self = @fieldParentPtr(Self, "inhibit_deactivate", listener);
@ -241,9 +241,13 @@ fn handleNewInput(listener: *wl.Listener(*wlr.InputDevice), device: *wlr.InputDe
} }
} }
fn handleNewPointerConstraint(listener: *wl.Listener(*wlr.PointerConstraintV1), constraint: *wlr.PointerConstraintV1) void { fn handleNewPointerConstraint(
_: *wl.Listener(*wlr.PointerConstraintV1),
constraint: *wlr.PointerConstraintV1,
) void {
const pointer_constraint = util.gpa.create(PointerConstraint) catch { const pointer_constraint = util.gpa.create(PointerConstraint) catch {
log.crit("out of memory", .{}); constraint.resource.getClient().postNoMemory();
log.err("out of memory", .{});
return; return;
}; };
@ -269,10 +273,9 @@ fn handleNewVirtualPointer(
} }
fn handleNewVirtualKeyboard( fn handleNewVirtualKeyboard(
listener: *wl.Listener(*wlr.VirtualKeyboardV1), _: *wl.Listener(*wlr.VirtualKeyboardV1),
virtual_keyboard: *wlr.VirtualKeyboardV1, virtual_keyboard: *wlr.VirtualKeyboardV1,
) void { ) void {
const self = @fieldParentPtr(Self, "new_virtual_keyboard", listener);
const seat = @intToPtr(*Seat, virtual_keyboard.seat.data); const seat = @intToPtr(*Seat, virtual_keyboard.seat.data);
seat.addDevice(&virtual_keyboard.input_device); seat.addDevice(&virtual_keyboard.input_device);
} }

View File

@ -95,7 +95,7 @@ fn handleKey(listener: *wl.Listener(*wlr.Keyboard.event.Key), event: *wlr.Keyboa
// First check translated keysyms as xkb reports them // First check translated keysyms as xkb reports them
for (wlr_keyboard.xkb_state.?.keyGetSyms(keycode)) |sym| { for (wlr_keyboard.xkb_state.?.keyGetSyms(keycode)) |sym| {
// Handle builtin mapping only when keys are pressed // Handle builtin mapping only when keys are pressed
if (!released and self.handleBuiltinMapping(sym)) { if (!released and handleBuiltinMapping(sym)) {
handled = true; handled = true;
break; break;
} else if (self.seat.handleMapping(sym, modifiers, released)) { } else if (self.seat.handleMapping(sym, modifiers, released)) {
@ -110,7 +110,7 @@ fn handleKey(listener: *wl.Listener(*wlr.Keyboard.event.Key), event: *wlr.Keyboa
const layout_index = wlr_keyboard.xkb_state.?.keyGetLayout(keycode); const layout_index = wlr_keyboard.xkb_state.?.keyGetLayout(keycode);
for (wlr_keyboard.keymap.?.keyGetSymsByLevel(keycode, layout_index, 0)) |sym| { for (wlr_keyboard.keymap.?.keyGetSymsByLevel(keycode, layout_index, 0)) |sym| {
// Handle builtin mapping only when keys are pressed // Handle builtin mapping only when keys are pressed
if (!released and self.handleBuiltinMapping(sym)) { if (!released and handleBuiltinMapping(sym)) {
handled = true; handled = true;
break; break;
} else if (self.seat.handleMapping(sym, modifiers, released)) { } else if (self.seat.handleMapping(sym, modifiers, released)) {
@ -129,14 +129,14 @@ fn handleKey(listener: *wl.Listener(*wlr.Keyboard.event.Key), event: *wlr.Keyboa
} }
/// Simply pass modifiers along to the client /// Simply pass modifiers along to the client
fn handleModifiers(listener: *wl.Listener(*wlr.Keyboard), wlr_keyboard: *wlr.Keyboard) void { fn handleModifiers(listener: *wl.Listener(*wlr.Keyboard), _: *wlr.Keyboard) void {
const self = @fieldParentPtr(Self, "modifiers", listener); const self = @fieldParentPtr(Self, "modifiers", listener);
self.seat.wlr_seat.setKeyboard(self.input_device); self.seat.wlr_seat.setKeyboard(self.input_device);
self.seat.wlr_seat.keyboardNotifyModifiers(&self.input_device.device.keyboard.modifiers); self.seat.wlr_seat.keyboardNotifyModifiers(&self.input_device.device.keyboard.modifiers);
} }
fn handleDestroy(listener: *wl.Listener(*wlr.Keyboard), wlr_keyboard: *wlr.Keyboard) void { fn handleDestroy(listener: *wl.Listener(*wlr.Keyboard), _: *wlr.Keyboard) void {
const self = @fieldParentPtr(Self, "destroy", listener); const self = @fieldParentPtr(Self, "destroy", listener);
const node = @fieldParentPtr(std.TailQueue(Self).Node, "data", self); const node = @fieldParentPtr(std.TailQueue(Self).Node, "data", self);
@ -147,15 +147,15 @@ fn handleDestroy(listener: *wl.Listener(*wlr.Keyboard), wlr_keyboard: *wlr.Keybo
/// Handle any builtin, harcoded compsitor mappings such as VT switching. /// Handle any builtin, harcoded compsitor mappings such as VT switching.
/// Returns true if the keysym was handled. /// Returns true if the keysym was handled.
fn handleBuiltinMapping(self: Self, keysym: xkb.Keysym) bool { fn handleBuiltinMapping(keysym: xkb.Keysym) bool {
switch (@enumToInt(keysym)) { switch (@enumToInt(keysym)) {
@enumToInt(xkb.Keysym.XF86Switch_VT_1)...@enumToInt(xkb.Keysym.XF86Switch_VT_12) => { xkb.Keysym.XF86Switch_VT_1...xkb.Keysym.XF86Switch_VT_12 => {
log.debug("switch VT keysym received", .{}); log.debug("switch VT keysym received", .{});
if (server.backend.isMulti()) { if (server.backend.isMulti()) {
if (server.backend.getSession()) |session| { if (server.backend.getSession()) |session| {
const vt = @enumToInt(keysym) - @enumToInt(xkb.Keysym.XF86Switch_VT_1) + 1; const vt = @enumToInt(keysym) - xkb.Keysym.XF86Switch_VT_1 + 1;
const log_server = std.log.scoped(.server); const log_server = std.log.scoped(.server);
log_server.notice("switching to VT {}", .{vt}); log_server.info("switching to VT {}", .{vt});
session.changeVt(vt) catch log_server.err("changing VT failed", .{}); session.changeVt(vt) catch log_server.err("changing VT failed", .{});
} }
} }

View File

@ -105,7 +105,7 @@ fn handleMap(listener: *wl.Listener(*wlr.LayerSurfaceV1), wlr_layer_surface: *wl
self.output.arrangeLayers(.mapped); self.output.arrangeLayers(.mapped);
} }
fn handleUnmap(listener: *wl.Listener(*wlr.LayerSurfaceV1), wlr_layer_surface: *wlr.LayerSurfaceV1) void { fn handleUnmap(listener: *wl.Listener(*wlr.LayerSurfaceV1), _: *wlr.LayerSurfaceV1) void {
const self = @fieldParentPtr(Self, "unmap", listener); const self = @fieldParentPtr(Self, "unmap", listener);
log.debug("layer surface '{s}' unmapped", .{self.wlr_layer_surface.namespace}); log.debug("layer surface '{s}' unmapped", .{self.wlr_layer_surface.namespace});
@ -137,7 +137,7 @@ fn handleUnmap(listener: *wl.Listener(*wlr.LayerSurfaceV1), wlr_layer_surface: *
server.root.startTransaction(); server.root.startTransaction();
} }
fn handleCommit(listener: *wl.Listener(*wlr.Surface), wlr_surface: *wlr.Surface) void { fn handleCommit(listener: *wl.Listener(*wlr.Surface), _: *wlr.Surface) void {
const self = @fieldParentPtr(Self, "commit", listener); const self = @fieldParentPtr(Self, "commit", listener);
assert(self.wlr_layer_surface.output != null); assert(self.wlr_layer_surface.output != null);

View File

@ -45,7 +45,7 @@ pub fn create(client: *wl.Client, version: u32, id: u32, output: *Output, namesp
if (namespaceInUse(namespace, output, client)) { if (namespaceInUse(namespace, output, client)) {
layout.sendNamespaceInUse(); layout.sendNamespaceInUse();
layout.setHandler(?*c_void, handleRequestInert, null, null); layout.setHandler(?*anyopaque, handleRequestInert, null, null);
return; return;
} }
@ -92,7 +92,7 @@ fn namespaceInUse(namespace: []const u8, output: *Output, client: *wl.Client) bo
/// This exists to handle layouts that have been rendered inert (due to the /// This exists to handle layouts that have been rendered inert (due to the
/// namespace already being in use) until the client destroys them. /// namespace already being in use) until the client destroys them.
fn handleRequestInert(layout: *river.LayoutV3, request: river.LayoutV3.Request, _: ?*c_void) void { fn handleRequestInert(layout: *river.LayoutV3, request: river.LayoutV3.Request, _: ?*anyopaque) void {
if (request == .destroy) layout.destroy(); if (request == .destroy) layout.destroy();
} }
@ -159,7 +159,7 @@ fn handleRequest(layout: *river.LayoutV3, request: river.LayoutV3.Request, self:
} }
} }
fn handleDestroy(layout: *river.LayoutV3, self: *Self) void { fn handleDestroy(_: *river.LayoutV3, self: *Self) void {
self.destroy(); self.destroy();
} }
@ -183,7 +183,7 @@ pub fn destroy(self: *Self) void {
} }
} }
self.layout.setHandler(?*c_void, handleRequestInert, null, null); self.layout.setHandler(?*anyopaque, handleRequestInert, null, null);
util.gpa.free(self.namespace); util.gpa.free(self.namespace);
util.gpa.destroy(node); util.gpa.destroy(node);

View File

@ -70,7 +70,7 @@ pub fn deinit(self: *const Self) void {
/// Destroy the LayoutDemand on timeout. /// Destroy the LayoutDemand on timeout.
/// All further responses to the event will simply be ignored. /// All further responses to the event will simply be ignored.
fn handleTimeout(layout: *Layout) callconv(.C) c_int { fn handleTimeout(layout: *Layout) callconv(.C) c_int {
log.notice( log.info(
"layout demand for layout '{s}' on output '{s}' timed out", "layout demand for layout '{s}' on output '{s}' timed out",
.{ layout.namespace, layout.output.wlr_output.name }, .{ layout.namespace, layout.output.wlr_output.name },
); );

View File

@ -38,27 +38,31 @@ server_destroy: wl.Listener(*wl.Server) = wl.Listener(*wl.Server).init(handleSer
pub fn init(self: *Self) !void { pub fn init(self: *Self) !void {
self.* = .{ self.* = .{
.global = try wl.Global.create(server.wl_server, river.LayoutManagerV3, 1, *Self, self, bind), .global = try wl.Global.create(server.wl_server, river.LayoutManagerV3, 1, ?*anyopaque, null, bind),
}; };
server.wl_server.addDestroyListener(&self.server_destroy); server.wl_server.addDestroyListener(&self.server_destroy);
} }
fn handleServerDestroy(listener: *wl.Listener(*wl.Server), wl_server: *wl.Server) void { fn handleServerDestroy(listener: *wl.Listener(*wl.Server), _: *wl.Server) void {
const self = @fieldParentPtr(Self, "server_destroy", listener); const self = @fieldParentPtr(Self, "server_destroy", listener);
self.global.destroy(); self.global.destroy();
} }
fn bind(client: *wl.Client, self: *Self, version: u32, id: u32) callconv(.C) void { fn bind(client: *wl.Client, _: ?*anyopaque, version: u32, id: u32) callconv(.C) void {
const layout_manager = river.LayoutManagerV3.create(client, 1, id) catch { const layout_manager = river.LayoutManagerV3.create(client, version, id) catch {
client.postNoMemory(); client.postNoMemory();
log.crit("out of memory", .{}); log.err("out of memory", .{});
return; return;
}; };
layout_manager.setHandler(*Self, handleRequest, null, self); layout_manager.setHandler(?*anyopaque, handleRequest, null, null);
} }
fn handleRequest(layout_manager: *river.LayoutManagerV3, request: river.LayoutManagerV3.Request, self: *Self) void { fn handleRequest(
layout_manager: *river.LayoutManagerV3,
request: river.LayoutManagerV3.Request,
_: ?*anyopaque,
) void {
switch (request) { switch (request) {
.destroy => layout_manager.destroy(), .destroy => layout_manager.destroy(),
@ -77,7 +81,7 @@ fn handleRequest(layout_manager: *river.LayoutManagerV3, request: river.LayoutMa
mem.span(req.namespace), mem.span(req.namespace),
) catch { ) catch {
layout_manager.getClient().postNoMemory(); layout_manager.getClient().postNoMemory();
log.crit("out of memory", .{}); log.err("out of memory", .{});
return; return;
}; };
}, },

View File

@ -44,7 +44,7 @@ pub fn init(
errdefer util.gpa.free(owned_args); errdefer util.gpa.free(owned_args);
for (command_args) |arg, i| { for (command_args) |arg, i| {
errdefer for (owned_args[0..i]) |a| util.gpa.free(a); errdefer for (owned_args[0..i]) |a| util.gpa.free(a);
owned_args[i] = try std.mem.dupeZ(util.gpa, u8, arg); owned_args[i] = try util.gpa.dupeZ(u8, arg);
} }
return Self{ return Self{
.keysym = keysym, .keysym = keysym,

View File

@ -236,7 +236,7 @@ pub fn arrangeLayers(self: *Self, target: ArrangeLayersTarget) void {
// Arrange all layer surfaces with exclusive zones, applying them to the // Arrange all layer surfaces with exclusive zones, applying them to the
// usable box along the way. // usable box along the way.
for (layers) |layer| self.arrangeLayer(self.getLayer(layer).*, full_box, &usable_box, true, target); for (layers) |layer| arrangeLayer(self.getLayer(layer).*, full_box, &usable_box, true, target);
// If the the usable_box has changed, we need to rearrange the output // If the the usable_box has changed, we need to rearrange the output
if (target == .mapped and !std.meta.eql(self.usable_box, usable_box)) { if (target == .mapped and !std.meta.eql(self.usable_box, usable_box)) {
@ -245,7 +245,7 @@ pub fn arrangeLayers(self: *Self, target: ArrangeLayersTarget) void {
} }
// Arrange the layers without exclusive zones // Arrange the layers without exclusive zones
for (layers) |layer| self.arrangeLayer(self.getLayer(layer).*, full_box, &usable_box, false, target); for (layers) |layer| arrangeLayer(self.getLayer(layer).*, full_box, &usable_box, false, target);
if (target == .unmapped) return; if (target == .unmapped) return;
@ -286,7 +286,6 @@ pub fn arrangeLayers(self: *Self, target: ArrangeLayersTarget) void {
/// Arrange the layer surfaces of a given layer /// Arrange the layer surfaces of a given layer
fn arrangeLayer( fn arrangeLayer(
self: *Self,
layer: std.TailQueue(LayerSurface), layer: std.TailQueue(LayerSurface),
full_box: Box, full_box: Box,
usable_box: *Box, usable_box: *Box,
@ -424,7 +423,7 @@ fn arrangeLayer(
} }
} }
fn handleDamageDestroy(listener: *wl.Listener(*wlr.OutputDamage), wlr_output: *wlr.OutputDamage) void { fn handleDamageDestroy(listener: *wl.Listener(*wlr.OutputDamage), _: *wlr.OutputDamage) void {
const self = @fieldParentPtr(Self, "damage_destroy", listener); const self = @fieldParentPtr(Self, "damage_destroy", listener);
// The wlr.OutputDamage is only destroyed by wlroots when the output is // The wlr.OutputDamage is only destroyed by wlroots when the output is
// destroyed and is never destroyed manually by river. // destroyed and is never destroyed manually by river.
@ -433,7 +432,7 @@ fn handleDamageDestroy(listener: *wl.Listener(*wlr.OutputDamage), wlr_output: *w
self.frame.link = .{ .prev = &self.frame.link, .next = &self.frame.link }; self.frame.link = .{ .prev = &self.frame.link, .next = &self.frame.link };
} }
fn handleDestroy(listener: *wl.Listener(*wlr.Output), wlr_output: *wlr.Output) void { fn handleDestroy(listener: *wl.Listener(*wlr.Output), _: *wlr.Output) void {
const self = @fieldParentPtr(Self, "destroy", listener); const self = @fieldParentPtr(Self, "destroy", listener);
std.log.scoped(.server).debug("output '{s}' destroyed", .{self.wlr_output.name}); std.log.scoped(.server).debug("output '{s}' destroyed", .{self.wlr_output.name});
@ -476,14 +475,14 @@ fn handleEnable(listener: *wl.Listener(*wlr.Output), wlr_output: *wlr.Output) vo
if (wlr_output.enabled) server.root.addOutput(self); if (wlr_output.enabled) server.root.addOutput(self);
} }
fn handleFrame(listener: *wl.Listener(*wlr.OutputDamage), wlr_output: *wlr.OutputDamage) void { fn handleFrame(listener: *wl.Listener(*wlr.OutputDamage), _: *wlr.OutputDamage) void {
// This function is called every time an output is ready to display a frame, // This function is called every time an output is ready to display a frame,
// generally at the output's refresh rate (e.g. 60Hz). // generally at the output's refresh rate (e.g. 60Hz).
const self = @fieldParentPtr(Self, "frame", listener); const self = @fieldParentPtr(Self, "frame", listener);
render.renderOutput(self); render.renderOutput(self);
} }
fn handleMode(listener: *wl.Listener(*wlr.Output), wlr_output: *wlr.Output) void { fn handleMode(listener: *wl.Listener(*wlr.Output), _: *wlr.Output) void {
const self = @fieldParentPtr(Self, "mode", listener); const self = @fieldParentPtr(Self, "mode", listener);
self.arrangeLayers(.mapped); self.arrangeLayers(.mapped);
self.arrangeViews(); self.arrangeViews();

View File

@ -57,13 +57,13 @@ pub fn destroy(self: *Self) void {
util.gpa.destroy(node); util.gpa.destroy(node);
} }
fn handleRequest(output_status: *zriver.OutputStatusV1, request: zriver.OutputStatusV1.Request, self: *Self) void { fn handleRequest(output_status: *zriver.OutputStatusV1, request: zriver.OutputStatusV1.Request, _: *Self) void {
switch (request) { switch (request) {
.destroy => output_status.destroy(), .destroy => output_status.destroy(),
} }
} }
fn handleDestroy(output_status: *zriver.OutputStatusV1, self: *Self) void { fn handleDestroy(_: *zriver.OutputStatusV1, self: *Self) void {
self.destroy(); self.destroy();
} }
@ -77,7 +77,7 @@ pub fn sendViewTags(self: Self) void {
if (node.view.surface == null) continue; if (node.view.surface == null) continue;
view_tags.append(node.view.current.tags) catch { view_tags.append(node.view.current.tags) catch {
self.output_status.postNoMemory(); self.output_status.postNoMemory();
log.crit("out of memory", .{}); log.err("out of memory", .{});
return; return;
}; };
} }

View File

@ -23,7 +23,6 @@ const wlr = @import("wlroots");
const wl = @import("wayland").server.wl; const wl = @import("wayland").server.wl;
const pixman = @import("pixman"); const pixman = @import("pixman");
const log = @import("log.zig");
const server = &@import("main.zig").server; const server = &@import("main.zig").server;
const util = @import("util.zig"); const util = @import("util.zig");
@ -103,7 +102,7 @@ fn constrainToRegion(self: *Self) void {
} }
} }
fn handleDestroy(listener: *wl.Listener(*wlr.PointerConstraintV1), constraint: *wlr.PointerConstraintV1) void { fn handleDestroy(listener: *wl.Listener(*wlr.PointerConstraintV1), _: *wlr.PointerConstraintV1) void {
const self = @fieldParentPtr(Self, "destroy", listener); const self = @fieldParentPtr(Self, "destroy", listener);
self.destroy.link.remove(); self.destroy.link.remove();

View File

@ -408,14 +408,11 @@ fn commitTransaction(self: *Self) void {
} }
/// Send the new output configuration to all wlr-output-manager clients /// Send the new output configuration to all wlr-output-manager clients
fn handleLayoutChange( fn handleLayoutChange(listener: *wl.Listener(*wlr.OutputLayout), _: *wlr.OutputLayout) void {
listener: *wl.Listener(*wlr.OutputLayout),
output_layout: *wlr.OutputLayout,
) void {
const self = @fieldParentPtr(Self, "layout_change", listener); const self = @fieldParentPtr(Self, "layout_change", listener);
const config = self.outputConfigFromCurrent() catch { const config = self.outputConfigFromCurrent() catch {
std.log.scoped(.output_manager).crit("out of memory", .{}); std.log.scoped(.output_manager).err("out of memory", .{});
return; return;
}; };
self.output_manager.setConfiguration(config); self.output_manager.setConfiguration(config);
@ -436,17 +433,16 @@ fn handleManagerApply(
// Send the config that was actually applied // Send the config that was actually applied
const applied_config = self.outputConfigFromCurrent() catch { const applied_config = self.outputConfigFromCurrent() catch {
std.log.scoped(.output_manager).crit("out of memory", .{}); std.log.scoped(.output_manager).err("out of memory", .{});
return; return;
}; };
self.output_manager.setConfiguration(applied_config); self.output_manager.setConfiguration(applied_config);
} }
fn handleManagerTest( fn handleManagerTest(
listener: *wl.Listener(*wlr.OutputConfigurationV1), _: *wl.Listener(*wlr.OutputConfigurationV1),
config: *wlr.OutputConfigurationV1, config: *wlr.OutputConfigurationV1,
) void { ) void {
const self = @fieldParentPtr(Self, "manager_test", listener);
defer config.destroy(); defer config.destroy();
if (testOutputConfig(config, true)) { if (testOutputConfig(config, true)) {
@ -553,6 +549,8 @@ fn applyHeadToOutput(head: *wlr.OutputConfigurationV1.Head, wlr_output: *wlr.Out
/// Create the config describing the current configuration /// Create the config describing the current configuration
fn outputConfigFromCurrent(self: *Self) !*wlr.OutputConfigurationV1 { fn outputConfigFromCurrent(self: *Self) !*wlr.OutputConfigurationV1 {
// TODO there no real reason this needs to allocate memory every time it is called.
// consider improving this wlroots api or reimplementing in zig-wlroots/river.
const config = try wlr.OutputConfigurationV1.create(); const config = try wlr.OutputConfigurationV1.create();
// this destroys all associated config heads as well // this destroys all associated config heads as well
errdefer config.destroy(); errdefer config.destroy();
@ -575,11 +573,9 @@ fn createHead(self: *Self, output: *Output, config: *wlr.OutputConfigurationV1)
} }
fn handlePowerManagerSetMode( fn handlePowerManagerSetMode(
listener: *wl.Listener(*wlr.OutputPowerManagerV1.event.SetMode), _: *wl.Listener(*wlr.OutputPowerManagerV1.event.SetMode),
event: *wlr.OutputPowerManagerV1.event.SetMode, event: *wlr.OutputPowerManagerV1.event.SetMode,
) void { ) void {
const self = @fieldParentPtr(Self, "power_manager_set_mode", listener);
const enable = event.mode == .on; const enable = event.mode == .on;
const log_text = if (enable) "Enabling" else "Disabling"; const log_text = if (enable) "Enabling" else "Disabling";

View File

@ -173,7 +173,7 @@ pub fn focus(self: *Self, _target: ?*View) void {
var it = self.focus_stack.first; var it = self.focus_stack.first;
while (it) |node| : (it = node.next) { while (it) |node| : (it = node.next) {
if (node.view == view) { if (node.view == view) {
const new_focus_node = self.focus_stack.remove(node); self.focus_stack.remove(node);
self.focus_stack.push(node); self.focus_stack.push(node);
break; break;
} }
@ -474,7 +474,7 @@ fn handleStartDrag(listener: *wl.Listener(*wlr.Drag), wlr_drag: *wlr.Drag) void
if (wlr_drag.icon) |wlr_drag_icon| { if (wlr_drag.icon) |wlr_drag_icon| {
const node = util.gpa.create(std.SinglyLinkedList(DragIcon).Node) catch { const node = util.gpa.create(std.SinglyLinkedList(DragIcon).Node) catch {
log.crit("out of memory", .{}); log.err("out of memory", .{});
wlr_drag.seat_client.client.postNoMemory(); wlr_drag.seat_client.client.postNoMemory();
return; return;
}; };
@ -484,7 +484,7 @@ fn handleStartDrag(listener: *wl.Listener(*wlr.Drag), wlr_drag: *wlr.Drag) void
self.cursor.mode = .passthrough; self.cursor.mode = .passthrough;
} }
fn handlePointerDragDestroy(listener: *wl.Listener(*wlr.Drag), wlr_drag: *wlr.Drag) void { fn handlePointerDragDestroy(listener: *wl.Listener(*wlr.Drag), _: *wlr.Drag) void {
const self = @fieldParentPtr(Self, "pointer_drag_destroy", listener); const self = @fieldParentPtr(Self, "pointer_drag_destroy", listener);
self.pointer_drag_destroy.link.remove(); self.pointer_drag_destroy.link.remove();

View File

@ -41,13 +41,13 @@ pub fn init(self: *Self, seat: *Seat, seat_status: *zriver.SeatStatusV1) void {
self.sendFocusedView(); self.sendFocusedView();
} }
fn handleRequest(seat_status: *zriver.SeatStatusV1, request: zriver.SeatStatusV1.Request, self: *Self) void { fn handleRequest(seat_status: *zriver.SeatStatusV1, request: zriver.SeatStatusV1.Request, _: *Self) void {
switch (request) { switch (request) {
.destroy => seat_status.destroy(), .destroy => seat_status.destroy(),
} }
} }
fn handleDestroy(seat_status: *zriver.SeatStatusV1, self: *Self) void { fn handleDestroy(_: *zriver.SeatStatusV1, self: *Self) void {
const node = @fieldParentPtr(std.SinglyLinkedList(Self).Node, "data", self); const node = @fieldParentPtr(std.SinglyLinkedList(Self).Node, "data", self);
self.seat.status_trackers.remove(node); self.seat.status_trackers.remove(node);
util.gpa.destroy(node); util.gpa.destroy(node);

View File

@ -77,9 +77,9 @@ pub fn init(self: *Self) !void {
errdefer self.wl_server.destroy(); errdefer self.wl_server.destroy();
const loop = self.wl_server.getEventLoop(); const loop = self.wl_server.getEventLoop();
self.sigint_source = try loop.addSignal(*wl.Server, std.os.SIGINT, terminate, self.wl_server); self.sigint_source = try loop.addSignal(*wl.Server, std.os.SIG.INT, terminate, self.wl_server);
errdefer self.sigint_source.remove(); errdefer self.sigint_source.remove();
self.sigterm_source = try loop.addSignal(*wl.Server, std.os.SIGTERM, terminate, self.wl_server); self.sigterm_source = try loop.addSignal(*wl.Server, std.os.SIG.TERM, terminate, self.wl_server);
errdefer self.sigterm_source.remove(); errdefer self.sigterm_source.remove();
// This frees itself when the wl.Server is destroyed // This frees itself when the wl.Server is destroyed
@ -170,6 +170,7 @@ pub fn start(self: Self) !void {
/// Handle SIGINT and SIGTERM by gracefully stopping the server /// Handle SIGINT and SIGTERM by gracefully stopping the server
fn terminate(signal: c_int, wl_server: *wl.Server) callconv(.C) c_int { fn terminate(signal: c_int, wl_server: *wl.Server) callconv(.C) c_int {
_ = signal;
wl_server.terminate(); wl_server.terminate();
return 0; return 0;
} }

View File

@ -40,30 +40,30 @@ server_destroy: wl.Listener(*wl.Server) = wl.Listener(*wl.Server).init(handleSer
pub fn init(self: *Self) !void { pub fn init(self: *Self) !void {
self.* = .{ self.* = .{
.global = try wl.Global.create(server.wl_server, zriver.StatusManagerV1, 2, *Self, self, bind), .global = try wl.Global.create(server.wl_server, zriver.StatusManagerV1, 2, ?*anyopaque, null, bind),
}; };
server.wl_server.addDestroyListener(&self.server_destroy); server.wl_server.addDestroyListener(&self.server_destroy);
} }
fn handleServerDestroy(listener: *wl.Listener(*wl.Server), wl_server: *wl.Server) void { fn handleServerDestroy(listener: *wl.Listener(*wl.Server), _: *wl.Server) void {
const self = @fieldParentPtr(Self, "server_destroy", listener); const self = @fieldParentPtr(Self, "server_destroy", listener);
self.global.destroy(); self.global.destroy();
} }
fn bind(client: *wl.Client, self: *Self, version: u32, id: u32) callconv(.C) void { fn bind(client: *wl.Client, _: ?*anyopaque, version: u32, id: u32) callconv(.C) void {
const status_manager = zriver.StatusManagerV1.create(client, version, id) catch { const status_manager = zriver.StatusManagerV1.create(client, version, id) catch {
client.postNoMemory(); client.postNoMemory();
log.crit("out of memory", .{}); log.err("out of memory", .{});
return; return;
}; };
status_manager.setHandler(*Self, handleRequest, null, self); status_manager.setHandler(?*anyopaque, handleRequest, null, null);
} }
fn handleRequest( fn handleRequest(
status_manager: *zriver.StatusManagerV1, status_manager: *zriver.StatusManagerV1,
request: zriver.StatusManagerV1.Request, request: zriver.StatusManagerV1.Request,
self: *Self, _: ?*anyopaque,
) void { ) void {
switch (request) { switch (request) {
.destroy => status_manager.destroy(), .destroy => status_manager.destroy(),
@ -74,7 +74,7 @@ fn handleRequest(
const node = util.gpa.create(std.SinglyLinkedList(OutputStatus).Node) catch { const node = util.gpa.create(std.SinglyLinkedList(OutputStatus).Node) catch {
status_manager.getClient().postNoMemory(); status_manager.getClient().postNoMemory();
log.crit("out of memory", .{}); log.err("out of memory", .{});
return; return;
}; };
@ -85,7 +85,7 @@ fn handleRequest(
) catch { ) catch {
status_manager.getClient().postNoMemory(); status_manager.getClient().postNoMemory();
util.gpa.destroy(node); util.gpa.destroy(node);
log.crit("out of memory", .{}); log.err("out of memory", .{});
return; return;
}; };
@ -99,7 +99,7 @@ fn handleRequest(
const node = util.gpa.create(std.SinglyLinkedList(SeatStatus).Node) catch { const node = util.gpa.create(std.SinglyLinkedList(SeatStatus).Node) catch {
status_manager.getClient().postNoMemory(); status_manager.getClient().postNoMemory();
log.crit("out of memory", .{}); log.err("out of memory", .{});
return; return;
}; };
@ -110,7 +110,7 @@ fn handleRequest(
) catch { ) catch {
status_manager.getClient().postNoMemory(); status_manager.getClient().postNoMemory();
util.gpa.destroy(node); util.gpa.destroy(node);
log.crit("out of memory", .{}); log.err("out of memory", .{});
return; return;
}; };

View File

@ -38,7 +38,7 @@ pub const Parent = union(enum) {
switch (parent) { switch (parent) {
.xdg_toplevel => |xdg_toplevel| xdg_toplevel.view.output.damage.addWhole(), .xdg_toplevel => |xdg_toplevel| xdg_toplevel.view.output.damage.addWhole(),
.layer_surface => |layer_surface| layer_surface.output.damage.addWhole(), .layer_surface => |layer_surface| layer_surface.output.damage.addWhole(),
.drag_icon => |drag_icon| { .drag_icon => |_| {
var it = server.root.outputs.first; var it = server.root.outputs.first;
while (it) |node| : (it = node.next) node.data.damage.addWhole(); while (it) |node| : (it = node.next) node.data.damage.addWhole();
}, },
@ -61,7 +61,7 @@ commit: wl.Listener(*wlr.Surface) = wl.Listener(*wlr.Surface).init(handleCommit)
pub fn create(wlr_subsurface: *wlr.Subsurface, parent: Parent) void { pub fn create(wlr_subsurface: *wlr.Subsurface, parent: Parent) void {
const subsurface = util.gpa.create(Subsurface) catch { const subsurface = util.gpa.create(Subsurface) catch {
std.log.crit("out of memory", .{}); std.log.err("out of memory", .{});
wlr_subsurface.resource.getClient().postNoMemory(); wlr_subsurface.resource.getClient().postNoMemory();
return; return;
}; };
@ -125,7 +125,7 @@ pub fn destroySubsurfaces(surface: *wlr.Surface) void {
} }
} }
fn handleDestroy(listener: *wl.Listener(*wlr.Subsurface), wlr_subsurface: *wlr.Subsurface) void { fn handleDestroy(listener: *wl.Listener(*wlr.Subsurface), _: *wlr.Subsurface) void {
const subsurface = @fieldParentPtr(Subsurface, "subsurface_destroy", listener); const subsurface = @fieldParentPtr(Subsurface, "subsurface_destroy", listener);
subsurface.destroy(); subsurface.destroy();
@ -138,14 +138,14 @@ fn handleMap(listener: *wl.Listener(*wlr.Subsurface), wlr_subsurface: *wlr.Subsu
subsurface.parent.damageWholeOutput(); subsurface.parent.damageWholeOutput();
} }
fn handleUnmap(listener: *wl.Listener(*wlr.Subsurface), wlr_subsurface: *wlr.Subsurface) void { fn handleUnmap(listener: *wl.Listener(*wlr.Subsurface), _: *wlr.Subsurface) void {
const subsurface = @fieldParentPtr(Subsurface, "unmap", listener); const subsurface = @fieldParentPtr(Subsurface, "unmap", listener);
subsurface.commit.link.remove(); subsurface.commit.link.remove();
subsurface.parent.damageWholeOutput(); subsurface.parent.damageWholeOutput();
} }
fn handleCommit(listener: *wl.Listener(*wlr.Surface), surface: *wlr.Surface) void { fn handleCommit(listener: *wl.Listener(*wlr.Surface), _: *wlr.Surface) void {
const subsurface = @fieldParentPtr(Subsurface, "commit", listener); const subsurface = @fieldParentPtr(Subsurface, "commit", listener);
subsurface.parent.damageWholeOutput(); subsurface.parent.damageWholeOutput();

View File

@ -231,7 +231,7 @@ pub fn configure(self: *Self) void {
pub fn sendFrameDone(self: Self) void { pub fn sendFrameDone(self: Self) void {
var now: os.timespec = undefined; var now: os.timespec = undefined;
os.clock_gettime(os.CLOCK_MONOTONIC, &now) catch @panic("CLOCK_MONOTONIC not supported"); os.clock_gettime(os.CLOCK.MONOTONIC, &now) catch @panic("CLOCK_MONOTONIC not supported");
self.surface.?.sendFrameDone(&now); self.surface.?.sendFrameDone(&now);
} }
@ -313,7 +313,7 @@ fn sendEnter(self: *Self, output: *Output) void {
self.forEachSurface(*wlr.Output, sendEnterIterator, output.wlr_output); self.forEachSurface(*wlr.Output, sendEnterIterator, output.wlr_output);
} }
fn sendEnterIterator(surface: *wlr.Surface, sx: c_int, sy: c_int, wlr_output: *wlr.Output) callconv(.C) void { fn sendEnterIterator(surface: *wlr.Surface, _: c_int, _: c_int, wlr_output: *wlr.Output) callconv(.C) void {
surface.sendEnter(wlr_output); surface.sendEnter(wlr_output);
} }
@ -321,7 +321,7 @@ fn sendLeave(self: *Self, output: *Output) void {
self.forEachSurface(*wlr.Output, sendLeaveIterator, output.wlr_output); self.forEachSurface(*wlr.Output, sendLeaveIterator, output.wlr_output);
} }
fn sendLeaveIterator(surface: *wlr.Surface, sx: c_int, sy: c_int, wlr_output: *wlr.Output) callconv(.C) void { fn sendLeaveIterator(surface: *wlr.Surface, _: c_int, _: c_int, wlr_output: *wlr.Output) callconv(.C) void {
surface.sendLeave(wlr_output); surface.sendLeave(wlr_output);
} }
@ -577,17 +577,16 @@ fn handleForeignFullscreen(
fn handleForeignClose( fn handleForeignClose(
listener: *wl.Listener(*wlr.ForeignToplevelHandleV1), listener: *wl.Listener(*wlr.ForeignToplevelHandleV1),
event: *wlr.ForeignToplevelHandleV1, _: *wlr.ForeignToplevelHandleV1,
) void { ) void {
const self = @fieldParentPtr(Self, "foreign_close", listener); const self = @fieldParentPtr(Self, "foreign_close", listener);
self.close(); self.close();
} }
fn handleRequestActivate( fn handleRequestActivate(
listener: *wl.Listener(*wlr.XdgActivationV1.event.RequestActivate), _: *wl.Listener(*wlr.XdgActivationV1.event.RequestActivate),
event: *wlr.XdgActivationV1.event.RequestActivate, event: *wlr.XdgActivationV1.event.RequestActivate,
) void { ) void {
const self = @fieldParentPtr(Self, "request_activate", listener);
if (fromWlrSurface(event.surface)) |view| { if (fromWlrSurface(event.surface)) |view| {
if (view.current.focus == 0) { if (view.current.focus == 0) {
view.pending.urgent = true; view.pending.urgent = true;

View File

@ -23,38 +23,38 @@ const wlr = @import("wlroots");
const Box = @import("Box.zig"); const Box = @import("Box.zig");
const View = @import("View.zig"); const View = @import("View.zig");
pub fn needsConfigure(self: Self) bool { pub fn needsConfigure(_: Self) bool {
unreachable; unreachable;
} }
pub fn configure(self: Self) void { pub fn configure(_: Self) void {
unreachable; unreachable;
} }
pub fn close(self: Self) void { pub fn setActivated(_: Self, _: bool) void {
unreachable; unreachable;
} }
pub fn setActivated(self: Self, activated: bool) void { pub fn setFullscreen(_: Self, _: bool) void {
unreachable; unreachable;
} }
pub fn setFullscreen(self: Self, fullscreen: bool) void { pub fn close(_: Self) void {
unreachable; unreachable;
} }
pub fn surfaceAt(self: Self, ox: f64, oy: f64, sx: *f64, sy: *f64) ?*wlr.Surface { pub fn surfaceAt(_: Self, _: f64, _: f64, _: *f64, _: *f64) ?*wlr.Surface {
unreachable; unreachable;
} }
pub fn getTitle(self: Self) ?[*:0]const u8 { pub fn getTitle(_: Self) ?[*:0]const u8 {
unreachable; unreachable;
} }
pub fn getAppId(self: Self) ?[*:0]const u8 { pub fn getAppId(_: Self) ?[*:0]const u8 {
unreachable; unreachable;
} }
pub fn getConstraints(self: Self) View.Constraints { pub fn getConstraints(_: Self) View.Constraints {
unreachable; unreachable;
} }

View File

@ -43,7 +43,7 @@ commit: wl.Listener(*wlr.Surface) = wl.Listener(*wlr.Surface).init(handleCommit)
pub fn create(wlr_xdg_popup: *wlr.XdgPopup, parent: Parent) void { pub fn create(wlr_xdg_popup: *wlr.XdgPopup, parent: Parent) void {
const xdg_popup = util.gpa.create(XdgPopup) catch { const xdg_popup = util.gpa.create(XdgPopup) catch {
std.log.crit("out of memory", .{}); std.log.err("out of memory", .{});
wlr_xdg_popup.resource.postNoMemory(); wlr_xdg_popup.resource.postNoMemory();
return; return;
}; };
@ -104,26 +104,26 @@ pub fn destroyPopups(wlr_xdg_surface: *wlr.XdgSurface) void {
} }
} }
fn handleDestroy(listener: *wl.Listener(*wlr.XdgSurface), wlr_xdg_surface: *wlr.XdgSurface) void { fn handleDestroy(listener: *wl.Listener(*wlr.XdgSurface), _: *wlr.XdgSurface) void {
const xdg_popup = @fieldParentPtr(XdgPopup, "surface_destroy", listener); const xdg_popup = @fieldParentPtr(XdgPopup, "surface_destroy", listener);
xdg_popup.destroy(); xdg_popup.destroy();
} }
fn handleMap(listener: *wl.Listener(*wlr.XdgSurface), xdg_surface: *wlr.XdgSurface) void { fn handleMap(listener: *wl.Listener(*wlr.XdgSurface), _: *wlr.XdgSurface) void {
const xdg_popup = @fieldParentPtr(XdgPopup, "map", listener); const xdg_popup = @fieldParentPtr(XdgPopup, "map", listener);
xdg_popup.wlr_xdg_popup.base.surface.events.commit.add(&xdg_popup.commit); xdg_popup.wlr_xdg_popup.base.surface.events.commit.add(&xdg_popup.commit);
xdg_popup.parent.damageWholeOutput(); xdg_popup.parent.damageWholeOutput();
} }
fn handleUnmap(listener: *wl.Listener(*wlr.XdgSurface), xdg_surface: *wlr.XdgSurface) void { fn handleUnmap(listener: *wl.Listener(*wlr.XdgSurface), _: *wlr.XdgSurface) void {
const xdg_popup = @fieldParentPtr(XdgPopup, "unmap", listener); const xdg_popup = @fieldParentPtr(XdgPopup, "unmap", listener);
xdg_popup.commit.link.remove(); xdg_popup.commit.link.remove();
xdg_popup.parent.damageWholeOutput(); xdg_popup.parent.damageWholeOutput();
} }
fn handleCommit(listener: *wl.Listener(*wlr.Surface), surface: *wlr.Surface) void { fn handleCommit(listener: *wl.Listener(*wlr.Surface), _: *wlr.Surface) void {
const xdg_popup = @fieldParentPtr(XdgPopup, "commit", listener); const xdg_popup = @fieldParentPtr(XdgPopup, "commit", listener);
xdg_popup.parent.damageWholeOutput(); xdg_popup.parent.damageWholeOutput();

View File

@ -147,7 +147,7 @@ pub fn getConstraints(self: Self) View.Constraints {
}; };
} }
fn handleDestroy(listener: *wl.Listener(*wlr.XdgSurface), xdg_surface: *wlr.XdgSurface) void { fn handleDestroy(listener: *wl.Listener(*wlr.XdgSurface), _: *wlr.XdgSurface) void {
const self = @fieldParentPtr(Self, "destroy", listener); const self = @fieldParentPtr(Self, "destroy", listener);
// Remove listeners that are active for the entire lifetime of the view // Remove listeners that are active for the entire lifetime of the view
@ -163,7 +163,6 @@ fn handleDestroy(listener: *wl.Listener(*wlr.XdgSurface), xdg_surface: *wlr.XdgS
self.view.destroy(); self.view.destroy();
} }
/// Called when the xdg surface is mapped, or ready to display on-screen.
fn handleMap(listener: *wl.Listener(*wlr.XdgSurface), xdg_surface: *wlr.XdgSurface) void { fn handleMap(listener: *wl.Listener(*wlr.XdgSurface), xdg_surface: *wlr.XdgSurface) void {
const self = @fieldParentPtr(Self, "map", listener); const self = @fieldParentPtr(Self, "map", listener);
const view = self.view; const view = self.view;
@ -225,13 +224,13 @@ fn handleMap(listener: *wl.Listener(*wlr.XdgSurface), xdg_surface: *wlr.XdgSurfa
} }
view.map() catch { view.map() catch {
log.crit("out of memory", .{}); log.err("out of memory", .{});
xdg_surface.resource.getClient().postNoMemory(); xdg_surface.resource.getClient().postNoMemory();
}; };
} }
/// Called when the surface is unmapped and will no longer be displayed. /// Called when the surface is unmapped and will no longer be displayed.
fn handleUnmap(listener: *wl.Listener(*wlr.XdgSurface), xdg_surface: *wlr.XdgSurface) void { fn handleUnmap(listener: *wl.Listener(*wlr.XdgSurface), _: *wlr.XdgSurface) void {
const self = @fieldParentPtr(Self, "unmap", listener); const self = @fieldParentPtr(Self, "unmap", listener);
// Remove listeners that are only active while mapped // Remove listeners that are only active while mapped
@ -258,7 +257,7 @@ fn handleAckConfigure(
} }
} }
fn handleCommit(listener: *wl.Listener(*wlr.Surface), surface: *wlr.Surface) void { fn handleCommit(listener: *wl.Listener(*wlr.Surface), _: *wlr.Surface) void {
const self = @fieldParentPtr(Self, "commit", listener); const self = @fieldParentPtr(Self, "commit", listener);
const view = self.view; const view = self.view;
@ -356,13 +355,13 @@ fn handleRequestResize(listener: *wl.Listener(*wlr.XdgToplevel.event.Resize), ev
} }
/// Called when the client sets / updates its title /// Called when the client sets / updates its title
fn handleSetTitle(listener: *wl.Listener(*wlr.XdgSurface), xdg_surface: *wlr.XdgSurface) void { fn handleSetTitle(listener: *wl.Listener(*wlr.XdgSurface), _: *wlr.XdgSurface) void {
const self = @fieldParentPtr(Self, "set_title", listener); const self = @fieldParentPtr(Self, "set_title", listener);
self.view.notifyTitle(); self.view.notifyTitle();
} }
/// Called when the client sets / updates its app_id /// Called when the client sets / updates its app_id
fn handleSetAppId(listener: *wl.Listener(*wlr.XdgSurface), xdg_surface: *wlr.XdgSurface) void { fn handleSetAppId(listener: *wl.Listener(*wlr.XdgSurface), _: *wlr.XdgSurface) void {
const self = @fieldParentPtr(Self, "set_app_id", listener); const self = @fieldParentPtr(Self, "set_app_id", listener);
self.view.notifyAppId(); self.view.notifyAppId();
} }

View File

@ -48,14 +48,14 @@ pub fn init(self: *Self, xwayland_surface: *wlr.XwaylandSurface) void {
} }
fn handleRequestConfigure( fn handleRequestConfigure(
listener: *wl.Listener(*wlr.XwaylandSurface.event.Configure), _: *wl.Listener(*wlr.XwaylandSurface.event.Configure),
event: *wlr.XwaylandSurface.event.Configure, event: *wlr.XwaylandSurface.event.Configure,
) void { ) void {
event.surface.configure(event.x, event.y, event.width, event.height); event.surface.configure(event.x, event.y, event.width, event.height);
} }
/// Called when the xwayland surface is destroyed /// Called when the xwayland surface is destroyed
fn handleDestroy(listener: *wl.Listener(*wlr.XwaylandSurface), xwayland_surface: *wlr.XwaylandSurface) void { fn handleDestroy(listener: *wl.Listener(*wlr.XwaylandSurface), _: *wlr.XwaylandSurface) void {
const self = @fieldParentPtr(Self, "destroy", listener); const self = @fieldParentPtr(Self, "destroy", listener);
// Remove listeners that are active for the entire lifetime // Remove listeners that are active for the entire lifetime
@ -84,7 +84,7 @@ fn handleMap(listener: *wl.Listener(*wlr.XwaylandSurface), xwayland_surface: *wl
} }
/// Called when the surface is unmapped and will no longer be displayed. /// Called when the surface is unmapped and will no longer be displayed.
fn handleUnmap(listener: *wl.Listener(*wlr.XwaylandSurface), xwayland_surface: *wlr.XwaylandSurface) void { fn handleUnmap(listener: *wl.Listener(*wlr.XwaylandSurface), _: *wlr.XwaylandSurface) void {
const self = @fieldParentPtr(Self, "unmap", listener); const self = @fieldParentPtr(Self, "unmap", listener);
// Remove self from the list of unmanged views in the root // Remove self from the list of unmanged views in the root
@ -94,7 +94,7 @@ fn handleUnmap(listener: *wl.Listener(*wlr.XwaylandSurface), xwayland_surface: *
self.commit.link.remove(); self.commit.link.remove();
} }
fn handleCommit(listener: *wl.Listener(*wlr.Surface), surface: *wlr.Surface) void { fn handleCommit(_: *wl.Listener(*wlr.Surface), _: *wlr.Surface) void {
var it = server.root.outputs.first; var it = server.root.outputs.first;
while (it) |node| : (it = node.next) node.data.damage.addWhole(); while (it) |node| : (it = node.next) node.data.damage.addWhole();
} }

View File

@ -143,7 +143,7 @@ pub fn getConstraints(self: Self) View.Constraints {
} }
/// Called when the xwayland surface is destroyed /// Called when the xwayland surface is destroyed
fn handleDestroy(listener: *wl.Listener(*wlr.XwaylandSurface), xwayland_surface: *wlr.XwaylandSurface) void { fn handleDestroy(listener: *wl.Listener(*wlr.XwaylandSurface), _: *wlr.XwaylandSurface) void {
const self = @fieldParentPtr(Self, "destroy", listener); const self = @fieldParentPtr(Self, "destroy", listener);
// Remove listeners that are active for the entire lifetime of the view // Remove listeners that are active for the entire lifetime of the view
@ -202,13 +202,13 @@ fn handleMap(listener: *wl.Listener(*wlr.XwaylandSurface), xwayland_surface: *wl
} }
view.map() catch { view.map() catch {
std.log.crit("out of memory", .{}); std.log.err("out of memory", .{});
surface.resource.getClient().postNoMemory(); surface.resource.getClient().postNoMemory();
}; };
} }
/// Called when the surface is unmapped and will no longer be displayed. /// Called when the surface is unmapped and will no longer be displayed.
fn handleUnmap(listener: *wl.Listener(*wlr.XwaylandSurface), xwayland_surface: *wlr.XwaylandSurface) void { fn handleUnmap(listener: *wl.Listener(*wlr.XwaylandSurface), _: *wlr.XwaylandSurface) void {
const self = @fieldParentPtr(Self, "unmap", listener); const self = @fieldParentPtr(Self, "unmap", listener);
// Remove listeners that are only active while mapped // Remove listeners that are only active while mapped
@ -253,12 +253,12 @@ fn handleCommit(listener: *wl.Listener(*wlr.Surface), surface: *wlr.Surface) voi
}; };
} }
fn handleSetTitle(listener: *wl.Listener(*wlr.XwaylandSurface), xwayland_surface: *wlr.XwaylandSurface) void { fn handleSetTitle(listener: *wl.Listener(*wlr.XwaylandSurface), _: *wlr.XwaylandSurface) void {
const self = @fieldParentPtr(Self, "set_title", listener); const self = @fieldParentPtr(Self, "set_title", listener);
self.view.notifyTitle(); self.view.notifyTitle();
} }
fn handleSetClass(listener: *wl.Listener(*wlr.XwaylandSurface), xwayland_surface: *wlr.XwaylandSurface) void { fn handleSetClass(listener: *wl.Listener(*wlr.XwaylandSurface), _: *wlr.XwaylandSurface) void {
const self = @fieldParentPtr(Self, "set_class", listener); const self = @fieldParentPtr(Self, "set_class", listener);
self.view.notifyAppId(); self.view.notifyAppId();
} }

View File

@ -38,7 +38,7 @@ pub const Orientation = enum {
// zig fmt: off // zig fmt: off
const command_impls = std.ComptimeStringMap( const command_impls = std.ComptimeStringMap(
fn (*std.mem.Allocator, *Seat, []const [:0]const u8, *?[]const u8) Error!void, fn (std.mem.Allocator, *Seat, []const [:0]const u8, *?[]const u8) Error!void,
.{ .{
.{ "attach-mode", @import("command/attach_mode.zig").attachMode }, .{ "attach-mode", @import("command/attach_mode.zig").attachMode },
.{ "background-color", @import("command/config.zig").backgroundColor }, .{ "background-color", @import("command/config.zig").backgroundColor },
@ -117,7 +117,7 @@ pub const Error = error{
/// The caller is then responsible for freeing that slice, which will be /// The caller is then responsible for freeing that slice, which will be
/// allocated using the provided allocator. /// allocated using the provided allocator.
pub fn run( pub fn run(
allocator: *std.mem.Allocator, allocator: std.mem.Allocator,
seat: *Seat, seat: *Seat,
args: []const [:0]const u8, args: []const [:0]const u8,
out: *?[]const u8, out: *?[]const u8,

View File

@ -25,10 +25,10 @@ const Error = @import("../command.zig").Error;
const Seat = @import("../Seat.zig"); const Seat = @import("../Seat.zig");
pub fn attachMode( pub fn attachMode(
allocator: *std.mem.Allocator, _: std.mem.Allocator,
seat: *Seat, _: *Seat,
args: []const [:0]const u8, args: []const [:0]const u8,
out: *?[]const u8, _: *?[]const u8,
) Error!void { ) Error!void {
if (args.len < 2) return Error.NotEnoughArguments; if (args.len < 2) return Error.NotEnoughArguments;
if (args.len > 2) return Error.TooManyArguments; if (args.len > 2) return Error.TooManyArguments;

View File

@ -22,10 +22,10 @@ const Seat = @import("../Seat.zig");
/// Close the focused view, if any. /// Close the focused view, if any.
pub fn close( pub fn close(
allocator: *std.mem.Allocator, _: std.mem.Allocator,
seat: *Seat, seat: *Seat,
args: []const [:0]const u8, _: []const [:0]const u8,
out: *?[]const u8, _: *?[]const u8,
) Error!void { ) Error!void {
// Note: we don't call arrange() here as it will be called // Note: we don't call arrange() here as it will be called
// automatically when the view is unmapped. // automatically when the view is unmapped.

View File

@ -25,10 +25,10 @@ const Seat = @import("../Seat.zig");
const Config = @import("../Config.zig"); const Config = @import("../Config.zig");
pub fn borderWidth( pub fn borderWidth(
allocator: *std.mem.Allocator, _: std.mem.Allocator,
seat: *Seat, _: *Seat,
args: []const [:0]const u8, args: []const [:0]const u8,
out: *?[]const u8, _: *?[]const u8,
) Error!void { ) Error!void {
if (args.len < 2) return Error.NotEnoughArguments; if (args.len < 2) return Error.NotEnoughArguments;
if (args.len > 2) return Error.TooManyArguments; if (args.len > 2) return Error.TooManyArguments;
@ -39,10 +39,10 @@ pub fn borderWidth(
} }
pub fn backgroundColor( pub fn backgroundColor(
allocator: *std.mem.Allocator, _: std.mem.Allocator,
seat: *Seat, _: *Seat,
args: []const [:0]const u8, args: []const [:0]const u8,
out: *?[]const u8, _: *?[]const u8,
) Error!void { ) Error!void {
if (args.len < 2) return Error.NotEnoughArguments; if (args.len < 2) return Error.NotEnoughArguments;
if (args.len > 2) return Error.TooManyArguments; if (args.len > 2) return Error.TooManyArguments;
@ -54,10 +54,10 @@ pub fn backgroundColor(
} }
pub fn borderColorFocused( pub fn borderColorFocused(
allocator: *std.mem.Allocator, _: std.mem.Allocator,
seat: *Seat, _: *Seat,
args: []const [:0]const u8, args: []const [:0]const u8,
out: *?[]const u8, _: *?[]const u8,
) Error!void { ) Error!void {
if (args.len < 2) return Error.NotEnoughArguments; if (args.len < 2) return Error.NotEnoughArguments;
if (args.len > 2) return Error.TooManyArguments; if (args.len > 2) return Error.TooManyArguments;
@ -69,10 +69,10 @@ pub fn borderColorFocused(
} }
pub fn borderColorUnfocused( pub fn borderColorUnfocused(
allocator: *std.mem.Allocator, _: std.mem.Allocator,
seat: *Seat, _: *Seat,
args: []const [:0]const u8, args: []const [:0]const u8,
out: *?[]const u8, _: *?[]const u8,
) Error!void { ) Error!void {
if (args.len < 2) return Error.NotEnoughArguments; if (args.len < 2) return Error.NotEnoughArguments;
if (args.len > 2) return Error.TooManyArguments; if (args.len > 2) return Error.TooManyArguments;
@ -84,10 +84,10 @@ pub fn borderColorUnfocused(
} }
pub fn borderColorUrgent( pub fn borderColorUrgent(
allocator: *std.mem.Allocator, _: std.mem.Allocator,
seat: *Seat, _: *Seat,
args: []const [:0]const u8, args: []const [:0]const u8,
out: *?[]const u8, _: *?[]const u8,
) Error!void { ) Error!void {
if (args.len < 2) return Error.NotEnoughArguments; if (args.len < 2) return Error.NotEnoughArguments;
if (args.len > 2) return Error.TooManyArguments; if (args.len > 2) return Error.TooManyArguments;
@ -99,10 +99,10 @@ pub fn borderColorUrgent(
} }
pub fn setCursorWarp( pub fn setCursorWarp(
allocator: *std.mem.Allocator, _: std.mem.Allocator,
seat: *Seat, _: *Seat,
args: []const [:0]const u8, args: []const [:0]const u8,
out: *?[]const u8, _: *?[]const u8,
) Error!void { ) Error!void {
if (args.len < 2) return Error.NotEnoughArguments; if (args.len < 2) return Error.NotEnoughArguments;
if (args.len > 2) return Error.TooManyArguments; if (args.len > 2) return Error.TooManyArguments;

View File

@ -27,10 +27,10 @@ const Seat = @import("../Seat.zig");
/// Declare a new keymap mode /// Declare a new keymap mode
pub fn declareMode( pub fn declareMode(
allocator: *std.mem.Allocator, _: std.mem.Allocator,
seat: *Seat, _: *Seat,
args: []const [:0]const u8, args: []const [:0]const u8,
out: *?[]const u8, _: *?[]const u8,
) Error!void { ) Error!void {
if (args.len < 2) return Error.NotEnoughArguments; if (args.len < 2) return Error.NotEnoughArguments;
if (args.len > 2) return Error.TooManyArguments; if (args.len > 2) return Error.TooManyArguments;
@ -40,8 +40,8 @@ pub fn declareMode(
if (config.mode_to_id.get(new_mode_name) != null) return; if (config.mode_to_id.get(new_mode_name) != null) return;
try config.modes.ensureCapacity(config.modes.items.len + 1); try config.modes.ensureUnusedCapacity(1);
const owned_name = try std.mem.dupe(util.gpa, u8, new_mode_name); const owned_name = try util.gpa.dupe(u8, new_mode_name);
errdefer util.gpa.free(owned_name); errdefer util.gpa.free(owned_name);
try config.mode_to_id.putNoClobber(owned_name, config.modes.items.len); try config.mode_to_id.putNoClobber(owned_name, config.modes.items.len);
config.modes.appendAssumeCapacity(Mode.init()); config.modes.appendAssumeCapacity(Mode.init());

View File

@ -24,7 +24,7 @@ const Seat = @import("../Seat.zig");
/// Switch to the given mode /// Switch to the given mode
pub fn enterMode( pub fn enterMode(
allocator: *std.mem.Allocator, allocator: std.mem.Allocator,
seat: *Seat, seat: *Seat,
args: []const [:0]const u8, args: []const [:0]const u8,
out: *?[]const u8, out: *?[]const u8,

View File

@ -24,10 +24,10 @@ const Seat = @import("../Seat.zig");
/// Exit the compositor, terminating the wayland session. /// Exit the compositor, terminating the wayland session.
pub fn exit( pub fn exit(
allocator: *std.mem.Allocator, _: std.mem.Allocator,
seat: *Seat, _: *Seat,
args: []const [:0]const u8, args: []const [:0]const u8,
out: *?[]const u8, _: *?[]const u8,
) Error!void { ) Error!void {
if (args.len > 1) return Error.TooManyArguments; if (args.len > 1) return Error.TooManyArguments;
server.wl_server.terminate(); server.wl_server.terminate();

View File

@ -23,7 +23,6 @@ const server = &@import("../main.zig").server;
const util = @import("../util.zig"); const util = @import("../util.zig");
const View = @import("../View.zig"); const View = @import("../View.zig");
const ViewStack = @import("view_stack.zig").ViewStack;
const Error = @import("../command.zig").Error; const Error = @import("../command.zig").Error;
const Seat = @import("../Seat.zig"); const Seat = @import("../Seat.zig");
@ -33,10 +32,10 @@ const FilterKind = enum {
}; };
pub fn floatFilterAdd( pub fn floatFilterAdd(
allocator: *mem.Allocator, _: mem.Allocator,
seat: *Seat, _: *Seat,
args: []const [:0]const u8, args: []const [:0]const u8,
out: *?[]const u8, _: *?[]const u8,
) Error!void { ) Error!void {
if (args.len < 3) return Error.NotEnoughArguments; if (args.len < 3) return Error.NotEnoughArguments;
if (args.len > 3) return Error.TooManyArguments; if (args.len > 3) return Error.TooManyArguments;
@ -51,14 +50,14 @@ pub fn floatFilterAdd(
const gop = try map.getOrPut(util.gpa, key); const gop = try map.getOrPut(util.gpa, key);
if (gop.found_existing) return; if (gop.found_existing) return;
errdefer assert(map.remove(key)); errdefer assert(map.remove(key));
gop.key_ptr.* = try std.mem.dupe(util.gpa, u8, key); gop.key_ptr.* = try util.gpa.dupe(u8, key);
} }
pub fn floatFilterRemove( pub fn floatFilterRemove(
allocator: *mem.Allocator, _: mem.Allocator,
seat: *Seat, _: *Seat,
args: []const [:0]const u8, args: []const [:0]const u8,
out: *?[]const u8, _: *?[]const u8,
) Error!void { ) Error!void {
if (args.len < 3) return Error.NotEnoughArguments; if (args.len < 3) return Error.NotEnoughArguments;
if (args.len > 3) return Error.TooManyArguments; if (args.len > 3) return Error.TooManyArguments;
@ -74,10 +73,10 @@ pub fn floatFilterRemove(
} }
pub fn csdFilterAdd( pub fn csdFilterAdd(
allocator: *mem.Allocator, _: mem.Allocator,
seat: *Seat, _: *Seat,
args: []const [:0]const u8, args: []const [:0]const u8,
out: *?[]const u8, _: *?[]const u8,
) Error!void { ) Error!void {
if (args.len < 3) return Error.NotEnoughArguments; if (args.len < 3) return Error.NotEnoughArguments;
if (args.len > 3) return Error.TooManyArguments; if (args.len > 3) return Error.TooManyArguments;
@ -92,16 +91,16 @@ pub fn csdFilterAdd(
const gop = try map.getOrPut(util.gpa, key); const gop = try map.getOrPut(util.gpa, key);
if (gop.found_existing) return; if (gop.found_existing) return;
errdefer assert(map.remove(key)); errdefer assert(map.remove(key));
gop.key_ptr.* = try std.mem.dupe(util.gpa, u8, key); gop.key_ptr.* = try util.gpa.dupe(u8, key);
csdFilterUpdateViews(kind, key, .add); csdFilterUpdateViews(kind, key, .add);
} }
pub fn csdFilterRemove( pub fn csdFilterRemove(
allocator: *mem.Allocator, _: mem.Allocator,
seat: *Seat, _: *Seat,
args: []const [:0]const u8, args: []const [:0]const u8,
out: *?[]const u8, _: *?[]const u8,
) Error!void { ) Error!void {
if (args.len < 3) return Error.NotEnoughArguments; if (args.len < 3) return Error.NotEnoughArguments;
if (args.len > 3) return Error.TooManyArguments; if (args.len > 3) return Error.TooManyArguments;

View File

@ -25,10 +25,10 @@ const Error = @import("../command.zig").Error;
const Seat = @import("../Seat.zig"); const Seat = @import("../Seat.zig");
pub fn focusFollowsCursor( pub fn focusFollowsCursor(
allocator: *std.mem.Allocator, _: std.mem.Allocator,
seat: *Seat, _: *Seat,
args: []const [:0]const u8, args: []const [:0]const u8,
out: *?[]const u8, _: *?[]const u8,
) Error!void { ) Error!void {
if (args.len < 2) return Error.NotEnoughArguments; if (args.len < 2) return Error.NotEnoughArguments;
if (args.len > 2) return Error.TooManyArguments; if (args.len > 2) return Error.TooManyArguments;

View File

@ -28,10 +28,10 @@ const ViewStack = @import("../view_stack.zig").ViewStack;
/// Focus either the next or the previous visible view, depending on the enum /// Focus either the next or the previous visible view, depending on the enum
/// passed. Does nothing if there are 1 or 0 views in the stack. /// passed. Does nothing if there are 1 or 0 views in the stack.
pub fn focusView( pub fn focusView(
allocator: *std.mem.Allocator, _: std.mem.Allocator,
seat: *Seat, seat: *Seat,
args: []const [:0]const u8, args: []const [:0]const u8,
out: *?[]const u8, _: *?[]const u8,
) Error!void { ) Error!void {
if (args.len < 2) return Error.NotEnoughArguments; if (args.len < 2) return Error.NotEnoughArguments;
if (args.len > 2) return Error.TooManyArguments; if (args.len > 2) return Error.TooManyArguments;

View File

@ -28,11 +28,13 @@ const InputConfig = @import("../InputConfig.zig");
const InputManager = @import("../InputManager.zig"); const InputManager = @import("../InputManager.zig");
pub fn listInputs( pub fn listInputs(
allocator: *mem.Allocator, allocator: mem.Allocator,
seat: *Seat, _: *Seat,
args: []const [:0]const u8, args: []const [:0]const u8,
out: *?[]const u8, out: *?[]const u8,
) Error!void { ) Error!void {
if (args.len > 1) return error.TooManyArguments;
var input_list = std.ArrayList(u8).init(allocator); var input_list = std.ArrayList(u8).init(allocator);
const writer = input_list.writer(); const writer = input_list.writer();
var prev = false; var prev = false;
@ -59,11 +61,13 @@ pub fn listInputs(
} }
pub fn listInputConfigs( pub fn listInputConfigs(
allocator: *mem.Allocator, allocator: mem.Allocator,
seat: *Seat, _: *Seat,
args: []const [:0]const u8, args: []const [:0]const u8,
out: *?[]const u8, out: *?[]const u8,
) Error!void { ) Error!void {
if (args.len > 1) return error.TooManyArguments;
var input_list = std.ArrayList(u8).init(allocator); var input_list = std.ArrayList(u8).init(allocator);
const writer = input_list.writer(); const writer = input_list.writer();
@ -122,10 +126,10 @@ pub fn listInputConfigs(
} }
pub fn input( pub fn input(
allocator: *mem.Allocator, _: mem.Allocator,
seat: *Seat, _: *Seat,
args: []const [:0]const u8, args: []const [:0]const u8,
out: *?[]const u8, _: *?[]const u8,
) Error!void { ) Error!void {
if (args.len < 4) return Error.NotEnoughArguments; if (args.len < 4) return Error.NotEnoughArguments;
if (args.len > 4) return Error.TooManyArguments; if (args.len > 4) return Error.TooManyArguments;

View File

@ -26,10 +26,10 @@ const Error = @import("../command.zig").Error;
const Seat = @import("../Seat.zig"); const Seat = @import("../Seat.zig");
pub fn outputLayout( pub fn outputLayout(
allocator: *std.mem.Allocator, _: std.mem.Allocator,
seat: *Seat, seat: *Seat,
args: []const [:0]const u8, args: []const [:0]const u8,
out: *?[]const u8, _: *?[]const u8,
) Error!void { ) Error!void {
if (args.len < 2) return Error.NotEnoughArguments; if (args.len < 2) return Error.NotEnoughArguments;
if (args.len > 2) return Error.TooManyArguments; if (args.len > 2) return Error.TooManyArguments;
@ -40,10 +40,10 @@ pub fn outputLayout(
} }
pub fn defaultLayout( pub fn defaultLayout(
allocator: *std.mem.Allocator, _: std.mem.Allocator,
seat: *Seat, _: *Seat,
args: []const [:0]const u8, args: []const [:0]const u8,
out: *?[]const u8, _: *?[]const u8,
) Error!void { ) Error!void {
if (args.len < 2) return Error.NotEnoughArguments; if (args.len < 2) return Error.NotEnoughArguments;
if (args.len > 2) return Error.TooManyArguments; if (args.len > 2) return Error.TooManyArguments;
@ -63,10 +63,10 @@ pub fn defaultLayout(
/// riverctl send-layout-cmd rivertile "mod-main-factor -0.1" /// riverctl send-layout-cmd rivertile "mod-main-factor -0.1"
/// riverctl send-layout-cmd rivertile "main-location top" /// riverctl send-layout-cmd rivertile "main-location top"
pub fn sendLayoutCmd( pub fn sendLayoutCmd(
allocator: *std.mem.Allocator, _: std.mem.Allocator,
seat: *Seat, seat: *Seat,
args: []const [:0]const u8, args: []const [:0]const u8,
out: *?[]const u8, _: *?[]const u8,
) Error!void { ) Error!void {
if (args.len < 3) return Error.NotEnoughArguments; if (args.len < 3) return Error.NotEnoughArguments;
if (args.len > 3) return Error.TooManyArguments; if (args.len > 3) return Error.TooManyArguments;
@ -81,6 +81,5 @@ pub fn sendLayoutCmd(
} else return; } else return;
layout.layout.sendUserCommand(args[2]); layout.layout.sendUserCommand(args[2]);
output.arrangeViews(); output.arrangeViews();
} }

View File

@ -34,7 +34,7 @@ const Seat = @import("../Seat.zig");
/// Example: /// Example:
/// map normal Mod4+Shift Return spawn foot /// map normal Mod4+Shift Return spawn foot
pub fn map( pub fn map(
allocator: *std.mem.Allocator, allocator: std.mem.Allocator,
seat: *Seat, seat: *Seat,
args: []const [:0]const u8, args: []const [:0]const u8,
out: *?[]const u8, out: *?[]const u8,
@ -46,7 +46,7 @@ pub fn map(
if (optionals.release and optionals.repeat) return Error.ConflictingOptions; if (optionals.release and optionals.repeat) return Error.ConflictingOptions;
const mode_id = try modeNameToId(allocator, seat, args[1 + offset], out); const mode_id = try modeNameToId(allocator, args[1 + offset], out);
const modifiers = try parseModifiers(allocator, args[2 + offset], out); const modifiers = try parseModifiers(allocator, args[2 + offset], out);
const keysym = try parseKeysym(allocator, args[3 + offset], out); const keysym = try parseKeysym(allocator, args[3 + offset], out);
@ -72,15 +72,15 @@ pub fn map(
/// Example: /// Example:
/// map-pointer normal Mod4 BTN_LEFT move-view /// map-pointer normal Mod4 BTN_LEFT move-view
pub fn mapPointer( pub fn mapPointer(
allocator: *std.mem.Allocator, allocator: std.mem.Allocator,
seat: *Seat, _: *Seat,
args: []const [:0]const u8, args: []const [:0]const u8,
out: *?[]const u8, out: *?[]const u8,
) Error!void { ) Error!void {
if (args.len < 5) return Error.NotEnoughArguments; if (args.len < 5) return Error.NotEnoughArguments;
if (args.len > 5) return Error.TooManyArguments; if (args.len > 5) return Error.TooManyArguments;
const mode_id = try modeNameToId(allocator, seat, args[1], out); const mode_id = try modeNameToId(allocator, args[1], out);
const modifiers = try parseModifiers(allocator, args[2], out); const modifiers = try parseModifiers(allocator, args[2], out);
const event_code = try parseEventCode(allocator, args[3], out); const event_code = try parseEventCode(allocator, args[3], out);
@ -111,7 +111,7 @@ pub fn mapPointer(
} }
} }
fn modeNameToId(allocator: *std.mem.Allocator, seat: *Seat, mode_name: []const u8, out: *?[]const u8) !usize { fn modeNameToId(allocator: std.mem.Allocator, mode_name: []const u8, out: *?[]const u8) !usize {
const config = &server.config; const config = &server.config;
return config.mode_to_id.get(mode_name) orelse { return config.mode_to_id.get(mode_name) orelse {
out.* = try std.fmt.allocPrint( out.* = try std.fmt.allocPrint(
@ -154,7 +154,7 @@ fn pointerMappingExists(
return null; return null;
} }
fn parseEventCode(allocator: *std.mem.Allocator, name: [:0]const u8, out: *?[]const u8) !u32 { fn parseEventCode(allocator: std.mem.Allocator, name: [:0]const u8, out: *?[]const u8) !u32 {
const event_code = c.libevdev_event_code_from_name(c.EV_KEY, name); const event_code = c.libevdev_event_code_from_name(c.EV_KEY, name);
if (event_code < 1) { if (event_code < 1) {
out.* = try std.fmt.allocPrint(allocator, "unknown button {s}", .{name}); out.* = try std.fmt.allocPrint(allocator, "unknown button {s}", .{name});
@ -164,7 +164,7 @@ fn parseEventCode(allocator: *std.mem.Allocator, name: [:0]const u8, out: *?[]co
return @intCast(u32, event_code); return @intCast(u32, event_code);
} }
fn parseKeysym(allocator: *std.mem.Allocator, name: [:0]const u8, out: *?[]const u8) !xkb.Keysym { fn parseKeysym(allocator: std.mem.Allocator, name: [:0]const u8, out: *?[]const u8) !xkb.Keysym {
const keysym = xkb.Keysym.fromName(name, .case_insensitive); const keysym = xkb.Keysym.fromName(name, .case_insensitive);
if (keysym == .NoSymbol) { if (keysym == .NoSymbol) {
out.* = try std.fmt.allocPrint(allocator, "invalid keysym '{s}'", .{name}); out.* = try std.fmt.allocPrint(allocator, "invalid keysym '{s}'", .{name});
@ -174,11 +174,11 @@ fn parseKeysym(allocator: *std.mem.Allocator, name: [:0]const u8, out: *?[]const
} }
fn parseModifiers( fn parseModifiers(
allocator: *std.mem.Allocator, allocator: std.mem.Allocator,
modifiers_str: []const u8, modifiers_str: []const u8,
out: *?[]const u8, out: *?[]const u8,
) !wlr.Keyboard.ModifierMask { ) !wlr.Keyboard.ModifierMask {
var it = std.mem.split(modifiers_str, "+"); var it = std.mem.split(u8, modifiers_str, "+");
var modifiers = wlr.Keyboard.ModifierMask{}; var modifiers = wlr.Keyboard.ModifierMask{};
outer: while (it.next()) |mod_name| { outer: while (it.next()) |mod_name| {
if (mem.eql(u8, mod_name, "None")) continue; if (mem.eql(u8, mod_name, "None")) continue;
@ -245,7 +245,7 @@ fn parseOptionalArgs(args: []const []const u8) OptionalArgsContainer {
/// Example: /// Example:
/// unmap normal Mod4+Shift Return /// unmap normal Mod4+Shift Return
pub fn unmap( pub fn unmap(
allocator: *std.mem.Allocator, allocator: std.mem.Allocator,
seat: *Seat, seat: *Seat,
args: []const [:0]const u8, args: []const [:0]const u8,
out: *?[]const u8, out: *?[]const u8,
@ -255,7 +255,7 @@ pub fn unmap(
const offset = optionals.i; const offset = optionals.i;
if (args.len - offset < 4) return Error.NotEnoughArguments; if (args.len - offset < 4) return Error.NotEnoughArguments;
const mode_id = try modeNameToId(allocator, seat, args[1 + offset], out); const mode_id = try modeNameToId(allocator, args[1 + offset], out);
const modifiers = try parseModifiers(allocator, args[2 + offset], out); const modifiers = try parseModifiers(allocator, args[2 + offset], out);
const keysym = try parseKeysym(allocator, args[3 + offset], out); const keysym = try parseKeysym(allocator, args[3 + offset], out);
@ -276,15 +276,15 @@ pub fn unmap(
/// Example: /// Example:
/// unmap-pointer normal Mod4 BTN_LEFT /// unmap-pointer normal Mod4 BTN_LEFT
pub fn unmapPointer( pub fn unmapPointer(
allocator: *std.mem.Allocator, allocator: std.mem.Allocator,
seat: *Seat, _: *Seat,
args: []const [:0]const u8, args: []const [:0]const u8,
out: *?[]const u8, out: *?[]const u8,
) Error!void { ) Error!void {
if (args.len < 4) return Error.NotEnoughArguments; if (args.len < 4) return Error.NotEnoughArguments;
if (args.len > 4) return Error.TooManyArguments; if (args.len > 4) return Error.TooManyArguments;
const mode_id = try modeNameToId(allocator, seat, args[1], out); const mode_id = try modeNameToId(allocator, args[1], out);
const modifiers = try parseModifiers(allocator, args[2], out); const modifiers = try parseModifiers(allocator, args[2], out);
const event_code = try parseEventCode(allocator, args[3], out); const event_code = try parseEventCode(allocator, args[3], out);

View File

@ -27,10 +27,10 @@ const View = @import("../View.zig");
const Box = @import("../Box.zig"); const Box = @import("../Box.zig");
pub fn move( pub fn move(
allocator: *std.mem.Allocator, _: std.mem.Allocator,
seat: *Seat, seat: *Seat,
args: []const [:0]const u8, args: []const [:0]const u8,
out: *?[]const u8, _: *?[]const u8,
) Error!void { ) Error!void {
if (args.len < 3) return Error.NotEnoughArguments; if (args.len < 3) return Error.NotEnoughArguments;
if (args.len > 3) return Error.TooManyArguments; if (args.len > 3) return Error.TooManyArguments;
@ -51,10 +51,10 @@ pub fn move(
} }
pub fn snap( pub fn snap(
allocator: *std.mem.Allocator, _: std.mem.Allocator,
seat: *Seat, seat: *Seat,
args: []const [:0]const u8, args: []const [:0]const u8,
out: *?[]const u8, _: *?[]const u8,
) Error!void { ) Error!void {
if (args.len < 2) return Error.NotEnoughArguments; if (args.len < 2) return Error.NotEnoughArguments;
if (args.len > 2) return Error.TooManyArguments; if (args.len > 2) return Error.TooManyArguments;
@ -78,10 +78,10 @@ pub fn snap(
} }
pub fn resize( pub fn resize(
allocator: *std.mem.Allocator, _: std.mem.Allocator,
seat: *Seat, seat: *Seat,
args: []const [:0]const u8, args: []const [:0]const u8,
out: *?[]const u8, _: *?[]const u8,
) Error!void { ) Error!void {
if (args.len < 3) return Error.NotEnoughArguments; if (args.len < 3) return Error.NotEnoughArguments;
if (args.len > 3) return Error.TooManyArguments; if (args.len > 3) return Error.TooManyArguments;

View File

@ -28,10 +28,10 @@ const Output = @import("../Output.zig");
const Seat = @import("../Seat.zig"); const Seat = @import("../Seat.zig");
pub fn focusOutput( pub fn focusOutput(
allocator: *std.mem.Allocator, _: std.mem.Allocator,
seat: *Seat, seat: *Seat,
args: []const [:0]const u8, args: []const [:0]const u8,
out: *?[]const u8, _: *?[]const u8,
) Error!void { ) Error!void {
if (args.len < 2) return Error.NotEnoughArguments; if (args.len < 2) return Error.NotEnoughArguments;
if (args.len > 2) return Error.TooManyArguments; if (args.len > 2) return Error.TooManyArguments;
@ -48,10 +48,10 @@ pub fn focusOutput(
} }
pub fn sendToOutput( pub fn sendToOutput(
allocator: *std.mem.Allocator, _: std.mem.Allocator,
seat: *Seat, seat: *Seat,
args: []const [:0]const u8, args: []const [:0]const u8,
out: *?[]const u8, _: *?[]const u8,
) Error!void { ) Error!void {
if (args.len < 2) return Error.NotEnoughArguments; if (args.len < 2) return Error.NotEnoughArguments;
if (args.len > 2) return Error.TooManyArguments; if (args.len > 2) return Error.TooManyArguments;

View File

@ -24,10 +24,10 @@ const Seat = @import("../Seat.zig");
/// Set the repeat rate and delay for all keyboards. /// Set the repeat rate and delay for all keyboards.
pub fn setRepeat( pub fn setRepeat(
allocator: *std.mem.Allocator, _: std.mem.Allocator,
seat: *Seat, seat: *Seat,
args: []const [:0]const u8, args: []const [:0]const u8,
out: *?[]const u8, _: *?[]const u8,
) Error!void { ) Error!void {
if (args.len < 3) return Error.NotEnoughArguments; if (args.len < 3) return Error.NotEnoughArguments;
if (args.len > 3) return Error.TooManyArguments; if (args.len > 3) return Error.TooManyArguments;

View File

@ -24,8 +24,8 @@ const Seat = @import("../Seat.zig");
/// Spawn a program. /// Spawn a program.
pub fn spawn( pub fn spawn(
allocator: *std.mem.Allocator, allocator: std.mem.Allocator,
seat: *Seat, _: *Seat,
args: []const [:0]const u8, args: []const [:0]const u8,
out: *?[]const u8, out: *?[]const u8,
) Error!void { ) Error!void {
@ -42,7 +42,7 @@ pub fn spawn(
if (pid == 0) { if (pid == 0) {
// Clean things up for the child in an intermediate fork // Clean things up for the child in an intermediate fork
if (c.setsid() < 0) unreachable; if (c.setsid() < 0) unreachable;
if (std.os.system.sigprocmask(std.os.SIG_SETMASK, &std.os.empty_sigset, null) < 0) unreachable; if (std.os.system.sigprocmask(std.os.SIG.SETMASK, &std.os.empty_sigset, null) < 0) unreachable;
const pid2 = std.os.fork() catch c._exit(1); const pid2 = std.os.fork() catch c._exit(1);
if (pid2 == 0) std.os.execveZ("/bin/sh", &child_args, std.c.environ) catch c._exit(1); if (pid2 == 0) std.os.execveZ("/bin/sh", &child_args, std.c.environ) catch c._exit(1);
@ -52,8 +52,8 @@ pub fn spawn(
// Wait the intermediate child. // Wait the intermediate child.
const ret = std.os.waitpid(pid, 0); const ret = std.os.waitpid(pid, 0);
if (!std.os.WIFEXITED(ret.status) or if (!std.os.W.IFEXITED(ret.status) or
(std.os.WIFEXITED(ret.status) and std.os.WEXITSTATUS(ret.status) != 0)) (std.os.W.IFEXITED(ret.status) and std.os.W.EXITSTATUS(ret.status) != 0))
{ {
out.* = try std.fmt.allocPrint(allocator, "fork/execve failed", .{}); out.* = try std.fmt.allocPrint(allocator, "fork/execve failed", .{});
return Error.Other; return Error.Other;

View File

@ -27,10 +27,10 @@ const ViewStack = @import("../view_stack.zig").ViewStack;
/// Swap the currently focused view with either the view higher or lower in the visible stack /// Swap the currently focused view with either the view higher or lower in the visible stack
pub fn swap( pub fn swap(
allocator: *std.mem.Allocator, _: std.mem.Allocator,
seat: *Seat, seat: *Seat,
args: []const [:0]const u8, args: []const [:0]const u8,
out: *?[]const u8, _: *?[]const u8,
) Error!void { ) Error!void {
if (args.len < 2) return Error.NotEnoughArguments; if (args.len < 2) return Error.NotEnoughArguments;
if (args.len > 2) return Error.TooManyArguments; if (args.len > 2) return Error.TooManyArguments;

View File

@ -24,7 +24,7 @@ const Seat = @import("../Seat.zig");
/// Switch focus to the passed tags. /// Switch focus to the passed tags.
pub fn setFocusedTags( pub fn setFocusedTags(
allocator: *std.mem.Allocator, allocator: std.mem.Allocator,
seat: *Seat, seat: *Seat,
args: []const [:0]const u8, args: []const [:0]const u8,
out: *?[]const u8, out: *?[]const u8,
@ -41,7 +41,7 @@ pub fn setFocusedTags(
/// Set the spawn tagmask /// Set the spawn tagmask
pub fn spawnTagmask( pub fn spawnTagmask(
allocator: *std.mem.Allocator, allocator: std.mem.Allocator,
seat: *Seat, seat: *Seat,
args: []const [:0]const u8, args: []const [:0]const u8,
out: *?[]const u8, out: *?[]const u8,
@ -52,7 +52,7 @@ pub fn spawnTagmask(
/// Set the tags of the focused view. /// Set the tags of the focused view.
pub fn setViewTags( pub fn setViewTags(
allocator: *std.mem.Allocator, allocator: std.mem.Allocator,
seat: *Seat, seat: *Seat,
args: []const [:0]const u8, args: []const [:0]const u8,
out: *?[]const u8, out: *?[]const u8,
@ -68,7 +68,7 @@ pub fn setViewTags(
/// Toggle focus of the passsed tags. /// Toggle focus of the passsed tags.
pub fn toggleFocusedTags( pub fn toggleFocusedTags(
allocator: *std.mem.Allocator, allocator: std.mem.Allocator,
seat: *Seat, seat: *Seat,
args: []const [:0]const u8, args: []const [:0]const u8,
out: *?[]const u8, out: *?[]const u8,
@ -87,7 +87,7 @@ pub fn toggleFocusedTags(
/// Toggle the passed tags of the focused view /// Toggle the passed tags of the focused view
pub fn toggleViewTags( pub fn toggleViewTags(
allocator: *std.mem.Allocator, allocator: std.mem.Allocator,
seat: *Seat, seat: *Seat,
args: []const [:0]const u8, args: []const [:0]const u8,
out: *?[]const u8, out: *?[]const u8,
@ -106,11 +106,12 @@ pub fn toggleViewTags(
/// Switch focus to tags that were selected previously /// Switch focus to tags that were selected previously
pub fn focusPreviousTags( pub fn focusPreviousTags(
allocator: *std.mem.Allocator, _: std.mem.Allocator,
seat: *Seat, seat: *Seat,
args: []const []const u8, args: []const []const u8,
out: *?[]const u8, _: *?[]const u8,
) Error!void { ) Error!void {
if (args.len > 1) return error.TooManyArguments;
const previous_tags = seat.focused_output.previous_tags; const previous_tags = seat.focused_output.previous_tags;
if (seat.focused_output.pending.tags != previous_tags) { if (seat.focused_output.pending.tags != previous_tags) {
seat.focused_output.previous_tags = seat.focused_output.pending.tags; seat.focused_output.previous_tags = seat.focused_output.pending.tags;
@ -123,11 +124,12 @@ pub fn focusPreviousTags(
/// Set the tags of the focused view to the tags that were selected previously /// Set the tags of the focused view to the tags that were selected previously
pub fn sendToPreviousTags( pub fn sendToPreviousTags(
allocator: *std.mem.Allocator, _: std.mem.Allocator,
seat: *Seat, seat: *Seat,
args: []const []const u8, args: []const []const u8,
out: *?[]const u8, _: *?[]const u8,
) Error!void { ) Error!void {
if (args.len > 1) return error.TooManyArguments;
const previous_tags = seat.focused_output.previous_tags; const previous_tags = seat.focused_output.previous_tags;
if (seat.focused == .view) { if (seat.focused == .view) {
const view = seat.focused.view; const view = seat.focused.view;
@ -138,7 +140,7 @@ pub fn sendToPreviousTags(
} }
fn parseTags( fn parseTags(
allocator: *std.mem.Allocator, allocator: std.mem.Allocator,
args: []const [:0]const u8, args: []const [:0]const u8,
out: *?[]const u8, out: *?[]const u8,
) Error!u32 { ) Error!u32 {

View File

@ -25,10 +25,10 @@ const Seat = @import("../Seat.zig");
/// Make the focused view float or stop floating, depending on its current /// Make the focused view float or stop floating, depending on its current
/// state. /// state.
pub fn toggleFloat( pub fn toggleFloat(
allocator: *std.mem.Allocator, _: std.mem.Allocator,
seat: *Seat, seat: *Seat,
args: []const [:0]const u8, args: []const [:0]const u8,
out: *?[]const u8, _: *?[]const u8,
) Error!void { ) Error!void {
if (args.len > 1) return Error.TooManyArguments; if (args.len > 1) return Error.TooManyArguments;

View File

@ -25,10 +25,10 @@ const Seat = @import("../Seat.zig");
/// Toggle fullscreen state of the currently focused view /// Toggle fullscreen state of the currently focused view
pub fn toggleFullscreen( pub fn toggleFullscreen(
allocator: *std.mem.Allocator, _: std.mem.Allocator,
seat: *Seat, seat: *Seat,
args: []const [:0]const u8, args: []const [:0]const u8,
out: *?[]const u8, _: *?[]const u8,
) Error!void { ) Error!void {
if (args.len > 1) return Error.TooManyArguments; if (args.len > 1) return Error.TooManyArguments;

View File

@ -21,10 +21,10 @@ const Error = @import("../command.zig").Error;
const Seat = @import("../Seat.zig"); const Seat = @import("../Seat.zig");
pub fn xcursorTheme( pub fn xcursorTheme(
allocator: *std.mem.Allocator, _: std.mem.Allocator,
seat: *Seat, seat: *Seat,
args: []const [:0]const u8, args: []const [:0]const u8,
out: *?[]const u8, _: *?[]const u8,
) Error!void { ) Error!void {
if (args.len < 2) return Error.NotEnoughArguments; if (args.len < 2) return Error.NotEnoughArguments;
if (args.len > 3) return Error.TooManyArguments; if (args.len > 3) return Error.TooManyArguments;

View File

@ -27,10 +27,10 @@ const ViewStack = @import("../view_stack.zig").ViewStack;
/// Bump the focused view to the top of the stack. If the view on the top of /// Bump the focused view to the top of the stack. If the view on the top of
/// the stack is focused, bump the second view to the top. /// the stack is focused, bump the second view to the top.
pub fn zoom( pub fn zoom(
allocator: *std.mem.Allocator, _: std.mem.Allocator,
seat: *Seat, seat: *Seat,
args: []const [:0]const u8, args: []const [:0]const u8,
out: *?[]const u8, _: *?[]const u8,
) Error!void { ) Error!void {
if (args.len > 1) return Error.TooManyArguments; if (args.len > 1) return Error.TooManyArguments;

View File

@ -17,9 +17,11 @@
const build_options = @import("build_options"); const build_options = @import("build_options");
const std = @import("std"); const std = @import("std");
const mem = std.mem;
const fs = std.fs; const fs = std.fs;
const io = std.io; const io = std.io;
const os = std.os; const os = std.os;
const builtin = @import("builtin");
const wlr = @import("wlroots"); const wlr = @import("wlroots");
const flags = @import("flags"); const flags = @import("flags");
@ -66,18 +68,20 @@ pub fn main() anyerror!void {
try io.getStdOut().writeAll(build_options.version ++ "\n"); try io.getStdOut().writeAll(build_options.version ++ "\n");
os.exit(0); os.exit(0);
} }
if (result.argFlag("-log-level")) |level_str| { if (result.argFlag("-log-level")) |level| {
const level = std.meta.stringToEnum(LogLevel, level_str) orelse { if (mem.eql(u8, level, std.log.Level.err.asText())) {
std.log.err("invalid log level '{s}'", .{level_str}); runtime_log_level = .err;
} else if (mem.eql(u8, level, std.log.Level.warn.asText())) {
runtime_log_level = .warn;
} else if (mem.eql(u8, level, std.log.Level.info.asText())) {
runtime_log_level = .info;
} else if (mem.eql(u8, level, std.log.Level.debug.asText())) {
runtime_log_level = .debug;
} else {
std.log.err("invalid log level '{s}'", .{level});
try io.getStdErr().writeAll(usage); try io.getStdErr().writeAll(usage);
os.exit(1); os.exit(1);
}; }
runtime_log_level = switch (level) {
.@"error" => .err,
.warning => .warn,
.info => .info,
.debug => .debug,
};
} }
const startup_command = blk: { const startup_command = blk: {
if (result.argFlag("-c")) |command| { if (result.argFlag("-c")) |command| {
@ -89,8 +93,8 @@ pub fn main() anyerror!void {
river_init_wlroots_log(switch (runtime_log_level) { river_init_wlroots_log(switch (runtime_log_level) {
.debug => .debug, .debug => .debug,
.notice, .info => .info, .info => .info,
.warn, .err, .crit, .alert, .emerg => .err, .warn, .err => .err,
}); });
std.log.info("initializing server", .{}); std.log.info("initializing server", .{});
@ -107,14 +111,14 @@ pub fn main() anyerror!void {
const pid = try os.fork(); const pid = try os.fork();
if (pid == 0) { if (pid == 0) {
if (c.setsid() < 0) unreachable; if (c.setsid() < 0) unreachable;
if (os.system.sigprocmask(os.SIG_SETMASK, &os.empty_sigset, null) < 0) unreachable; if (os.system.sigprocmask(os.SIG.SETMASK, &os.empty_sigset, null) < 0) unreachable;
os.execveZ("/bin/sh", &child_args, std.c.environ) catch c._exit(1); os.execveZ("/bin/sh", &child_args, std.c.environ) catch c._exit(1);
} }
util.gpa.free(cmd); util.gpa.free(cmd);
// Since the child has called setsid, the pid is the pgid // Since the child has called setsid, the pid is the pgid
break :blk pid; break :blk pid;
} else null; } else null;
defer if (child_pgid) |pgid| os.kill(-pgid, os.SIGTERM) catch |err| { defer if (child_pgid) |pgid| os.kill(-pgid, os.SIG.TERM) catch |err| {
std.log.err("failed to kill init process group: {s}", .{@errorName(err)}); std.log.err("failed to kill init process group: {s}", .{@errorName(err)});
}; };
@ -149,37 +153,23 @@ fn defaultInitPath() !?[:0]const u8 {
pub const log_level: std.log.Level = .debug; pub const log_level: std.log.Level = .debug;
/// Set the default log level based on the build mode. /// Set the default log level based on the build mode.
var runtime_log_level: std.log.Level = switch (std.builtin.mode) { var runtime_log_level: std.log.Level = switch (builtin.mode) {
.Debug => .debug, .Debug => .debug,
.ReleaseSafe, .ReleaseFast, .ReleaseSmall => .info, .ReleaseSafe, .ReleaseFast, .ReleaseSmall => .info,
}; };
/// River only exposes these 4 log levels to the user for simplicity
const LogLevel = enum {
@"error",
warning,
info,
debug,
};
pub fn log( pub fn log(
comptime message_level: std.log.Level, comptime level: std.log.Level,
comptime scope: @TypeOf(.EnumLiteral), comptime scope: @TypeOf(.EnumLiteral),
comptime format: []const u8, comptime format: []const u8,
args: anytype, args: anytype,
) void { ) void {
if (@enumToInt(message_level) > @enumToInt(runtime_log_level)) return; if (@enumToInt(level) > @enumToInt(runtime_log_level)) return;
const river_level: LogLevel = switch (message_level) {
.emerg, .alert, .crit, .err => .@"error",
.warn => .warning,
.notice, .info => .info,
.debug => .debug,
};
const scope_prefix = if (scope == .default) ": " else "(" ++ @tagName(scope) ++ "): "; const scope_prefix = if (scope == .default) ": " else "(" ++ @tagName(scope) ++ "): ";
const stderr = std.io.getStdErr().writer(); const stderr = std.io.getStdErr().writer();
stderr.print(@tagName(river_level) ++ scope_prefix ++ format ++ "\n", args) catch {}; stderr.print(level.asText() ++ scope_prefix ++ format ++ "\n", args) catch {};
} }
/// See wlroots_log_wrapper.c /// See wlroots_log_wrapper.c

View File

@ -48,7 +48,7 @@ const SurfaceRenderData = struct {
/// The rendering order in this function must be kept in sync with Cursor.surfaceAt() /// The rendering order in this function must be kept in sync with Cursor.surfaceAt()
pub fn renderOutput(output: *Output) void { pub fn renderOutput(output: *Output) void {
var now: os.timespec = undefined; var now: os.timespec = undefined;
os.clock_gettime(os.CLOCK_MONOTONIC, &now) catch @panic("CLOCK_MONOTONIC not supported"); os.clock_gettime(os.CLOCK.MONOTONIC, &now) catch @panic("CLOCK_MONOTONIC not supported");
var needs_frame: bool = undefined; var needs_frame: bool = undefined;
var damage_region: pixman.Region32 = undefined; var damage_region: pixman.Region32 = undefined;
@ -91,7 +91,7 @@ pub fn renderOutput(output: *Output) void {
it = ViewStack(View).iter(output.views.last, .reverse, output.current.tags, renderFilter); it = ViewStack(View).iter(output.views.last, .reverse, output.current.tags, renderFilter);
while (it.next()) |view| { while (it.next()) |view| {
if (view.current.focus != 0 or view.current.float) continue; if (view.current.focus != 0 or view.current.float) continue;
if (view.draw_borders) renderBorders(output, view, &now); if (view.draw_borders) renderBorders(output, view);
renderView(output, view, &now); renderView(output, view, &now);
} }
@ -99,7 +99,7 @@ pub fn renderOutput(output: *Output) void {
it = ViewStack(View).iter(output.views.last, .reverse, output.current.tags, renderFilter); it = ViewStack(View).iter(output.views.last, .reverse, output.current.tags, renderFilter);
while (it.next()) |view| { while (it.next()) |view| {
if (view.current.focus == 0 or view.current.float) continue; if (view.current.focus == 0 or view.current.float) continue;
if (view.draw_borders) renderBorders(output, view, &now); if (view.draw_borders) renderBorders(output, view);
renderView(output, view, &now); renderView(output, view, &now);
} }
@ -107,7 +107,7 @@ pub fn renderOutput(output: *Output) void {
it = ViewStack(View).iter(output.views.last, .reverse, output.current.tags, renderFilter); it = ViewStack(View).iter(output.views.last, .reverse, output.current.tags, renderFilter);
while (it.next()) |view| { while (it.next()) |view| {
if (view.current.focus != 0 or !view.current.float) continue; if (view.current.focus != 0 or !view.current.float) continue;
if (view.draw_borders) renderBorders(output, view, &now); if (view.draw_borders) renderBorders(output, view);
renderView(output, view, &now); renderView(output, view, &now);
} }
@ -115,7 +115,7 @@ pub fn renderOutput(output: *Output) void {
it = ViewStack(View).iter(output.views.last, .reverse, output.current.tags, renderFilter); it = ViewStack(View).iter(output.views.last, .reverse, output.current.tags, renderFilter);
while (it.next()) |view| { while (it.next()) |view| {
if (view.current.focus == 0 or !view.current.float) continue; if (view.current.focus == 0 or !view.current.float) continue;
if (view.draw_borders) renderBorders(output, view, &now); if (view.draw_borders) renderBorders(output, view);
renderView(output, view, &now); renderView(output, view, &now);
} }
@ -316,7 +316,7 @@ fn renderTexture(
server.renderer.renderSubtextureWithMatrix(texture, source_box, &matrix, 1.0) catch return; server.renderer.renderSubtextureWithMatrix(texture, source_box, &matrix, 1.0) catch return;
} }
fn renderBorders(output: *const Output, view: *View, now: *os.timespec) void { fn renderBorders(output: *const Output, view: *View) void {
const config = &server.config; const config = &server.config;
const color = blk: { const color = blk: {
if (view.current.urgent) break :blk &config.border_color_urgent; if (view.current.urgent) break :blk &config.border_color_urgent;

View File

@ -328,11 +328,11 @@ test "iteration (View)" {
const allocator = testing.allocator; const allocator = testing.allocator;
const filters = struct { const filters = struct {
fn all(view: *View, context: void) bool { fn all(_: *View, _: void) bool {
return true; return true;
} }
fn none(view: *View, context: void) bool { fn none(_: *View, _: void) bool {
return false; return false;
} }

View File

@ -20,6 +20,7 @@ const mem = std.mem;
const io = std.io; const io = std.io;
const os = std.os; const os = std.os;
const assert = std.debug.assert; const assert = std.debug.assert;
const builtin = @import("builtin");
const wayland = @import("wayland"); const wayland = @import("wayland");
const wl = wayland.client.wl; const wl = wayland.client.wl;
@ -47,8 +48,7 @@ pub const Globals = struct {
pub fn main() !void { pub fn main() !void {
_main() catch |err| { _main() catch |err| {
if (std.builtin.mode == .Debug) if (builtin.mode == .Debug) return err;
return err;
switch (err) { switch (err) {
error.RiverControlNotAdvertised => fatal( error.RiverControlNotAdvertised => fatal(
@ -96,7 +96,7 @@ fn _main() !void {
for (result.args) |arg| control.addArgument(arg); for (result.args) |arg| control.addArgument(arg);
const callback = try control.runCommand(seat); const callback = try control.runCommand(seat);
callback.setListener(?*c_void, callbackListener, null); callback.setListener(?*anyopaque, callbackListener, null);
// Loop until our callback is called and we exit. // Loop until our callback is called and we exit.
while (true) _ = try display.dispatch(); while (true) _ = try display.dispatch();
@ -116,7 +116,7 @@ fn registryListener(registry: *wl.Registry, event: wl.Registry.Event, globals: *
} }
} }
fn callbackListener(callback: *zriver.CommandCallbackV1, event: zriver.CommandCallbackV1.Event, _: ?*c_void) void { fn callbackListener(_: *zriver.CommandCallbackV1, event: zriver.CommandCallbackV1.Event, _: ?*anyopaque) void {
switch (event) { switch (event) {
.success => |success| { .success => |success| {
if (mem.len(success.output) > 0) { if (mem.len(success.output) > 0) {

View File

@ -140,7 +140,7 @@ const Output = struct {
.namespace_in_use => fatal("namespace 'rivertile' already in use.", .{}), .namespace_in_use => fatal("namespace 'rivertile' already in use.", .{}),
.user_command => |ev| { .user_command => |ev| {
var it = mem.tokenize(mem.span(ev.command), " "); var it = mem.tokenize(u8, mem.span(ev.command), " ");
const raw_cmd = it.next() orelse { const raw_cmd = it.next() orelse {
std.log.err("not enough arguments", .{}); std.log.err("not enough arguments", .{});
return; return;
@ -357,7 +357,7 @@ pub fn main() !void {
} }
const display = wl.Display.connect(null) catch { const display = wl.Display.connect(null) catch {
std.debug.warn("Unable to connect to Wayland server.\n", .{}); std.debug.print("Unable to connect to Wayland server.\n", .{});
os.exit(1); os.exit(1);
}; };
defer display.disconnect(); defer display.disconnect();