Skip to content

RediWM is a Wayland compositor written in Zig (OpenGL ES) that includes everything in one process

start up improvements

oxydizer4d3697e6a381
diff --git a/TESTING.md b/TESTING.md
index c2706d9..a043ea9 100644
--- a/TESTING.md
+++ b/TESTING.md
@@ -375,6 +375,27 @@ scale, input rate and compiler backend identical across comparisons.
native scaling; `--publication-delay-ms 1000` models slow login environment
publication. `--cold-cache` disables reuse of the app catalogue between runs
without flushing OS caches. Compare the same renderer, scale and build mode.
+ The `startup` IPC counters distinguish `first_presented_ns` (successful
+ scene submission) from `first_visible_ns` (the backend's presentation
+ acknowledgement for a scene buffer, excluding the initial empty modeset).
+ `backend_start_ns`/`backend_ready_ns` bracket display backend startup;
+ `input_ready_ns` marks completed input enumeration. `services_started_ns`
+ means optional service initialization has been issued, not that every
+ external service has replied. Native unlocked sessions enumerate input
+ after presentation; greeter/lock recovery initialize input immediately.
+ Optional services start one per event-loop turn before autostart. A one-shot
+ 250 ms fallback handles missing presentation feedback, and an inactive seat
+ resumes pending input on its activation event. `reveal_done_ns` marks the
+ end of the fade in from black (`reveal.zig`); it stays zero headless, where
+ outputs carry no veil, so judge the fade nested or on a real login.
+ `rediwm-dm` carries the accepted handoff's monotonic timestamp through PAM
+ and the login shell: `login_to_compositor_ns` includes greeter shutdown,
+ PAM session opening, shell profiles and supervisor setup;
+ `login_to_visible_ns` includes those plus the compositor's first presented
+ scene acknowledgement. These are zero without a supplied login timestamp;
+ unlike the other offsets their origin is the accepted login, including
+ across a compositor restart in that login. Physical login/VT timings still
+ need a real greeter login; headless runs do not enumerate native devices.
`startup.py` also checks startup and shutdown with stalled audio;
`session_readiness.py` withholds the supervisor's acknowledgement while
exercising frames, input, IPC and exec restart.
diff --git a/src/Input.zig b/src/Input.zig
index a130a1f..44e13a5 100644
--- a/src/Input.zig
+++ b/src/Input.zig
@@ -108,6 +108,9 @@ cursor_theme_len: usize = 0,
cursor_theme_size: u32 = 0,
cursor_source: enum { default, theme, surface, hidden } = .default,
cursor_name: ?[*:0]const u8 = "default",
+/// No image until native input is enumerated (`holdCursor`): an arrow that
+/// cannot move yet is not shown. The image state above is still tracked.
+cursor_held: bool = false,
cursor_serial: CursorSerial = .{},
keyboards: wl.list.Head(Keyboard, .link) = undefined,
pointers: wl.list.Head(Pointer, .link) = undefined,
@@ -536,7 +539,7 @@ fn applyCursorThemeImpl(input: *Input, theme: []const u8, size: u32, force: bool
while (it.next()) |out| mgr.load(out.wlr_output.scale) catch {};
if (input.server.xwayland) |xwayland| xwayland.applyCursor();
switch (input.cursor_source) {
- .theme => if (input.cursor_name) |name| input.cursor.setXcursor(mgr, name),
+ .theme => if (input.cursor_name) |name| input.showXcursor(name),
.default => {
input.default_cursor_applied = false;
input.setDefaultCursor();
@@ -565,14 +568,40 @@ pub fn setDefaultCursor(input: *Input) void {
input.cursor_source = .default;
if (busy) {
// Launch feedback: an app is starting. wlroots animates the spinner.
- input.cursor.setXcursor(input.cursor_mgr, "progress");
+ input.showXcursor("progress");
input.cursor_name = "progress";
return;
}
- input.cursor.setXcursor(input.cursor_mgr, "default");
+ input.showXcursor("default");
input.cursor_name = "default";
}
+fn showXcursor(input: *Input, name: [*:0]const u8) void {
+ if (!input.cursor_held) input.cursor.setXcursor(input.cursor_mgr, name);
+}
+
+/// Startup with native input still pending: no cursor image until
+/// `releaseCursor`.
+pub fn holdCursor(input: *Input) void {
+ input.cursor_held = true;
+ input.cursor.unsetImage();
+}
+
+/// Shows whatever image the held cursor would have had.
+pub fn releaseCursor(input: *Input) void {
+ if (!input.cursor_held) return;
+ input.cursor_held = false;
+ switch (input.cursor_source) {
+ .theme => if (input.cursor_name) |name| input.showXcursor(name),
+ // A client surface image was never applied; the next enter sets it.
+ .default, .surface => {
+ input.default_cursor_applied = false;
+ input.setDefaultCursor();
+ },
+ .hidden => {},
+ }
+}
+
/// Launch feedback started or ended: swap the arrow for the progress cursor
/// (or back) wherever the default cursor is showing.
pub fn refreshBusyCursor(input: *Input) void {
@@ -587,7 +616,7 @@ fn setShellCursor(input: *Input, over_text: bool) void {
pub fn setNamedCursor(input: *Input, name: [*:0]const u8) void {
input.default_cursor_applied = false;
- input.cursor.setXcursor(input.cursor_mgr, name);
+ input.showXcursor(name);
input.cursor_source = .theme;
input.cursor_name = name;
}
@@ -1220,7 +1249,7 @@ fn requestSetCursor(
const input: *Input = @fieldParentPtr("request_set_cursor", listener);
if (input.clientMaySetCursor(event.seat_client)) {
input.default_cursor_applied = false;
- input.cursor.setSurface(event.surface, event.hotspot_x, event.hotspot_y);
+ if (!input.cursor_held) input.cursor.setSurface(event.surface, event.hotspot_x, event.hotspot_y);
input.cursor_source = if (event.surface != null) .surface else .hidden;
input.cursor_name = null;
}
diff --git a/src/Output.zig b/src/Output.zig
index f1e8a74..f2e0fce 100644
--- a/src/Output.zig
+++ b/src/Output.zig
@@ -83,6 +83,10 @@ wifi_popup: ?*@import("network/popup.zig").Popup = null,
power_menu: ?*PowerMenu = null,
color: OutputColor = .{},
frame_seq: u64 = 0,
+// Match a scene buffer, excluding the backend's initial empty modeset.
+startup_commit_seq: ?u32 = null,
+startup_committing: bool = false,
+startup_presented: bool = false,
animation_budget: anim.FrameBudget = .{},
idle_blanked: bool = false,
/// Turned off by a wlr-output-power-management client (`output_power.zig`):
@@ -111,6 +115,7 @@ committed_cursor: CursorState = .{},
link: wl.list.Link = undefined,
frame: wl.Listener(*wlr.Output) = .init(handleFrame),
+present: wl.Listener(*wlr.Output.event.Present) = .init(handlePresent),
request_state: wl.Listener(*wlr.Output.event.RequestState) = .init(handleRequestState),
workspace_id: u8 = 0,
destroy: wl.Listener(*wlr.Output) = .init(handleDestroy),
@@ -646,6 +651,7 @@ pub fn create(server: *Server, wlr_output: *wlr.Output) !void {
// double-free us.
wlr_output.data = output;
wlr_output.events.frame.add(&output.frame);
+ wlr_output.events.present.add(&output.present);
wlr_output.events.request_state.add(&output.request_state);
wlr_output.events.destroy.add(&output.destroy);
server.outputs.append(output);
@@ -654,6 +660,7 @@ pub fn create(server: *Server, wlr_output: *wlr.Output) !void {
// Apply the saved enable policy before publishing the added event so
// observers see the final logical state in one coherent notification.
output.applyConfig();
+ server.reveal.outputCreated(output);
if (server.locker != null) output.lock_view.cover(output);
syncLayout(server);
@@ -1320,6 +1327,7 @@ fn runFrame(output: *Output) void {
log.err("handleFrame: no scene output for {s}", .{output.wlr_output.name});
return;
};
+ const reveal_animating = output.server.reveal.tick(output, now_ms);
const projection_started = stats.nowNs();
output.server.world.refreshBounds();
output.server.world.syncPresentation();
@@ -1358,7 +1366,14 @@ fn runFrame(output: *Output) void {
if (should_commit) {
if (output.server.capture_mgr) |cm| cm.guardScreencopy(output.wlr_output);
if (output.server.buildOutputState(scene_output, &state)) {
+ if (@import("startup.zig").marks.first_visible_ns == 0) {
+ output.startup_commit_seq = output.wlr_output.commit_seq +% 1;
+ output.startup_presented = false;
+ }
+ output.startup_committing = true;
committed = output.commitFrameState(&state);
+ output.startup_committing = false;
+ if (!committed) output.startup_commit_seq = null;
} else {
committed = false;
}
@@ -1380,7 +1395,8 @@ fn runFrame(output: *Output) void {
stats.recordPresentedFrame(commit_duration, output.wlr_output.refresh);
@import("startup.zig").notePresented(@intCast(output.server.outputs.length()), output.server.maxOutputScale());
output.server.session_startup.onPresented();
- output.server.startup_warmup.schedule(output.server);
+ // Headless backends can acknowledge synchronously inside commit.
+ if (output.startup_presented) output.startupVisible();
}
if (!deferred) {
var now = timestamp();
@@ -1403,7 +1419,7 @@ fn runFrame(output: *Output) void {
// Keep repainting every refresh interval until the last hover/press/FLIP
// animation settles; otherwise chrome and the bar only redraw when a
// client does.
- const keep_going = mini_map_animating or switcher_animating or osd_animating or dock_animating or bar_animating or chrome_animating or cc_animating or sm_animating or pm_animating or taskbar_popup_animating or notif_animating or desktop_animating or lock_animating or polkit_animating;
+ const keep_going = mini_map_animating or switcher_animating or osd_animating or dock_animating or bar_animating or chrome_animating or cc_animating or sm_animating or pm_animating or taskbar_popup_animating or notif_animating or desktop_animating or lock_animating or polkit_animating or reveal_animating;
// A pinned clock is advanced explicitly by IPC, which schedules its own
// frame. Global window/taskbar springs must not spin between those steps.
if (keep_going and !anim.clockOverridden()) {
@@ -1464,6 +1480,21 @@ fn handleRequestState(
if (output.server.idle) |im| im.recheckInhibitors();
}
+fn handlePresent(listener: *wl.Listener(*wlr.Output.event.Present), event: *wlr.Output.event.Present) void {
+ const output: *Output = @fieldParentPtr("present", listener);
+ if (@import("startup.zig").marks.first_visible_ns != 0 or !event.presented) return;
+ if (output.startup_commit_seq == null or event.commit_seq != output.startup_commit_seq.?) return;
+ output.startup_presented = true;
+ if (!output.startup_committing) output.startupVisible();
+}
+
+fn startupVisible(output: *Output) void {
+ if (@import("startup.zig").marks.first_visible_ns != 0) return;
+ @import("startup.zig").noteVisible();
+ output.server.startup_tasks.onVisible();
+ output.server.reveal.onVisible();
+}
+
fn handleDestroy(listener: *wl.Listener(*wlr.Output), _: *wlr.Output) void {
const output: *Output = @fieldParentPtr("destroy", listener);
if (output.tearing_idle) |source| source.remove();
@@ -1541,6 +1572,7 @@ fn handleDestroy(listener: *wl.Listener(*wlr.Output), _: *wlr.Output) void {
if (output.vblank_timer) |timer| timer.remove();
output.link.remove();
output.frame.link.remove();
+ output.present.link.remove();
output.request_state.link.remove();
output.destroy.link.remove();
diff --git a/src/Server.zig b/src/Server.zig
index 7aab4df..4ba6080 100644
--- a/src/Server.zig
+++ b/src/Server.zig
@@ -169,6 +169,8 @@ scale_override: ?f32 = null,
icon_theme_cfg: icon_theme.Config = .{ .theme_name = "", .base_dirs = &.{} },
startup_warmup: @import("startup_warmup.zig") = .{},
session_startup: @import("session/startup.zig") = .{},
+startup_tasks: @import("startup_tasks.zig") = .{},
+reveal: @import("reveal.zig") = .{},
/// The compositor-drawn desktop, while `[desktop] enabled`.
desktop: ?*@import("desktop/embedded.zig").Desktop = null,
io: std.Io,
@@ -527,52 +529,26 @@ pub fn init(server: *Server, scale: ?f32, icon_theme_cfg: icon_theme.Config, io:
break :blk null;
};
- if (!greeter) server.notifications = notifications_mod.Manager.create(server, @import("main.zig").gpa) catch |err| blk: {
- log.warn("init: could not create notifications manager: {}", .{err});
- break :blk null;
- };
-
server.power = power_mod.Manager.create(server, @import("main.zig").gpa) catch |err| blk: {
log.warn("init: could not create power manager: {}", .{err});
break :blk null;
};
- server.power_profiles = power_profiles_mod.Manager.create(server, @import("main.zig").gpa) catch |err| blk: {
- log.warn("init: could not create power profiles manager: {}", .{err});
- break :blk null;
- };
-
- if (!greeter) server.network = @import("network/manager.zig").Manager.create(server) catch null;
if (!greeter and @import("session/app_scope.zig").enabled(environ))
server.app_scopes = @import("session/app_scope.zig").Scopes.create(@import("main.zig").gpa, server.wl_server.getEventLoop(), environ) catch null;
- server.configurePolkit(server.config.polkit);
-
if (!greeter) server.services = services_mod.Manager.create(server, @import("main.zig").gpa) catch |err| blk: {
log.warn("init: could not create services manager: {}", .{err});
break :blk null;
};
- if (!greeter) server.layout_autosave = layout_autosave_mod.Autosave.create(server) catch |err| blk: {
- log.warn("init: could not create layout autosave: {}", .{err});
- break :blk null;
- };
-
- if (!greeter) server.audio = audio_mod.AudioManager.createAsync(@import("main.zig").gpa) catch |err| blk: {
- log.warn("init: PipeWire/PulseAudio not available, audio control disabled: {}", .{err});
- break :blk null;
- };
- if (server.audio) |mgr| {
- if (createAudioWakeFd()) |fd| {
- mgr.setWakeFd(fd);
- server.audio_wake_source = server.wl_server.getEventLoop().addFd(*Server, fd, .{ .readable = true }, handleAudioWake, server) catch |err| blk: {
- log.warn("init: could not register audio wake fd: {}", .{err});
- break :blk null;
- };
- } else {
- log.warn("init: could not create audio wake eventfd; taskbar/UI may lag behind external volume changes", .{});
- }
- }
+ // Layout autosave (periodic save and the startup restore) is off for now:
+ // the restore moves windows seconds after login. Every user checks for
+ // null, so re-enabling is uncommenting this.
+ // if (!greeter) server.layout_autosave = layout_autosave_mod.Autosave.create(server) catch |err| blk: {
+ // log.warn("init: could not create layout autosave: {}", .{err});
+ // break :blk null;
+ // };
if (battery_mod.openUeventSocket()) |fd| {
server.battery_uevent_fd = fd;
@@ -843,6 +819,7 @@ fn handleSessionActive(listener: *wl.Listener(void)) void {
if (session.active) {
log.info("session became active (VT switch back)", .{});
server.reactivateSession();
+ server.startup_tasks.onSessionActive();
} else {
log.info("session became inactive (VT switch away)", .{});
server.deactivateSession();
@@ -872,6 +849,51 @@ pub fn getSystemd(server: *Server) !*@import("systemd.zig").Client {
return client;
}
+/// One optional service per event-loop turn after the first desktop frame.
+/// Power/lock inhibitors and child ownership are initialized synchronously.
+pub fn startDesktopService(server: *Server, step: usize) bool {
+ if (server.greeter_mode) return false;
+ switch (step) {
+ 0 => {
+ server.notifications = notifications_mod.Manager.create(server, @import("main.zig").gpa) catch |err| blk: {
+ log.warn("init: could not create notifications manager: {}", .{err});
+ break :blk null;
+ };
+ },
+ 1 => {
+ server.configurePolkit(server.config.polkit);
+ },
+ 2 => {
+ server.network = @import("network/manager.zig").Manager.create(server) catch null;
+ },
+ 3 => {
+ server.power_profiles = power_profiles_mod.Manager.create(server, @import("main.zig").gpa) catch |err| blk: {
+ log.warn("init: could not create power profiles manager: {}", .{err});
+ break :blk null;
+ };
+ },
+ 4 => {
+ server.audio = audio_mod.AudioManager.createAsync(@import("main.zig").gpa) catch |err| blk: {
+ log.warn("init: PipeWire/PulseAudio not available, audio control disabled: {}", .{err});
+ break :blk null;
+ };
+ if (server.audio) |mgr| {
+ if (createAudioWakeFd()) |fd| {
+ mgr.setWakeFd(fd);
+ server.audio_wake_source = server.wl_server.getEventLoop().addFd(*Server, fd, .{ .readable = true }, handleAudioWake, server) catch |err| blk: {
+ log.warn("init: could not register audio wake fd: {}", .{err});
+ break :blk null;
+ };
+ } else {
+ log.warn("init: could not create audio wake eventfd; taskbar/UI may lag behind external volume changes", .{});
+ }
+ }
+ },
+ else => return false,
+ }
+ return true;
+}
+
pub fn deinit(server: *Server) void {
if (server.theme_job) |job| job.deinit();
server.theme_job = null;
@@ -882,6 +904,8 @@ pub fn deinit(server: *Server) void {
// here. In both cases save before tearing down Xwayland or native clients.
const already_terminating = server.shutting_down;
server.shutting_down = true;
+ server.startup_tasks.deinit();
+ server.reveal.deinit();
server.session_startup.deinit();
if (!already_terminating) {
if (server.layout_autosave) |as| as.saveNow();
@@ -1677,6 +1701,7 @@ fn handleWallpaperWake(fd: c_int, mask: wl.EventMask, server: *Server) c_int {
} else return 0;
// Removing the source from its own callback is safe; the worker is done.
server.stopWallpaperLoad();
+ server.reveal.onWallpaper();
if (server.input.open_control_center) |cc| cc.refresh();
if (server.ipc) |ipc| ipc.wait_mgr.checkAll();
return 0;
diff --git a/src/child_env.zig b/src/child_env.zig
index c9057e3..5d0de03 100644
--- a/src/child_env.zig
+++ b/src/child_env.zig
@@ -38,7 +38,7 @@ pub fn apply(map: *Map, spec: Spec) !void {
try map.put("QT_STYLE_OVERRIDE", "Fusion");
}
// Private supervisor authority must never escape to descendant launches.
- inline for (.{ "REDIWM_SESSION_FD", "REDIWM_LOGIN_SESSION", "REDIWM_SESSION_PRIMARY" }) |key| _ = map.swapRemove(key);
+ inline for (.{ "REDIWM_SESSION_FD", "REDIWM_LOGIN_SESSION", "REDIWM_SESSION_PRIMARY", "REDIWM_LOGIN_STARTED_NS" }) |key| _ = map.swapRemove(key);
switch (spec.input_method) {
.none => {},
inline .fcitx, .ibus => |im| {
@@ -220,9 +220,9 @@ test "input methods configure new children and preserve inherited settings for n
test "private session authority and stale activation tokens never reach children" {
var map = Map.init(std.testing.allocator);
defer map.deinit();
- inline for (.{ "REDIWM_SESSION_FD", "REDIWM_LOGIN_SESSION", "REDIWM_SESSION_PRIMARY", "XDG_ACTIVATION_TOKEN", "DESKTOP_STARTUP_ID" }) |key| try map.put(key, "inherited");
+ inline for (.{ "REDIWM_SESSION_FD", "REDIWM_LOGIN_SESSION", "REDIWM_SESSION_PRIMARY", "REDIWM_LOGIN_STARTED_NS", "XDG_ACTIVATION_TOKEN", "DESKTOP_STARTUP_ID" }) |key| try map.put(key, "inherited");
try apply(&map, .{});
- inline for (.{ "REDIWM_SESSION_FD", "REDIWM_LOGIN_SESSION", "REDIWM_SESSION_PRIMARY", "XDG_ACTIVATION_TOKEN", "DESKTOP_STARTUP_ID" }) |key| try std.testing.expect(map.get(key) == null);
+ inline for (.{ "REDIWM_SESSION_FD", "REDIWM_LOGIN_SESSION", "REDIWM_SESSION_PRIMARY", "REDIWM_LOGIN_STARTED_NS", "XDG_ACTIVATION_TOKEN", "DESKTOP_STARTUP_ID" }) |key| try std.testing.expect(map.get(key) == null);
}
test "Qt app colors override inherited theming only after explicit opt in" {
diff --git a/src/config/default.zig b/src/config/default.zig
index 95197d2..49fb3bd 100644
--- a/src/config/default.zig
+++ b/src/config/default.zig
@@ -207,6 +207,10 @@ pub const source =
\\# duration_ms = 160
\\# ease = "out_cubic"
\\# decay_rate = 0.998
+ \\#
+ \\# [animations.session_reveal] # the desktop's fade in from black at login
+ \\# duration_ms = 420 # off = true shows it at once
+ \\# ease = "in_out_sine"
\\
\\# ───────────────────────────────────────────────
\\# Authentication
diff --git a/src/dm/daemon.zig b/src/dm/daemon.zig
index c655bb5..ea5f2d4 100644
--- a/src/dm/daemon.zig
+++ b/src/dm/daemon.zig
@@ -85,6 +85,7 @@ pub const Daemon = struct {
/// `start` accepted: waiting for the greeter to exit before the session.
handoff: bool = false,
+ login_started_ns: u64 = 0,
stopping: bool = false,
pub fn init(config: config_mod.Config, io: std.Io, is_test: bool, confdir: ?[]const u8) Daemon {
@@ -394,6 +395,7 @@ pub const Daemon = struct {
// ---- hand-off: greeter out, session in -------------------------------
fn beginHandoff(self: *Daemon) void {
+ self.login_started_ns = @as(u64, @intCast(monotonicMs())) * std.time.ns_per_ms;
// Blank while the greeter still covers the VT, so logind's switch
// back to text mode shows nothing.
self.blankVt();
@@ -421,9 +423,18 @@ pub const Daemon = struct {
};
}
- fn sendStart(_: *Daemon, worker: Worker, exec: []const u8, desktop: []const u8, desktops: []const u8) !void {
+ fn sendStart(self: *Daemon, worker: Worker, exec: []const u8, desktop: []const u8, desktops: []const u8) !void {
var buf: [proto.max_frame]u8 = undefined;
- try proto.writeJson(worker.ctrl, &buf, proto.Start{ .exec = exec, .desktop = desktop, .desktops = desktops });
+ defer self.login_started_ns = 0;
+ try proto.writeJson(worker.ctrl, &buf, proto.Start{
+ .exec = exec,
+ .desktop = desktop,
+ .desktops = desktops,
+ .login_started_ns = if (desktop.len == 0) 0 else if (self.login_started_ns != 0)
+ self.login_started_ns
+ else
+ @as(u64, @intCast(monotonicMs())) * std.time.ns_per_ms,
+ });
}
// ---- worker reports ------------------------------------------------------
diff --git a/src/dm/proto.zig b/src/dm/proto.zig
index ee661af..05cd1e0 100644
--- a/src/dm/proto.zig
+++ b/src/dm/proto.zig
@@ -110,6 +110,7 @@ pub const Start = struct {
exec: []const u8,
desktop: []const u8,
desktops: []const u8,
+ login_started_ns: u64 = 0,
};
/// At most `max` bytes of `text`, cut on a UTF-8 boundary, with invalid
@@ -137,14 +138,15 @@ test "dm frames round-trip and refuse oversized payloads" {
defer _ = linux.close(fds[0]);
defer _ = linux.close(fds[1]);
try writeFrameParts(fds[0], &.{ &.{answer_tag}, "p\"w\\\x08" });
- var buf: [64]u8 = undefined;
+ var buf: [256]u8 = undefined;
try std.testing.expectEqualStrings("Ap\"w\\\x08", try readFrame(fds[1], &buf));
var json_buf: [256]u8 = undefined;
- try writeJson(fds[0], &json_buf, Start{ .exec = "sh -c \"x\"", .desktop = "a", .desktops = "b" });
+ try writeJson(fds[0], &json_buf, Start{ .exec = "sh -c \"x\"", .desktop = "a", .desktops = "b", .login_started_ns = 123456789 });
const frame = try readFrame(fds[1], &buf);
const parsed = try std.json.parseFromSlice(Start, std.testing.allocator, frame, .{});
defer parsed.deinit();
try std.testing.expectEqualStrings("sh -c \"x\"", parsed.value.exec);
+ try std.testing.expectEqual(@as(u64, 123456789), parsed.value.login_started_ns);
try writeFrame(fds[0], "0123456789");
try std.testing.expectError(error.FrameTooLarge, readFrame(fds[1], buf[0..4]));
}
diff --git a/src/dm/worker.zig b/src/dm/worker.zig
index 66d550a..3a4f142 100644
--- a/src/dm/worker.zig
+++ b/src/dm/worker.zig
@@ -108,7 +108,7 @@ pub fn runWorker(ctrl_fd: c_int, greeter_fd: c_int, confdir: ?[]const u8, is_tes
return 1;
}
- const env = try sessionEnv(a, pamh, init.user, start.desktops, greeter_fd >= 0);
+ const env = try sessionEnv(a, pamh, init.user, start.desktops, greeter_fd >= 0, start.login_started_ns);
const fork_rc = linux.fork();
if (linux.errno(fork_rc) != .SUCCESS) {
report(ctrl_fd, .session_failed, "fork failed");
@@ -195,10 +195,10 @@ fn account(a: std.mem.Allocator, user_z: [:0]const u8) Account {
/// The child's environment: PAM's (XDG_RUNTIME_DIR, XDG_SESSION_ID...) plus
/// the account's identity. Keys we set ourselves are never taken from PAM.
-fn sessionEnv(a: std.mem.Allocator, pamh: *pam_handle_t, user: []const u8, desktops: []const u8, greeter: bool) ![:null]?[*:0]const u8 {
+fn sessionEnv(a: std.mem.Allocator, pamh: *pam_handle_t, user: []const u8, desktops: []const u8, greeter: bool, login_started_ns: u64) ![:null]?[*:0]const u8 {
const user_z = try a.dupeZ(u8, user);
const acct = account(a, user_z);
- const owned = [_][]const u8{ "HOME", "USER", "LOGNAME", "SHELL", "XDG_CURRENT_DESKTOP", "REDIWM_GREETER_FD" };
+ const owned = [_][]const u8{ "HOME", "USER", "LOGNAME", "SHELL", "XDG_CURRENT_DESKTOP", "REDIWM_GREETER_FD", "REDIWM_LOGIN_STARTED_NS" };
var list: std.ArrayList(?[*:0]const u8) = .empty;
var has_path = false;
if (rediwm_pam_getenvlist(pamh)) |pam_env| {
@@ -220,6 +220,7 @@ fn sessionEnv(a: std.mem.Allocator, pamh: *pam_handle_t, user: []const u8, deskt
if (!has_path) try list.append(a, "PATH=" ++ default_path);
if (desktops.len > 0) try list.append(a, try std.fmt.allocPrintSentinel(a, "XDG_CURRENT_DESKTOP={s}", .{desktops}, 0));
if (greeter) try list.append(a, "REDIWM_GREETER_FD=3");
+ if (!greeter and login_started_ns != 0) try list.append(a, try std.fmt.allocPrintSentinel(a, "REDIWM_LOGIN_STARTED_NS={d}", .{login_started_ns}, 0));
return list.toOwnedSliceSentinel(a, null);
}
diff --git a/src/input/tablet.zig b/src/input/tablet.zig
index a7cdb05..4031c75 100644
--- a/src/input/tablet.zig
+++ b/src/input/tablet.zig
@@ -212,7 +212,7 @@ fn setCursor(listener: *wl.Listener(*wlr.TabletV2TabletTool.event.SetCursor), ev
const focused = (tool.v2 orelse return).focused_surface orelse return;
if (event.seat_client.client != focused.resource.getClient()) return;
input.default_cursor_applied = false;
- input.cursor.setSurface(event.surface, event.hotspot_x, event.hotspot_y);
+ if (!input.cursor_held) input.cursor.setSurface(event.surface, event.hotspot_x, event.hotspot_y);
input.cursor_source = if (event.surface != null) .surface else .hidden;
input.cursor_name = null;
}
diff --git a/src/ipc/handlers.zig b/src/ipc/handlers.zig
index 4c08312..0b3bf50 100644
--- a/src/ipc/handlers.zig
+++ b/src/ipc/handlers.zig
@@ -2826,6 +2826,14 @@ fn startupStats() protocol.StartupStats {
.catalog_cache_read_duration_ns = m.catalog_cache_read_duration_ns,
.catalog_scan_duration_ns = m.catalog_scan_duration_ns,
.wallpaper_decode_duration_ns = m.wallpaper_decode_duration_ns,
+ .backend_start_ns = startup.offset(m.backend_start_ns),
+ .backend_ready_ns = startup.offset(m.backend_ready_ns),
+ .input_ready_ns = startup.offset(m.input_ready_ns),
+ .first_visible_ns = startup.offset(m.first_visible_ns),
+ .services_started_ns = startup.offset(m.services_started_ns),
+ .login_to_compositor_ns = startup.loginOffset(m.origin_ns),
+ .login_to_visible_ns = startup.loginOffset(m.first_visible_ns),
+ .reveal_done_ns = startup.offset(m.reveal_done_ns),
};
}
diff --git a/src/ipc/protocol.zig b/src/ipc/protocol.zig
index e53d0cf..33048da 100644
--- a/src/ipc/protocol.zig
+++ b/src/ipc/protocol.zig
@@ -794,6 +794,14 @@ pub const StartupStats = struct {
catalog_cache_read_duration_ns: u64 = 0,
catalog_scan_duration_ns: u64 = 0,
wallpaper_decode_duration_ns: u64 = 0,
+ backend_start_ns: u64 = 0,
+ backend_ready_ns: u64 = 0,
+ input_ready_ns: u64 = 0,
+ first_visible_ns: u64 = 0,
+ services_started_ns: u64 = 0,
+ login_to_compositor_ns: u64 = 0,
+ login_to_visible_ns: u64 = 0,
+ reveal_done_ns: u64 = 0,
};
pub const InhibitorData = struct {
@@ -3101,7 +3109,7 @@ fn stringifyStartup(st: StartupStats, writer: anytype) !void {
st.catalog_loading,
st.catalog_generation,
});
- try writer.print("\"renderer_ready_ns\":{d},\"config_ready_ns\":{d},\"catalog_cache_read_ns\":{d},\"catalog_scan_ns\":{d},\"wallpaper_decode_ns\":{d},\"socket_ready_ns\":{d},\"ipc_ready_ns\":{d},\"session_ready_ns\":{d},\"session_clients_started_ns\":{d},\"xwayland_ready_ns\":{d},\"first_presented_ns\":{d},\"first_ipc_ns\":{d},\"first_input_ns\":{d},\"catalog_published_ns\":{d},\"wallpaper_presented_ns\":{d},\"catalog_cache_read_duration_ns\":{d},\"catalog_scan_duration_ns\":{d},\"wallpaper_decode_duration_ns\":{d}}}", .{
+ try writer.print("\"renderer_ready_ns\":{d},\"config_ready_ns\":{d},\"catalog_cache_read_ns\":{d},\"catalog_scan_ns\":{d},\"wallpaper_decode_ns\":{d},\"socket_ready_ns\":{d},\"ipc_ready_ns\":{d},\"session_ready_ns\":{d},\"session_clients_started_ns\":{d},\"xwayland_ready_ns\":{d},\"first_presented_ns\":{d},\"first_ipc_ns\":{d},\"first_input_ns\":{d},\"catalog_published_ns\":{d},\"wallpaper_presented_ns\":{d},\"catalog_cache_read_duration_ns\":{d},\"catalog_scan_duration_ns\":{d},\"wallpaper_decode_duration_ns\":{d},\"backend_start_ns\":{d},\"backend_ready_ns\":{d},\"input_ready_ns\":{d},\"first_visible_ns\":{d},\"services_started_ns\":{d},\"login_to_compositor_ns\":{d},\"login_to_visible_ns\":{d},\"reveal_done_ns\":{d}}}", .{
st.renderer_ready_ns,
st.config_ready_ns,
st.catalog_cache_read_ns,
@@ -3120,6 +3128,14 @@ fn stringifyStartup(st: StartupStats, writer: anytype) !void {
st.catalog_cache_read_duration_ns,
st.catalog_scan_duration_ns,
st.wallpaper_decode_duration_ns,
+ st.backend_start_ns,
+ st.backend_ready_ns,
+ st.input_ready_ns,
+ st.first_visible_ns,
+ st.services_started_ns,
+ st.login_to_compositor_ns,
+ st.login_to_visible_ns,
+ st.reveal_done_ns,
});
}
diff --git a/src/ipc_serializers.jsonl b/src/ipc_serializers.jsonl
index 6740b49..463cd2c 100644
--- a/src/ipc_serializers.jsonl
+++ b/src/ipc_serializers.jsonl
@@ -67,7 +67,7 @@
{"Ok":{"SamplePixels":{"output":"text \"quoted\"\n\\","x":0,"y":0,"width":0,"height":0,"gpu_readback":false,"pixels":[0]}}}
{"Ok":{"SamplePixels":{"output":"text \"quoted\"\n\\","x":7,"y":7,"width":7,"height":7,"gpu_readback":true,"pixels":[7]}}}
{"Ok":{"PerformanceStats":{"output_commits":0,"output_failed_commits":0,"fps":0.0,"frame_time_ms":0.0,"missed_frames":0,"refresh_hz":0.0,"titlebar_paints":0,"footer_paints":0,"edge_samples_attempted":0,"edge_samples_succeeded":0,"edge_samples_skipped":0,"edge_sample_ns":0,"panel_paints":0,"panel_allocated_bytes":0,"panel_reused_bytes":0,"icon_cache_hits":0,"icon_cache_misses":0,"icon_decode_ns":0,"icon_decode_count":0,"icon_decoded_bytes":0,"icon_queue_depth_max":0,"taskbar_paints":0,"taskbar_paint_ns":0,"taskbar_raster_pixels":0,"taskbar_clock_frame_requests":0,"taskbar_clock_paints":0,"taskbar_start_paints":0,"taskbar_chip_paints":0,"taskbar_tray_paints":0,"taskbar_hover_paints":0,"taskbar_press_paints":0,"taskbar_audio_paints":0,"recent_errors_count":0,"anim_frames_scheduled":0,"anim_wasted_wakeups":0,"anim_longest_ms":0,"anim_speed":0,"anim_enabled":false,"anim_reduced_motion":false}}}
-{"Ok":{"PerformanceStats":{"screenshot_selection":{"motion_events":7,"updates":7,"update_ns":7,"toolbar_paints":7,"label_paints":7,"scene_nodes_created":7},"frame_work":{"cpu_frame":{"samples":7,"total_samples":7,"avg_ms":1.23456,"p50_ms":1.23456,"p95_ms":1.23456,"p99_ms":1.23456,"max_ms":1.23456},"taskbar_cpu":{"samples":7,"total_samples":7,"avg_ms":1.23456,"p50_ms":1.23456,"p95_ms":1.23456,"p99_ms":1.23456,"max_ms":1.23456},"chrome_cpu":{"samples":7,"total_samples":7,"avg_ms":1.23456,"p50_ms":1.23456,"p95_ms":1.23456,"p99_ms":1.23456,"max_ms":1.23456},"panels_cpu":{"samples":7,"total_samples":7,"avg_ms":1.23456,"p50_ms":1.23456,"p95_ms":1.23456,"p99_ms":1.23456,"max_ms":1.23456},"anim_cpu":{"samples":7,"total_samples":7,"avg_ms":1.23456,"p50_ms":1.23456,"p95_ms":1.23456,"p99_ms":1.23456,"max_ms":1.23456},"projection_cpu":{"samples":7,"total_samples":7,"avg_ms":1.23456,"p50_ms":1.23456,"p95_ms":1.23456,"p99_ms":1.23456,"max_ms":1.23456},"glass_cpu":{"samples":7,"total_samples":7,"avg_ms":1.23456,"p50_ms":1.23456,"p95_ms":1.23456,"p99_ms":1.23456,"max_ms":1.23456},"scene_commit_cpu":{"samples":7,"total_samples":7,"avg_ms":1.23456,"p50_ms":1.23456,"p95_ms":1.23456,"p99_ms":1.23456,"max_ms":1.23456},"gpu_elapsed":{"samples":7,"total_samples":7,"avg_ms":1.23456,"p50_ms":1.23456,"p95_ms":1.23456,"p99_ms":1.23456,"max_ms":1.23456},"gpu_timing_available":true,"gpu_samples_dropped":7},"output_commits":7,"output_failed_commits":7,"fps":1.2,"frame_time_ms":1.2,"missed_frames":7,"refresh_hz":1.2,"titlebar_paints":7,"footer_paints":7,"edge_samples_attempted":7,"edge_samples_succeeded":7,"edge_samples_skipped":7,"edge_sample_ns":7,"panel_paints":7,"panel_allocated_bytes":7,"panel_reused_bytes":7,"icon_cache_hits":7,"icon_cache_misses":7,"icon_decode_ns":7,"icon_decode_count":7,"icon_decoded_bytes":7,"icon_queue_depth_max":7,"taskbar_paints":7,"taskbar_paint_ns":7,"taskbar_raster_pixels":7,"taskbar_clock_frame_requests":7,"taskbar_clock_paints":7,"taskbar_start_paints":7,"taskbar_chip_paints":7,"taskbar_tray_paints":7,"taskbar_hover_paints":7,"taskbar_press_paints":7,"taskbar_audio_paints":7,"recent_errors_count":7,"anim_frames_scheduled":7,"anim_wasted_wakeups":7,"anim_longest_ms":7,"anim_speed":1.23456,"anim_enabled":true,"anim_reduced_motion":true,"startup":{"build_mode":"text \"quoted\"\n\\","renderer":"text \"quoted\"\n\\","scale":1.23,"output_count":7,"catalog_entries":7,"autostart_count":7,"catalog_state":"text \"quoted\"\n\\","wallpaper_state":"text \"quoted\"\n\\","catalog_provisional":true,"catalog_loading":true,"catalog_generation":7,"renderer_ready_ns":7,"config_ready_ns":7,"catalog_cache_read_ns":7,"catalog_scan_ns":7,"wallpaper_decode_ns":7,"socket_ready_ns":7,"ipc_ready_ns":7,"session_ready_ns":7,"session_clients_started_ns":7,"xwayland_ready_ns":7,"first_presented_ns":7,"first_ipc_ns":7,"first_input_ns":7,"catalog_published_ns":7,"wallpaper_presented_ns":7,"catalog_cache_read_duration_ns":7,"catalog_scan_duration_ns":7,"wallpaper_decode_duration_ns":7},"desktop":{"paints":7,"damage_pixels":7,"tile_presents":7,"texture_uploads":7},"output_skipped_commits":7,"glass_reblurs":7}}}
+{"Ok":{"PerformanceStats":{"screenshot_selection":{"motion_events":7,"updates":7,"update_ns":7,"toolbar_paints":7,"label_paints":7,"scene_nodes_created":7},"frame_work":{"cpu_frame":{"samples":7,"total_samples":7,"avg_ms":1.23456,"p50_ms":1.23456,"p95_ms":1.23456,"p99_ms":1.23456,"max_ms":1.23456},"taskbar_cpu":{"samples":7,"total_samples":7,"avg_ms":1.23456,"p50_ms":1.23456,"p95_ms":1.23456,"p99_ms":1.23456,"max_ms":1.23456},"chrome_cpu":{"samples":7,"total_samples":7,"avg_ms":1.23456,"p50_ms":1.23456,"p95_ms":1.23456,"p99_ms":1.23456,"max_ms":1.23456},"panels_cpu":{"samples":7,"total_samples":7,"avg_ms":1.23456,"p50_ms":1.23456,"p95_ms":1.23456,"p99_ms":1.23456,"max_ms":1.23456},"anim_cpu":{"samples":7,"total_samples":7,"avg_ms":1.23456,"p50_ms":1.23456,"p95_ms":1.23456,"p99_ms":1.23456,"max_ms":1.23456},"projection_cpu":{"samples":7,"total_samples":7,"avg_ms":1.23456,"p50_ms":1.23456,"p95_ms":1.23456,"p99_ms":1.23456,"max_ms":1.23456},"glass_cpu":{"samples":7,"total_samples":7,"avg_ms":1.23456,"p50_ms":1.23456,"p95_ms":1.23456,"p99_ms":1.23456,"max_ms":1.23456},"scene_commit_cpu":{"samples":7,"total_samples":7,"avg_ms":1.23456,"p50_ms":1.23456,"p95_ms":1.23456,"p99_ms":1.23456,"max_ms":1.23456},"gpu_elapsed":{"samples":7,"total_samples":7,"avg_ms":1.23456,"p50_ms":1.23456,"p95_ms":1.23456,"p99_ms":1.23456,"max_ms":1.23456},"gpu_timing_available":true,"gpu_samples_dropped":7},"output_commits":7,"output_failed_commits":7,"fps":1.2,"frame_time_ms":1.2,"missed_frames":7,"refresh_hz":1.2,"titlebar_paints":7,"footer_paints":7,"edge_samples_attempted":7,"edge_samples_succeeded":7,"edge_samples_skipped":7,"edge_sample_ns":7,"panel_paints":7,"panel_allocated_bytes":7,"panel_reused_bytes":7,"icon_cache_hits":7,"icon_cache_misses":7,"icon_decode_ns":7,"icon_decode_count":7,"icon_decoded_bytes":7,"icon_queue_depth_max":7,"taskbar_paints":7,"taskbar_paint_ns":7,"taskbar_raster_pixels":7,"taskbar_clock_frame_requests":7,"taskbar_clock_paints":7,"taskbar_start_paints":7,"taskbar_chip_paints":7,"taskbar_tray_paints":7,"taskbar_hover_paints":7,"taskbar_press_paints":7,"taskbar_audio_paints":7,"recent_errors_count":7,"anim_frames_scheduled":7,"anim_wasted_wakeups":7,"anim_longest_ms":7,"anim_speed":1.23456,"anim_enabled":true,"anim_reduced_motion":true,"startup":{"build_mode":"text \"quoted\"\n\\","renderer":"text \"quoted\"\n\\","scale":1.23,"output_count":7,"catalog_entries":7,"autostart_count":7,"catalog_state":"text \"quoted\"\n\\","wallpaper_state":"text \"quoted\"\n\\","catalog_provisional":true,"catalog_loading":true,"catalog_generation":7,"renderer_ready_ns":7,"config_ready_ns":7,"catalog_cache_read_ns":7,"catalog_scan_ns":7,"wallpaper_decode_ns":7,"socket_ready_ns":7,"ipc_ready_ns":7,"session_ready_ns":7,"session_clients_started_ns":7,"xwayland_ready_ns":7,"first_presented_ns":7,"first_ipc_ns":7,"first_input_ns":7,"catalog_published_ns":7,"wallpaper_presented_ns":7,"catalog_cache_read_duration_ns":7,"catalog_scan_duration_ns":7,"wallpaper_decode_duration_ns":7,"backend_start_ns":7,"backend_ready_ns":7,"input_ready_ns":7,"first_visible_ns":7,"services_started_ns":7,"login_to_compositor_ns":7,"login_to_visible_ns":7,"reveal_done_ns":7},"desktop":{"paints":7,"damage_pixels":7,"tile_presents":7,"texture_uploads":7},"output_skipped_commits":7,"glass_reblurs":7}}}
{"Ok":{"IdleState":{"enabled":false,"state":"text \"quoted\"\n\\","blank_after_seconds":0,"suspend_after_seconds":0,"idle_ms":0,"is_inhibited":false,"inhibitor_count":0,"suspend_request_count":0,"inhibitors":[{"surface_ptr":0,"window_id":null,"app_id":null,"title":null,"is_active":false,"reason":null}]}}}
{"Ok":{"IdleState":{"enabled":true,"state":"text \"quoted\"\n\\","blank_after_seconds":7,"suspend_after_seconds":7,"idle_ms":7,"is_inhibited":true,"inhibitor_count":7,"suspend_request_count":7,"inhibitors":[{"surface_ptr":7,"window_id":7,"app_id":"text \"quoted\"\n\\","title":"text \"quoted\"\n\\","is_active":true,"reason":"text \"quoted\"\n\\"}]}}}
{"Ok":{"CaptureState":{"supported":false,"active_sessions":0,"sessions":[{"output":null,"window_id":null}],"last_failure":null,"indicator":null}}}
diff --git a/src/main.zig b/src/main.zig
index eda7641..8bcde6b 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -130,12 +130,14 @@ fn start(init: std.process.Init) !bool {
};
log.info("restarted after a crash while locked; the session stays locked", .{});
}
- server.backend.start() catch return error.BackendStartFailed;
+ server.reveal.arm(&server);
+ try server.startup_tasks.start(&server);
try server.session_startup.start(&server);
if (server.session_startup.failure) |err| return err;
log.info("Running compositor on WAYLAND_DISPLAY={s}", .{socket});
server.wl_server.run();
+ if (server.startup_tasks.failure) |err| return err;
if (server.session_startup.failure) |err| return err;
return server.restart_requested;
}
diff --git a/src/reveal.zig b/src/reveal.zig
new file mode 100644
index 0000000..7538d3f
--- /dev/null
+++ b/src/reveal.zig
@@ -0,0 +1,193 @@
+//! The session's fade in from black and the greeter's fade out to it: a veil
+//! the output pass draws over everything but the cursor
+//! (`rediwm_scene_output_set_veil`). Only displays someone looks at (DRM,
+//! nested) carry it; headless outputs never do. Output frames drive the fade;
+//! the one timer is a one-shot bound, so nothing wakes once it is over.
+const std = @import("std");
+const wl = @import("wayland").server.wl;
+const wlr = @import("wlroots");
+const anim = @import("ui").anim;
+const Server = @import("Server.zig");
+const Output = @import("Output.zig");
+const startup = @import("startup.zig");
+
+const Reveal = @This();
+
+/// After the first frame is shown, how long the fade waits for the decoded
+/// wallpaper, so it does not rise on the plain colour and then swap.
+const wallpaper_wait_ms = 150;
+/// The fade begins by then even if no frame is ever acknowledged.
+const max_hold_ms = 1000;
+const cover_ms = 200;
+/// Past the cover's own length: a display that stops presenting must not keep
+/// the greeter from exiting.
+const cover_slack_ms = 250;
+/// The black frame reaches the screen before the greeter exits.
+const covered_settle_ms = 20;
+
+const Phase = enum {
+ off,
+ /// Black on every veiled output until the first frame and the wallpaper.
+ held,
+ revealing,
+ covering,
+ /// Black; `on_covered` runs from the timer.
+ covered,
+};
+
+server: ?*Server = null,
+phase: Phase = .off,
+visible: bool = false,
+fade: anim.Anim = .{},
+timer: ?*wl.EventSource = null,
+on_covered: ?*const fn (*Server) void = null,
+
+/// Before the backend starts, so each output's first frame is already black.
+/// A crash-restart into a locked session shows its lock at once; the greeter
+/// (also a lock) fades in like a session.
+pub fn arm(self: *Reveal, server: *Server) void {
+ self.server = server;
+ if ((server.locker != null and !server.greeter_mode) or anim.curveFor(.session_reveal) == .off) return;
+ self.phase = .held;
+ self.armTimer(max_hold_ms);
+}
+
+pub fn deinit(self: *Reveal) void {
+ if (self.timer) |timer| timer.remove();
+ self.timer = null;
+ self.phase = .off;
+}
+
+fn veils(wlr_output: *wlr.Output) bool {
+ return wlr_output.isDrm() or wlr_output.isWl();
+}
+
+/// A display that appears while the desktop is still held starts black too.
+pub fn outputCreated(self: *Reveal, output: *Output) void {
+ if (self.phase != .held or !veils(output.wlr_output)) return;
+ self.setVeil(output, 1);
+}
+
+/// The first frame reached a screen.
+pub fn onVisible(self: *Reveal) void {
+ self.visible = true;
+ if (self.phase != .held) return;
+ const server = self.server orelse return;
+ if (server.wallpaper_loader == null) return self.begin();
+ self.armTimer(wallpaper_wait_ms);
+}
+
+/// The wallpaper decoded (and is on its node) or failed.
+pub fn onWallpaper(self: *Reveal) void {
+ if (self.phase == .held and self.visible) self.begin();
+}
+
+fn begin(self: *Reveal) void {
+ self.disarmTimer();
+ self.phase = .revealing;
+ self.fade = .initCurve(1, 0, anim.nowMs(), anim.curveFor(.session_reveal));
+ // Reduced motion keeps a short fade rather than a cut.
+ self.fade.property = .opacity;
+ self.scheduleFrames();
+}
+
+/// Fades every veiled output to black, then calls `done` (the greeter's
+/// exit). With nothing to fade it calls `done` at once.
+pub fn cover(self: *Reveal, server: *Server, done: *const fn (*Server) void) void {
+ self.server = server;
+ if (self.phase == .covering or self.phase == .covered) return;
+ var any = false;
+ var it = server.outputs.iterator(.forward);
+ while (it.next()) |output| {
+ if (veils(output.wlr_output) and output.wlr_output.enabled) any = true;
+ }
+ const now = anim.nowMs();
+ const from = self.current(now);
+ var fade: anim.Anim = .initCurve(from, 1, now, .{ .duration = .{ .ms = cover_ms, .ease = .in_out_sine } });
+ fade.property = .opacity;
+ if (!any or fade.settled(now)) return done(server);
+ self.on_covered = done;
+ self.fade = fade;
+ self.phase = .covering;
+ const length: f32 = @as(f32, cover_ms) / @max(anim.speed(), 0.25);
+ self.armTimer(@as(c_int, @intFromFloat(length)) + cover_slack_ms);
+ self.scheduleFrames();
+}
+
+fn current(self: *const Reveal, now_ms: i64) f32 {
+ return switch (self.phase) {
+ .off => 0,
+ .held, .covered => 1,
+ .revealing, .covering => self.fade.value(now_ms),
+ };
+}
+
+/// Once per output frame, before the frame is built. True while it fades.
+pub fn tick(self: *Reveal, output: *Output, now_ms: i64) bool {
+ if (self.phase != .revealing and self.phase != .covering) return false;
+ if (!veils(output.wlr_output)) return false;
+ if (!self.fade.settled(now_ms)) {
+ // Whole alpha steps: an unchanged one repaints nothing.
+ self.setVeil(output, @round(self.fade.value(now_ms) * 255) / 255);
+ return true;
+ }
+ if (self.phase == .revealing) {
+ self.phase = .off;
+ startup.markRevealed();
+ // Every output, so one that is between frames is not left dark.
+ var it = output.server.outputs.iterator(.forward);
+ while (it.next()) |each| self.setVeil(each, 0);
+ } else {
+ self.phase = .covered;
+ var it = output.server.outputs.iterator(.forward);
+ while (it.next()) |each| if (veils(each.wlr_output)) self.setVeil(each, 1);
+ self.armTimer(covered_settle_ms);
+ }
+ return false;
+}
+
+fn setVeil(self: *Reveal, output: *Output, alpha: f32) void {
+ const server = self.server orelse return;
+ const scene_output = server.scene.getSceneOutput(output.wlr_output) orelse return;
+ if (!server.output_renderer.setVeil(scene_output, alpha)) {
+ std.log.scoped(.reveal).warn("could not veil {s}", .{output.wlr_output.name});
+ }
+}
+
+fn scheduleFrames(self: *Reveal) void {
+ const server = self.server orelse return;
+ var it = server.outputs.iterator(.forward);
+ while (it.next()) |output| output.wlr_output.scheduleFrame();
+}
+
+fn armTimer(self: *Reveal, ms: c_int) void {
+ const server = self.server orelse return;
+ if (self.timer == null) {
+ self.timer = server.wl_server.getEventLoop().addTimer(*Reveal, handleTimer, self) catch null;
+ }
+ const timer = self.timer orelse return self.expire();
+ timer.timerUpdate(@max(ms, 1)) catch self.expire();
+}
+
+fn disarmTimer(self: *Reveal) void {
+ if (self.timer) |timer| timer.timerUpdate(0) catch {};
+}
+
+fn handleTimer(self: *Reveal) c_int {
+ self.expire();
+ return 0;
+}
+
+fn expire(self: *Reveal) void {
+ switch (self.phase) {
+ .held => self.begin(),
+ .covering, .covered => {
+ self.disarmTimer();
+ self.phase = .covered;
+ const done = self.on_covered orelse return;
+ self.on_covered = null;
+ if (self.server) |server| done(server);
+ },
+ .off, .revealing => {},
+ }
+}
diff --git a/src/scene_output.c b/src/scene_output.c
index daa87fb..8172c73 100644
--- a/src/scene_output.c
+++ b/src/scene_output.c
@@ -52,6 +52,10 @@ struct output_state {
struct wlr_box cursors[4];
int ncursors;
struct wl_list caches;
+ // rediwm_scene_output_set_veil: black over the frame (0 to 1), and whether it
+ // changed since the last frame was built, so that change re-blurs no glass.
+ float veil;
+ bool veil_changed;
};
struct entry {
struct rediwm_item item;
@@ -111,9 +115,14 @@ static void output_destroyed(struct wl_listener *listener, void *data) {
struct output_state *os = wl_container_of(listener, os, destroy);
output_state_destroy(os);
}
-static struct output_state *output_state_get(struct rediwm_output_renderer *r, struct wlr_output *output) {
+static struct output_state *output_state_find(struct rediwm_output_renderer *r, struct wlr_output *output) {
struct output_state *os;
wl_list_for_each(os, &r->outputs, link) if (os->output == output) return os;
+ return NULL;
+}
+static struct output_state *output_state_get(struct rediwm_output_renderer *r, struct wlr_output *output) {
+ struct output_state *os = output_state_find(r, output);
+ if (os) return os;
os = calloc(1, sizeof(*os));
if (!os) return NULL;
os->renderer = r;
@@ -142,6 +151,16 @@ void rediwm_scene_output_damage_whole(struct wlr_scene_output *out) {
&out->private.pending_commit_damage, 0, 0, out->output->width, out->output->height);
wlr_output_schedule_frame(out->output);
}
+bool rediwm_scene_output_set_veil(struct rediwm_output_renderer *r, struct wlr_scene_output *out, float alpha) {
+ alpha = alpha < 0 ? 0 : alpha > 1 ? 1 : alpha;
+ struct output_state *os = alpha > 0 ? output_state_get(r, out->output) : output_state_find(r, out->output);
+ if (!os) return alpha == 0;
+ if (os->veil == alpha) return true;
+ os->veil = alpha;
+ os->veil_changed = true;
+ rediwm_scene_output_damage_whole(out);
+ return true;
+}
// Stage 3 parity deliberately retains the legacy layout snap, then snaps
// output-scaled edges. Removing that first snap is a geometry change, not a
// renderer switch. No view node position/size is consulted here.
@@ -521,6 +540,11 @@ static bool decide_effects(struct rediwm_output_renderer *r, struct output_state
os->cursors[i] = cursors[i];
}
os->ncursors = ncursors;
+ // The veil is drawn over every effect, so repainting the output for it changes
+ // nothing a blur reads. While it changes, damage no event explains goes
+ // unnoticed too; a resize or failed frame still re-blurs on its own.
+ if (os->veil_changed)
+ pixman_region32_union_rect(&a.explained, &a.explained, 0, 0, v->width, v->height);
pixman_region32_t unexplained;
pixman_region32_init(&unexplained);
pixman_region32_subtract(&unexplained, &out->private.pending_commit_damage, &a.explained);
@@ -814,7 +838,7 @@ static bool audit_read(struct wlr_renderer *renderer, struct wlr_buffer *buffer,
}
static void audit_damage(struct rediwm_output_renderer *r, struct wlr_scene_output *out,
struct wlr_buffer *real, struct entry *entries, size_t len, const struct output_view *v,
- const pixman_region32_t *damage) {
+ const pixman_region32_t *damage, float veil) {
struct wlr_output *output = out->output;
int slot = -1;
for (int i = 0; i < 8; i++) {
@@ -842,6 +866,8 @@ static void audit_damage(struct rediwm_output_renderer *r, struct wlr_scene_outp
// Blurs are kept as the real pass left them: this audits damage, not glass.
for (size_t i = 0; i < len; i++) entries[i].reblur = false;
for (size_t i = len; i > 0; i--) render_entry(r, &entries[i - 1], out, pass, v, &whole, false);
+ if (veil > 0) wlr_render_pass_add_rect(pass, &(struct wlr_render_rect_options){
+ .box = {0, 0, real->width, real->height}, .color = {0, 0, 0, veil}, .clip = &whole});
wlr_output_add_software_cursors_to_render_pass(output, pass, &whole);
bool submitted = wlr_render_pass_submit(pass);
pixman_region32_fini(&whole);
@@ -940,6 +966,8 @@ bool rediwm_scene_output_build_state(struct rediwm_output_renderer *r,
pixman_region32_t changed;
pixman_region32_init(&changed);
struct output_state *os = r->has_backdrops ? output_state_get(r, output) : NULL;
+ struct output_state *veiled = output_state_find(r, output);
+ const float veil = veiled ? veiled->veil : 0;
if (os && !decide_effects(r, os, out, &v, &changed)) {
pixman_region32_fini(&changed);
pixman_region32_fini(&collector.covered);
@@ -954,7 +982,7 @@ bool rediwm_scene_output_build_state(struct rediwm_output_renderer *r,
}
pixman_region32_fini(&changed);
wlr_output_state_set_damage(state, &out->private.pending_commit_damage);
- bool scanout = len == 1 && try_scanout(&entries[0], out, state, &v);
+ bool scanout = len == 1 && veil == 0 && try_scanout(&entries[0], out, state, &v);
if (out->private.prev_scanout != scanout) {
out->private.prev_scanout = scanout;
wlr_log(WLR_DEBUG, "Direct scan-out %s", scanout ? "enabled" : "disabled");
@@ -985,13 +1013,15 @@ bool rediwm_scene_output_build_state(struct rediwm_output_renderer *r,
ok = true;
for (size_t i = len; i > 0; i--)
if (!render_entry(r, &entries[i - 1], out, pass, &v, &damage, false)) ok = false;
+ if (veil > 0) wlr_render_pass_add_rect(pass, &(struct wlr_render_rect_options){
+ .box = {0, 0, buffer->width, buffer->height}, .color = {0, 0, 0, veil}, .clip = &damage});
wlr_output_add_software_cursors_to_render_pass(output, pass, &damage);
bool submitted = wlr_render_pass_submit(pass);
// Successful reads still need release points when another item failed to
// import. No sample event is sent for a failed GPU submission.
if (submitted) for (size_t i = 0; i < len; i++) if (entries[i].sampled) sample(&entries[i], out, false);
#ifdef REDIWM_DAMAGE_AUDIT
- if (submitted && ok) audit_damage(r, out, buffer, entries, len, &v, &damage);
+ if (submitted && ok) audit_damage(r, out, buffer, entries, len, &v, &damage, veil);
#endif
ok = ok && submitted;
pixman_region32_fini(&background);
@@ -1007,6 +1037,7 @@ done:
if (buffer) wlr_buffer_unlock(buffer);
if (!ok) rediwm_scene_output_damage_whole(out);
pixman_region32_fini(&collector.covered);
+ if (ok && veiled) veiled->veil_changed = false;
if (os) {
// Outside the pass: drop the blurs of effects this output no longer shows;
// after a failed frame, trust none of them.
diff --git a/src/scene_output.h b/src/scene_output.h
index 7944de9..0ec85fb 100644
--- a/src/scene_output.h
+++ b/src/scene_output.h
@@ -24,3 +24,9 @@ struct wlr_render_pass *rediwm_output_begin_pass(struct rediwm_output_renderer *
bool rediwm_scene_output_build_state(struct rediwm_output_renderer *,
struct rediwm_projection *, struct wlr_scene_output *, struct wlr_output_state *);
void rediwm_scene_output_damage_whole(struct wlr_scene_output *);
+// Black over everything the output pass draws except the software cursor, at this
+// alpha (0 = none, 1 = black), for the session's fade in and the greeter's fade
+// out. A change repaints the whole output but re-blurs no glass: the veil lies
+// above every effect. Direct scan-out waits until it is 0. False only when the
+// state for a nonzero veil could not be allocated.
+bool rediwm_scene_output_set_veil(struct rediwm_output_renderer *, struct wlr_scene_output *, float alpha);
diff --git a/src/scene_output.zig b/src/scene_output.zig
index 3fb3e7d..50c64a5 100644
--- a/src/scene_output.zig
+++ b/src/scene_output.zig
@@ -18,6 +18,8 @@ pub const Renderer = opaque {
pub const buildState = rediwm_scene_output_build_state;
extern fn rediwm_output_begin_pass(renderer: *Renderer, buffer: *wlr.Buffer, options: ?*const wlr.Renderer.BufferPassOptions) ?*wlr.RenderPass;
pub const beginPass = rediwm_output_begin_pass;
+ extern fn rediwm_scene_output_set_veil(renderer: *Renderer, output: *wlr.SceneOutput, alpha: f32) bool;
+ pub const setVeil = rediwm_scene_output_set_veil;
};
extern fn rediwm_scene_output_damage_whole(output: *wlr.SceneOutput) void;
pub const damageWhole = rediwm_scene_output_damage_whole;
diff --git a/src/session/lock.zig b/src/session/lock.zig
index a441326..2ef2f34 100644
--- a/src/session/lock.zig
+++ b/src/session/lock.zig
@@ -259,7 +259,8 @@ pub const Lock = struct {
.started => {
self.status = "Starting session…";
std.log.info("greeter: rediwm-dm accepted the session; exiting", .{});
- self.server.terminate();
+ // Out to black, as the session comes in from it.
+ self.server.reveal.cover(self.server, Server.terminate);
},
.disconnected => {
self.status = "Lost contact with login service. Try again.";
@@ -1311,6 +1312,7 @@ test "greeter signs in through rediwm-dm and exits only once the session starts"
server.io = std.testing.io;
server.shutting_down = false;
server.layout_autosave = null;
+ server.reveal = .{};
var users = [_]greeter_mod.User{
.{ .name = "rediwm-test-a", .real = "Test A", .home = "", .uid = 1000 },
.{ .name = "rediwm-test-b", .real = "", .home = "", .uid = 1001 },
@@ -1441,6 +1443,7 @@ test "greeter reports a lost login service and exits to be replaced" {
server.wl_server = display;
server.shutting_down = false;
server.layout_autosave = null;
+ server.reveal = .{};
var users = [_]greeter_mod.User{.{ .name = "rediwm-test-a", .real = "", .home = "", .uid = 1000 }};
var sessions = [_]greeter_mod.Session{.{ .id = "rediwm", .name = "RediWM", .exec = "rediwm-session", .desktops = "rediwm" }};
const greeter = try std.heap.c_allocator.create(Greeter);
diff --git a/src/session/startup.zig b/src/session/startup.zig
index ece9b4a..6e706d0 100644
--- a/src/session/startup.zig
+++ b/src/session/startup.zig
@@ -50,8 +50,9 @@ fn onReady(owner: *anyopaque, result: activation.Readiness.Failure!void) void {
self.schedule();
}
-fn schedule(self: *Startup) void {
+pub fn schedule(self: *Startup) void {
const server = self.server orelse return;
+ if (!server.startup_tasks.complete) return;
if (!self.acknowledged or self.launched or self.timer != null or server.greeter_mode or server.shutting_down) return;
// A session with no outputs must still be able to launch its clients.
if (!self.presented and server.outputs.length() != 0) return;
diff --git a/src/startup.zig b/src/startup.zig
index 21860ab..022a0bc 100644
--- a/src/startup.zig
+++ b/src/startup.zig
@@ -37,6 +37,15 @@ pub const Marks = struct {
session_clients_started_ns: u64 = 0,
xwayland_ready_ns: u64 = 0,
first_presented_ns: u64 = 0,
+ // Backend presentation acknowledgement, distinct from scene submission.
+ first_visible_ns: u64 = 0,
+ backend_start_ns: u64 = 0,
+ backend_ready_ns: u64 = 0,
+ input_ready_ns: u64 = 0,
+ services_started_ns: u64 = 0,
+ // The fade in from black finished (zero without one, e.g. headless).
+ reveal_done_ns: u64 = 0,
+ login_started_ns: u64 = 0,
first_ipc_ns: u64 = 0,
first_input_ns: u64 = 0,
catalog_published_ns: u64 = 0,
@@ -66,7 +75,12 @@ pub const Marks = struct {
pub var marks: Marks = .{};
pub fn initOrigin(environ: std.process.Environ) void {
+ marks = .{};
marks.origin_ns = stats.nowNs();
+ if (environ.getPosix("REDIWM_LOGIN_STARTED_NS")) |value| {
+ const started = std.fmt.parseInt(u64, value, 10) catch 0;
+ if (started <= marks.origin_ns) marks.login_started_ns = started;
+ }
marks.log_enabled = envEnabled(environ, "REDIWM_STARTUP_TIMING");
if (marks.log_enabled) {
log.info("process entry (build_mode={s})", .{marks.build_mode});
@@ -120,6 +134,39 @@ pub fn markFirstIpc() void {
stampFirst(&marks.first_ipc_ns, "first_ipc");
}
+pub fn markBackendStart() void {
+ stampFirst(&marks.backend_start_ns, "backend_start");
+}
+
+pub fn markBackendReady() void {
+ stampFirst(&marks.backend_ready_ns, "backend_ready");
+}
+
+pub fn markInputReady() void {
+ stampFirst(&marks.input_ready_ns, "input_ready");
+}
+
+pub fn markServicesStarted() void {
+ stampFirst(&marks.services_started_ns, "services_started");
+}
+
+pub fn markRevealed() void {
+ stampFirst(&marks.reveal_done_ns, "reveal_done");
+}
+
+pub fn noteVisible() void {
+ if (marks.first_visible_ns != 0) return;
+ stampFirst(&marks.first_visible_ns, "first_visible");
+ if (marks.login_started_ns != 0 and marks.log_enabled) {
+ log.info("login_to_visible {d}ms", .{loginOffset(marks.first_visible_ns) / 1_000_000});
+ }
+}
+
+pub fn loginOffset(abs_ns: u64) u64 {
+ if (marks.login_started_ns == 0 or abs_ns < marks.login_started_ns) return 0;
+ return abs_ns - marks.login_started_ns;
+}
+
pub fn markSessionReady() void {
stampFirst(&marks.session_ready_ns, "session_ready");
}
diff --git a/src/startup_tasks.zig b/src/startup_tasks.zig
new file mode 100644
index 0000000..ae66185
--- /dev/null
+++ b/src/startup_tasks.zig
@@ -0,0 +1,149 @@
+//! Show the desktop before enumerating native input and starting optional
+//! services. Backends remain owned by wlroots' multi-backend throughout.
+const std = @import("std");
+const wl = @import("wayland").server.wl;
+const wlr = @import("wlroots");
+const Server = @import("Server.zig");
+const startup = @import("startup.zig");
+
+const Tasks = @This();
+server: ?*Server = null,
+timer: ?*wl.EventSource = null,
+input_pending: bool = false,
+step: usize = 0,
+complete: bool = false,
+failure: ?anyerror = null,
+
+extern fn wlr_backend_is_libinput(backend: *wlr.Backend) bool;
+
+pub fn start(self: *Tasks, server: *Server) !void {
+ self.server = server;
+ startup.markBackendStart();
+ // Greeter and lock recovery need their input immediately. Nested and
+ // headless backends already own their output and input together.
+ if (server.session != null and !server.greeter_mode and server.locker == null and server.backend.isMulti()) {
+ server.backend.multiForEachBackend(*Tasks, startDisplayBackend, self);
+ if (self.failure) |err| return err;
+ } else {
+ try server.backend.start();
+ }
+ startup.markBackendReady();
+ if (self.input_pending) server.input.holdCursor() else startup.markInputReady();
+ if (server.greeter_mode) {
+ self.complete = true;
+ return;
+ }
+ self.timer = try server.wl_server.getEventLoop().addTimer(*Tasks, tick, self);
+ // A disabled/unplugged display or failed flip must not leave input or
+ // services waiting indefinitely. This is a one-shot bound.
+ try self.timer.?.timerUpdate(if (server.outputs.length() == 0) 1 else 250);
+}
+
+fn startDisplayBackend(backend: *wlr.Backend, self: *Tasks) void {
+ self.startSelectedBackend(backend, wlr_backend_is_libinput(backend), false);
+}
+
+fn startInputBackend(backend: *wlr.Backend, self: *Tasks) void {
+ self.startSelectedBackend(backend, wlr_backend_is_libinput(backend), true);
+}
+
+fn startSelectedBackend(self: *Tasks, backend: *wlr.Backend, is_input: bool, input_stage: bool) void {
+ if (self.failure != null) return;
+ if (is_input != input_stage) {
+ if (is_input) self.input_pending = true;
+ return;
+ }
+ backend.start() catch |err| {
+ self.failure = err;
+ };
+}
+
+pub fn onVisible(self: *Tasks) void {
+ // Do not re-arm between every frame or restart a completed queue.
+ if (self.step != 0 or self.complete) return;
+ if (self.timer) |timer| timer.timerUpdate(1) catch self.fail(error.TimerUpdateFailed);
+}
+
+pub fn onSessionActive(self: *Tasks) void {
+ if (self.input_pending) self.onVisible();
+}
+
+fn tick(self: *Tasks) c_int {
+ const server = self.server orelse return 0;
+ if (server.shutting_down or server.restart_requested) {
+ self.deinit();
+ return 0;
+ }
+ if (self.input_pending) {
+ // Device acquisition requires the active seat. A VT switch during
+ // the first frame wait is resumed by handleSessionActive, not polling.
+ if (server.session) |session| if (!session.active) return 0;
+ self.input_pending = false;
+ server.backend.multiForEachBackend(*Tasks, startInputBackend, self);
+ if (self.failure) |err| {
+ self.fail(err);
+ return 0;
+ }
+ startup.markInputReady();
+ server.input.releaseCursor();
+ } else if (server.startDesktopService(self.step)) {
+ self.step += 1;
+ } else {
+ self.complete = true;
+ startup.markServicesStarted();
+ self.deinit();
+ server.session_startup.schedule();
+ server.startup_warmup.schedule(server);
+ return 0;
+ }
+ if (self.timer) |timer| timer.timerUpdate(1) catch self.fail(error.TimerUpdateFailed);
+ return 0;
+}
+
+fn fail(self: *Tasks, err: anyerror) void {
+ self.failure = err;
+ self.deinit();
+ if (self.server) |server| server.wl_server.terminate();
+}
+
+pub fn deinit(self: *Tasks) void {
+ if (self.timer) |timer| timer.remove();
+ self.timer = null;
+}
+
+test "staged backends retain multi ownership and only start in their own stage" {
+ // Real headless backends exercise wlroots' start/ownership contracts;
+ // classifying one as input avoids touching the host seat in this test.
+ const loop = try wl.EventLoop.create();
+ defer loop.destroy();
+ const multi = try wlr.Backend.createMulti(loop);
+ defer multi.destroy();
+ const display = try wlr.Backend.createHeadless(loop);
+ try std.testing.expect(multi.multiAdd(display));
+ const input = try wlr.Backend.createHeadless(loop);
+ try std.testing.expect(multi.multiAdd(input));
+ _ = try display.headlessAddOutput(32, 32);
+ _ = try input.headlessAddOutput(32, 32);
+ const Observer = struct {
+ listener: wl.Listener(*wlr.Output) = .init(newOutput),
+ count: usize = 0,
+ fn newOutput(listener: *wl.Listener(*wlr.Output), _: *wlr.Output) void {
+ const self: *@This() = @fieldParentPtr("listener", listener);
+ self.count += 1;
+ }
+ };
+ var observer: Observer = .{};
+ multi.events.new_output.add(&observer.listener);
+ defer observer.listener.link.remove();
+ var tasks: Tasks = .{};
+ tasks.startSelectedBackend(input, true, false);
+ try std.testing.expect(tasks.input_pending);
+ try std.testing.expectEqual(@as(usize, 0), observer.count);
+ tasks.startSelectedBackend(display, false, false);
+ try std.testing.expectEqual(@as(usize, 1), observer.count);
+ tasks.startSelectedBackend(display, false, true);
+ try std.testing.expectEqual(@as(usize, 1), observer.count);
+ tasks.startSelectedBackend(input, true, true);
+ try std.testing.expectEqual(@as(usize, 2), observer.count);
+ try std.testing.expect(tasks.failure == null);
+}
diff --git a/src/startup_warmup.zig b/src/startup_warmup.zig
index 2ae26d4..bfb3ec4 100644
--- a/src/startup_warmup.zig
+++ b/src/startup_warmup.zig
@@ -1,4 +1,4 @@
-// Small, disposable warmup after the first successful scene submission.
+// Small, disposable warmup after the first frame and desktop service setup.
// Icon decoding stays on its worker; font caches stay on the compositor thread.
const std = @import("std");
const wl = @import("wayland").server.wl;
diff --git a/src/ui/anim.zig b/src/ui/anim.zig
index c03d892..0cbee19 100644
--- a/src/ui/anim.zig
+++ b/src/ui/anim.zig
@@ -3,7 +3,8 @@
// tests (`setNowMs`) and dropped frames are all the same `x(t)`.
//
// Models:
-// - `.duration` — today's ease over a fixed ms window (`out_cubic`, `flip_bezier`).
+// - `.duration` — today's ease over a fixed ms window (`out_cubic`, `flip_bezier`,
+// `in_out_sine`).
// - `.spring` — damped harmonic oscillator (libadwaita / RBBAnimation closed form).
// Parameterised by damping ratio, not raw damping. Velocity is the analytic
// derivative so a retarget continues from the current speed.
@@ -18,7 +19,7 @@
// "should I keep waking up?".
const std = @import("std");
-pub const Ease = enum { out_cubic, flip_bezier };
+pub const Ease = enum { out_cubic, flip_bezier, in_out_sine };
pub const Spring = struct {
damping_ratio: f32 = 1.0,
@@ -105,6 +106,7 @@ pub const Target = enum {
camera_zoom,
camera_reveal,
camera_desktop,
+ session_reveal,
pub const count = std.meta.tags(Target).len;
@@ -167,6 +169,8 @@ pub fn defaultSpec(target: Target) TargetSpec {
.camera_zoom => .{ .curve = .{ .spring = springs.camera_zoom } },
.camera_reveal => .{ .curve = .{ .duration = .{ .ms = 320, .ease = .out_cubic } } },
.camera_desktop => .{ .curve = desktopSwitchCurve(default_desktop_switch_ms) },
+ // Out of black: an even ramp, not one that is almost bright at once.
+ .session_reveal => .{ .curve = .{ .duration = .{ .ms = 420, .ease = .in_out_sine } } },
};
}
@@ -1077,6 +1081,7 @@ fn sampleDuration(from: f32, to: f32, elapsed_ms: f64, duration_ms: i64, ease: E
const eased: f32 = switch (ease) {
.out_cubic => 1 - std.math.pow(f32, 1 - t32, 3),
.flip_bezier => cubicBezierY(t32, 0.22, 0.9, 0.3, 1),
+ .in_out_sine => 0.5 - 0.5 * @cos(std.math.pi * t32),
};
const deriv = easeDeriv(ease, t);
const vel = (to - from) * deriv * (1000.0 / dur);
@@ -1091,6 +1096,7 @@ fn easeDeriv(ease: Ease, t: f64) f64 {
return switch (ease) {
.out_cubic => 3.0 * (1.0 - tt) * (1.0 - tt),
.flip_bezier => cubicBezierDeriv(tt, 0.22, 0.9, 0.3, 1.0),
+ .in_out_sine => 0.5 * std.math.pi * @sin(std.math.pi * tt),
};
}
diff --git a/src/ui_tests.zig b/src/ui_tests.zig
index 31636a1..632357a 100644
--- a/src/ui_tests.zig
+++ b/src/ui_tests.zig
@@ -51,6 +51,7 @@ test {
_ = @import("start_menu/applications.zig");
_ = @import("start_menu/catalog_cache.zig");
_ = @import("startup.zig");
+ _ = @import("startup_tasks.zig");
_ = @import("start_menu/launch.zig");
_ = @import("start_menu/search.zig");
_ = @import("start_menu/model.zig");
diff --git a/tests/dm.py b/tests/dm.py
index 2e16c6f..208c1e3 100644
--- a/tests/dm.py
+++ b/tests/dm.py
@@ -216,6 +216,7 @@ expect("ok")
send({"type": "start", "session": "rediwm"})
expect("ok")
open(TMP + "/greeter-exit-time.txt", "w").write(str(__import__("time").time_ns()))
+open(TMP + "/greeter-exit-monotonic.txt", "w").write(str(__import__("time").monotonic_ns()))
finish()
"""
with Fixture("login", body) as f:
@@ -228,6 +229,7 @@ finish()
"XDG_SEAT": "seat0", "XDG_VTNR": "1", "XDG_CURRENT_DESKTOP": "RediWM:wlroots", "USER": "alice"}.items():
assert env.get(key) == want, (key, env.get(key))
assert "REDIWM_GREETER_FD" not in env, env
+ assert 0 < int(env["REDIWM_LOGIN_STARTED_NS"]) <= int(f.path("greeter-exit-monotonic.txt").read_text()), env
# The daemon's blocked signals and systemd's ignored SIGPIPE never reach the session.
signals = dict(line.split(":") for line in f.path("session-signals.txt").read_text().splitlines())
assert int(signals["SigBlk"], 16) == 0, signals
diff --git a/tests/session_readiness.py b/tests/session_readiness.py
index 5eac143..8e689a4 100644
--- a/tests/session_readiness.py
+++ b/tests/session_readiness.py
@@ -28,7 +28,7 @@ s = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
s.sendto(json.dumps({'pid':os.getpid(), 'wayland':os.getenv('WAYLAND_DISPLAY'),
'ipc':os.getenv('REDIWM_SOCKET'), 'desktop':os.getenv('XDG_CURRENT_DESKTOP'),
'display':os.getenv('DISPLAY'), 'path':os.getenv('PATH'),
- 'private':[os.getenv(key) for key in ('REDIWM_SESSION_FD','REDIWM_LOGIN_SESSION','REDIWM_SESSION_PRIMARY')]}).encode(), sys.argv[1])
+ 'private':[os.getenv(key) for key in ('REDIWM_SESSION_FD','REDIWM_LOGIN_SESSION','REDIWM_SESSION_PRIMARY','REDIWM_LOGIN_STARTED_NS')]}).encode(), sys.argv[1])
time.sleep(60)
''')
command = f'{sys.executable} {helper} {tmp / "child.sock"}'
@@ -38,6 +38,7 @@ time.sleep(60)
env = dict(os.environ, XDG_RUNTIME_DIR=directory, WLR_BACKENDS='headless',
WLR_RENDERER='gles2', WLR_HEADLESS_OUTPUTS='1', REDIWM_CONFIG=str(config),
REDIWM_SESSION_FD=str(child.fileno()), REDIWM_LOGIN_SESSION='must-not-escape',
+ REDIWM_LOGIN_STARTED_NS=str(time.monotonic_ns()),
XDG_CACHE_HOME=str(tmp / 'cache'), DISPLAY=':host',
XDG_STATE_HOME=str(tmp / 'state'),
PULSE_SERVER='unix:' + str(tmp / 'missing-pulse'),
@@ -73,13 +74,14 @@ time.sleep(60)
assert launched['wayland'] == ready['WAYLAND_DISPLAY'], launched
assert launched['ipc'] == ready['REDIWM_SOCKET'], launched
assert launched['desktop'] == 'rediwm' and launched['display'] is None, launched
- assert launched['private'] == [None, None, None], launched
+ assert launched['private'] == [None, None, None, None], launched
assert launched['path'].startswith(str(ROOT / 'zig-out/bin') + ':'), launched
handles.append(os.pidfd_open(launched['pid']))
assert not select.select([receiver], [], [], .1)[0], 'duplicate helper launch'
with IPCClient(ready['REDIWM_SOCKET']) as ipc:
after = ipc.get_perf()['startup']
assert after['session_clients_started_ns'] >= after['session_ready_ns'] > after['first_presented_ns'], after
+ assert 0 < after['first_visible_ns'] <= after['services_started_ns'] <= after['session_clients_started_ns'], after
ipc.wait_for('wallpaper_presented', timeout_ms=10000)
if attempt == 0:
try:
diff --git a/tests/startup.py b/tests/startup.py
index f8ee3e8..549a430 100644
--- a/tests/startup.py
+++ b/tests/startup.py
@@ -8,6 +8,7 @@ import json
import re
import socket
import struct
+import sys
import tempfile
import time
@@ -50,6 +51,7 @@ def test_responsive_before_publication():
"REDIWM_CATALOG_SCAN_DELAY_MS": "800",
"REDIWM_WALLPAPER_DECODE_DELAY_MS": "800",
"REDIWM_DISABLE_CATALOG_CACHE": "1",
+ "REDIWM_LOGIN_STARTED_NS": str(time.monotonic_ns() - 250_000_000),
})
try:
with IPCClient(socket_path=tmp, timeout=15) as client:
@@ -73,6 +75,12 @@ def test_responsive_before_publication():
client.wait_for("catalog_published", timeout_ms=5000)
client.wait_for("wallpaper_presented", timeout_ms=5000)
published = stats(client)
+ assert 0 < published["backend_start_ns"] <= published["backend_ready_ns"], published
+ assert published["backend_ready_ns"] <= published["input_ready_ns"], published
+ assert 0 < published["first_visible_ns"] <= published["services_started_ns"], published
+ assert published["services_started_ns"] <= published["session_clients_started_ns"], published
+ assert published["login_to_compositor_ns"] >= 250_000_000, published
+ assert published["login_to_visible_ns"] == published["login_to_compositor_ns"] + published["first_visible_ns"], published
assert published["catalog_state"] == "published", published
assert published["wallpaper_state"] == "presented", published
assert published["catalog_entries"] >= 4, published
@@ -285,6 +293,31 @@ def test_stalled_wayland_client_recovers():
log.close()
+def test_services_without_outputs():
+ with tempfile.TemporaryDirectory(prefix="rediwm-startup-no-output-") as directory:
+ tmp = Path(directory)
+ helper = tmp / "launched.py"
+ helper.write_text("import socket\ns = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)\n"
+ f"s.sendto(b'ready', {str(tmp / 'launched.sock')!r})\n")
+ with socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM) as receiver:
+ receiver.bind(str(tmp / 'launched.sock'))
+ receiver.settimeout(5)
+ command = f"{sys.executable} {helper}"
+ process, log = spawn_compositor(tmp, outputs="0", config_content=
+ '[compositor]\nxwayland = false\n[[autostart]]\ncmd = ' + json.dumps(command) + '\n')
+ try:
+ assert receiver.recv(32) == b'ready'
+ with IPCClient(socket_path=tmp) as client:
+ result = stats(client)
+ assert result["first_visible_ns"] == 0, result
+ assert result["first_presented_ns"] == 0, result
+ assert 0 < result["services_started_ns"] <= result["session_clients_started_ns"], result
+ print("startup: services and autostart complete without an output")
+ finally:
+ stop_process(process)
+ log.close()
+
+
if __name__ == "__main__":
test_responsive_before_publication()
test_cache_then_revalidate()
@@ -292,3 +325,4 @@ if __name__ == "__main__":
test_early_shutdown_joins_workers()
test_stalled_audio_does_not_block()
test_stalled_wayland_client_recovers()
+ test_services_without_outputs()