code: update to zig 0.8.0
This commit is contained in:
parent
ca4abd261f
commit
c0a2286847
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,2 +1,3 @@
|
|||||||
zig-cache
|
zig-cache/
|
||||||
|
zig-out/
|
||||||
doc/*.[1-9]
|
doc/*.[1-9]
|
||||||
|
10
build.zig
10
build.zig
@ -48,14 +48,12 @@ pub fn build(b: *zbs.Builder) !void {
|
|||||||
|
|
||||||
const examples = b.option(bool, "examples", "Set to true to build examples") orelse false;
|
const examples = b.option(bool, "examples", "Set to true to build examples") orelse false;
|
||||||
|
|
||||||
// This logic must match std.build.resolveInstallPrefix()
|
const rel_config_path = if (mem.eql(u8, try fs.path.resolve(b.allocator, &[_][]const u8{b.install_prefix}), "/usr"))
|
||||||
const prefix = b.install_prefix orelse if (b.dest_dir) |_| "/usr" else b.cache_root;
|
|
||||||
const rel_config_path = if (mem.eql(u8, try fs.path.resolve(b.allocator, &[_][]const u8{prefix}), "/usr"))
|
|
||||||
"../etc/river/init"
|
"../etc/river/init"
|
||||||
else
|
else
|
||||||
"etc/river/init";
|
"etc/river/init";
|
||||||
b.installFile("example/init", rel_config_path);
|
b.installFile("example/init", rel_config_path);
|
||||||
const abs_config_path = try fs.path.resolve(b.allocator, &[_][]const u8{ prefix, rel_config_path });
|
const abs_config_path = try fs.path.resolve(b.allocator, &[_][]const u8{ b.install_prefix, rel_config_path });
|
||||||
assert(fs.path.isAbsolute(abs_config_path));
|
assert(fs.path.isAbsolute(abs_config_path));
|
||||||
|
|
||||||
const scanner = ScanProtocolsStep.create(b);
|
const scanner = ScanProtocolsStep.create(b);
|
||||||
@ -226,7 +224,7 @@ const ScdocStep = struct {
|
|||||||
for (scd_paths) |path| {
|
for (scd_paths) |path| {
|
||||||
const command = try std.fmt.allocPrint(
|
const command = try std.fmt.allocPrint(
|
||||||
self.builder.allocator,
|
self.builder.allocator,
|
||||||
"scdoc < {} > {}",
|
"scdoc < {s} > {s}",
|
||||||
.{ path, path[0..(path.len - 4)] },
|
.{ path, path[0..(path.len - 4)] },
|
||||||
);
|
);
|
||||||
_ = try self.builder.exec(&[_][]const u8{ "sh", "-c", command });
|
_ = try self.builder.exec(&[_][]const u8{ "sh", "-c", command });
|
||||||
@ -243,7 +241,7 @@ const ScdocStep = struct {
|
|||||||
|
|
||||||
const output = try std.fmt.allocPrint(
|
const output = try std.fmt.allocPrint(
|
||||||
self.builder.allocator,
|
self.builder.allocator,
|
||||||
"share/man/man{}/{}",
|
"share/man/man{s}/{s}",
|
||||||
.{ section, basename_no_ext },
|
.{ section, basename_no_ext },
|
||||||
);
|
);
|
||||||
|
|
||||||
|
2
deps/zig-wayland
vendored
2
deps/zig-wayland
vendored
@ -1 +1 @@
|
|||||||
Subproject commit a453b26a078b94b19ac5e0d40407e241fcd1b6af
|
Subproject commit a8e1efcfd34ac798f19d8a62ebe3bb368c17f585
|
2
deps/zig-wlroots
vendored
2
deps/zig-wlroots
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 6c62568adfe92a1852566b7d091e99f4b28cbabb
|
Subproject commit d6444e7a8d43750e2d4ce0cb76483ff968848cb1
|
2
deps/zig-xkbcommon
vendored
2
deps/zig-xkbcommon
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 9e4d41fe9414094db31c873c2ad9cadcd8999cf6
|
Subproject commit 10cdca686dacb91d6cfe37f1839b6aedfb53cc4c
|
@ -112,8 +112,8 @@ pub fn init() !Self {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn deinit(self: *Self) void {
|
pub fn deinit(self: *Self) void {
|
||||||
var it = self.mode_to_id.iterator();
|
var it = self.mode_to_id.keyIterator();
|
||||||
while (it.next()) |e| util.gpa.free(e.key);
|
while (it.next()) |key| util.gpa.free(key.*);
|
||||||
self.mode_to_id.deinit();
|
self.mode_to_id.deinit();
|
||||||
|
|
||||||
for (self.modes.items) |mode| mode.deinit();
|
for (self.modes.items) |mode| mode.deinit();
|
||||||
|
@ -77,8 +77,8 @@ fn handleRequest(control: *zriver.ControlV1, request: zriver.ControlV1.Request,
|
|||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
const entry = self.args_map.getEntry(.{ .client = control.getClient(), .id = control.getId() }).?;
|
const args = self.args_map.getPtr(.{ .client = control.getClient(), .id = control.getId() }).?;
|
||||||
entry.value.append(util.gpa, owned_slice) catch {
|
args.append(util.gpa, owned_slice) catch {
|
||||||
control.getClient().postNoMemory();
|
control.getClient().postNoMemory();
|
||||||
util.gpa.free(owned_slice);
|
util.gpa.free(owned_slice);
|
||||||
return;
|
return;
|
||||||
@ -96,16 +96,15 @@ fn handleRequest(control: *zriver.ControlV1, request: zriver.ControlV1.Request,
|
|||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
const entry = self.args_map.getEntry(.{ .client = control.getClient(), .id = control.getId() }).?;
|
const args = self.args_map.getPtr(.{ .client = control.getClient(), .id = control.getId() }).?;
|
||||||
defer {
|
defer {
|
||||||
for (entry.value.items) |arg| util.gpa.free(arg);
|
for (args.items) |arg| util.gpa.free(arg);
|
||||||
entry.value.items.len = 0;
|
args.items.len = 0;
|
||||||
}
|
}
|
||||||
const args = entry.value.items;
|
|
||||||
|
|
||||||
var out: ?[]const u8 = null;
|
var out: ?[]const u8 = null;
|
||||||
defer if (out) |s| util.gpa.free(s);
|
defer if (out) |s| util.gpa.free(s);
|
||||||
command.run(util.gpa, seat, args, &out) catch |err| {
|
command.run(util.gpa, seat, args.items, &out) catch |err| {
|
||||||
const failure_message = switch (err) {
|
const failure_message = switch (err) {
|
||||||
command.Error.OutOfMemory => {
|
command.Error.OutOfMemory => {
|
||||||
callback.getClient().postNoMemory();
|
callback.getClient().postNoMemory();
|
||||||
@ -137,9 +136,9 @@ fn handleRequest(control: *zriver.ControlV1, request: zriver.ControlV1.Request,
|
|||||||
|
|
||||||
/// Remove the resource from the hash map and free all stored args
|
/// Remove the resource from the hash map and free all stored args
|
||||||
fn handleDestroy(control: *zriver.ControlV1, self: *Self) void {
|
fn handleDestroy(control: *zriver.ControlV1, self: *Self) void {
|
||||||
var list = self.args_map.remove(
|
var args = self.args_map.fetchRemove(
|
||||||
.{ .client = control.getClient(), .id = control.getId() },
|
.{ .client = control.getClient(), .id = control.getId() },
|
||||||
).?.value;
|
).?.value;
|
||||||
for (list.items) |arg| util.gpa.free(arg);
|
for (args.items) |arg| util.gpa.free(arg);
|
||||||
list.deinit(util.gpa);
|
args.deinit(util.gpa);
|
||||||
}
|
}
|
||||||
|
@ -149,7 +149,7 @@ pub fn setTheme(self: *Self, theme: ?[*:0]const u8, _size: ?u32) !void {
|
|||||||
while (it) |node| : (it = node.next) {
|
while (it) |node| : (it = node.next) {
|
||||||
const wlr_output = node.data.wlr_output;
|
const wlr_output = node.data.wlr_output;
|
||||||
self.xcursor_manager.load(wlr_output.scale) catch
|
self.xcursor_manager.load(wlr_output.scale) catch
|
||||||
log.err("failed to load xcursor theme '{}' at scale {}", .{ theme, wlr_output.scale });
|
log.err("failed to load xcursor theme '{s}' at scale {}", .{ theme, wlr_output.scale });
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this cursor belongs to the default seat, set the xcursor environment
|
// If this cursor belongs to the default seat, set the xcursor environment
|
||||||
@ -162,7 +162,7 @@ pub fn setTheme(self: *Self, theme: ?[*:0]const u8, _size: ?u32) !void {
|
|||||||
|
|
||||||
if (build_options.xwayland) {
|
if (build_options.xwayland) {
|
||||||
self.xcursor_manager.load(1) catch {
|
self.xcursor_manager.load(1) catch {
|
||||||
log.err("failed to load xcursor theme '{}' at scale 1", .{theme});
|
log.err("failed to load xcursor theme '{s}' at scale 1", .{theme});
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
const wlr_xcursor = self.xcursor_manager.getXcursor("left_ptr", 1).?;
|
const wlr_xcursor = self.xcursor_manager.getXcursor("left_ptr", 1).?;
|
||||||
@ -525,8 +525,8 @@ fn surfaceAtFilter(view: *View, filter_tags: u32) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Enter move or resize mode
|
/// Enter move or resize mode
|
||||||
pub fn enterMode(self: *Self, mode: @TagType(Mode), view: *View) void {
|
pub fn enterMode(self: *Self, mode: std.meta.Tag((Mode)), view: *View) void {
|
||||||
log.debug("enter {} mode", .{@tagName(mode)});
|
log.debug("enter {s} mode", .{@tagName(mode)});
|
||||||
|
|
||||||
self.seat.focus(view);
|
self.seat.focus(view);
|
||||||
|
|
||||||
@ -575,7 +575,7 @@ pub fn enterMode(self: *Self, mode: @TagType(Mode), view: *View) void {
|
|||||||
fn leaveMode(self: *Self, event: *wlr.Pointer.event.Button) void {
|
fn leaveMode(self: *Self, event: *wlr.Pointer.event.Button) void {
|
||||||
std.debug.assert(self.mode != .passthrough);
|
std.debug.assert(self.mode != .passthrough);
|
||||||
|
|
||||||
log.debug("leave {} mode", .{@tagName(self.mode)});
|
log.debug("leave {s} mode", .{@tagName(self.mode)});
|
||||||
|
|
||||||
// If we were in down mode, we need pass along the release event
|
// If we were in down mode, we need pass along the release event
|
||||||
if (self.mode == .down)
|
if (self.mode == .down)
|
||||||
|
@ -74,7 +74,7 @@ pub fn init(self: *Self, output: *Output, wlr_layer_surface: *wlr.LayerSurfaceV1
|
|||||||
fn handleDestroy(listener: *wl.Listener(*wlr.LayerSurfaceV1), wlr_layer_surface: *wlr.LayerSurfaceV1) void {
|
fn handleDestroy(listener: *wl.Listener(*wlr.LayerSurfaceV1), wlr_layer_surface: *wlr.LayerSurfaceV1) void {
|
||||||
const self = @fieldParentPtr(Self, "destroy", listener);
|
const self = @fieldParentPtr(Self, "destroy", listener);
|
||||||
|
|
||||||
log.debug("layer surface '{}' destroyed", .{self.wlr_layer_surface.namespace});
|
log.debug("layer surface '{s}' destroyed", .{self.wlr_layer_surface.namespace});
|
||||||
|
|
||||||
// Remove listeners active the entire lifetime of the layer surface
|
// Remove listeners active the entire lifetime of the layer surface
|
||||||
self.destroy.link.remove();
|
self.destroy.link.remove();
|
||||||
@ -90,7 +90,7 @@ fn handleDestroy(listener: *wl.Listener(*wlr.LayerSurfaceV1), wlr_layer_surface:
|
|||||||
fn handleMap(listener: *wl.Listener(*wlr.LayerSurfaceV1), wlr_layer_surface: *wlr.LayerSurfaceV1) void {
|
fn handleMap(listener: *wl.Listener(*wlr.LayerSurfaceV1), wlr_layer_surface: *wlr.LayerSurfaceV1) void {
|
||||||
const self = @fieldParentPtr(Self, "map", listener);
|
const self = @fieldParentPtr(Self, "map", listener);
|
||||||
|
|
||||||
log.debug("layer surface '{}' mapped", .{wlr_layer_surface.namespace});
|
log.debug("layer surface '{s}' mapped", .{wlr_layer_surface.namespace});
|
||||||
|
|
||||||
// Add listeners that are only active while mapped
|
// Add listeners that are only active while mapped
|
||||||
wlr_layer_surface.surface.events.commit.add(&self.commit);
|
wlr_layer_surface.surface.events.commit.add(&self.commit);
|
||||||
@ -104,7 +104,7 @@ fn handleMap(listener: *wl.Listener(*wlr.LayerSurfaceV1), wlr_layer_surface: *wl
|
|||||||
fn handleUnmap(listener: *wl.Listener(*wlr.LayerSurfaceV1), wlr_layer_surface: *wlr.LayerSurfaceV1) void {
|
fn handleUnmap(listener: *wl.Listener(*wlr.LayerSurfaceV1), wlr_layer_surface: *wlr.LayerSurfaceV1) void {
|
||||||
const self = @fieldParentPtr(Self, "unmap", listener);
|
const self = @fieldParentPtr(Self, "unmap", listener);
|
||||||
|
|
||||||
log.debug("layer surface '{}' unmapped", .{self.wlr_layer_surface.namespace});
|
log.debug("layer surface '{s}' unmapped", .{self.wlr_layer_surface.namespace});
|
||||||
|
|
||||||
// remove listeners only active while the layer surface is mapped
|
// remove listeners only active while the layer surface is mapped
|
||||||
self.commit.link.remove();
|
self.commit.link.remove();
|
||||||
|
@ -99,8 +99,8 @@ fn handleRequestInert(layout: *river.LayoutV2, request: river.LayoutV2.Request,
|
|||||||
/// Send a layout demand to the client
|
/// Send a layout demand to the client
|
||||||
pub fn startLayoutDemand(self: *Self, views: u32) void {
|
pub fn startLayoutDemand(self: *Self, views: u32) void {
|
||||||
log.debug(
|
log.debug(
|
||||||
"starting layout demand '{}' on output '{}'",
|
"starting layout demand '{s}' on output '{s}'",
|
||||||
.{ self.namespace, self.output.wlr_output.name },
|
.{ self.namespace, mem.sliceTo(&self.output.wlr_output.name, 0) },
|
||||||
);
|
);
|
||||||
|
|
||||||
std.debug.assert(self.output.layout_demand == null);
|
std.debug.assert(self.output.layout_demand == null);
|
||||||
@ -137,8 +137,8 @@ fn handleRequest(layout: *river.LayoutV2, request: river.LayoutV2.Request, self:
|
|||||||
// to the layout demand matching the serial.
|
// to the layout demand matching the serial.
|
||||||
.push_view_dimensions => |req| {
|
.push_view_dimensions => |req| {
|
||||||
log.debug(
|
log.debug(
|
||||||
"layout '{}' on output '{}' pushed view dimensions: {} {} {} {}",
|
"layout '{s}' on output '{s}' pushed view dimensions: {} {} {} {}",
|
||||||
.{ self.namespace, self.output.wlr_output.name, req.x, req.y, req.width, req.height },
|
.{ self.namespace, mem.sliceTo(&self.output.wlr_output.name, 0), req.x, req.y, req.width, req.height },
|
||||||
);
|
);
|
||||||
|
|
||||||
if (self.output.layout_demand) |*layout_demand| {
|
if (self.output.layout_demand) |*layout_demand| {
|
||||||
@ -154,8 +154,8 @@ fn handleRequest(layout: *river.LayoutV2, request: river.LayoutV2.Request, self:
|
|||||||
// of the layout demand matching the serial as done.
|
// of the layout demand matching the serial as done.
|
||||||
.commit => |req| {
|
.commit => |req| {
|
||||||
log.debug(
|
log.debug(
|
||||||
"layout '{}' on output '{}' commited",
|
"layout '{s}' on output '{s}' commited",
|
||||||
.{ self.namespace, self.output.wlr_output.name },
|
.{ self.namespace, mem.sliceTo(&self.output.wlr_output.name, 0) },
|
||||||
);
|
);
|
||||||
|
|
||||||
if (self.output.layout_demand) |*layout_demand| {
|
if (self.output.layout_demand) |*layout_demand| {
|
||||||
@ -170,8 +170,8 @@ fn handleRequest(layout: *river.LayoutV2, request: river.LayoutV2.Request, self:
|
|||||||
|
|
||||||
fn handleDestroy(layout: *river.LayoutV2, self: *Self) void {
|
fn handleDestroy(layout: *river.LayoutV2, self: *Self) void {
|
||||||
log.debug(
|
log.debug(
|
||||||
"destroying layout '{}' on output '{}'",
|
"destroying layout '{s}' on output '{s}'",
|
||||||
.{ self.namespace, self.output.wlr_output.name },
|
.{ self.namespace, mem.sliceTo(&self.output.wlr_output.name, 0) },
|
||||||
);
|
);
|
||||||
|
|
||||||
// Remove layout from the list
|
// Remove layout from the list
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
const Self = @This();
|
const Self = @This();
|
||||||
|
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
|
const mem = std.mem;
|
||||||
const wlr = @import("wlroots");
|
const wlr = @import("wlroots");
|
||||||
const wayland = @import("wayland");
|
const wayland = @import("wayland");
|
||||||
const wl = wayland.server.wl;
|
const wl = wayland.server.wl;
|
||||||
@ -69,8 +70,8 @@ pub fn deinit(self: *const Self) void {
|
|||||||
/// 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.notice(
|
||||||
"layout demand for layout '{}' on output '{}' timed out",
|
"layout demand for layout '{s}' on output '{s}' timed out",
|
||||||
.{ layout.namespace, layout.output.wlr_output.name },
|
.{ layout.namespace, mem.sliceTo(&layout.output.wlr_output.name, 0) },
|
||||||
);
|
);
|
||||||
layout.output.layout_demand.?.deinit();
|
layout.output.layout_demand.?.deinit();
|
||||||
layout.output.layout_demand = null;
|
layout.output.layout_demand = null;
|
||||||
|
@ -67,7 +67,7 @@ fn handleRequest(layout_manager: *river.LayoutManagerV2, request: river.LayoutMa
|
|||||||
const wlr_output = wlr.Output.fromWlOutput(req.output) orelse return;
|
const wlr_output = wlr.Output.fromWlOutput(req.output) orelse return;
|
||||||
const output = @intToPtr(*Output, wlr_output.data);
|
const output = @intToPtr(*Output, wlr_output.data);
|
||||||
|
|
||||||
log.debug("bind layout '{}' on output '{}'", .{ req.namespace, output.wlr_output.name });
|
log.debug("bind layout '{s}' on output '{s}'", .{ req.namespace, mem.sliceTo(&output.wlr_output.name, 0) });
|
||||||
|
|
||||||
Layout.create(
|
Layout.create(
|
||||||
layout_manager.getClient(),
|
layout_manager.getClient(),
|
||||||
|
@ -304,7 +304,7 @@ fn arrangeLayer(
|
|||||||
// should only ever be encountered very rarely and matches the
|
// should only ever be encountered very rarely and matches the
|
||||||
// behavior of other compositors.
|
// behavior of other compositors.
|
||||||
std.log.scoped(.layer_shell).warn(
|
std.log.scoped(.layer_shell).warn(
|
||||||
"margins of layer surface '{}' are too large to be reasonably handled. Closing.",
|
"margins of layer surface '{s}' are too large to be reasonably handled. Closing.",
|
||||||
.{layer_surface.wlr_layer_surface.namespace},
|
.{layer_surface.wlr_layer_surface.namespace},
|
||||||
);
|
);
|
||||||
layer_surface.wlr_layer_surface.close();
|
layer_surface.wlr_layer_surface.close();
|
||||||
@ -333,7 +333,7 @@ fn arrangeLayer(
|
|||||||
if (vertical_margin_size >= bounds.height) {
|
if (vertical_margin_size >= bounds.height) {
|
||||||
// TODO find a better solution, see explanation above
|
// TODO find a better solution, see explanation above
|
||||||
std.log.scoped(.layer_shell).warn(
|
std.log.scoped(.layer_shell).warn(
|
||||||
"margins of layer surface '{}' are too large to be reasonably handled. Closing.",
|
"margins of layer surface '{s}' are too large to be reasonably handled. Closing.",
|
||||||
.{layer_surface.wlr_layer_surface.namespace},
|
.{layer_surface.wlr_layer_surface.namespace},
|
||||||
);
|
);
|
||||||
layer_surface.wlr_layer_surface.close();
|
layer_surface.wlr_layer_surface.close();
|
||||||
@ -419,7 +419,7 @@ fn arrangeLayer(
|
|||||||
fn handleDestroy(listener: *wl.Listener(*wlr.Output), wlr_output: *wlr.Output) void {
|
fn handleDestroy(listener: *wl.Listener(*wlr.Output), wlr_output: *wlr.Output) void {
|
||||||
const self = @fieldParentPtr(Self, "destroy", listener);
|
const self = @fieldParentPtr(Self, "destroy", listener);
|
||||||
|
|
||||||
std.log.scoped(.server).debug("output '{}' destroyed", .{self.wlr_output.name});
|
std.log.scoped(.server).debug("output '{s}' destroyed", .{mem.sliceTo(&self.wlr_output.name, 0)});
|
||||||
|
|
||||||
// Remove the destroyed output from root if it wasn't already removed
|
// Remove the destroyed output from root if it wasn't already removed
|
||||||
server.root.removeOutput(self);
|
server.root.removeOutput(self);
|
||||||
@ -482,7 +482,7 @@ pub fn getEffectiveResolution(self: *Self) struct { width: u32, height: u32 } {
|
|||||||
|
|
||||||
fn setTitle(self: Self) void {
|
fn setTitle(self: Self) void {
|
||||||
var buf: ["river - ".len + self.wlr_output.name.len + 1]u8 = undefined;
|
var buf: ["river - ".len + self.wlr_output.name.len + 1]u8 = undefined;
|
||||||
const title = fmt.bufPrintZ(&buf, "river - {}", .{mem.spanZ(&self.wlr_output.name)}) catch unreachable;
|
const title = fmt.bufPrintZ(&buf, "river - {s}", .{mem.sliceTo(&self.wlr_output.name, 0)}) catch unreachable;
|
||||||
if (self.wlr_output.isWl()) {
|
if (self.wlr_output.isWl()) {
|
||||||
self.wlr_output.wlSetTitle(title);
|
self.wlr_output.wlSetTitle(title);
|
||||||
} else if (wlr.config.has_x11_backend and self.wlr_output.isX11()) {
|
} else if (wlr.config.has_x11_backend and self.wlr_output.isX11()) {
|
||||||
|
@ -19,6 +19,7 @@ const Self = @This();
|
|||||||
|
|
||||||
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 assert = std.debug.assert;
|
const assert = std.debug.assert;
|
||||||
const wlr = @import("wlroots");
|
const wlr = @import("wlroots");
|
||||||
const wl = @import("wayland").server.wl;
|
const wl = @import("wayland").server.wl;
|
||||||
@ -75,7 +76,7 @@ xwayland_unmanaged_views: if (build_options.xwayland)
|
|||||||
std.TailQueue(XwaylandUnmanaged)
|
std.TailQueue(XwaylandUnmanaged)
|
||||||
else
|
else
|
||||||
void = if (build_options.xwayland)
|
void = if (build_options.xwayland)
|
||||||
.{},
|
.{},
|
||||||
|
|
||||||
/// Number of layout demands pending before the transaction may be started.
|
/// Number of layout demands pending before the transaction may be started.
|
||||||
pending_layout_demands: u32 = 0,
|
pending_layout_demands: u32 = 0,
|
||||||
@ -128,7 +129,7 @@ pub fn deinit(self: *Self) void {
|
|||||||
|
|
||||||
fn handleNewOutput(listener: *wl.Listener(*wlr.Output), wlr_output: *wlr.Output) void {
|
fn handleNewOutput(listener: *wl.Listener(*wlr.Output), wlr_output: *wlr.Output) void {
|
||||||
const self = @fieldParentPtr(Self, "new_output", listener);
|
const self = @fieldParentPtr(Self, "new_output", listener);
|
||||||
std.log.scoped(.output_manager).debug("new output {}", .{wlr_output.name});
|
std.log.scoped(.output_manager).debug("new output {s}", .{mem.sliceTo(&wlr_output.name, 0)});
|
||||||
|
|
||||||
const node = util.gpa.create(std.TailQueue(Output).Node) catch {
|
const node = util.gpa.create(std.TailQueue(Output).Node) catch {
|
||||||
wlr_output.destroy();
|
wlr_output.destroy();
|
||||||
@ -475,7 +476,7 @@ fn applyOutputConfig(self: *Self, config: *wlr.OutputConfigurationV1) bool {
|
|||||||
// Since we have done a successful test commit, this will only fail
|
// Since we have done a successful test commit, this will only fail
|
||||||
// due to error in the output's backend implementation.
|
// due to error in the output's backend implementation.
|
||||||
output.wlr_output.commit() catch
|
output.wlr_output.commit() catch
|
||||||
std.log.scoped(.output_manager).err("output commit failed for {}", .{output.wlr_output.name});
|
std.log.scoped(.output_manager).err("output commit failed for {s}", .{mem.sliceTo(&output.wlr_output.name, 0)});
|
||||||
|
|
||||||
if (output.wlr_output.enabled) {
|
if (output.wlr_output.enabled) {
|
||||||
// Moves the output if it is already in the layout
|
// Moves the output if it is already in the layout
|
||||||
@ -514,8 +515,8 @@ fn testOutputConfig(config: *wlr.OutputConfigurationV1, rollback: bool) bool {
|
|||||||
|
|
||||||
if (too_small) {
|
if (too_small) {
|
||||||
std.log.scoped(.output_manager).info(
|
std.log.scoped(.output_manager).info(
|
||||||
"The requested output resolution {}x{} scaled with {} for {} would be too small.",
|
"The requested output resolution {}x{} scaled with {} for {s} would be too small.",
|
||||||
.{ width, height, scale, wlr_output.name },
|
.{ width, height, scale, mem.sliceTo(&wlr_output.name, 0) },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -586,11 +587,12 @@ fn handlePowerManagerSetMode(
|
|||||||
|
|
||||||
const log_text = if (enable) "Enabling" else "Disabling";
|
const log_text = if (enable) "Enabling" else "Disabling";
|
||||||
std.log.scoped(.output_manager).debug(
|
std.log.scoped(.output_manager).debug(
|
||||||
"{} dpms for output {}",
|
"{s} dpms for output {s}",
|
||||||
.{ log_text, event.output.name },
|
.{ log_text, mem.sliceTo(&event.output.name, 0) },
|
||||||
);
|
);
|
||||||
|
|
||||||
event.output.enable(enable);
|
event.output.enable(enable);
|
||||||
event.output.commit() catch
|
event.output.commit() catch {
|
||||||
std.log.scoped(.server).err("output commit failed for {}", .{event.output.name});
|
std.log.scoped(.server).err("output commit failed for {s}", .{mem.sliceTo(&event.output.name, 0)});
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
@ -319,13 +319,14 @@ pub fn handleMapping(
|
|||||||
command.Error.Other => out.?,
|
command.Error.Other => out.?,
|
||||||
else => command.errToMsg(err),
|
else => command.errToMsg(err),
|
||||||
};
|
};
|
||||||
std.log.scoped(.command).err("{}: {}", .{ args[0], failure_message });
|
std.log.scoped(.command).err("{s}: {s}", .{ args[0], failure_message });
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
if (out) |s| {
|
if (out) |s| {
|
||||||
const stdout = std.io.getStdOut().outStream();
|
const stdout = std.io.getStdOut().writer();
|
||||||
stdout.print("{}", .{s}) catch
|
stdout.print("{s}", .{s}) catch |err| {
|
||||||
|err| std.log.scoped(.command).err("{}: write to stdout failed {}", .{ args[0], err });
|
std.log.scoped(.command).err("{s}: write to stdout failed {}", .{ args[0], err });
|
||||||
|
};
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ const Self = @This();
|
|||||||
|
|
||||||
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 wlr = @import("wlroots");
|
const wlr = @import("wlroots");
|
||||||
const wl = @import("wayland").server.wl;
|
const wl = @import("wayland").server.wl;
|
||||||
|
|
||||||
@ -188,7 +189,7 @@ fn handleNewLayerSurface(listener: *wl.Listener(*wlr.LayerSurfaceV1), wlr_layer_
|
|||||||
const self = @fieldParentPtr(Self, "new_layer_surface", listener);
|
const self = @fieldParentPtr(Self, "new_layer_surface", listener);
|
||||||
|
|
||||||
log.debug(
|
log.debug(
|
||||||
"New layer surface: namespace {}, layer {}, anchor {}, size {}x{}, margin ({},{},{},{}), exclusive_zone {}",
|
"New layer surface: namespace {s}, layer {}, anchor {}, size {}x{}, margin ({},{},{},{}), exclusive_zone {}",
|
||||||
.{
|
.{
|
||||||
wlr_layer_surface.namespace,
|
wlr_layer_surface.namespace,
|
||||||
wlr_layer_surface.client_pending.layer,
|
wlr_layer_surface.client_pending.layer,
|
||||||
@ -208,13 +209,13 @@ fn handleNewLayerSurface(listener: *wl.Listener(*wlr.LayerSurfaceV1), wlr_layer_
|
|||||||
if (wlr_layer_surface.output == null) {
|
if (wlr_layer_surface.output == null) {
|
||||||
const output = self.input_manager.defaultSeat().focused_output;
|
const output = self.input_manager.defaultSeat().focused_output;
|
||||||
if (output == &self.root.noop_output) {
|
if (output == &self.root.noop_output) {
|
||||||
log.err("no output available for layer surface '{}'", .{wlr_layer_surface.namespace});
|
log.err("no output available for layer surface '{s}'", .{wlr_layer_surface.namespace});
|
||||||
wlr_layer_surface.close();
|
wlr_layer_surface.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
log.debug("new layer surface had null output, assigning it to output '{}'", .{
|
log.debug("new layer surface had null output, assigning it to output '{s}'", .{
|
||||||
output.wlr_output.name,
|
mem.sliceTo(&output.wlr_output.name, 0),
|
||||||
});
|
});
|
||||||
wlr_layer_surface.output = output.wlr_output;
|
wlr_layer_surface.output = output.wlr_output;
|
||||||
}
|
}
|
||||||
@ -241,7 +242,7 @@ fn handleNewXwaylandSurface(listener: *wl.Listener(*wlr.XwaylandSurface), wlr_xw
|
|||||||
}
|
}
|
||||||
|
|
||||||
log.debug(
|
log.debug(
|
||||||
"new xwayland surface: title '{}', class '{}'",
|
"new xwayland surface: title '{s}', class '{s}'",
|
||||||
.{ wlr_xwayland_surface.title, wlr_xwayland_surface.class },
|
.{ wlr_xwayland_surface.title, wlr_xwayland_surface.class },
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -446,7 +446,7 @@ pub fn shouldTrackConfigure(self: Self) bool {
|
|||||||
pub fn map(self: *Self) void {
|
pub fn map(self: *Self) void {
|
||||||
self.pending.target_opacity = server.config.opacity.unfocused;
|
self.pending.target_opacity = server.config.opacity.unfocused;
|
||||||
|
|
||||||
log.debug("view '{}' mapped", .{self.getTitle()});
|
log.debug("view '{s}' mapped", .{self.getTitle()});
|
||||||
|
|
||||||
if (self.foreign_toplevel_handle == null) {
|
if (self.foreign_toplevel_handle == null) {
|
||||||
self.foreign_toplevel_handle = wlr.ForeignToplevelHandleV1.create(
|
self.foreign_toplevel_handle = wlr.ForeignToplevelHandleV1.create(
|
||||||
@ -487,7 +487,7 @@ pub fn map(self: *Self) void {
|
|||||||
|
|
||||||
/// Called by the impl when the surface will no longer be displayed
|
/// Called by the impl when the surface will no longer be displayed
|
||||||
pub fn unmap(self: *Self) void {
|
pub fn unmap(self: *Self) void {
|
||||||
log.debug("view '{}' unmapped", .{self.getTitle()});
|
log.debug("view '{s}' unmapped", .{self.getTitle()});
|
||||||
|
|
||||||
self.destroying = true;
|
self.destroying = true;
|
||||||
if (self.saved_buffers.items.len == 0) self.saveBuffers();
|
if (self.saved_buffers.items.len == 0) self.saveBuffers();
|
||||||
@ -558,7 +558,7 @@ fn killOpacityTimer(self: *Self) void {
|
|||||||
fn armOpacityTimer(self: *Self) void {
|
fn armOpacityTimer(self: *Self) void {
|
||||||
const delta_t = server.config.opacity.delta_t;
|
const delta_t = server.config.opacity.delta_t;
|
||||||
self.opacity_timer.?.timerUpdate(delta_t) catch |err| {
|
self.opacity_timer.?.timerUpdate(delta_t) catch |err| {
|
||||||
log.err("failed to update opacity timer: {}", .{err});
|
log.err("failed to update opacity timer: {s}", .{err});
|
||||||
self.killOpacityTimer();
|
self.killOpacityTimer();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -577,7 +577,7 @@ fn handleOpacityTimer(self: *Self) callconv(.C) c_int {
|
|||||||
fn attachOpacityTimer(self: *Self) void {
|
fn attachOpacityTimer(self: *Self) void {
|
||||||
const event_loop = server.wl_server.getEventLoop();
|
const event_loop = server.wl_server.getEventLoop();
|
||||||
self.opacity_timer = event_loop.addTimer(*Self, handleOpacityTimer, self) catch {
|
self.opacity_timer = event_loop.addTimer(*Self, handleOpacityTimer, self) catch {
|
||||||
log.err("failed to create opacity timer for view '{}'", .{self.getTitle()});
|
log.err("failed to create opacity timer for view '{s}'", .{self.getTitle()});
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
self.armOpacityTimer();
|
self.armOpacityTimer();
|
||||||
|
@ -45,7 +45,7 @@ pub fn enterMode(
|
|||||||
const mode_id = server.config.mode_to_id.get(target_mode) orelse {
|
const mode_id = server.config.mode_to_id.get(target_mode) orelse {
|
||||||
out.* = try std.fmt.allocPrint(
|
out.* = try std.fmt.allocPrint(
|
||||||
allocator,
|
allocator,
|
||||||
"cannot enter non-existant mode '{}'",
|
"cannot enter non-existant mode '{s}'",
|
||||||
.{target_mode},
|
.{target_mode},
|
||||||
);
|
);
|
||||||
return Error.Other;
|
return Error.Other;
|
||||||
|
@ -85,7 +85,7 @@ pub fn mapPointer(
|
|||||||
else {
|
else {
|
||||||
out.* = try std.fmt.allocPrint(
|
out.* = try std.fmt.allocPrint(
|
||||||
allocator,
|
allocator,
|
||||||
"invalid pointer action {}, must be move-view or resize-view",
|
"invalid pointer action {s}, must be move-view or resize-view",
|
||||||
.{args[4]},
|
.{args[4]},
|
||||||
);
|
);
|
||||||
return Error.Other;
|
return Error.Other;
|
||||||
@ -110,7 +110,7 @@ fn modeNameToId(allocator: *std.mem.Allocator, seat: *Seat, mode_name: []const u
|
|||||||
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(
|
||||||
allocator,
|
allocator,
|
||||||
"cannot add/remove mapping to/from non-existant mode '{}'",
|
"cannot add/remove mapping to/from non-existant mode '{s}'",
|
||||||
.{mode_name},
|
.{mode_name},
|
||||||
);
|
);
|
||||||
return Error.Other;
|
return Error.Other;
|
||||||
@ -153,7 +153,7 @@ fn parseEventCode(allocator: *std.mem.Allocator, event_code_str: []const u8, out
|
|||||||
defer allocator.free(event_code_name);
|
defer allocator.free(event_code_name);
|
||||||
const ret = c.libevdev_event_code_from_name(c.EV_KEY, event_code_name);
|
const ret = c.libevdev_event_code_from_name(c.EV_KEY, event_code_name);
|
||||||
if (ret < 1) {
|
if (ret < 1) {
|
||||||
out.* = try std.fmt.allocPrint(allocator, "unknown button {}", .{event_code_str});
|
out.* = try std.fmt.allocPrint(allocator, "unknown button {s}", .{event_code_str});
|
||||||
return Error.Other;
|
return Error.Other;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,7 +165,7 @@ fn parseKeysym(allocator: *std.mem.Allocator, keysym_str: []const u8, out: *?[]c
|
|||||||
defer allocator.free(keysym_name);
|
defer allocator.free(keysym_name);
|
||||||
const keysym = xkb.Keysym.fromName(keysym_name, .case_insensitive);
|
const keysym = xkb.Keysym.fromName(keysym_name, .case_insensitive);
|
||||||
if (keysym == .NoSymbol) {
|
if (keysym == .NoSymbol) {
|
||||||
out.* = try std.fmt.allocPrint(allocator, "invalid keysym '{}'", .{keysym_str});
|
out.* = try std.fmt.allocPrint(allocator, "invalid keysym '{s}'", .{keysym_str});
|
||||||
return Error.Other;
|
return Error.Other;
|
||||||
}
|
}
|
||||||
return keysym;
|
return keysym;
|
||||||
@ -195,11 +195,7 @@ fn parseModifiers(
|
|||||||
continue :outer;
|
continue :outer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
out.* = try std.fmt.allocPrint(
|
out.* = try std.fmt.allocPrint(allocator, "invalid modifier '{s}'", .{mod_name});
|
||||||
allocator,
|
|
||||||
"invalid modifier '{}'",
|
|
||||||
.{mod_name},
|
|
||||||
);
|
|
||||||
return Error.Other;
|
return Error.Other;
|
||||||
}
|
}
|
||||||
return modifiers;
|
return modifiers;
|
||||||
|
@ -52,7 +52,7 @@ pub fn main() anyerror!void {
|
|||||||
_ = it.nextPosix();
|
_ = it.nextPosix();
|
||||||
while (it.nextPosix()) |arg| {
|
while (it.nextPosix()) |arg| {
|
||||||
if (std.mem.eql(u8, arg, "-h")) {
|
if (std.mem.eql(u8, arg, "-h")) {
|
||||||
const stdout = std.io.getStdOut().outStream();
|
const stdout = std.io.getStdOut().writer();
|
||||||
try stdout.print(usage, .{});
|
try stdout.print(usage, .{});
|
||||||
os.exit(0);
|
os.exit(0);
|
||||||
} else if (std.mem.eql(u8, arg, "-c")) {
|
} else if (std.mem.eql(u8, arg, "-c")) {
|
||||||
@ -67,13 +67,13 @@ pub fn main() anyerror!void {
|
|||||||
} else if (std.mem.eql(u8, arg, "-l")) {
|
} else if (std.mem.eql(u8, arg, "-l")) {
|
||||||
if (it.nextPosix()) |level_str| {
|
if (it.nextPosix()) |level_str| {
|
||||||
const log_level = std.fmt.parseInt(u3, level_str, 10) catch
|
const log_level = std.fmt.parseInt(u3, level_str, 10) catch
|
||||||
printErrorExit("Error: invalid log level '{}'", .{level_str});
|
printErrorExit("Error: invalid log level '{s}'", .{level_str});
|
||||||
level = @intToEnum(std.log.Level, log_level);
|
level = @intToEnum(std.log.Level, log_level);
|
||||||
} else {
|
} else {
|
||||||
printErrorExit("Error: flag '-l' requires exactly one argument", .{});
|
printErrorExit("Error: flag '-l' requires exactly one argument", .{});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const stderr = std.io.getStdErr().outStream();
|
const stderr = std.io.getStdErr().writer();
|
||||||
try stderr.print(usage, .{});
|
try stderr.print(usage, .{});
|
||||||
os.exit(1);
|
os.exit(1);
|
||||||
}
|
}
|
||||||
@ -99,7 +99,7 @@ pub fn main() anyerror!void {
|
|||||||
// Run the child in a new process group so that we can send SIGTERM to all
|
// Run the child in a new process group so that we can send SIGTERM to all
|
||||||
// descendants on exit.
|
// descendants on exit.
|
||||||
const child_pgid = if (startup_command) |cmd| blk: {
|
const child_pgid = if (startup_command) |cmd| blk: {
|
||||||
std.log.info("running startup command '{}'", .{cmd});
|
std.log.info("running startup command '{s}'", .{cmd});
|
||||||
const child_args = [_:null]?[*:0]const u8{ "/bin/sh", "-c", cmd, null };
|
const child_args = [_:null]?[*:0]const u8{ "/bin/sh", "-c", cmd, null };
|
||||||
const pid = try os.fork();
|
const pid = try os.fork();
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
@ -112,7 +112,7 @@ pub fn main() anyerror!void {
|
|||||||
break :blk pid;
|
break :blk pid;
|
||||||
} else null;
|
} else null;
|
||||||
defer if (child_pgid) |pgid|
|
defer if (child_pgid) |pgid|
|
||||||
os.kill(-pgid, os.SIGTERM) catch |e| std.log.err("failed to kill startup process: {}", .{e});
|
os.kill(-pgid, os.SIGTERM) catch |e| std.log.err("failed to kill startup process: {s}", .{e});
|
||||||
|
|
||||||
std.log.info("running server", .{});
|
std.log.info("running server", .{});
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ pub fn main() anyerror!void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn printErrorExit(comptime format: []const u8, args: anytype) noreturn {
|
fn printErrorExit(comptime format: []const u8, args: anytype) noreturn {
|
||||||
const stderr = std.io.getStdErr().outStream();
|
const stderr = std.io.getStdErr().writer();
|
||||||
stderr.print(format ++ "\n", args) catch os.exit(1);
|
stderr.print(format ++ "\n", args) catch os.exit(1);
|
||||||
os.exit(1);
|
os.exit(1);
|
||||||
}
|
}
|
||||||
@ -138,11 +138,11 @@ fn testConfigPath(comptime fmt: []const u8, args: anytype) std.fmt.AllocPrintErr
|
|||||||
|
|
||||||
fn getStartupCommand() std.fmt.AllocPrintError!?[:0]const u8 {
|
fn getStartupCommand() std.fmt.AllocPrintError!?[:0]const u8 {
|
||||||
if (os.getenv("XDG_CONFIG_HOME")) |xdg_config_home| {
|
if (os.getenv("XDG_CONFIG_HOME")) |xdg_config_home| {
|
||||||
if (try testConfigPath("{}/river/init", .{xdg_config_home})) |path| {
|
if (try testConfigPath("{s}/river/init", .{xdg_config_home})) |path| {
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
} else if (os.getenv("HOME")) |home| {
|
} else if (os.getenv("HOME")) |home| {
|
||||||
if (try testConfigPath("{}/.config/river/init", .{home})) |path| {
|
if (try testConfigPath("{s}/.config/river/init", .{home})) |path| {
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
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 os = std.os;
|
const os = std.os;
|
||||||
const wlr = @import("wlroots");
|
const wlr = @import("wlroots");
|
||||||
const wl = @import("wayland").server.wl;
|
const wl = @import("wayland").server.wl;
|
||||||
@ -159,7 +160,7 @@ pub fn renderOutput(output: *Output) void {
|
|||||||
|
|
||||||
// TODO: handle failure
|
// TODO: handle failure
|
||||||
output.wlr_output.commit() catch
|
output.wlr_output.commit() catch
|
||||||
log.err("output commit failed for {}", .{output.wlr_output.name});
|
log.err("output commit failed for {s}", .{mem.sliceTo(&output.wlr_output.name, 0)});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn renderFilter(view: *View, filter_tags: u32) bool {
|
fn renderFilter(view: *View, filter_tags: u32) bool {
|
||||||
|
@ -92,17 +92,17 @@ fn callbackListener(callback: *zriver.CommandCallbackV1, event: zriver.CommandCa
|
|||||||
switch (event) {
|
switch (event) {
|
||||||
.success => |success| {
|
.success => |success| {
|
||||||
if (mem.len(success.output) > 0) {
|
if (mem.len(success.output) > 0) {
|
||||||
const stdout = std.io.getStdOut().outStream();
|
const stdout = std.io.getStdOut().writer();
|
||||||
stdout.print("{}\n", .{success.output}) catch @panic("failed to write to stdout");
|
stdout.print("{s}\n", .{success.output}) catch @panic("failed to write to stdout");
|
||||||
}
|
}
|
||||||
os.exit(0);
|
os.exit(0);
|
||||||
},
|
},
|
||||||
.failure => |failure| printErrorExit("Error: {}\n", .{failure.failure_message}),
|
.failure => |failure| printErrorExit("Error: {s}\n", .{failure.failure_message}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn printErrorExit(comptime format: []const u8, args: anytype) noreturn {
|
pub fn printErrorExit(comptime format: []const u8, args: anytype) noreturn {
|
||||||
const stderr = std.io.getStdErr().outStream();
|
const stderr = std.io.getStdErr().writer();
|
||||||
stderr.print("err: " ++ format ++ "\n", args) catch std.os.exit(1);
|
stderr.print("err: " ++ format ++ "\n", args) catch std.os.exit(1);
|
||||||
std.os.exit(1);
|
std.os.exit(1);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user