Skip to content

Commit 27cea18

Browse files
committed
enh(code): idk maybe fix of ghost windows
1 parent 9f46837 commit 27cea18

File tree

4 files changed

+13
-17
lines changed

4 files changed

+13
-17
lines changed

src/background/hook.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ pub fn init_zombie_window_killer() -> Result<()> {
242242
for addr in guard.iter() {
243243
let window = Window::from(*addr);
244244
if !window.is_window() {
245-
// log::trace!("Reaping window: {:0x}", window.address());
245+
log::trace!("Reaping window: {:0x}", window.address());
246246
log_error!(HookManager::event_tx().send((WinEvent::ObjectDestroy, window)));
247247
}
248248
}

src/background/modules/apps/application/windows.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ impl UserAppsManager {
1818
pub(super) fn init_listing_app_windows() -> Vec<UserAppWindow> {
1919
let mut initial = Vec::new();
2020
let _ = WindowEnumerator::new().for_each(|window| {
21-
if is_interactable_and_not_hidden(&window) {
21+
if is_interactable_window(&window) {
2222
initial.push(window.to_serializable());
2323
}
2424
});
@@ -29,7 +29,7 @@ impl UserAppsManager {
2929
std::thread::sleep(std::time::Duration::from_millis(1000));
3030
Self::instance()
3131
.interactable_windows
32-
.retain(|w| is_interactable_and_not_hidden(&Window::from(w.hwnd)));
32+
.retain(|w| is_interactable_window(&Window::from(w.hwnd)));
3333
});
3434

3535
initial
@@ -40,14 +40,14 @@ impl UserAppsManager {
4040

4141
match event {
4242
WinEvent::ObjectCreate | WinEvent::ObjectShow => {
43-
if !is_interactable && is_interactable_and_not_hidden(&window) {
43+
if !is_interactable && is_interactable_window(&window) {
4444
USER_APPS_MANAGER.add_win(&window);
4545
Self::send(UserAppsEvent::WinAdded(window.address()));
4646
}
4747
}
4848
WinEvent::ObjectNameChange | WinEvent::ObjectParentChange => {
4949
let was_interactable = is_interactable;
50-
is_interactable = is_interactable_and_not_hidden(&window);
50+
is_interactable = is_interactable_window(&window);
5151
match (was_interactable, is_interactable) {
5252
(false, true) => {
5353
USER_APPS_MANAGER.add_win(&window);
@@ -117,9 +117,9 @@ impl UserAppsManager {
117117
/// for the users.
118118
///
119119
/// As windows properties can change, this should be reevaluated on every change.
120-
pub fn is_interactable_and_not_hidden(window: &Window) -> bool {
120+
pub fn is_interactable_window(window: &Window) -> bool {
121121
// It must be a visible Window and not cloaked
122-
if !window.is_visible() || window.is_cloaked() {
122+
if !window.is_window() || !window.is_visible() || window.is_cloaked() {
123123
return false;
124124
}
125125

src/background/modules/system_tray/application/tray_icon.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,6 @@ impl SystemTrayManager {
143143
.upsert(to_update.stable_id.clone(), to_update.clone());
144144
Some(SystrayEvent::IconUpdate(to_update.clone()))
145145
} else {
146-
log::info!("Tray icon added: {:?}", icon_data);
147-
148146
// Icon doesn't exist yet, so add new icon. Skip icons that
149147
// cannot be identified.
150148
let stable_id = icon_data.guid.map(SysTrayIconId::Guid).or({
@@ -156,6 +154,8 @@ impl SystemTrayManager {
156154
}
157155
})?;
158156

157+
log::trace!("Tray icon added: {}", stable_id);
158+
159159
let mut icon_image_hash = None;
160160
let mut icon_path = None;
161161

@@ -189,11 +189,9 @@ impl SystemTrayManager {
189189
}
190190
}
191191
Win32TrayEvent::IconRemove { data: icon_data } => {
192-
log::info!("Tray icon removed: {:?}", icon_data);
193-
194192
let icon_id = self.find_icon(icon_data).map(|icon| icon.stable_id.clone());
195-
196193
if let Some(icon_id) = icon_id {
194+
log::trace!("Tray icon removed: {}", icon_id);
197195
self.icons.remove(&icon_id);
198196
Some(SystrayEvent::IconRemove(icon_id))
199197
} else {
@@ -209,7 +207,7 @@ impl SystemTrayManager {
209207
icon_id: &SysTrayIconId,
210208
action: &SystrayIconAction,
211209
) -> crate::Result<()> {
212-
log::info!("Sending icon action: {:?} to: {:?}", action, icon_id);
210+
log::trace!("Sending icon action: {:?} to: {:?}", action, icon_id);
213211
let icon = self
214212
.icons
215213
.get(icon_id, |v| v.clone())

src/background/windows_api/window/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ use windows::{
2323
use crate::{
2424
cli::ServicePipe,
2525
error::Result,
26-
modules::{
27-
apps::application::is_interactable_and_not_hidden, start::application::START_MENU_MANAGER,
28-
},
26+
modules::{apps::application::is_interactable_window, start::application::START_MENU_MANAGER},
2927
widgets::{
3028
launcher::SeelenRofi, toolbar::FancyToolbar, wallpaper_manager::SeelenWall,
3129
weg::instance::SeelenWeg, window_manager::instance::WindowManagerV2,
@@ -315,7 +313,7 @@ impl Window {
315313

316314
/// read inner called doc for more info
317315
pub fn is_interactable_and_not_hidden(&self) -> bool {
318-
is_interactable_and_not_hidden(self)
316+
is_interactable_window(self)
319317
}
320318

321319
pub fn show_window(&self, command: SHOW_WINDOW_CMD) -> Result<()> {

0 commit comments

Comments
 (0)