[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

オープン 初心者向け
#53 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@lijy91 がすでに取り組んでいます。

2026年11月23日 から。

  • #54 @lijy91 による — オープン
  • #101 @lijy91 による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
67/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
cpp, dart, flutter
領域
desktop

調査の方向性

src/platform/windows/window_windows.cpp の HandleHiddenTitleBarFrame 内にある WM_NCCALCSIZE の最大化分岐から始め、すぐ上で proposed がどのように保存されるか、GetMonitorInfoW が MonitorFromWindow からどのようにモニターを取得するかを読んでください。タイトルバーを非表示にして、セカンダリ モニターで最大化し、最小化して復元し、その後クライアント矩形と WM_NCHITTEST を確認して再現してください。復元後のクライアント領域がセカンダリ モニターの作業領域であり、プライマリ モニターと最大化移動のケースが変わっていなければ完了です。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
TypeScript
スター
190
フォーク
18
平均マージ
8時間 17分
マージ済み PR(30日)
11

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。