refactor(core): a ContainerWindow is Clone, not Copy

Step 11(iii) prerequisite. The macOS Window holds retained Accessibility
references and cannot be Copy, so the bound of ContainerWindow is Clone.
KDE and Windows windows are still Copy; they satisfy it unchanged. The seven
places in komorebi-core/src/workspace.rs that copied a window out of a
borrowed Option (if let Some(window) = self.maximized_window) borrow it
instead (&self.maximized_window), and two places clone where the old text
used the value twice (new_maximized_window, new_maximized_window's
unmaximize hook). No behaviour change on KDE or Windows: a clone of a Copy
type is the copy.

Verified: native cargo test -p komorebi-core, fast-check: Windows clippy
--all-targets -D warnings PASS, KDE check + lib tests PASS (291 passed), macOS
fake-CC type-check PASS. Not run: Windows e2e (needed only if you want a
second look: no Windows window type changed).
This commit is contained in:
LGUG2Z committed 2026-11-05 10:30:05 -08:00
1 parent b937a3d716
commit 6fa0819605
2 files changed
+10 -9

No files matched your search

+3 -2
View File
@@ -19,10 +19,11 @@ use std::collections::VecDeque;
/// What a container needs of a platform's window.
///
/// The window is a small `Copy` handle (Windows: an `HWND`; KDE: the compositor's id). Showing and
/// The window is a handle that is cheap to clone (Windows: an `HWND`; KDE: the compositor's id; macOS: an
/// Accessibility element). Showing and
/// hiding it is the platform's business, so the container calls these four operations and nothing
/// else; none of them reports a failure, because a window that cannot be hidden is left where it is.
pub trait ContainerWindow: Copy + PartialEq + std::fmt::Debug {
pub trait ContainerWindow: Clone + PartialEq + std::fmt::Debug {
/// What names a window to the rest of the daemon: `isize` on Windows, `u32` on KDE.
type Id: Copy + PartialEq;
+7 -7
View File
@@ -654,7 +654,7 @@ impl<P: WorkspacePlatform> Workspace<P> {
/// The compositor reports no focused window.
pub fn is_focused_window_monocle_or_maximized(&self) -> eyre::Result<bool> {
let window_id = P::foreground_window_id().ok_or_eyre("no foreground window")?;
if let Some(window) = self.maximized_window
if let Some(window) = &self.maximized_window
&& window_id == window.id()
{
return Ok(true);
@@ -683,7 +683,7 @@ impl<P: WorkspacePlatform> Workspace<P> {
}
}
if let Some(window) = self.maximized_window
if let Some(window) = &self.maximized_window
&& window_id == window.id()
{
return true;
@@ -716,7 +716,7 @@ impl<P: WorkspacePlatform> Workspace<P> {
}
}
if let Some(window) = self.maximized_window
if let Some(window) = &self.maximized_window
&& let Some(window_exe) = window.exe()
&& exe == window_exe
{
@@ -750,7 +750,7 @@ impl<P: WorkspacePlatform> Workspace<P> {
}
}
if let Some(window) = self.maximized_window
if let Some(window) = &self.maximized_window
&& window_id == window.id()
{
return true;
@@ -839,7 +839,7 @@ impl<P: WorkspacePlatform> Workspace<P> {
container.load_focused_window();
}
self.new_container_for_window(window);
self.new_container_for_window(window.clone());
let mut container = Container::default();
container.add_window(window);
@@ -1392,7 +1392,7 @@ impl<P: WorkspacePlatform> Workspace<P> {
/// Takes the focused window of the workspace (the maximized one, the monocle's or the focused
/// container's) out of its place and makes it a floating window.
pub fn new_floating_window(&mut self) -> eyre::Result<()> {
let window = if let Some(maximized_window) = self.maximized_window {
let window = if let Some(maximized_window) = self.maximized_window.clone() {
P::unmaximize_window(&maximized_window)?;
self.maximized_window = None;
self.maximized_window_restore_idx = None;
@@ -1467,7 +1467,7 @@ impl<P: WorkspacePlatform> Workspace<P> {
self.resize_dimensions = resize_dimensions;
}
if let Some(window) = self.maximized_window {
if let Some(window) = &self.maximized_window {
window.hide_window();
}