[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

Abierto Apto para principiantes
#53 0 comentarios 1 reacción 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@lijy91 ya está trabajando en esto.

Desde el 23/11/2026.

  • #54 de @lijy91 — abierto
  • #101 de @lijy91 — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
67/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
cpp, dart, flutter
Área
desktop

Línea de trabajo

Empieza en src/platform/windows/window_windows.cpp, en la rama maximizada de WM_NCCALCSIZE dentro de HandleHiddenTitleBarFrame; lee cómo se guarda proposed justo arriba y cómo GetMonitorInfoW obtiene su monitor desde MonitorFromWindow. Reproduce con una barra de título oculta, maximiza en un monitor secundario, minimiza y restaura, luego comprueba el rectángulo de cliente y WM_NCHITTEST. Está hecho cuando el área de cliente restaurada sea el área de trabajo del monitor secundario y los casos de monitor primario y de movimiento maximizado queden sin cambios.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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();
  1. Put the maximized window on the secondary monitor.
  2. Minimize it (caption button, window.minimize() or SC_MINIMIZE).
  3. 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.

Lenguaje dominante
TypeScript
Estrellas
190
Forks
18
Merge medio
8 h 17 min
PR fusionados (30 d)
11

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.