fix: remove macOS frameless window 28px shift compensation (window drift on restart)#62
Conversation
The tauri-plugin-window-state v2.4.1 has no macOS-specific offset for frameless windows - it correctly uses outer_position() for saving and set_position() for restoring. The 28px compensation was added for a bug in an older plugin version that no longer applies. On macOS frameless windows (decorations: false), outer_position() returns the window frame origin which equals the content origin since there is no titlebar. The compensation was causing the saved position to be offset by 28px, leading to the window appearing lower on restart when the correction failed to apply. This removes all +/-28 compensation from both save (quit_app) and restore (lib.rs setup thread, restore_window_state command) paths.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
💤 Files with no reviewable changes (2)
📝 WalkthroughWalkthroughThe PR removes the macOS-specific 28-pixel Y-position adjustment from both window restoration paths. Restored window position and size now rely on the saved state values in ChangesmacOS restore adjustment removal
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~4 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
quit_app,restore_window_state, and thelib.rssetup threaddecorations: false)bug in an older version of
tauri-plugin-window-stateouter_position()and restores viaset_position(). For frameless windows,outer position equals content origin (no titlebar offset on macOS)
Root cause
The
+28inquit_appshifted the window down before saving, and the-28inrestore were supposed to correct it. But when the correction didn't apply
reliably (timing issues in the 300ms delayed restore, race with plugin's
auto-restore on
on_window_readyand auto-save onRunEvent::Exit), the savedposition would be 28px too low, causing the window to appear shifted down on
restart.
Files changed
src-tauri/src/commands/system.rs— removed+28fromquit_app, removed-28outer_position block fromrestore_window_statesrc-tauri/src/lib.rs— removed-28outer_position block from setuprestore thread
Verification
cargo checkpasses (no new warnings, only pre-existing objc macro warnings)Summary by CodeRabbit