Repository navigation
Window: open on one screen at a size that fits, like any other window - #259
Merged
elripalda merged 2 commits intoNov 17, 2026
Merged
Conversation
The kept window place was restored size first, place second. The window starts on the main screen, so moving it onto a screen with another scale made Windows rescale the size just set: it grew past the screen, across both monitors, and that size was kept for every later start. Now the place goes first and the size second (as tauri-plugin-window-state does), and the kept place is fitted to the free area of the screen its title bar is on, which also repairs a window.json that already holds a size wider than the screen. Leaving Big Picture gets the same order.
…screen The first window (1360x860 from tauri.conf.json, centred on the main screen) was never fitted to it: at 150% on a 1080p laptop that's 2040x1290 pixels, bigger than the screen. When it doesn't fit (also when the kept screen is gone), it now shrinks to nine tenths of the screen's free area and is centred. A window that fits stays exactly as it opened. While maximized, the kept place wasn't updated, so a window maximized on another screen (Win+Shift+arrow, or dragged there) reopened on the old one. Its normal place now moves to the screen it's maximized on, centred there, so it reopens maximized on that screen.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The launcher window now opens like any other window:
tauri.conf.json) wasn't fitted to the screen. At 150% on a 1080p laptop that's 2040x1290 pixels, bigger than the screen. It now shrinks to fit when it's too big. The same goes when the screen it was kept on is no longer there.Why
The huge window.
restore_window_placeset the kept size first and moved the window to its kept place second. The window starts on the main screen, so when the kept place is on a screen with another scale (100% and 150%, say), the move makes Windows rescale the window to keep its logical size. tao does this in itsWM_DPICHANGEDhandler. The physical size we had just set grew by the scale ratio, past the screen. The 700 ms save after a move or resize then wrote that grown size towindow.json. The only check on restore was that the title bar is on some screen, so the oversized window came back at every start. That explains the "sometimes": it starts after the window was last closed on the other screen. tauri-plugin-window-state restores in the other order (place, then size) for this reason.The first window.
center: truecentres the configured size on the main screen but doesn't shrink it, and nothing else looked at it.Maximized on another screen. While maximized,
keep_window_placekept the normal place from before, so the screen it was maximized on was never saved.How
All in
lib.rsunless noted.restore_window_place: sets the place first, then the size. It uses the kept place if its title bar is on a screen (same check as before), otherwisefirst_place.fit_on_screen: caps the kept size at that screen's work area and moves the window in only as far as needed for all of it to show. This also repairs awindow.jsonthat already holds an oversized window, so players who hit the bug before don't keep the giant window after updating.first_place/centred_on_screen: when the window as it first opened doesn't fit its screen, it shrinks to nine tenths of the free area and is centred. Nine tenths keeps it looking like a window rather than a maximized one. A window that fits isn't touched.keep_window_place/normal_place_on: while maximized, the kept normal place moves to the screen the window is maximized on (centred there) if it isn't on it already. On the next start the place goes there first, somaximize()lands on that screen.display.rs,leave_tv_mode: same order swap (place, then size) when coming back from Big Picture on another screen.One change in behaviour: a window that was left hanging off a screen edge, or across two screens, now comes back fully on the screen its title bar was on.
Tests
fit_on_screen: a window that fits is unchanged, one wider than both screens shrinks to one, one hanging off the edge moves back on, one on a second screen stays there.centred_on_screen: a too-big first window shrinks and centres.normal_place_on: a window maximized on its own screen keeps its place, and one maximized on another screen moves there.cargo test: 660 passed.node --test tests/*.test.cjs: 280 passed.