From f7dccfe0f5e271c4747b8922b5d61d825463adf4 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sun, 9 Jul 2023 19:26:40 -0700 Subject: [PATCH] fix(wm): lars' secret sauce for min-width apps This commit applies a technique shared by Lars from GlazeWM and first noticed by J.SH on Discord to add the SWP_NOSENDCHANGING flag when positioning windows to overcome any hard-coded minimum width restrictions an application might have. --- komorebi/src/process_command.rs | 6 ++++-- komorebi/src/window_manager.rs | 2 +- komorebi/src/windows_api.rs | 5 ++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 7eab95c5..7060dc96 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -703,10 +703,12 @@ impl WindowManager { if let Layout::Custom(ref mut custom) = rule.1 { match sizing { Sizing::Increase => { - custom.set_primary_width_percentage(percentage + 5.0); + custom + .set_primary_width_percentage(percentage + 5.0); } Sizing::Decrease => { - custom.set_primary_width_percentage(percentage - 5.0); + custom + .set_primary_width_percentage(percentage - 5.0); } } } diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index c7fb1f5e..e313d3e5 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -1040,7 +1040,7 @@ impl WindowManager { .get_mut(first_idx) .ok_or_else(|| anyhow!("There is no monitor"))? .remove_workspaces(); - + let second_workspaces = self .monitors_mut() .get_mut(second_idx) diff --git a/komorebi/src/windows_api.rs b/komorebi/src/windows_api.rs index 2575f030..efe585c3 100644 --- a/komorebi/src/windows_api.rs +++ b/komorebi/src/windows_api.rs @@ -303,7 +303,10 @@ impl WindowsApi { } pub fn position_window(hwnd: HWND, layout: &Rect, top: bool) -> Result<()> { - let flags = SetWindowPosition::NO_ACTIVATE; + let flags = SetWindowPosition::NO_ACTIVATE + | SetWindowPosition::NO_SEND_CHANGING + | SetWindowPosition::NO_COPY_BITS + | SetWindowPosition::FRAME_CHANGED; let position = if top { HWND_TOPMOST } else { HWND_BOTTOM }; Self::set_window_pos(hwnd, layout, position, flags.bits())