mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-07-01 10:41:03 +02:00
feat(launcher): slightly improve focus logic when clicking item with multiple windows
This commit is contained in:
parent
4a9410abac
commit
27f920d012
1 changed files with 10 additions and 4 deletions
|
@ -274,10 +274,14 @@ impl Module<gtk::Box> for LauncherModule {
|
||||||
let items = lock!(items);
|
let items = lock!(items);
|
||||||
|
|
||||||
let id = match event {
|
let id = match event {
|
||||||
ItemEvent::FocusItem(app_id) => items
|
ItemEvent::FocusItem(app_id) => items.get(&app_id).and_then(|item| {
|
||||||
.get(&app_id)
|
item.windows
|
||||||
.and_then(|item| item.windows.first().map(|(_, win)| win.id)),
|
.iter()
|
||||||
ItemEvent::FocusWindow(id) => Some(id), // FIXME: Broken on wlroots-git
|
.find(|(_, win)| !win.open_state.is_focused())
|
||||||
|
.or_else(|| item.windows.first())
|
||||||
|
.map(|(_, win)| win.id)
|
||||||
|
}),
|
||||||
|
ItemEvent::FocusWindow(id) => Some(id),
|
||||||
ItemEvent::OpenItem(_) => unreachable!(),
|
ItemEvent::OpenItem(_) => unreachable!(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -285,6 +289,8 @@ impl Module<gtk::Box> for LauncherModule {
|
||||||
if let Some(window) =
|
if let Some(window) =
|
||||||
items.iter().find_map(|(_, item)| item.windows.get(&id))
|
items.iter().find_map(|(_, item)| item.windows.get(&id))
|
||||||
{
|
{
|
||||||
|
debug!("Focusing window {id}: {}", window.name);
|
||||||
|
|
||||||
let seat = wl.get_seats().pop().expect("Failed to get Wayland seat");
|
let seat = wl.get_seats().pop().expect("Failed to get Wayland seat");
|
||||||
window.focus(&seat);
|
window.focus(&seat);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue