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 {
64776477
64786478 info!("locking session");
64796479
6480- if self.output_state.is_empty() {
6481- // There are no outputs, lock the session right away.
6482- self.screenshot_ui.close();
6483- self.cursor_manager
6484- .set_cursor_image(CursorImageStatus::default_named());
6480+ // If we have outputs, we need to redraw them before locking. But before we do that,
6481+ // let's wait for the lock surfaces.
6482+ //
6483+ // Give them a second; swaylock can take its time to paint a big enough image.
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();
64856493
6486- let lock = confirmation.ext_session_lock().clone();
6487- confirmation.lock();
6488- self.lock_state = LockState::Locked(lock);
6489- } else {
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();
6494+ self.lock_state = LockState::WaitingForSurfaces {
6495+ confirmation,
6496+ deadline_token,
6497+ };
65036498
6504- self.lock_state = LockState::WaitingForSurfaces {
6505- confirmation,
6506- deadline_token,
6507- };
6499+ // If there are no outputs, we can lock right away.
6500+ //
6501+ // This does mean the deadline timer above is immediately removed, but it's a rare case,
6502+ // and consolidating the locking code into one place is worth it.
6503+ if self.output_state.is_empty() {
6504+ self.continue_to_locking();
65086505 }
65096506 }
65106507