forge
Explore
Log in

Don't you dare go Hollow

Consolidate lock confirmation to continue_to_locking()

Browse files at this commit

64404054fa3cb7a1c8a8e4ee1a751bd4314b8bebIvan MolodetskikhParent: eff4211
src/niri.rsmodified+23 -26
@@ -6477,34 +6477,31 @@ impl Niri {
6477 6477
6478 info!("locking session");6478 info!("locking session");
6479 6479
6480- if self.output_state.is_empty() {6480+ // If we have outputs, we need to redraw them before locking. But before we do that,
6481- // There are no outputs, lock the session right away.6481+ // let's wait for the lock surfaces.
6482- self.screenshot_ui.close();6482+ //
6483- self.cursor_manager6483+ // Give them a second; swaylock can take its time to paint a big enough image.
6484- .set_cursor_image(CursorImageStatus::default_named());6484+ let timer = Timer::from_duration(Duration::from_millis(1000));
6485+ let deadline_token = self
6486+ .event_loop
6487+ .insert_source(timer, |_, _, state| {
6488+ trace!("lock deadline expired, continuing");
6489+ state.niri.continue_to_locking();
6490+ TimeoutAction::Drop
6491+ })
6492+ .unwrap();
6485 6493
6486- let lock = confirmation.ext_session_lock().clone();6494+ self.lock_state = LockState::WaitingForSurfaces {
6487- confirmation.lock();6495+ confirmation,
6488- self.lock_state = LockState::Locked(lock);6496+ deadline_token,
6489- } else {6497+ };
6490- // There are outputs which we need to redraw before locking. But before we do that,
6491- // let's wait for the lock surfaces.
6492- //
6493- // Give them a second; swaylock can take its time to paint a big enough image.
6494- let timer = Timer::from_duration(Duration::from_millis(1000));
6495- let deadline_token = self
6496- .event_loop
6497- .insert_source(timer, |_, _, state| {
6498- trace!("lock deadline expired, continuing");
6499- state.niri.continue_to_locking();
6500- TimeoutAction::Drop
6501- })
6502- .unwrap();
6503 6498
6504- self.lock_state = LockState::WaitingForSurfaces {6499+ // If there are no outputs, we can lock right away.
6505- confirmation,6500+ //
6506- deadline_token,6501+ // This does mean the deadline timer above is immediately removed, but it's a rare case,
6507- };6502+ // and consolidating the locking code into one place is worth it.
6503+ if self.output_state.is_empty() {
6504+ self.continue_to_locking();
6508 }6505 }
6509 }6506 }
6510 6507