Skip to content

Commit

Permalink
feat(webview2): hide the webview when the window is minimized (#702)
Browse files Browse the repository at this point in the history
* feat(webview2): hide the webview when the window is minimized

* update covector readme
  • Loading branch information
amrbashir authored Sep 27, 2022
1 parent 6032594 commit 51b49c5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changes/hide-webview-windows.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wry": "patch"
---

On Windows, hide the webview when the window is minimized to reduce memory and cpu usage.
3 changes: 1 addition & 2 deletions .changes/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ Use the following format:

```md
---
"package-a": patch
"package-b": minor
"wry": patch
---

Change summary goes here
Expand Down
8 changes: 8 additions & 0 deletions src/webview/webview2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,14 @@ window.addEventListener('mousemove', (e) => window.chrome.webview.postMessage('_
right: client_rect.right - client_rect.left,
bottom: client_rect.bottom - client_rect.top,
});

if wparam == WPARAM(win32wm::SIZE_MINIMIZED as _) {
let _ = (*controller).SetIsVisible(false);
}

if wparam == WPARAM(win32wm::SIZE_RESTORED as _) {
let _ = (*controller).SetIsVisible(true);
}
}

win32wm::WM_SETFOCUS | win32wm::WM_ENTERSIZEMOVE => {
Expand Down

0 comments on commit 51b49c5

Please sign in to comment.