@@ -83,6 +83,21 @@ void IdleManager::setScreenSaverInhibitLocks(std::int64_t locks) {
8383 }
8484}
8585
86+ void IdleManager::setSessionLocked (bool locked) {
87+ if (m_sessionLocked == locked) {
88+ return ;
89+ }
90+ m_sessionLocked = locked;
91+ recreateBehaviorNotifications ();
92+ }
93+
94+ double IdleManager::effectiveTimeoutSeconds (const IdleBehaviorConfig& config) const {
95+ if (m_sessionLocked && std::isfinite (config.lockedTimeoutSeconds ) && config.lockedTimeoutSeconds > 0.0 ) {
96+ return config.lockedTimeoutSeconds ;
97+ }
98+ return config.timeoutSeconds ;
99+ }
100+
86101void IdleManager::reload (const IdleConfig& config) {
87102 clearBehaviors ();
88103 m_idleConfig = config;
@@ -157,19 +172,24 @@ void IdleManager::recreateBehaviorNotification(BehaviorState& behavior) {
157172 return ;
158173 }
159174
175+ // Re-arming an idled behavior (e.g. on unlock) has no natural resume event, so run it here —
176+ // otherwise screen_off's display-off is never undone and the screen stays black.
177+ if (behavior.phase == BehaviorPhase::Idled) {
178+ runResumeBehavior (behavior);
179+ }
180+
160181 if (behavior.notification != nullptr ) {
161182 ext_idle_notification_v1_destroy (behavior.notification );
162183 behavior.notification = nullptr ;
163184 }
164185 behavior.phase = BehaviorPhase::Waiting;
165186
166- if (!behavior.config .enabled
167- || !std::isfinite (behavior.config .timeoutSeconds )
168- || behavior.config .timeoutSeconds <= 0.0 ) {
187+ const double timeout = effectiveTimeoutSeconds (behavior.config );
188+ if (!behavior.config .enabled || !std::isfinite (timeout) || timeout <= 0.0 ) {
169189 return ;
170190 }
171191
172- const auto timeoutMs = timeoutSecondsToMilliseconds (behavior. config . timeoutSeconds );
192+ const auto timeoutMs = timeoutSecondsToMilliseconds (timeout );
173193 behavior.notification = m_wayland->createIdleNotification (timeoutMs);
174194 if (behavior.notification == nullptr ) {
175195 kLog .warn (" failed to re-register idle behavior '{}'" , behavior.config .name );
@@ -187,7 +207,7 @@ void IdleManager::recreateBehaviorNotifications() {
187207 for (auto & behavior : m_behaviors) {
188208 recreateBehaviorNotification (*behavior);
189209 }
190- kLog .info (" idle behavior notifications reset after screensaver inhibit released " );
210+ kLog .debug (" idle behavior notifications re-armed " );
191211}
192212
193213void IdleManager::createBehavior (const IdleBehaviorConfig& config) {
@@ -198,7 +218,11 @@ void IdleManager::createBehavior(const IdleBehaviorConfig& config) {
198218 kLog .warn (" idle behavior '{}' ignored: timeout must be >= 0 seconds" , config.name );
199219 return ;
200220 }
201- if (config.timeoutSeconds == 0.0 ) {
221+ if (!std::isfinite (config.lockedTimeoutSeconds ) || config.lockedTimeoutSeconds < 0.0 ) {
222+ kLog .warn (" idle behavior '{}' ignored: locked timeout must be >= 0 seconds" , config.name );
223+ return ;
224+ }
225+ if (config.timeoutSeconds == 0.0 && config.lockedTimeoutSeconds == 0.0 ) {
202226 kLog .debug (" idle behavior '{}' disabled by zero timeout" , config.name );
203227 return ;
204228 }
@@ -211,15 +235,11 @@ void IdleManager::createBehavior(const IdleBehaviorConfig& config) {
211235 auto behavior = std::make_unique<BehaviorState>();
212236 behavior->owner = this ;
213237 behavior->config = config;
214- const auto timeoutMs = timeoutSecondsToMilliseconds (config.timeoutSeconds );
215- behavior->notification = m_wayland->createIdleNotification (timeoutMs);
216- if (behavior->notification == nullptr ) {
217- kLog .warn (" failed to register idle behavior '{}'" , config.name );
218- return ;
219- }
220-
221- ext_idle_notification_v1_add_listener (behavior->notification , &kIdleNotificationListener , behavior.get ());
222- kLog .info (" registered idle behavior '{}' timeout={}s" , config.name , config.timeoutSeconds );
238+ recreateBehaviorNotification (*behavior);
239+ kLog .info (
240+ " registered idle behavior '{}' timeout={}s locked_timeout={}s" , config.name , config.timeoutSeconds ,
241+ config.lockedTimeoutSeconds
242+ );
223243 m_behaviors.push_back (std::move (behavior));
224244}
225245
0 commit comments