From 3e7451f13281e1b2ff5d16d1448e854ee271adef Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Fri, 30 Oct 2026 18:47:35 -0700 Subject: [PATCH] feat(process_command): toggle-monocle acts while a window is maximized komorebi for Windows does not ignore it while a window is maximized: the monocle of the tiles that are left comes on and goes off, and the window stays maximized. Match it, and drop toggle-monocle from the commands that are about the tiles. --- komorebi/src/process_command.rs | 15 ++++++++------- komorebi/tests/maximize_commands.rs | 1 - komorebi/tests/user_maximize.rs | 21 ++++++++++++++++++++- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 24d48610..993e57bc 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -122,9 +122,10 @@ //! or restores it and puts it back in its tile ([`WindowManager::toggle_maximize`]). A window //! the user maximizes leaves the layout the same way //! ([`WindowManager::adopt_maximize_change`]). While a window is maximized, by either, the -//! messages about the tiles (**MoveWindow**, **CycleMoveWindow**, the stack messages, the -//! resize, promote and preselect messages, **ToggleLock**, **ToggleFloat**, **ToggleMonocle** -//! and the ones that send a container to another monitor or workspace) are ignored. +//! messages about the tiles (**MoveWindow**, **CycleMoveWindow**, the unstack and cycle messages, +//! the resize, promote and preselect messages, **ToggleLock** and the ones that send a container +//! to another monitor or workspace) are ignored. **ToggleFloat**, **StackWindow** and +//! **ToggleMonocle** are not: see `is_layout_command`. //! - **WorkspacePadding** and **ContainerPadding** set the paddings of a workspace given by the //! index of its monitor and its own, **NamedWorkspacePadding** and //! **NamedWorkspaceContainerPadding** those of the workspace with a name @@ -335,11 +336,12 @@ pub fn listen_for_commands(wm: Arc>) { /// locking, the monocle, and sending containers to other monitors and workspaces), which a /// maximized window has left /// -/// Two commands that look like them are not here, because komorebi for Windows does not ignore +/// Three commands that look like them are not here, because komorebi for Windows does not ignore /// them either (`maximizing.user` in the end-to-end suite has them as what both ports do): /// `toggle-float` floats the maximized window, which ends the maximize -/// ([`Workspace::new_floating_window`](crate::workspace::Workspace::new_floating_window)), and -/// `stack left` and `stack right` stack the tiles that are left. +/// ([`Workspace::new_floating_window`](crate::workspace::Workspace::new_floating_window)), +/// `stack left` and `stack right` stack the tiles that are left, and `toggle-monocle` turns the +/// monocle of the tiles that are left on, with the window staying maximized. fn is_layout_command(message: &SocketMessage) -> bool { matches!( message, @@ -359,7 +361,6 @@ fn is_layout_command(message: &SocketMessage) -> bool { | SocketMessage::PromoteFocus | SocketMessage::PromoteWindow(_) | SocketMessage::ToggleLock - | SocketMessage::ToggleMonocle | SocketMessage::MoveContainerToLastWorkspace | SocketMessage::SendContainerToLastWorkspace | SocketMessage::MoveContainerToMonitorNumber(_) diff --git a/komorebi/tests/maximize_commands.rs b/komorebi/tests/maximize_commands.rs index 67490cef..ab566f9d 100644 --- a/komorebi/tests/maximize_commands.rs +++ b/komorebi/tests/maximize_commands.rs @@ -186,7 +186,6 @@ fn while_a_window_is_maximized_what_is_about_the_tiles_does_nothing() { SocketMessage::SendContainerToMonitorNumber(1), SocketMessage::Promote, SocketMessage::ToggleLock, - SocketMessage::ToggleMonocle, SocketMessage::PreselectDirection(OperationDirection::Left), ] { send(&fake, &mut wm, message); diff --git a/komorebi/tests/user_maximize.rs b/komorebi/tests/user_maximize.rs index d44a9c94..971d63a8 100644 --- a/komorebi/tests/user_maximize.rs +++ b/komorebi/tests/user_maximize.rs @@ -117,7 +117,6 @@ fn nothing_that_is_about_the_layout_happens_while_a_window_is_maximized() { SocketMessage::UnstackWindow, SocketMessage::StackAll, SocketMessage::Promote, - SocketMessage::ToggleMonocle, SocketMessage::ToggleLock, SocketMessage::SendContainerToWorkspaceNumber(1), SocketMessage::MoveContainerToWorkspaceNumber(1), @@ -269,3 +268,23 @@ fn stack_left_stacks_the_tiles_that_are_left_while_a_window_is_maximized() { assert_eq!(workspace.maximized_window.map(|w| w.id), Some(30_092)); assert_eq!(workspace.containers().len(), 1, "the two tiles are stacked"); } + +#[test] +fn toggle_monocle_turns_the_monocle_of_the_tiles_that_are_left_on_while_a_window_is_maximized() { + let (fake, mut wm) = tiled(30_111, 3); + user_maximizes(&fake, &mut wm, 30_112, true); + + command(&fake, &mut wm, SocketMessage::ToggleMonocle); + + let workspace = wm.focused_workspace().unwrap(); + assert!(workspace.monocle_container.is_some()); + assert_eq!(workspace.maximized_window.map(|w| w.id), Some(30_112)); + assert!(fake.is_maximized(30_112)); + + command(&fake, &mut wm, SocketMessage::ToggleMonocle); + + let workspace = wm.focused_workspace().unwrap(); + assert!(workspace.monocle_container.is_none()); + assert_eq!(workspace.containers().len(), 2); + assert_eq!(workspace.maximized_window.map(|w| w.id), Some(30_112)); +}