diff --git a/komorebi/src/monitor.rs b/komorebi/src/monitor.rs index 6e63886e..39c2fc30 100644 --- a/komorebi/src/monitor.rs +++ b/komorebi/src/monitor.rs @@ -12,9 +12,8 @@ use crate::border_manager::BORDER_ENABLED; use crate::border_manager::BORDER_OFFSET; use crate::border_manager::BORDER_WIDTH; use crate::core::Rect; -use crate::windows_backend::backend; use komorebi_backend::MonitorId; -use komorebi_backend::WindowId; +use komorebi_core::ContainerWindow; use crate::DEFAULT_CONTAINER_PADDING; use crate::DEFAULT_WORKSPACE_PADDING; @@ -459,7 +458,7 @@ impl Monitor { } for window in target_workspace.floating_windows_mut() { - let _ = backend().restore(WindowId::from_hwnd(window.hwnd)); + window.restore_window(); } target_workspace.reintegrate_monocle_container()?; diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 61b9372b..0df5ab04 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -99,6 +99,7 @@ use crate::winevent_listener; use crate::workspace::WorkspaceLayer; use crate::workspace::WorkspaceWindowLocation; use komorebi_backend::WindowId; +use komorebi_core::ContainerWindow; use stackbar_manager::STACKBAR_FOCUSED_TEXT_COLOUR; use stackbar_manager::STACKBAR_LABEL; use stackbar_manager::STACKBAR_MODE; @@ -2322,7 +2323,7 @@ if (!(Get-Process komorebi-bar -ErrorAction SilentlyContinue)) if i == focused_idx { to_focus = Some(*window); } else { - let _ = backend().restore(WindowId::from_hwnd(window.hwnd)); + window.restore_window(); backend().raise(WindowId::from_hwnd(window.hwnd))?; } } @@ -2330,7 +2331,7 @@ if (!(Get-Process komorebi-bar -ErrorAction SilentlyContinue)) if let Some(focused_window) = &to_focus { // The focused window should be the last one raised to make sure it is // on top - let _ = backend().restore(WindowId::from_hwnd(focused_window.hwnd)); + focused_window.restore_window(); backend().raise(WindowId::from_hwnd(focused_window.hwnd))?; } @@ -2355,7 +2356,7 @@ if (!(Get-Process komorebi-bar -ErrorAction SilentlyContinue)) backend().raise(WindowId::from_hwnd(window.hwnd))?; } for window in workspace.floating_windows() { - let _ = backend().hide(WindowId::from_hwnd(window.hwnd)); + window.hide_window(); } } else { let focused_container_idx = workspace.focused_container_idx(); diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index 4aff0d79..bd9f6243 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -10,6 +10,7 @@ use crate::core::Rect; use crate::core::WindowContainerBehaviour; use crate::windows_backend::backend; use komorebi_backend::WindowId; +use komorebi_core::ContainerWindow; use crate::CURRENT_VIRTUAL_DESKTOP; use crate::DefaultLayout; @@ -511,7 +512,7 @@ impl WindowManager { "ignoring show event for window already associated with another workspace" ); - let _ = backend().hide(WindowId::from_hwnd(window.hwnd)); + window.hide_window(); proceed = false; } @@ -643,7 +644,7 @@ impl WindowManager { if !(monocle_window_event || workspace.layer != WorkspaceLayer::Tiling) && monocle_container.is_some() { - let _ = backend().hide(WindowId::from_hwnd(window.hwnd)); + window.hide_window(); } } } @@ -1063,7 +1064,7 @@ impl WindowManager { container.restore(); } for window in workspace.floating_windows_mut() { - let _ = backend().restore(WindowId::from_hwnd(window.hwnd)); + window.restore_window(); } workspace.reintegrate_monocle_container()?; } diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 01cf30fe..2626e88c 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -50,6 +50,7 @@ use crate::core::WindowManagementBehaviour; use crate::core::config_generation::MatchingRule; use crate::windows_backend::backend; use komorebi_backend::WindowId; +use komorebi_core::ContainerWindow; use crate::CrossBoundaryBehaviour; use crate::DATA_DIR; @@ -702,7 +703,7 @@ impl WindowManager { // Hide the window we are about to remove if it is on the currently focused workspace if op.is_origin(focused_monitor_idx, focused_workspace_idx) { - let _ = backend().hide(WindowId::from_hwnd(window.hwnd)); + window.hide_window(); should_update_focused_workspace = true; } @@ -1510,7 +1511,7 @@ impl WindowManager { } if !ignore_restore { - let _ = backend().restore(WindowId::from_hwnd(window.hwnd)); + window.restore_window(); } } } @@ -1758,7 +1759,7 @@ impl WindowManager { } for window in target_workspace.floating_windows_mut() { - let _ = backend().restore(WindowId::from_hwnd(window.hwnd)); + window.restore_window(); } target_workspace.reintegrate_monocle_container()?; @@ -3178,7 +3179,7 @@ impl WindowManager { } for window in workspace.floating_windows_mut() { - let _ = backend().hide(WindowId::from_hwnd(window.hwnd)); + window.hide_window(); } Ok(()) @@ -3195,7 +3196,7 @@ impl WindowManager { } for window in workspace.floating_windows_mut() { - let _ = backend().restore(WindowId::from_hwnd(window.hwnd)); + window.restore_window(); } workspace.reintegrate_monocle_container() diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index 03b6c7cf..62916991 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -51,6 +51,7 @@ use crate::windows_backend::backend; use color_eyre::eyre; use color_eyre::eyre::OptionExt; use komorebi_backend::WindowId; +use komorebi_core::ContainerWindow; use komorebi_scrolling::ScrollingSpace; use komorebi_themes::Base16ColourPalette; use komorebi_themes::KomorebiThemeCustom as Custom; @@ -409,7 +410,7 @@ impl Workspace { } if should_hide { - let _ = backend().hide(WindowId::from_hwnd(window.hwnd)); + window.hide_window(); } } @@ -418,7 +419,7 @@ impl Workspace { } if let Some(window) = self.maximized_window { - let _ = backend().hide(WindowId::from_hwnd(window.hwnd)); + window.hide_window(); } if let Some(container) = &self.monocle_container { @@ -578,7 +579,7 @@ impl Workspace { } for window in self.floating_windows() { - let _ = backend().restore(WindowId::from_hwnd(window.hwnd)); + window.restore_window(); } // Do this here to make sure that an error doesn't stop the restoration of other windows @@ -588,7 +589,7 @@ impl Workspace { if self.maximized_window.is_none() && matches!(self.layer, WorkspaceLayer::Tiling) { backend().focus(WindowId::from_hwnd(window.hwnd), mouse_follows_focus)?; } else if let Some(maximized_window) = self.maximized_window { - let _ = backend().restore(WindowId::from_hwnd(maximized_window.hwnd)); + maximized_window.restore_window(); backend().focus( WindowId::from_hwnd(maximized_window.hwnd), mouse_follows_focus, @@ -600,7 +601,7 @@ impl Workspace { )?; } } else if let Some(maximized_window) = self.maximized_window { - let _ = backend().restore(WindowId::from_hwnd(maximized_window.hwnd)); + maximized_window.restore_window(); backend().focus( WindowId::from_hwnd(maximized_window.hwnd), mouse_follows_focus, @@ -836,19 +837,20 @@ impl Workspace { // If a window has been unmaximized via toggle-maximize, this block // will make sure that it is unmaximized via restore_window if window.is_maximized() && !managed_maximized_window { - let _ = backend().unminimize(WindowId::from_hwnd(window.hwnd)); + let _ = + backend().unminimize(WindowId::from_hwnd(window.hwnd)); } } if hidden.get(i).copied().unwrap_or_default() { // it is seen on another monitor wherever it rests here - let _ = backend().hide(WindowId::from_hwnd(window.hwnd)); + window.hide_window(); } else { if crate::scrolling::should_restore_when_placed( window.hwnd, container.focused_window().map(|w| w.hwnd), &HIDDEN_HWNDS.lock(), ) { - let _ = backend().restore(WindowId::from_hwnd(window.hwnd)); + window.restore_window(); } backend().set_rect(WindowId::from_hwnd(window.hwnd), layout)?; @@ -896,7 +898,8 @@ impl Workspace { } pub fn container_for_window(&self, window_id: isize) -> Option<&Container> { - self.containers().get(self.container_idx_for_window(window_id)?) + self.containers() + .get(self.container_idx_for_window(window_id)?) } /// If there is a container which holds the window with `window_id` it will focus that container.