Skip to content

fix(window-state): stop macOS overlay windows changing size on every restore - #3416

Merged
lucasfernog merged 10 commits into
tauri-apps:v2from
gkucmierz:fix/macos-logical-coordinates
Oct 18, 2026
Merged

lucasfernog merged 10 commits into
tauri-apps:v2from
gkucmierz:fix/macos-logical-coordinates

Conversation

@gkucmierz

@gkucmierz gkucmierz commented May 9, 2026 •

Copy link
Copy Markdown
Contributor

On macOS, set_size sets the window's content rect, but inner_size reports the webview's bounds. With titleBarStyle: Overlay the two differ, so each restore changed the window's height by the title bar height.

This PR saves the content-rect size on macOS: outer_size minus the title bar height, which is inner_position.y - outer_position.y. That's exactly what set_size restores, whatever the title bar style.

Also, a maximized window is now checked against the monitors using the position it will actually be restored to (prev_x/prev_y), not the monitor corner.

…y shrink and multi-monitor DPI scaling drift
@gkucmierz
gkucmierz requested a review from a team as a code owner May 9, 2026 07:26
…ng the title bar

The 20-40px outer/inner heuristic also matched ordinary decorated windows, saving their outer size so they grew by the title bar height on every restore. Derive the title bar height from the content rect instead, in one helper shared by update_state, the Resized handler and the initial metadata.
State files written by earlier versions hold physical pixels, and logical coordinates are not one global space across monitors with different scale factors, so a position converted with one monitor's scale was restored on another. Converting with the window's scale at Moved time could also pick up a stale scale mid-drag, and an unavailable scale silently stored physical values as logical.
For a maximized window the monitor check tested x and y, which are the monitor's corner, while the window was then placed at prev_x and prev_y. A window maximized after leaving a now-disconnected monitor passed the check and was restored off-screen.
Restores each window three times, also with an overlay title bar, and checks the inner and outer size (or position) still match the first save, so drift between saving and restoring accumulates and fails the test.
0.3.0 returns a new-session response that WebdriverIO 10 rejects as not W3C, so every macOS e2e spec failed to create a session.
@github-actions

Copy link
Copy Markdown
Contributor

Package Changes Through 798cc24

There are 11 changes which include deep-link with patch, deep-link-js with patch, notification with minor, notification-js with minor, shell with minor, shell-js with minor, single-instance with patch, updater with patch, updater-js with patch, window-state with patch, window-state-js with patch

Planned Package Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
api-example 2.0.56 2.0.57
api-example-js 2.0.52 2.0.53
deep-link-example-js 2.2.17 2.2.18
deep-link 2.6.2 2.6.3
deep-link-js 2.6.2 2.6.3
notification 2.7.0 2.8.0
notification-js 2.7.0 2.8.0
shell 2.5.0 2.6.0
shell-js 2.5.0 2.6.0
single-instance 2.5.4 2.5.5
updater 2.14.0 2.14.1
updater-js 2.14.0 2.14.1
window-state 2.5.0 2.5.1
window-state-js 2.5.0 2.5.1

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatednpm/​@​crabnebula/​test-runner-backend@​0.3.0 ⏵ 0.3.188 +11007794 +1100

View full report

@lucasfernog lucasfernog changed the title fix(window-state): convert macOS coordinates to Logical to fix overlay shrink and multi-monitor DPI scaling drift fix(window-state): stop macOS overlay windows changing size on every restore Oct 17, 2026
@lucasfernog
lucasfernog merged commit 11211c3 into tauri-apps:v2 Oct 18, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants