Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(windows): Focus webview when window starts moving or resizing. #695

Merged
merged 7 commits into from
Sep 16, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changes/fix-webview-focus.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wry": patch
---

Focus webview when window starts moving or resizing on Windows to automatically close `<select>` dropdowns.
amrbashir marked this conversation as resolved.
Show resolved Hide resolved
7 changes: 6 additions & 1 deletion src/webview/webview2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -616,11 +616,16 @@ window.addEventListener('mousemove', (e) => window.chrome.webview.postMessage('_
});
}

win32wm::WM_SETFOCUS => {
win32wm::WM_ENTERSIZEMOVE | win32wm::WM_SETFOCUS => {
FabianLars marked this conversation as resolved.
Show resolved Hide resolved
let controller = dwrefdata as *mut ICoreWebView2Controller;
let _ = (*controller).MoveFocus(COREWEBVIEW2_MOVE_FOCUS_REASON_PROGRAMMATIC);
}

win32wm::WM_MOVE | win32wm::WM_MOVING => {
amrbashir marked this conversation as resolved.
Show resolved Hide resolved
let controller = dwrefdata as *mut ICoreWebView2Controller;
let _ = (*controller).NotifyParentWindowPositionChanged();
}

win32wm::WM_DESTROY => {
Box::from_raw(dwrefdata as *mut ICoreWebView2Controller);
}
Expand Down