Skip to content

Commit 42dcf64

Browse files
authored
fix: get window monitor from minimized state (leanflutter#495)
Signed-off-by: fufesou <[email protected]>
1 parent db6e067 commit 42dcf64

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

windows/window_manager_plugin.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,12 @@ class WindowManagerPlugin : public flutter::Plugin {
6666
LONG l = 8;
6767
LONG t = 8;
6868

69-
HMONITOR monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
69+
// HMONITOR monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
70+
// Don't use `MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST)` above.
71+
// Because if the window is restored from minimized state, the window is not in the correct monitor.
72+
// The monitor is always the left-most monitor.
73+
// https://github.com/leanflutter/window_manager/issues/489
74+
HMONITOR monitor = MonitorFromRect(&sz->rgrc[0], MONITOR_DEFAULTTONEAREST);
7075
if (monitor != NULL) {
7176
MONITORINFO monitorInfo;
7277
monitorInfo.cbSize = sizeof(MONITORINFO);

0 commit comments

Comments
 (0)