From 0c2e37e1278138c832fd44b6e722ec2e1e0332e8 Mon Sep 17 00:00:00 2001 From: James Tucker Date: Sun, 25 Feb 2024 14:29:08 -0800 Subject: [PATCH] fix(komorebi): raise windows and border to top, not topmost topmost has a special meaning, in that it is a sticky raise, which is not what we want - we don't want to be permanently above all other windows, as this leads to bugs where for example the windows can end up stuck above non-topmost windows in a different security context, such as programs running with administrator priviliges. --- komorebi/src/windows_api.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/komorebi/src/windows_api.rs b/komorebi/src/windows_api.rs index bb7d1fb2..45c0099a 100644 --- a/komorebi/src/windows_api.rs +++ b/komorebi/src/windows_api.rs @@ -103,7 +103,7 @@ use windows::Win32::UI::WindowsAndMessaging::GWL_EXSTYLE; use windows::Win32::UI::WindowsAndMessaging::GWL_STYLE; use windows::Win32::UI::WindowsAndMessaging::GW_HWNDNEXT; use windows::Win32::UI::WindowsAndMessaging::HWND_BOTTOM; -use windows::Win32::UI::WindowsAndMessaging::HWND_TOPMOST; +use windows::Win32::UI::WindowsAndMessaging::HWND_TOP; use windows::Win32::UI::WindowsAndMessaging::LWA_ALPHA; use windows::Win32::UI::WindowsAndMessaging::LWA_COLORKEY; use windows::Win32::UI::WindowsAndMessaging::SET_WINDOW_POS_FLAGS; @@ -358,7 +358,7 @@ impl WindowsApi { bottom: layout.bottom + shadow_rect.bottom, }; - let position = if top { HWND_TOPMOST } else { HWND_BOTTOM }; + let position = if top { HWND_TOP } else { HWND_BOTTOM }; Self::set_window_pos(hwnd, &rect, position, flags.bits()) } @@ -369,7 +369,7 @@ impl WindowsApi { pub fn raise_window(hwnd: HWND) -> Result<()> { let flags = SetWindowPosition::NO_MOVE; - let position = HWND_TOPMOST; + let position = HWND_TOP; Self::set_window_pos(hwnd, &Rect::default(), position, flags.bits()) } @@ -380,12 +380,13 @@ impl WindowsApi { SetWindowPosition::NO_ACTIVATE }; - // Always raise the border window to topmost, so that when it is a - // single-pixel inset border, it always draws atop the window (i.e. - // support an offset of -1 that draws over the Windows 11 default - // translucent single pixel border, while reamining visible in cases - // such as the EPIC Games launcher that uses an opaque custom border). - let position = HWND_TOPMOST; + // Always raise the border window to the top, but not overlapping + // topmost windows, so that when it is a single-pixel inset border, it + // always draws atop the window (i.e. support an offset of -1 that + // draws over the Windows 11 default translucent single pixel border, + // while reamining visible in cases such as the EPIC Games launcher that + // uses an opaque custom border). + let position = HWND_TOP; Self::set_window_pos(hwnd, layout, position, flags.bits()) }