1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-08-17 14:51:04 +02:00

feat(launcher): add option to minimize window if focused

This commit is contained in:
pachliopta 2024-11-10 16:20:28 +11:00 committed by Jake Stanger
parent 9c13e534b7
commit 64b953ce5e
No known key found for this signature in database
GPG key ID: C51FC8F9CB0BEA61
6 changed files with 58 additions and 7 deletions

View file

@ -193,24 +193,31 @@ impl ItemButton {
button.add_class("focused");
}
let menu_state = Rc::new(RwLock::new(MenuState {
num_windows: item.windows.len(),
}));
{
let app_id = item.app_id.clone();
let tx = controller_tx.clone();
let menu_state = menu_state.clone();
button.connect_clicked(move |button| {
// lazy check :| TODO: Improve this
let style_context = button.style_context();
if style_context.has_class("open") {
try_send!(tx, ItemEvent::FocusItem(app_id.clone()));
let menu_state = read_lock!(menu_state);
if style_context.has_class("focused") && menu_state.num_windows == 1 {
try_send!(tx, ItemEvent::MinimizeItem(app_id.clone()));
} else {
try_send!(tx, ItemEvent::FocusItem(app_id.clone()));
}
} else {
try_send!(tx, ItemEvent::OpenItem(app_id.clone()));
}
});
}
let menu_state = Rc::new(RwLock::new(MenuState {
num_windows: item.windows.len(),
}));
{
let app_id = item.app_id.clone();
let tx = tx.clone();