From 6c7586e8d7c8c6a59b73864fc3096abf3f60d0ac Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Wed, 18 Jan 2023 11:41:46 +0100 Subject: session-lock: properly handle disabled outputs Outputs that are part of the layout but currently disabled (e.g. due to use of wlr-output-power-management) are not correctly handled as river currently waits for them to present a new locked frame before sending the locked event. This new frame never comes however since the output is disabled. Fix this by maintaining the correct Output.lock_render_state as outputs are enabled/disabled. Additionally add missing maybeLock() calls to handle the case that all outputs in the layout are disabled. --- river/LockManager.zig | 5 +++++ river/Output.zig | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/river/LockManager.zig b/river/LockManager.zig index 1fb897d..0c108fc 100644 --- a/river/LockManager.zig +++ b/river/LockManager.zig @@ -95,6 +95,8 @@ fn handleLock(listener: *wl.Listener(*wlr.SessionLockV1), lock: *wlr.SessionLock manager.lock_surfaces_timer.timerUpdate(200) catch { log.err("error setting lock surfaces timer, imperfect frames may be shown", .{}); manager.state = .waiting_for_blank; + // This call is necessary in the case that all outputs in the layout are disabled. + manager.maybeLock(); }; { @@ -138,6 +140,9 @@ fn handleLockSurfacesTimeout(manager: *LockManager) c_int { } } + // This call is necessary in the case that all outputs in the layout are disabled. + manager.maybeLock(); + return 0; } diff --git a/river/Output.zig b/river/Output.zig index b14247a..2e22524 100644 --- a/river/Output.zig +++ b/river/Output.zig @@ -507,6 +507,18 @@ fn handleEnable(listener: *wl.Listener(*wlr.Output), wlr_output: *wlr.Output) vo // Add the output to root.outputs and the output layout if it has not // already been added. if (wlr_output.enabled) server.root.addOutput(self); + + if (wlr_output.enabled) { + switch (server.lock_manager.state) { + .unlocked => self.lock_render_state = .unlocked, + .waiting_for_lock_surfaces, .waiting_for_blank, .locked => { + assert(self.lock_render_state == .blanked); + }, + } + } else { + // Disabling and re-enabling an output always blanks it. + self.lock_render_state = .blanked; + } } fn handleFrame(listener: *wl.Listener(*wlr.OutputDamage), _: *wlr.OutputDamage) void { -- cgit v1.2.3