Skip to content

Commit

Permalink
Merge pull request #605 from JakeStanger/fix/launcher-favourites
Browse files Browse the repository at this point in the history
fix(launcher): favourites staying focused when closed in hyprland
  • Loading branch information
JakeStanger authored May 22, 2024
2 parents fd58ce7 + 9a39420 commit b0d3bfd
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/modules/launcher/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,22 @@ impl Module<gtk::Box> for LauncherModule {
}?;
}
ToplevelEvent::Update(info) => {
if let Some(item) = lock!(items).get_mut(&info.app_id) {
// check if open, as updates can be sent as program closes
// if it's a focused favourite closing, it otherwise incorrectly re-focuses.
let is_open = if let Some(item) = lock!(items).get_mut(&info.app_id) {
item.set_window_focused(info.id, info.focused);
item.set_window_name(info.id, info.title.clone());
}

send_update(LauncherUpdate::Focus(info.app_id.clone(), info.focused))
.await?;
item.open_state.is_open()
} else {
false
};

send_update(LauncherUpdate::Focus(
info.app_id.clone(),
is_open && info.focused,
))
.await?;
send_update(LauncherUpdate::Title(
info.app_id.clone(),
info.id,
Expand Down Expand Up @@ -355,8 +364,7 @@ impl Module<gtk::Box> for LauncherModule {
button.set_open(true);
button.set_focused(win.open_state.is_focused());

let mut menu_state = write_lock!(button.menu_state);
menu_state.num_windows += 1;
write_lock!(button.menu_state).num_windows += 1;
}
}
LauncherUpdate::RemoveItem(app_id) => {
Expand Down

0 comments on commit b0d3bfd

Please sign in to comment.