-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add --idle-timeout-when-locked
for idle timeout when session is locked
#3546
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this needs to be a little more flexible. Particularly, we want to give time for any lockscreen to render, so that on resume it's already there.
Not sure if we need it to be configurable, maybe just hardcoding a second-long delay would be appropriate…?
@AlanGriffiths @mattkae thoughts?
@@ -215,6 +267,16 @@ void msh::BasicIdleHandler::set_display_off_timeout(std::optional<time::Duration | |||
display_config_controller, mir_power_mode_off, multiplexer); | |||
observers.push_back(power_setter); | |||
idle_hub->register_interest(power_setter, off_timeout); | |||
if (off_timeout == time::Duration{} && previous_off_timeout) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it is "just me", but I find that off_timeout == time::Duration{0}
better expresses a comparison to zero. (I know comparing to "default constructed" has the same meaning to the compiler but it takes more thought to read)
I don't think turning the screen off will actually prevent the lockscreen rendering. Is this actually down to our "smooth boot" changes? I.e. showing the preexisting display buffer until we have something to composite. If so, we could also avoid flashing the old content by just blanking the display before poweroff. |
I agree. I think it might be a little bit less jarring if we let the lockscreen render¹ between locking and turning the display off, though? For reference, GNOME lets the lockscreen animate in before turning the display off. ¹: Probably just a 5sec delay; while we could, I don't think we need to actually check that the lockscreen has submitted buffers for each output. |
I am 👍 for a timer that will idle the screen X seconds after a lock. That way, the lock client has some time to respond before the screen goes dim. I also think that the X seconds here should be configurable by the compositor implementer. Different authors may want this behavior to happen on a different timing (or not at all) |
When talking with Harlen yesterday talking about the appropriate behaviour here, we had something of an idea: This might be worth supporting directly in ¹: In the degenerate case where we want the screen to turn off immediately on session lock, we very much don't want the screen off timer to continue to fire immediately, because that will ensure the screen turns off even while the user is trying to unlock their session! |
--idle-timeout-on-lock
for idle timeout when session is locked
--idle-timeout-on-lock
for idle timeout when session is locked--idle-timeout-on-lock
for idle timeout when session is locked
I've updated the title and top comment to reflect the latest changes. While the new behavior aligns with Chris's description, I kept the logic in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some quick things to fix. I'll look at the functionality tomorrow
src/platform/symbols.map
Outdated
MIR_PLATFORM_2.18 { | ||
MIR_PLATFORM_2.19 { | ||
global: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we're breaking the mirplatform ABI: idle_timeout_on_lock_opt
should be in a new 2.19 stanza
/// set_display_off_timeout while the session is locked and remains idle. If Mir becomes active after the session | ||
/// is locked, this timeout is disabled. If the session is already locked when this function is called, the new | ||
/// timeout will only take effect after the next session lock. | ||
virtual void set_display_off_timeout_on_lock(std::optional<time::Duration> timeout) = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Aside] This is breaking the mirserver ABI. We need to bump accordingly (either now or before 2.19)
Don't worry about it here - there's other stuff breaking things in the pipeline
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, I didn't notice it before because the symbols checking tool doesn't detect changes in the vtable.
If it's just a matter of bumping MIR_VERSION_MINOR
and MIRSERVER_ABI
, we can do it now. Is it enough to follow the how-to?
explicit SessionLockListener(std::function<void()> const& on_lock) : on_lock_{on_lock} {}; | ||
|
||
private: | ||
void on_lock() override { on_lock_(); }; | ||
void on_unlock() override {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
explicit SessionLockListener(std::function<void()> const& on_lock) : on_lock_{on_lock} {}; | |
private: | |
void on_lock() override { on_lock_(); }; | |
void on_unlock() override {}; | |
explicit SessionLockListener(std::function<void()> const& on_lock) : on_lock_{on_lock} {} | |
private: | |
void on_lock() override { on_lock_(); } | |
void on_unlock() override {} |
Have I misunderstood this? In a VT:
Expect: after 10s the screen dims and turns off In case it matters...
|
I suspect that, by the time you release the modifier keys, you activate the session and restore the 600s timeout. We'll probably need something a bit more elaborate than the 0-timeout idle handler to prevent this immediate reactivation. I'll work on that. |
I changed the 0-timeout idle handler to a 200ms timeout. This should serve as a grace period to prevent immediate reactivation when the session is locked using a keyboard shortcut. |
This is better but doesn't work very well. It too easy to "linger" on a shift key when locking the screen. Also consider the case when the screen is woken by activity but not unlocked. In both cases, it would be better to recognize that the screen is still locked and just reset the timeout to |
Agreed. That appears to be the easiest solution as well, since it doesn't require restoring to a timeout that changes the behavior. The other option would be to ignore key releases after the session is locked, but that would be more involved. |
In which case, maybe |
@hbatagelo ping! |
e989b38
to
705f236
Compare
705f236
to
004fcd3
Compare
--idle-timeout-on-lock
for idle timeout when session is locked--idle-timeout-when-locked
for idle timeout when session is locked
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a pre-existing nit about validating on use, not on input, but it is protected by validating on input first
{ | ||
fatal_error("BasicIdleHandler given invalid timeout %d, should be >0", off_timeout.count()); | ||
fatal_error("BasicIdleHandler given invalid timeout %d, should be >0", off_timeout->count()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is the wrong time to be validating input and erroring. (That should be on startup when the input is parsed)
Fixes #3306.
This PR adds a new configuration option,
--idle-timeout-when-locked
, that allows the compositor to apply a separate idle timeout when the session is locked. The default value is 0, meaning the display will stay on indefinitely when the session is locked.Examples showing its interaction with the existing
--idle-timeout
option:--idle-timeout=60 --idle-timeout-when-locked=10
: The display turns off after 60s of idle time when the session is unlocked, and after 10s of idle time when the session is locked.--idle-timeout=0 --idle-timeout-when-locked=10
: The display never turns off when idle, but it turns off after 10s of idle time when the session is locked.--idle-timeout=60 --idle-timeout-when-locked=0
: The display turns off after 60s of idle time but never when the session is locked.--idle-timeout=0 --idle-timeout-on-lock=0
: This is the default behavior. The display never turns off, wether the session is locked or unlocked.Implementation details:
BasicIdleHandler
now registers a session lock listener via theSessionLockListener
class, which takeson_lock
andon_unlock
callbacks to track the state of the session lock. When the idle handlers (the dimmer and the power setter) are registered, they will use the timeout value from--idle-timeout-when-locked
when the session is locked, and from--idle-timeout
when the session is not locked.