Skip to content

Commit b3909f5

Browse files
authored
fix: moveAbove not working on Windows (electron#23161)
* fix moveAbove on Windows systems The documentation for [setWindowPos](https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowpos) second argument `hWndInsertAfter` is a bit confusing... > A handle to the window to precede the positioned window in the Z order. This parameter must be a window handle or one of the following values. Since Windows refers to the Z order from low to high it means that the window provided as reference will always _precede_ the electron window, which is the opposite of what we want in this function, since the electron window is displayed behind the referenced window. The change is simply to ask `SetWindowPos` to position our window *behind* the window that's *above* the reference window, effectively making our window sit just above the reference one. * lint
1 parent a041882 commit b3909f5

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

shell/browser/native_window_views.cc

+2-4
Original file line numberDiff line numberDiff line change
@@ -654,10 +654,8 @@ bool NativeWindowViews::MoveAbove(const std::string& sourceId) {
654654
if (!::IsWindow(otherWindow))
655655
return false;
656656

657-
gfx::Point pos = GetPosition();
658-
gfx::Size size = GetSize();
659-
::SetWindowPos(GetAcceleratedWidget(), otherWindow, pos.x(), pos.y(),
660-
size.width(), size.height(),
657+
::SetWindowPos(GetAcceleratedWidget(), GetWindow(otherWindow, GW_HWNDPREV), 0,
658+
0, 0, 0,
661659
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
662660
#elif defined(USE_X11)
663661
if (!IsWindowValid(id.id))

0 commit comments

Comments
 (0)