Skip to content

Commit

Permalink
fix(windows): create child webviews on top of the z-order (#1271)
Browse files Browse the repository at this point in the history
  • Loading branch information
amrbashir authored May 21, 2024
1 parent 03d2535 commit d6f8dd7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changes/child-webview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wry": "patch"
---

On Windows, create child webview at the top of z-order to align with other platforms.
17 changes: 15 additions & 2 deletions src/webview2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
},
Expand Down Expand Up @@ -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)
}

Expand Down

0 comments on commit d6f8dd7

Please sign in to comment.