Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changes/window-close-no-op.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
wry: patch
---

Make `window.close` no-op since it would leave a broken window, and behavior is inconsistent between windows and apple platforms
6 changes: 4 additions & 2 deletions src/webkitgtk/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,10 @@ impl InnerWebView {
web_context: &mut WebContext,
attributes: &mut WebViewAttributes,
) {
// window.close()
webview.connect_close(move |webview| unsafe { webview.destroy() });
// Simply destroying the webview would leave blank window which is not good.
// TODO: we need to add api to register callback on `window.close`
// and ask user code if close the window, or just ignore `window.close`.
//webview.connect_close(move |webview| unsafe { webview.destroy() });

// Synthetic mouse events
synthetic_mouse_events::setup(webview);
Expand Down
12 changes: 7 additions & 5 deletions src/webview2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -576,11 +576,13 @@ impl InnerWebView {
attributes: &mut WebViewAttributes,
token: &mut EventRegistrationToken,
) -> Result<()> {
// Close container HWND when `window.close` is called in JS
webview.add_WindowCloseRequested(
&WindowCloseRequestedEventHandler::create(Box::new(move |_, _| DestroyWindow(hwnd))),
token,
)?;
// Simply destroying the hwnd would cause inconsistent window state so ignoring for now.
// TODO: we need to add api to register callback on `window.close`
// and ask user code if close the window, or just ignore `window.close`.
// webview.add_WindowCloseRequested(
// &WindowCloseRequestedEventHandler::create(Box::new(move |_, _| DestroyWindow(hwnd))),
// token,
// )?;

// Document title changed handler
if let Some(document_title_changed_handler) = attributes.document_title_changed_handler.take() {
Expand Down