[Windows] Hidden title bar: a maximized window restored from minimized on a secondary monitor gets the primary monitor's work area as its client area
Maintainer antworten meist innerhalb von 1 Tag
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 67/100
Rechercherichtung
Beginne in src/platform/windows/window_windows.cpp beim maximierten Zweig von WM_NCCALCSIZE innerhalb von HandleHiddenTitleBarFrame; lies, wie proposed direkt darüber gespeichert wird und wie GetMonitorInfoW seinen Monitor über MonitorFromWindow erhält. Reproduziere mit einer ausgeblendeten Titelleiste: auf einem sekundären Monitor maximieren, minimieren und wiederherstellen, dann das Client-Rechteck und WM_NCHITTEST prüfen. Fertig, wenn der wiederhergestellte Clientbereich der Arbeitsbereich des sekundären Monitors ist und die Fälle mit primärem Monitor und maximiertem Verschieben unverändert sind.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Environment
- window_manager 0.7.1 (also 0.7.0), nativeapi / cnativeapi / nativeapi_flutter 0.6.2 (also 0.6.1)
- Flutter 3.50.0, Windows 11 (build 26300), x64
- Two 1920×1080 monitors at 100 %, the secondary one to the right of the primary one
Steps to reproduce
final window = WindowManager.instance.getCurrent()!;
window.titleBarStyle = TitleBarStyle.hidden;
window.maximize();
- Put the maximized window on the secondary monitor.
- Minimize it (caption button,
window.minimize()orSC_MINIMIZE). - Restore it (taskbar button or
SC_RESTORE).
Expected
Client area = work area of the secondary monitor, as before minimizing.
Actual
Measured right after the restore:
| before minimize | after restore | |
|---|---|---|
| window rect | (1912,-8)-(3848,1040) | (1912,-8)-(3848,1040) |
| client rect (screen coordinates) | (1920,0)-(3840,1032) | (0,0)-(1920,1032), the primary monitor's work area, outside the window |
WM_NCHITTEST, middle of the window |
HTCLIENT |
HTNOWHERE |
WM_NCHITTEST, top band |
HTCLIENT |
HTCAPTION |
| Flutter view (child HWND) | (1920,0)-(3840,1032) | (0,0)-(1920,1032) |
The app looks frozen: clicks no longer reach the Flutter view, and the top band behaves like the native caption. On the primary monitor the same steps work.
Moving a maximized window from one monitor to another without minimizing it (SetWindowPos while zoomed) is not affected.
Cause
HandleHiddenTitleBarFrame, maximized branch of WM_NCCALCSIZE (src/platform/windows/window_windows.cpp, nativeapi-core main):
MONITORINFO monitor = {sizeof(monitor)};
if (GetMonitorInfoW(MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST), &monitor))
params->rgrc[0] = monitor.rcWork;
During WM_NCCALCSIZE the window still has its previous rect. When it leaves the minimized state that rect is the placeholder at (-32000, -32000), so MonitorFromWindow answers the monitor nearest to that point rather than the one the window is restored to.
Suggested fix
proposed (the incoming rgrc[0], saved a few lines above) is the rect the window is moving to:
// The maximized frame extends beyond the work area by its resize borders.
// Fit the captionless client to the work area, excluding those borders.
+ // The window still has its previous rect here, the minimized placeholder at
+ // (-32000, -32000) when it leaves the minimized state: take the monitor of the
+ // rect it is moving to.
MONITORINFO monitor = {sizeof(monitor)};
- if (GetMonitorInfoW(MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST), &monitor))
+ if (GetMonitorInfoW(MonitorFromRect(&proposed, MONITOR_DEFAULTTONEAREST), &monitor))
params->rgrc[0] = monitor.rcWork;
Tested with a patched cnativeapi 0.6.2 (dependency_overrides) and an unmodified Flutter runner: the client rect is (1920,0)-(3840,1032) as soon as the window is restored, hit testing and the Flutter view are back on the secondary monitor, and the primary monitor and the maximized move case are unchanged.
Workaround until a release
In the runner's FlutterWindow::MessageHandler, on WM_WINDOWPOSCHANGED: if IsZoomed(hwnd) and the client rect (mapped to screen) is not inside GetWindowRect, call SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED). The window has its final rect by then, so the next WM_NCCALCSIZE picks the right monitor.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 190
- Forks
- 18
- Ø Merge
- 8 Std. 17 Min.
- Gemergte PRs (30 T.)
- 11
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
KilledByAPixel/LittleJS#188 ·
-
enhancement
Schwierigkeit 2/5 Unter einer Stunde Anfängerfreundlichkeit 88/100
stfc/goldilocks-agent#156 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Add: BRIDGE Jazz SDOffenstreams:add
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 85/100
Maintainer antworten meist innerhalb von 1 Tag
-
[BUG] iOS - Share extension crashes when the shared page contains "%s" or "% s" (NSLog format string)Evtl. vergeben @kexhest hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
achorein/expo-share-intent#244 ·
-
[Bug]: 歌曲管理排序存在问题Offenbug 需要确认
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
laoshuikaixue/VoiceHub#687 ·
Maintainer antworten meist innerhalb von 1 Tag