feat(macos): set traffic-light position via Tauri builder API and sync with zoom

Use Tauri's native `traffic_light_position()` builder method to position
macOS window controls instead of runtime objc2 calls. A global AtomicU32
tracks the current zoom level so newly created windows reflect the latest
zoom. The frontend syncs zoom changes to the backend via a new
`update_traffic_light_position` command.

- Add `traffic_light_position()` to `apply_platform_window_style` builder
- Add `CURRENT_ZOOM` atomic and `traffic_light_position()` helper
- Register `update_traffic_light_position` Tauri command
- Add `syncTrafficLightPosition` in appearance-provider to sync on zoom
  change, mount, and cross-tab storage events
- Consolidate `ensure_windows_undecorated` calls into `post_window_setup`
- Remove dead `on_window_resized` no-op and its Resized event listener

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
xintaofei
2026-04-12 18:11:40 +08:00
parent 883fb64db0
commit 843cf8df19
4 changed files with 77 additions and 15 deletions

View File

@@ -136,7 +136,9 @@ mod tauri_app {
.title(&entry.name)
.inner_size(1260.0, 860.0)
.min_inner_size(900.0, 600.0);
let _ = windows::apply_platform_window_style(builder).build();
if let Ok(w) = windows::apply_platform_window_style(builder).build() {
windows::post_window_setup(&w);
}
}
}
@@ -334,6 +336,7 @@ mod tauri_app {
windows::open_stash_window,
windows::open_push_window,
windows::open_project_boot_window,
windows::update_traffic_light_position,
project_boot::detect_package_manager,
project_boot::create_shadcn_project,
system_settings::get_system_proxy_settings,