diff --git a/komorebi-bar/src/komorebi.rs b/komorebi-bar/src/komorebi.rs index 17d60904..22d53e8f 100644 --- a/komorebi-bar/src/komorebi.rs +++ b/komorebi-bar/src/komorebi.rs @@ -546,9 +546,12 @@ impl KomorebiNotificationState { self.layout = KomorebiLayout::Paused; } + let mut has_window_container_information = false; + if let Some(container) = monitor.workspaces()[focused_workspace_idx].monocle_container() { + has_window_container_information = true; self.focused_container_information = ( container .windows() @@ -565,6 +568,7 @@ impl KomorebiNotificationState { } else if let Some(container) = monitor.workspaces()[focused_workspace_idx].focused_container() { + has_window_container_information = true; self.focused_container_information = ( container .windows() @@ -578,7 +582,24 @@ impl KomorebiNotificationState { .collect::>(), container.focused_window_idx(), ); - } else { + } + + for floating_window in + monitor.workspaces()[focused_workspace_idx].floating_windows() + { + if floating_window.is_focused() { + has_window_container_information = true; + self.focused_container_information = ( + vec![floating_window.title().unwrap_or_default()], + vec![windows_icons::get_icon_by_process_id( + floating_window.process_id(), + )], + 0, + ); + } + } + + if !has_window_container_information { self.focused_container_information.0.clear(); self.focused_container_information.1.clear(); self.focused_container_information.2 = 0; diff --git a/komorebi/src/lib.rs b/komorebi/src/lib.rs index 43190f85..ad85181e 100644 --- a/komorebi/src/lib.rs +++ b/komorebi/src/lib.rs @@ -64,7 +64,6 @@ use crate::core::config_generation::IdWithIdentifier; use crate::core::config_generation::MatchingRule; use crate::core::config_generation::MatchingStrategy; use crate::core::config_generation::WorkspaceMatchingRule; -use crate::winevent::WinEvent; use color_eyre::Result; use os_info::Version; use parking_lot::Mutex; @@ -309,10 +308,7 @@ pub fn notify_subscribers(notification: Notification, state_has_been_modified: b | NotificationEvent::Socket(SocketMessage::Theme(_)) | NotificationEvent::Socket(SocketMessage::ReloadStaticConfiguration(_)) | NotificationEvent::WindowManager(WindowManagerEvent::TitleUpdate(_, _)) - | NotificationEvent::WindowManager(WindowManagerEvent::Show( - WinEvent::ObjectNameChange, - _ - )) + | NotificationEvent::WindowManager(WindowManagerEvent::Show(_, _)) ); let notification = &serde_json::to_string(¬ification)?; diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index a39060d5..5af766c4 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -363,6 +363,10 @@ impl Window { Ok(()) } + pub fn is_focused(self) -> bool { + WindowsApi::foreground_window().unwrap_or_default() == self.hwnd + } + pub fn transparent(self) -> Result<()> { let mut ex_style = self.ex_style()?; ex_style.insert(ExtendedWindowStyle::LAYERED);