Skip to content

fix(window): recover a too-small window when several monitors are left - #2732

Draft
cheng-block wants to merge 3 commits into
block:mainfrom
cheng-block:cheng/fix-window-restore-multi-monitor
Draft

cheng-block wants to merge 3 commits into
block:mainfrom
cheng-block:cheng/fix-window-restore-multi-monitor

Conversation

@cheng-block

@cheng-block cheng-block commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Why

Use a 2x laptop, a second 2x monitor, and a 1x external to the right of the laptop. Quit Buzz on the external, unplug it, and relaunch. The window opens at half size, at or below the 480x400 minimum. The fix in #2405 covers this only when one monitor is left.

On macOS a monitor's physical rect is its point rect times its scale. So the rect saved on the 1x external can fall inside the 2x laptop. reachable_client (src-tauri/src/window_state.rs) sees the header on screen and keeps that rect. It replaces a too-small size only when one monitor is left, where the scale is certain.

What

The saved rect is now kept only if a monitor under the window could have saved that size at its own scale.

How

  • restore_request runs the existing minimum check at each monitor's scale, Windows shadow insets included. This replaces the one-monitor special case.
  • The header check is unchanged. The fitting monitor need not hold the header, since the size was saved where most of the window was.
  • Otherwise the window moves to the top of the primary monitor, as in fix(window): restore position before size and never fall back to a sub-minimum window #2405, at the default size if still too small there.
  • With no minimum set, the result matches main. The state file, the plugin version and onboarding geometry are unchanged.

Risk

Only window restore at launch changes, and only when the saved size is below the minimum at some monitor's scale.

  • A size from a gone monitor that still meets the minimum at the new scale is kept, at the wrong size. Fixing it needs the save-time scale, which only tauri-plugin-window-state could store.
  • On Windows the check assumes tao's default border metrics. With thicker borders, a window kept at the minimum reopens at the default size, now also with several monitors.
  • Not changed: with a different-scale monitor still attached, the reachable path sends physical pixels that macOS converts at the startup scale. In a manual run the window grew to 4800x3200 px maximized after one relaunch.
  • Already on main: onboarding_snapshot_is_kept_until_next_launch_restore segfaults on macOS, because it calls ns_window() on the fake view from MockRuntime.

Testing

No manual testing beyond the in-app check.

In-app check

Pending. It needs a 2x laptop, a second 2x monitor and a 1x external to the right of the laptop.

  1. Move Buzz to the 1x external and resize it to about 700x550 points.
  2. Quit Buzz, then unplug only the 1x external.
  3. Relaunch Buzz.
  4. The window opens at 1200x800 points at the top of the primary screen, not at the minimum size.

cheng-block and others added 3 commits November 5, 2026 16:38
Replace the single-monitor special case with one rule: a monitor only
holds the saved rect if the saved size meets the minimum at that
monitor's scale. A smaller size was saved at a lower scale, so with two
2x monitors left after unplugging a 1x external the window is now
relocated with the default size instead of opening clamped.

(cherry picked from commit 7de4895, resolved onto the restructured
restore_request / reachable_client from block#2405)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Signed-off-by: Cheng Peng <cheng@block.xyz>
(cherry picked from commit 55d8657)
Keep header visibility geometric again and check the minimum separately:
at least one monitor under the header must have a scale at which the
saved size fits. A 1x window spanning onto a 2x laptop stays where it
was.

(cherry picked from commit 7e2393e, resolved onto the restructured
restore_request / reachable_client from block#2405; its minimum rounding part
is already in block#2405)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Signed-off-by: Cheng Peng <cheng@block.xyz>
(cherry picked from commit 6f018b1)
The saved size comes from the scale of the monitor that held most of the
window, which need not hold the header. Count a monitor whose scale fits
the saved size when it intersects the saved client, not only when it
holds a header corner. A window hanging below a 2x monitor onto a 1x one,
or spanning a 1x monitor between two 2x ones, now stays put. Header
visibility is main's check again.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Signed-off-by: Cheng Peng <cheng@block.xyz>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant