fix(window): preserve fullscreen when adding project tabs (#2389)

Adding a project to a native macOS tab group anchored the group on the newly opened window, so AppKit took that window's normal frame and the group left full screen (black margins, stacked title bar and tab strip). Tab sync now anchors on the group's currently selected window and only selects the new tab. Verified on macOS with the system tab preference set to always and manual, in full screen and windowed: open, switch, close, merge and detach tabs. Fixes #2224.
Цей коміт міститься в:
l0ng-ai authored and GitHub committed 2026-11-10 00:53:59 +08:00
1 джерело 29af5994e3
коміт 4126822be8
2 files changed
+14 -6

No files matched your search

+12 -5
Переглянути файл
@@ -83,16 +83,23 @@ fn same_group(a: &NSWindow, b: &NSWindow) -> bool {
}
}
/// Puts `members` in one native tab group and shows `selected`.
pub fn sync_tab_group(members: Vec<WebviewWindow>, selected: &WebviewWindow) -> tauri::Result<()> {
/// Adds `members` to the existing anchor's native tab group and shows `selected`.
pub fn sync_tab_group(
members: Vec<WebviewWindow>,
anchor: &WebviewWindow,
selected: &WebviewWindow,
) -> tauri::Result<()> {
let anchor = anchor.clone();
let target = selected.clone();
on_main(selected, move || {
let Some(shown) = native(&target) else { return };
for member in members.iter().filter(|m| m.label() != target.label()) {
let Some(anchor_window) = native(&anchor) else { return };
// Joining into a new tab's desktop window would take the existing group out of full screen.
for member in members.iter().filter(|m| m.label() != anchor.label()) {
if let Some(window) = native(member)
&& !same_group(shown, window)
&& !same_group(anchor_window, window)
{
shown.addTabbedWindow_ordered(window, objc2_app_kit::NSWindowOrderingMode::Above);
anchor_window.addTabbedWindow_ordered(window, objc2_app_kit::NSWindowOrderingMode::Above);
}
}
if let Some(group) = shown.tabGroup() {
+2 -1
Переглянути файл
@@ -100,8 +100,9 @@ pub fn select(app: &AppHandle, caller: &str, target: &str) -> IdeResult<()> {
#[cfg(target_os = "macos")]
fn native_select(app: &AppHandle, group: &Group, to: &WebviewWindow) -> IdeResult<()> {
let members = group.members.iter().filter_map(|m| app.get_webview_window(m)).collect();
let anchor = app.get_webview_window(&group.selected).unwrap_or_else(|| to.clone());
to.unminimize().map_err(|e| IdeError::internal(e.to_string()))?;
crate::macos::sync_tab_group(members, to).map_err(|e| IdeError::internal(e.to_string()))
crate::macos::sync_tab_group(members, &anchor, to).map_err(|e| IdeError::internal(e.to_string()))
}
#[cfg(target_os = "macos")]