From de97d6658eb9d78663bc7fb20adbf195ff79a4c1 Mon Sep 17 00:00:00 2001 From: nevaforget Date: Mon, 6 Apr 2026 22:29:37 +0200 Subject: [PATCH] fix: grab keyboard focus on map instead of realize (v0.7.4) Layer-shell keyboard grab is only confirmed by the compositor at map time. The previous realize-time grab_focus() could fire before the compositor assigned keyboard input, causing intermittent input loss. --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/greeter.rs | 12 ++++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ce6c60a..4e1770f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -575,7 +575,7 @@ dependencies = [ [[package]] name = "moongreet" -version = "0.7.1" +version = "0.7.4" dependencies = [ "gdk-pixbuf", "gdk4", diff --git a/Cargo.toml b/Cargo.toml index b159f14..6b921b7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "moongreet" -version = "0.7.3" +version = "0.7.4" edition = "2024" description = "A greetd greeter for Wayland with GTK4 and Layer Shell" license = "MIT" diff --git a/src/greeter.rs b/src/greeter.rs index b6b1390..ecedc80 100644 --- a/src/greeter.rs +++ b/src/greeter.rs @@ -553,6 +553,18 @@ pub fn create_greeter_window( )); window.add_controller(key_controller); + // Grab keyboard focus after map — layer-shell keyboard grab is only + // confirmed by the compositor at map time, not at realize time. + window.connect_map(clone!( + #[weak] + password_entry, + move |_| { + glib::idle_add_local_once(move || { + password_entry.grab_focus(); + }); + } + )); + // Defer initial user selection until realized (for correct theme colors) window.connect_realize(clone!( #[strong]