fix: quit in ::unlocked instead of after unlock() (v0.6.17)

The real cause of the unlock SIGSEGV: gtk4-session-lock destroys the lock
windows itself when the lock ends (per its header), so unlock_callback's
`unlock(); app.quit();` destroyed them a second time — surface already gone
→ gdk_surface_get_display NULL → crash in gtk_window_destroy. Reproduces on
a plain single-monitor lock/unlock, no suspend needed.

unlock_callback now calls only unlock(); a new connect_unlocked handler
quits the app after the library finishes teardown. Mirrors the upstream
examples/simple.rs exactly.

Reverts the v0.6.15/v0.6.16 monitor-pruning + LockscreenHandles.monitor:
it was a misdiagnosis (the crash is monitor-independent) and manually
manipulated library-managed lock windows, which the upstream example
explicitly warns against. Monitor removal is left to the library.
This commit is contained in:
2026-06-02 17:19:09 +02:00
parent 215ab0a984
commit e51a847d48
6 changed files with 22 additions and 34 deletions
-5
View File
@@ -27,9 +27,6 @@ pub struct LockscreenHandles {
pub password_entry: gtk::PasswordEntry,
pub unlock_callback: Rc<dyn Fn()>,
pub username: String,
/// The monitor this window was assigned to (session-lock path only).
/// Used to prune the window when its monitor is removed on suspend/resume.
pub monitor: Option<gdk::Monitor>,
state: Rc<RefCell<LockscreenState>>,
}
@@ -73,7 +70,6 @@ pub fn create_lockscreen_window(
password_entry: gtk::PasswordEntry::new(),
unlock_callback,
username: String::new(),
monitor: None,
state: Rc::new(RefCell::new(LockscreenState {
failed_attempts: 0,
fp_listener_rc: None,
@@ -364,7 +360,6 @@ pub fn create_lockscreen_window(
password_entry: password_entry.clone(),
unlock_callback,
username: user.username,
monitor: None,
state: state.clone(),
}
}