Skip to content

fix: remove macOS frameless window 28px shift compensation (window drift on restart)#62

Merged
VariableThe merged 1 commit into
mainfrom
fix/remove-macos-window-shift-compensation
Jun 25, 2026
Merged

fix: remove macOS frameless window 28px shift compensation (window drift on restart)#62
VariableThe merged 1 commit into
mainfrom
fix/remove-macos-window-shift-compensation

Conversation

@VariableThe

@VariableThe VariableThe commented Jun 25, 2026

Copy link
Copy Markdown
Owner

Summary

  • Removes the macOS-specific +/-28px window position compensation from quit_app,
    restore_window_state, and the lib.rs setup thread
  • The compensation was added for a macOS frameless window (decorations: false)
    bug in an older version of tauri-plugin-window-state
  • The current plugin (v2.4.1) has no macOS-specific offset — it correctly saves
    outer_position() and restores via set_position(). For frameless windows,
    outer position equals content origin (no titlebar offset on macOS)

Root cause

The +28 in quit_app shifted the window down before saving, and the -28 in
restore 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_ready and auto-save on RunEvent::Exit), the saved
position would be 28px too low, causing the window to appear shifted down on
restart.

Files changed

  • src-tauri/src/commands/system.rs — removed +28 from quit_app, removed
    -28 outer_position block from restore_window_state
  • src-tauri/src/lib.rs — removed -28 outer_position block from setup
    restore thread

Verification

  • cargo check passes (no new warnings, only pre-existing objc macro warnings)

Summary by CodeRabbit

  • Bug Fixes
    • Improved window state restoration on macOS by removing an extra position adjustment, so restored windows now appear closer to their saved location.
    • Startup window recovery now relies on the previously saved window state without applying an additional vertical offset.

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.
@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b4df5851-e2ca-475b-89b8-7bf889ca66b5

📥 Commits

Reviewing files that changed from the base of the PR and between 949b62f and e956457.

📒 Files selected for processing (2)
  • src-tauri/src/commands/system.rs
  • src-tauri/src/lib.rs
💤 Files with no reviewable changes (2)
  • src-tauri/src/lib.rs
  • src-tauri/src/commands/system.rs

📝 Walkthrough

Walkthrough

The 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 system.rs and lib.rs.

Changes

macOS restore adjustment removal

Layer / File(s) Summary
Remove macOS Y offset from restore paths
src-tauri/src/commands/system.rs, src-tauri/src/lib.rs
Both restore paths stop subtracting 28 from the window Y position and stop calling set_position for that adjustment.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~4 minutes

Poem

🐇 Hop, hop, the window rests in place,
No extra nibble on the Y-axis trace.
JSON says where the frame should stay,
And macOS paws take the offset away.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: removing the macOS frameless window 28px compensation to fix restart drift.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/remove-macos-window-shift-compensation

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@VariableThe VariableThe merged commit 7a974c7 into main Jun 25, 2026
4 checks passed
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