diff --git a/komorebi-bar/src/bar.rs b/komorebi-bar/src/bar.rs index f07db84a..1ed0d365 100644 --- a/komorebi-bar/src/bar.rs +++ b/komorebi-bar/src/bar.rs @@ -620,6 +620,20 @@ impl Komobar { // Tell egui to use these fonts: ctx.set_fonts(fonts); } + + pub fn position_bar(&self) { + if let Some(hwnd) = self.hwnd { + let window = komorebi_client::Window::from(hwnd); + match window.set_position(&self.size_rect, false) { + Ok(_) => { + tracing::info!("updated bar position"); + } + Err(error) => { + tracing::error!("{}", error.to_string()) + } + } + } + } } impl eframe::App for Komobar { // Needed for transparency @@ -687,6 +701,18 @@ impl eframe::App for Komobar { tracing::info!( "This bar's monitor reconnected. The bar will be enabled again!" ); + + // Restore the bar in case it has been minimized when the monitor + // disconnected + if let Some(hwnd) = self.hwnd { + let window = komorebi_client::Window::from(hwnd); + if window.is_miminized() { + komorebi_client::WindowsApi::restore_window(hwnd); + } + } + + // Reposition the Bar + self.position_bar(); } self.disabled = false; } @@ -783,17 +809,7 @@ impl eframe::App for Komobar { }; if self.size_rect != current_rect { - if let Some(hwnd) = self.hwnd { - let window = komorebi_client::Window::from(hwnd); - match window.set_position(&self.size_rect, false) { - Ok(_) => { - tracing::info!("updated bar position"); - } - Err(error) => { - tracing::error!("{}", error.to_string()) - } - } - } + self.position_bar(); } } diff --git a/komorebi-client/src/lib.rs b/komorebi-client/src/lib.rs index 8f95a160..cb26551e 100644 --- a/komorebi-client/src/lib.rs +++ b/komorebi-client/src/lib.rs @@ -65,6 +65,7 @@ pub use komorebi::StaticConfig; pub use komorebi::SubscribeOptions; pub use komorebi::TabsConfig; pub use komorebi::WindowContainerBehaviour; +pub use komorebi::WindowsApi; pub use komorebi::WorkspaceConfig; use komorebi::DATA_DIR;