diff --git a/komorebi/src/border_manager/border.rs b/komorebi/src/border_manager/border.rs index 46c7c5e9..882a44be 100644 --- a/komorebi/src/border_manager/border.rs +++ b/komorebi/src/border_manager/border.rs @@ -132,8 +132,10 @@ impl Border { rects.insert(self.hwnd, rect); } - // Update the position of the border - WindowsApi::set_border_pos(self.hwnd(), &rect, HWND((*Z_ORDER.lock()).into()))?; + // Update the position of the border if required + if !WindowsApi::window_rect(self.hwnd())?.eq(&rect) { + WindowsApi::set_border_pos(self.hwnd(), &rect, HWND((*Z_ORDER.lock()).into()))?; + } // Invalidate the rect to trigger the callback to update colours etc. self.invalidate(); diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index 6e8787ff..14273550 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -139,6 +139,10 @@ impl Window { } pub fn set_position(&self, layout: &Rect, top: bool) -> Result<()> { + if WindowsApi::window_rect(self.hwnd())?.eq(layout) { + return Ok(()); + } + let rect = *layout; WindowsApi::position_window(self.hwnd(), &rect, top) }