Skip to content

Commit

Permalink
fix(wm): lars' secret sauce for min-width apps
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
LGUG2Z committed Jul 10, 2023
1 parent fc71988 commit f7dccfe
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
6 changes: 4 additions & 2 deletions komorebi/src/process_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion komorebi/src/window_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion komorebi/src/windows_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit f7dccfe

Please sign in to comment.