refactor(windows): plain hide and restore go through backend()

The 23 window.hide() and window.restore() calls (container, workspace,
monitor, process_command, process_event, window_manager) become
let _ = backend().hide(..) / restore(..): WindowsBackend runs Window::hide
and Window::restore, so hiding behaviour (cloak, hide, minimize), border
and HIDDEN_HWNDS bookkeeping are the same. Not switched: hide_with_border
and restore_with_border (the shared trait has no border flag), the
animation transition and ghost dispatcher calls (they run inside the
slide-in machinery), minimize, close, raise and maximize (to follow).

BEHAVIOUR: a window that is already gone is skipped (IsWindow first), so it
is no longer added to HIDDEN_HWNDS or shown; the result is ignored as
before. e2e gate needed: commands, workspaces, stacking, lifecycle_hidden,
minimize/monitor scenarios. Verified: Windows clippy -D warnings via
tools/fast-check PASS; e2e not run.
This commit is contained in:
LGUG2Z committed 2026-10-31 10:22:41 -07:00
1 parent 3a86e8fb6a
commit fad90dbd3e
6 files changed
+26 -22

No files matched your search

+5 -3
View File
@@ -5,6 +5,8 @@ use serde::Serialize;
use crate::Lockable;
use crate::ring::Ring;
use crate::window::Window;
use crate::windows_backend::backend;
use komorebi_backend::WindowId;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
@@ -63,14 +65,14 @@ impl Container {
}
if should_hide {
window.hide();
let _ = backend().hide(WindowId::from_hwnd(window.hwnd));
}
}
}
pub fn restore(&self) {
if let Some(window) = self.focused_window() {
window.restore();
let _ = backend().restore(WindowId::from_hwnd(window.hwnd));
}
}
@@ -151,7 +153,7 @@ impl Container {
for (i, window) in self.windows().iter().enumerate() {
if i != focused_window_idx {
window.hide();
let _ = backend().hide(WindowId::from_hwnd(window.hwnd));
}
}
}
+3 -1
View File
@@ -12,6 +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::WindowId;
use crate::DEFAULT_CONTAINER_PADDING;
use crate::DEFAULT_WORKSPACE_PADDING;
@@ -438,7 +440,7 @@ impl Monitor {
}
for window in target_workspace.floating_windows_mut() {
window.restore();
let _ = backend().restore(WindowId::from_hwnd(window.hwnd));
}
target_workspace.reintegrate_monocle_container()?;
+3 -3
View File
@@ -1308,7 +1308,7 @@ impl WindowManager {
if i == focused_idx {
to_focus = Some(*window);
} else {
window.restore();
let _ = backend().restore(WindowId::from_hwnd(window.hwnd));
window.raise()?;
}
}
@@ -1316,7 +1316,7 @@ impl WindowManager {
if let Some(focused_window) = &to_focus {
// The focused window should be the last one raised to make sure it is
// on top
focused_window.restore();
let _ = backend().restore(WindowId::from_hwnd(focused_window.hwnd));
focused_window.raise()?;
}
@@ -1341,7 +1341,7 @@ impl WindowManager {
window.raise()?;
}
for window in workspace.floating_windows() {
window.hide();
let _ = backend().hide(WindowId::from_hwnd(window.hwnd));
}
} else {
let focused_container_idx = workspace.focused_container_idx();
+3 -3
View File
@@ -511,7 +511,7 @@ impl WindowManager {
"ignoring show event for window already associated with another workspace"
);
window.hide();
let _ = backend().hide(WindowId::from_hwnd(window.hwnd));
proceed = false;
}
@@ -643,7 +643,7 @@ impl WindowManager {
if !(monocle_window_event || workspace.layer != WorkspaceLayer::Tiling)
&& monocle_container.is_some()
{
window.hide();
let _ = backend().hide(WindowId::from_hwnd(window.hwnd));
}
}
}
@@ -1063,7 +1063,7 @@ impl WindowManager {
container.restore();
}
for window in workspace.floating_windows_mut() {
window.restore();
let _ = backend().restore(WindowId::from_hwnd(window.hwnd));
}
workspace.reintegrate_monocle_container()?;
}
+5 -5
View File
@@ -702,7 +702,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) {
window.hide();
let _ = backend().hide(WindowId::from_hwnd(window.hwnd));
should_update_focused_workspace = true;
}
@@ -1510,7 +1510,7 @@ impl WindowManager {
}
if !ignore_restore {
window.restore();
let _ = backend().restore(WindowId::from_hwnd(window.hwnd));
}
}
}
@@ -1758,7 +1758,7 @@ impl WindowManager {
}
for window in target_workspace.floating_windows_mut() {
window.restore();
let _ = backend().restore(WindowId::from_hwnd(window.hwnd));
}
target_workspace.reintegrate_monocle_container()?;
@@ -3160,7 +3160,7 @@ impl WindowManager {
}
for window in workspace.floating_windows_mut() {
window.hide();
let _ = backend().hide(WindowId::from_hwnd(window.hwnd));
}
Ok(())
@@ -3177,7 +3177,7 @@ impl WindowManager {
}
for window in workspace.floating_windows_mut() {
window.restore();
let _ = backend().restore(WindowId::from_hwnd(window.hwnd));
}
workspace.reintegrate_monocle_container()
+7 -7
View File
@@ -408,7 +408,7 @@ impl Workspace {
}
if should_hide {
window.hide();
let _ = backend().hide(WindowId::from_hwnd(window.hwnd));
}
}
@@ -417,7 +417,7 @@ impl Workspace {
}
if let Some(window) = self.maximized_window {
window.hide();
let _ = backend().hide(WindowId::from_hwnd(window.hwnd));
}
if let Some(container) = &self.monocle_container {
@@ -577,7 +577,7 @@ impl Workspace {
}
for window in self.floating_windows() {
window.restore();
let _ = backend().restore(WindowId::from_hwnd(window.hwnd));
}
// Do this here to make sure that an error doesn't stop the restoration of other windows
@@ -587,7 +587,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 {
maximized_window.restore();
let _ = backend().restore(WindowId::from_hwnd(maximized_window.hwnd));
backend().focus(
WindowId::from_hwnd(maximized_window.hwnd),
mouse_follows_focus,
@@ -599,7 +599,7 @@ impl Workspace {
)?;
}
} else if let Some(maximized_window) = self.maximized_window {
maximized_window.restore();
let _ = backend().restore(WindowId::from_hwnd(maximized_window.hwnd));
backend().focus(
WindowId::from_hwnd(maximized_window.hwnd),
mouse_follows_focus,
@@ -840,14 +840,14 @@ impl Workspace {
}
if hidden.get(i).copied().unwrap_or_default() {
// it is seen on another monitor wherever it rests here
window.hide();
let _ = backend().hide(WindowId::from_hwnd(window.hwnd));
} else {
if crate::scrolling::should_restore_when_placed(
window.hwnd,
container.focused_window().map(|w| w.hwnd),
&HIDDEN_HWNDS.lock(),
) {
window.restore();
let _ = backend().restore(WindowId::from_hwnd(window.hwnd));
}
backend().set_rect(WindowId::from_hwnd(window.hwnd), layout)?;