mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-18 22:58:34 +01:00
refactor(windows): hide and restore go through ContainerWindow::hide_window / restore_window
The 21 let _ = backend().hide(WindowId::from_hwnd(w.hwnd)) / restore(..) calls in workspace, monitor, window_manager, process_command and process_event become w.hide_window() / w.restore_window(), the methods of komorebi_core::ContainerWindow that the Windows Window already implements with exactly that backend call. Same text as KDE's window.hide(). Item 2 of the Windows list in core-model.md section 7. Not a behaviour change. Verified: Windows clippy -D warnings via tools/fast-check PASS.
This commit is contained in:
1 parent
846fac7a73
commit
f3d4765186
5 files changed
+28
-23
No files matched your search
@@ -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()?;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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()?;
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in new issue
Block a user