fix: restore keyboard focus on action buttons after dismiss (v0.8.2)
All checks were successful
Update PKGBUILD version / update-pkgver (push) Successful in 2s
All checks were successful
Update PKGBUILD version / update-pkgver (push) Successful in 2s
After cancelling a confirmation prompt, the focused widget was removed from the tree without restoring focus to the action buttons. With layer-shell exclusive keyboard mode, GTK does not recover focus automatically — the UI became keyboard-unreachable.
This commit is contained in:
parent
e97535e41b
commit
d030f1360a
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -616,7 +616,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "moonset"
|
||||
version = "0.8.1"
|
||||
version = "0.8.2"
|
||||
dependencies = [
|
||||
"dirs",
|
||||
"gdk-pixbuf",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "moonset"
|
||||
version = "0.8.1"
|
||||
version = "0.8.2"
|
||||
edition = "2024"
|
||||
description = "Wayland session power menu with GTK4 and Layer Shell"
|
||||
license = "MIT"
|
||||
|
||||
14
src/panel.rs
14
src/panel.rs
@ -292,6 +292,7 @@ pub fn create_panel_window(texture: Option<&gdk::Texture>, blur_radius: Option<f
|
||||
&confirm_area,
|
||||
&confirm_box,
|
||||
&error_label,
|
||||
&button_box,
|
||||
);
|
||||
button_box.append(&button);
|
||||
}
|
||||
@ -375,6 +376,7 @@ fn create_action_button(
|
||||
confirm_area: >k::Box,
|
||||
confirm_box: &Rc<RefCell<Option<gtk::Box>>>,
|
||||
error_label: >k::Label,
|
||||
button_box: >k::Box,
|
||||
) -> gtk::Button {
|
||||
let button_content = gtk::Box::new(gtk::Orientation::Vertical, 4);
|
||||
button_content.set_halign(gtk::Align::Center);
|
||||
@ -404,6 +406,8 @@ fn create_action_button(
|
||||
confirm_box,
|
||||
#[weak]
|
||||
error_label,
|
||||
#[weak]
|
||||
button_box,
|
||||
move |_| {
|
||||
on_action_clicked(
|
||||
&action_def,
|
||||
@ -412,6 +416,7 @@ fn create_action_button(
|
||||
&confirm_area,
|
||||
&confirm_box,
|
||||
&error_label,
|
||||
&button_box,
|
||||
);
|
||||
}
|
||||
));
|
||||
@ -434,6 +439,7 @@ fn on_action_clicked(
|
||||
confirm_area: >k::Box,
|
||||
confirm_box: &Rc<RefCell<Option<gtk::Box>>>,
|
||||
error_label: >k::Label,
|
||||
button_box: >k::Box,
|
||||
) {
|
||||
dismiss_confirm(confirm_area, confirm_box);
|
||||
error_label.set_visible(false);
|
||||
@ -443,7 +449,7 @@ fn on_action_clicked(
|
||||
return;
|
||||
}
|
||||
|
||||
show_confirm(action_def, strings, app, confirm_area, confirm_box, error_label);
|
||||
show_confirm(action_def, strings, app, confirm_area, confirm_box, error_label, button_box);
|
||||
}
|
||||
|
||||
/// Show inline confirmation below the action buttons.
|
||||
@ -454,6 +460,7 @@ fn show_confirm(
|
||||
confirm_area: >k::Box,
|
||||
confirm_box: &Rc<RefCell<Option<gtk::Box>>>,
|
||||
error_label: >k::Label,
|
||||
button_box: >k::Box,
|
||||
) {
|
||||
let new_box = gtk::Box::new(gtk::Orientation::Vertical, 8);
|
||||
new_box.set_halign(gtk::Align::Center);
|
||||
@ -501,8 +508,13 @@ fn show_confirm(
|
||||
confirm_area,
|
||||
#[strong]
|
||||
confirm_box,
|
||||
#[weak]
|
||||
button_box,
|
||||
move |_| {
|
||||
dismiss_confirm(&confirm_area, &confirm_box);
|
||||
if let Some(first) = button_box.first_child() {
|
||||
first.grab_focus();
|
||||
}
|
||||
}
|
||||
));
|
||||
button_row.append(&no_btn);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user