mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-07-06 21:15:13 +02:00
fix(bar): restore + reposition on monitor reconnect
This commit is contained in:
+27
-11
@@ -620,6 +620,20 @@ impl Komobar {
|
|||||||
// Tell egui to use these fonts:
|
// Tell egui to use these fonts:
|
||||||
ctx.set_fonts(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 {
|
impl eframe::App for Komobar {
|
||||||
// Needed for transparency
|
// Needed for transparency
|
||||||
@@ -687,6 +701,18 @@ impl eframe::App for Komobar {
|
|||||||
tracing::info!(
|
tracing::info!(
|
||||||
"This bar's monitor reconnected. The bar will be enabled again!"
|
"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;
|
self.disabled = false;
|
||||||
}
|
}
|
||||||
@@ -783,17 +809,7 @@ impl eframe::App for Komobar {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if self.size_rect != current_rect {
|
if self.size_rect != current_rect {
|
||||||
if let Some(hwnd) = self.hwnd {
|
self.position_bar();
|
||||||
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())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ pub use komorebi::StaticConfig;
|
|||||||
pub use komorebi::SubscribeOptions;
|
pub use komorebi::SubscribeOptions;
|
||||||
pub use komorebi::TabsConfig;
|
pub use komorebi::TabsConfig;
|
||||||
pub use komorebi::WindowContainerBehaviour;
|
pub use komorebi::WindowContainerBehaviour;
|
||||||
|
pub use komorebi::WindowsApi;
|
||||||
pub use komorebi::WorkspaceConfig;
|
pub use komorebi::WorkspaceConfig;
|
||||||
|
|
||||||
use komorebi::DATA_DIR;
|
use komorebi::DATA_DIR;
|
||||||
|
|||||||
Reference in New Issue
Block a user