macOS: fix render_thread "stuck" after dragging surface to another tab within the same window

The reason the thread is stuck is because the surface's occlusion state is set to invisible after target tab's activate while dragging, since the dragged surface is still in previous tree before dropping, and after dropping the occlusion state of this surface is not updated to visible, which causing the surface is accepting input but not rendering.
This commit is contained in:
Lukas
2026-04-19 23:13:40 +02:00
parent 366c34831a
commit 2c6dd59406
2 changed files with 13 additions and 1 deletions

View File

@@ -292,6 +292,7 @@ class BaseTerminalController: NSWindowController,
if to.isEmpty {
focusedSurface = nil
}
syncSurfaceTreeOcclusionState()
}
/// Update all surfaces with the focus state. This ensures that libghostty has an accurate view about
@@ -1256,10 +1257,15 @@ class BaseTerminalController: NSWindowController,
}
func windowDidChangeOcclusionState(_ notification: Notification) {
syncSurfaceTreeOcclusionState()
}
private func syncSurfaceTreeOcclusionState() {
let visible = self.window?.occlusionState.contains(.visible) ?? false
for view in surfaceTree {
if let surface = view.surface {
if let surface = view.surface, view.isWindowVisible != visible {
ghostty_surface_set_occlusion(surface, visible)
view.isWindowVisible = visible
}
}
}

View File

@@ -89,6 +89,12 @@ extension Ghostty {
// Whether the cursor is currently visible (not hidden by typing, etc.)
@Published private(set) var cursorVisible: Bool = true
/// Whether the belonging window is visible
///
/// We track this to restore surface occlusion state
/// after this surface is dragged to another window
var isWindowVisible = false
/// The configuration derived from the Ghostty config so we don't need to rely on references.
@Published private(set) var derivedConfig: DerivedConfig