Wayland compositor (wlroots)
git clone https://git.lucas.co/cce-compositor.git
river: clean up logging scopes
river/Cursor.zig | 2 +-
river/InputConfig.zig | 2 +-
river/InputDevice.zig | 2 +-
river/InputManager.zig | 2 +-
river/InputRelay.zig | 2 +-
river/Keyboard.zig | 7 +++----
river/KeyboardGroup.zig | 2 +-
river/LockManager.zig | 2 +-
river/OutputManager.zig | 2 +-
river/PointerConstraint.zig | 2 +-
river/Seat.zig | 2 +-
river/Server.zig | 17 +++++------------
river/Switch.zig | 2 +-
river/TabletTool.zig | 2 +-
river/TextInput.zig | 2 +-
river/Window.zig | 2 +-
river/XdgToplevel.zig | 4 +++-
river/XwaylandOverrideRedirect.zig | 5 +++++
river/XwaylandWindow.zig | 5 +++++
river/main.zig | 15 +++++++++++++++
20 files changed, 50 insertions(+), 31 deletions(-)
diff --git a/river/Cursor.zig b/river/Cursor.zig
index 38c900e..2618c9a 100644
--- a/river/Cursor.zig
+++ b/river/Cursor.zig
@@ -43,7 +43,7 @@ const TabletTool = @import("TabletTool.zig");
const Window = @import("Window.zig");
const XwaylandOverrideRedirect = @import("XwaylandOverrideRedirect.zig");
-const log = std.log.scoped(.cursor);
+const log = std.log.scoped(.input);
const Mode = union(enum) {
passthrough: void,
diff --git a/river/InputConfig.zig b/river/InputConfig.zig
index c3d4533..fa2421c 100644
--- a/river/InputConfig.zig
+++ b/river/InputConfig.zig
@@ -23,7 +23,7 @@ const math = std.math;
const meta = std.meta;
const wlr = @import("wlroots");
-const log = std.log.scoped(.input_config);
+const log = std.log.scoped(.input);
const c = @import("c.zig");
diff --git a/river/InputDevice.zig b/river/InputDevice.zig
index a35eefd..fd8bde9 100644
--- a/river/InputDevice.zig
+++ b/river/InputDevice.zig
@@ -33,7 +33,7 @@ const Keyboard = @import("Keyboard.zig");
const Switch = @import("Switch.zig");
const Tablet = @import("Tablet.zig");
-const log = std.log.scoped(.input_manager);
+const log = std.log.scoped(.input);
seat: *Seat,
wlr_device: *wlr.InputDevice,
diff --git a/river/InputManager.zig b/river/InputManager.zig
index db6ef2b..313f101 100644
--- a/river/InputManager.zig
+++ b/river/InputManager.zig
@@ -39,7 +39,7 @@ const TextInput = @import("TextInput.zig");
const default_seat_name = "default";
-const log = std.log.scoped(.input_manager);
+const log = std.log.scoped(.input);
new_input: wl.Listener(*wlr.InputDevice) = wl.Listener(*wlr.InputDevice).init(handleNewInput),
diff --git a/river/InputRelay.zig b/river/InputRelay.zig
index 69d655d..ca21f69 100644
--- a/river/InputRelay.zig
+++ b/river/InputRelay.zig
@@ -29,7 +29,7 @@ const TextInput = @import("TextInput.zig");
const InputPopup = @import("InputPopup.zig");
const Seat = @import("Seat.zig");
-const log = std.log.scoped(.input_relay);
+const log = std.log.scoped(.input);
/// List of all text input objects for the seat.
/// Multiple text input objects may be created per seat, even multiple from the same client.
diff --git a/river/Keyboard.zig b/river/Keyboard.zig
index 799e423..baf2ba2 100644
--- a/river/Keyboard.zig
+++ b/river/Keyboard.zig
@@ -29,7 +29,7 @@ const util = @import("util.zig");
const Seat = @import("Seat.zig");
const InputDevice = @import("InputDevice.zig");
-const log = std.log.scoped(.keyboard);
+const log = std.log.scoped(.input);
pub const Event = union(enum) {
key: wlr.Keyboard.event.Key,
@@ -256,9 +256,8 @@ fn handleBuiltinMapping(keysym: xkb.Keysym) bool {
log.debug("switch VT keysym received", .{});
if (server.session) |session| {
const vt = @intFromEnum(keysym) - xkb.Keysym.XF86Switch_VT_1 + 1;
- const log_server = std.log.scoped(.server);
- log_server.info("switching to VT {}", .{vt});
- session.changeVt(vt) catch log_server.err("changing VT failed", .{});
+ std.log.info("switching to VT {}", .{vt});
+ session.changeVt(vt) catch std.log.err("changing VT failed", .{});
}
return true;
},
diff --git a/river/KeyboardGroup.zig b/river/KeyboardGroup.zig
index 5f79608..248ee15 100644
--- a/river/KeyboardGroup.zig
+++ b/river/KeyboardGroup.zig
@@ -25,7 +25,7 @@ const wlr = @import("wlroots");
const wl = @import("wayland").server.wl;
const xkb = @import("xkbcommon");
-const log = std.log.scoped(.keyboard_group);
+const log = std.log.scoped(.input);
const server = &@import("main.zig").server;
const util = @import("util.zig");
diff --git a/river/LockManager.zig b/river/LockManager.zig
index 98ecbb8..b955681 100644
--- a/river/LockManager.zig
+++ b/river/LockManager.zig
@@ -30,7 +30,7 @@ const util = @import("util.zig");
const LockSurface = @import("LockSurface.zig");
const Output = @import("Output.zig");
-const log = std.log.scoped(.session_lock);
+const log = std.log.scoped(.lock);
wlr_manager: *wlr.SessionLockManagerV1,
diff --git a/river/OutputManager.zig b/river/OutputManager.zig
index 22cfe0e..403a73b 100644
--- a/river/OutputManager.zig
+++ b/river/OutputManager.zig
@@ -34,7 +34,7 @@ const SceneNodeData = @import("SceneNodeData.zig");
const Window = @import("Window.zig");
const XwaylandOverrideRedirect = @import("XwaylandOverrideRedirect.zig");
-const log = std.log.scoped(.output_manager);
+const log = std.log.scoped(.output);
new_output: wl.Listener(*wlr.Output) = wl.Listener(*wlr.Output).init(handleNewOutput),
diff --git a/river/PointerConstraint.zig b/river/PointerConstraint.zig
index dbf89e0..e193091 100644
--- a/river/PointerConstraint.zig
+++ b/river/PointerConstraint.zig
@@ -26,7 +26,7 @@ const util = @import("util.zig");
const Seat = @import("Seat.zig");
-const log = std.log.scoped(.pointer_constraint);
+const log = std.log.scoped(.input);
wlr_constraint: *wlr.PointerConstraintV1,
diff --git a/river/Seat.zig b/river/Seat.zig
index 15b2b6a..f665e42 100644
--- a/river/Seat.zig
+++ b/river/Seat.zig
@@ -44,7 +44,7 @@ const Tablet = @import("Tablet.zig");
const Window = @import("Window.zig");
const XwaylandOverrideRedirect = @import("XwaylandOverrideRedirect.zig");
-const log = std.log.scoped(.seat);
+const log = std.log.scoped(.input);
pub const Event = union(enum) {
keyboard_key: struct {
diff --git a/river/Server.zig b/river/Server.zig
index 2a892b7..dcaf36e 100644
--- a/river/Server.zig
+++ b/river/Server.zig
@@ -42,7 +42,7 @@ const XdgToplevel = @import("XdgToplevel.zig");
const XwaylandOverrideRedirect = @import("XwaylandOverrideRedirect.zig");
const XwaylandWindow = @import("XwaylandWindow.zig");
-const log = std.log.scoped(.server);
+const log = std.log;
wl_server: *wl.Server,
@@ -328,8 +328,6 @@ fn terminate(_: c_int, wl_server: *wl.Server) c_int {
}
fn handleNewXdgToplevel(_: *wl.Listener(*wlr.XdgToplevel), xdg_toplevel: *wlr.XdgToplevel) void {
- log.debug("new xdg_toplevel", .{});
-
XdgToplevel.create(xdg_toplevel) catch {
log.err("out of memory", .{});
xdg_toplevel.resource.postNoMemory();
@@ -344,19 +342,14 @@ fn handleNewToplevelDecoration(
XdgDecoration.init(wlr_decoration);
}
-fn handleNewXwaylandSurface(_: *wl.Listener(*wlr.XwaylandSurface), xwayland_surface: *wlr.XwaylandSurface) void {
- log.debug(
- "new xwayland surface: title='{?s}', class='{?s}', override redirect={}",
- .{ xwayland_surface.title, xwayland_surface.class, xwayland_surface.override_redirect },
- );
-
- if (xwayland_surface.override_redirect) {
- _ = XwaylandOverrideRedirect.create(xwayland_surface) catch {
+fn handleNewXwaylandSurface(_: *wl.Listener(*wlr.XwaylandSurface), xsurface: *wlr.XwaylandSurface) void {
+ if (xsurface.override_redirect) {
+ _ = XwaylandOverrideRedirect.create(xsurface) catch {
log.err("out of memory", .{});
return;
};
} else {
- _ = XwaylandWindow.create(xwayland_surface) catch {
+ _ = XwaylandWindow.create(xsurface) catch {
log.err("out of memory", .{});
return;
};
diff --git a/river/Switch.zig b/river/Switch.zig
index 470511c..6d1268e 100644
--- a/river/Switch.zig
+++ b/river/Switch.zig
@@ -26,7 +26,7 @@ const util = @import("util.zig");
const Seat = @import("Seat.zig");
const InputDevice = @import("InputDevice.zig");
-const log = std.log.scoped(.switch_device);
+const log = std.log.scoped(.input);
pub const Type = enum {
lid,
diff --git a/river/TabletTool.zig b/river/TabletTool.zig
index 5802929..cea658e 100644
--- a/river/TabletTool.zig
+++ b/river/TabletTool.zig
@@ -28,7 +28,7 @@ const util = @import("util.zig");
const Tablet = @import("Tablet.zig");
-const log = std.log.scoped(.tablet_tool);
+const log = std.log.scoped(.input);
const Mode = union(enum) {
passthrough,
diff --git a/river/TextInput.zig b/river/TextInput.zig
index 1364454..9070768 100644
--- a/river/TextInput.zig
+++ b/river/TextInput.zig
@@ -27,7 +27,7 @@ const util = @import("util.zig");
const InputRelay = @import("InputRelay.zig");
const Seat = @import("Seat.zig");
-const log = std.log.scoped(.text_input);
+const log = std.log.scoped(.input);
link: wl.list.Link,
diff --git a/river/Window.zig b/river/Window.zig
index 7bc65ff..2b0abc4 100644
--- a/river/Window.zig
+++ b/river/Window.zig
@@ -36,7 +36,7 @@ const WmNode = @import("WmNode.zig");
const XdgToplevel = @import("XdgToplevel.zig");
const XwaylandWindow = @import("XwaylandWindow.zig");
-const log = std.log.scoped(.window);
+const log = std.log.scoped(.wm);
pub const Constraints = struct {
min_width: u31 = 1,
diff --git a/river/XdgToplevel.zig b/river/XdgToplevel.zig
index ce7df68..b3063d5 100644
--- a/river/XdgToplevel.zig
+++ b/river/XdgToplevel.zig
@@ -31,7 +31,7 @@ const XdgPopup = @import("XdgPopup.zig");
const Window = @import("Window.zig");
const XdgDecoration = @import("XdgDecoration.zig");
-const log = std.log.scoped(.xdg_shell);
+const log = std.log.scoped(.xdg);
/// TODO(zig): get rid of this and use @fieldParentPtr(), https://github.com/ziglang/zig/issues/6611
window: *Window,
@@ -75,6 +75,8 @@ set_title: wl.Listener(void) = wl.Listener(void).init(handleSetTitle),
set_app_id: wl.Listener(void) = wl.Listener(void).init(handleSetAppId),
pub fn create(wlr_toplevel: *wlr.XdgToplevel) error{OutOfMemory}!void {
+ log.debug("new xdg_toplevel", .{});
+
const window = try Window.create(.{ .toplevel = .{
.window = undefined,
.wlr_toplevel = wlr_toplevel,
diff --git a/river/XwaylandOverrideRedirect.zig b/river/XwaylandOverrideRedirect.zig
index c3f5161..6a6ae1a 100644
--- a/river/XwaylandOverrideRedirect.zig
+++ b/river/XwaylandOverrideRedirect.zig
@@ -50,6 +50,11 @@ unmap: wl.Listener(void) = wl.Listener(void).init(handleUnmap),
set_geometry: wl.Listener(void) = wl.Listener(void).init(handleSetGeometry),
pub fn create(xsurface: *wlr.XwaylandSurface) error{OutOfMemory}!void {
+ log.debug("new xwayland override redirect: title='{?s}', class='{?s}'", .{
+ xsurface.title,
+ xsurface.class,
+ });
+
const override_redirect = try util.gpa.create(XwaylandOverrideRedirect);
errdefer util.gpa.destroy(override_redirect);
diff --git a/river/XwaylandWindow.zig b/river/XwaylandWindow.zig
index b04f041..ca6dd85 100644
--- a/river/XwaylandWindow.zig
+++ b/river/XwaylandWindow.zig
@@ -58,6 +58,11 @@ map: wl.Listener(void) = wl.Listener(void).init(handleMap),
unmap: wl.Listener(void) = wl.Listener(void).init(handleUnmap),
pub fn create(xsurface: *wlr.XwaylandSurface) error{OutOfMemory}!void {
+ log.debug("new xwayland window: title='{?s}', class='{?s}'", .{
+ xsurface.title,
+ xsurface.class,
+ });
+
const window = try Window.create(.{ .xwayland = .{
.window = undefined,
.xsurface = xsurface,
diff --git a/river/main.zig b/river/main.zig
index 4226e6a..cb9a8fb 100644
--- a/river/main.zig
+++ b/river/main.zig
@@ -179,6 +179,21 @@ pub fn logFn(
) void {
if (@intFromEnum(level) > @intFromEnum(runtime_log_level)) return;
+ // Scopes should be added to this list sparingly.
+ // Only add new scopes if filtering based on them would be meaningful.
+ switch (scope) {
+ .default,
+ .wlroots,
+ .output,
+ .input,
+ .lock,
+ .wm,
+ .xdg,
+ .xwayland,
+ => {},
+ else => @compileError("invalid log scope"),
+ }
+
const scope_prefix = if (scope == .default) ": " else "(" ++ @tagName(scope) ++ "): ";
const stderr = io.getStdErr().writer();