diff --git a/.changes/child-webview.md b/.changes/child-webview.md new file mode 100644 index 000000000..1e7e50383 --- /dev/null +++ b/.changes/child-webview.md @@ -0,0 +1,5 @@ +--- +"wry": "patch" +--- + +On Windows, create child webview at the top of z-order to align with other platforms. diff --git a/src/webview2/mod.rs b/src/webview2/mod.rs index 2fdde4a28..73059a468 100644 --- a/src/webview2/mod.rs +++ b/src/webview2/mod.rs @@ -31,8 +31,9 @@ use windows::{ self as win32wm, CreateWindowExW, DefWindowProcW, DestroyWindow, GetClientRect, PostMessageW, RegisterClassExW, RegisterWindowMessageA, SendMessageW, SetParent, SetWindowPos, ShowWindow, CS_HREDRAW, CS_VREDRAW, CW_USEDEFAULT, HCURSOR, HICON, HMENU, - SWP_ASYNCWINDOWPOS, SWP_NOACTIVATE, SWP_NOMOVE, SWP_NOZORDER, SW_HIDE, SW_SHOW, - WINDOW_EX_STYLE, WM_USER, WNDCLASSEXW, WS_CHILD, WS_CLIPCHILDREN, WS_VISIBLE, + HWND_TOP, SWP_ASYNCWINDOWPOS, SWP_NOACTIVATE, SWP_NOMOVE, SWP_NOOWNERZORDER, SWP_NOSIZE, + SWP_NOZORDER, SW_HIDE, SW_SHOW, WINDOW_EX_STYLE, WM_USER, WNDCLASSEXW, WS_CHILD, + WS_CLIPCHILDREN, WS_VISIBLE, }, }, }, @@ -240,6 +241,18 @@ impl InnerWebView { ) }; + unsafe { + SetWindowPos( + hwnd, + HWND_TOP, + 0, + 0, + 0, + 0, + SWP_ASYNCWINDOWPOS | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOSIZE, + ) + }?; + Ok(hwnd) }