From da7160a3a220d8af03a5cba6d1d8216b7c24304c Mon Sep 17 00:00:00 2001 From: amrbashir Date: Tue, 21 May 2024 04:19:05 +0300 Subject: [PATCH] fix(windows): create child webviews on top of the z-order closes tauri-apps/tauri#9798 --- .changes/child-webview.md | 5 +++++ src/webview2/mod.rs | 17 +++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 .changes/child-webview.md 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 4fd93e733..26d91e65b 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) }