mirror of
https://github.com/JakeStanger/ironbar.git
synced 2025-01-07 16:56:50 +03:00
fix(focused): incorrectly clearing when unfocused window title changes (#556)
Fixes #544
This commit is contained in:
parent
dffb3e5d54
commit
ea2b20816d
@ -62,12 +62,16 @@ impl Module<gtk::Box> for FocusedModule {
|
|||||||
let wl = context.client::<wayland::Client>();
|
let wl = context.client::<wayland::Client>();
|
||||||
|
|
||||||
spawn(async move {
|
spawn(async move {
|
||||||
|
let mut current = None;
|
||||||
|
|
||||||
let mut wlrx = wl.subscribe_toplevels();
|
let mut wlrx = wl.subscribe_toplevels();
|
||||||
let handles = wl.toplevel_info_all();
|
let handles = wl.toplevel_info_all();
|
||||||
|
|
||||||
let focused = handles.into_iter().find(|info| info.focused);
|
let focused = handles.into_iter().find(|info| info.focused);
|
||||||
|
|
||||||
if let Some(focused) = focused {
|
if let Some(focused) = focused {
|
||||||
|
current = Some(focused.id);
|
||||||
|
|
||||||
try_send!(
|
try_send!(
|
||||||
tx,
|
tx,
|
||||||
ModuleUpdateEvent::Update(Some((focused.title.clone(), focused.app_id)))
|
ModuleUpdateEvent::Update(Some((focused.title.clone(), focused.app_id)))
|
||||||
@ -77,8 +81,12 @@ impl Module<gtk::Box> for FocusedModule {
|
|||||||
while let Ok(event) = wlrx.recv().await {
|
while let Ok(event) = wlrx.recv().await {
|
||||||
match event {
|
match event {
|
||||||
ToplevelEvent::Update(info) => {
|
ToplevelEvent::Update(info) => {
|
||||||
|
println!("{current:?} | {info:?}");
|
||||||
if info.focused {
|
if info.focused {
|
||||||
debug!("Changing focus");
|
debug!("Changing focus");
|
||||||
|
|
||||||
|
current = Some(info.id);
|
||||||
|
|
||||||
send_async!(
|
send_async!(
|
||||||
tx,
|
tx,
|
||||||
ModuleUpdateEvent::Update(Some((
|
ModuleUpdateEvent::Update(Some((
|
||||||
@ -86,13 +94,16 @@ impl Module<gtk::Box> for FocusedModule {
|
|||||||
info.app_id.clone()
|
info.app_id.clone()
|
||||||
)))
|
)))
|
||||||
);
|
);
|
||||||
} else {
|
} else if info.id == current.unwrap_or_default() {
|
||||||
|
debug!("Clearing focus");
|
||||||
|
current = None;
|
||||||
send_async!(tx, ModuleUpdateEvent::Update(None));
|
send_async!(tx, ModuleUpdateEvent::Update(None));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ToplevelEvent::Remove(info) => {
|
ToplevelEvent::Remove(info) => {
|
||||||
if info.focused {
|
if info.focused {
|
||||||
debug!("Clearing focus");
|
debug!("Clearing focus");
|
||||||
|
current = None;
|
||||||
send_async!(tx, ModuleUpdateEvent::Update(None));
|
send_async!(tx, ModuleUpdateEvent::Update(None));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user