Skip to content

Commit

Permalink
fix: get window monitor from minimized state (#495)
Browse files Browse the repository at this point in the history
Signed-off-by: fufesou <[email protected]>
  • Loading branch information
fufesou authored Oct 27, 2024
1 parent db6e067 commit 42dcf64
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion windows/window_manager_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@ class WindowManagerPlugin : public flutter::Plugin {
LONG l = 8;
LONG t = 8;

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

0 comments on commit 42dcf64

Please sign in to comment.