Skip to content

Commit 2c6dd59

Browse files
committed
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.
1 parent 366c348 commit 2c6dd59

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

macos/Sources/Features/Terminal/BaseTerminalController.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ class BaseTerminalController: NSWindowController,
292292
if to.isEmpty {
293293
focusedSurface = nil
294294
}
295+
syncSurfaceTreeOcclusionState()
295296
}
296297

297298
/// Update all surfaces with the focus state. This ensures that libghostty has an accurate view about
@@ -1256,10 +1257,15 @@ class BaseTerminalController: NSWindowController,
12561257
}
12571258

12581259
func windowDidChangeOcclusionState(_ notification: Notification) {
1260+
syncSurfaceTreeOcclusionState()
1261+
}
1262+
1263+
private func syncSurfaceTreeOcclusionState() {
12591264
let visible = self.window?.occlusionState.contains(.visible) ?? false
12601265
for view in surfaceTree {
1261-
if let surface = view.surface {
1266+
if let surface = view.surface, view.isWindowVisible != visible {
12621267
ghostty_surface_set_occlusion(surface, visible)
1268+
view.isWindowVisible = visible
12631269
}
12641270
}
12651271
}

macos/Sources/Ghostty/Surface View/SurfaceView_AppKit.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ extension Ghostty {
8989
// Whether the cursor is currently visible (not hidden by typing, etc.)
9090
@Published private(set) var cursorVisible: Bool = true
9191

92+
/// Whether the belonging window is visible
93+
///
94+
/// We track this to restore surface occlusion state
95+
/// after this surface is dragged to another window
96+
var isWindowVisible = false
97+
9298
/// The configuration derived from the Ghostty config so we don't need to rely on references.
9399
@Published private(set) var derivedConfig: DerivedConfig
94100

0 commit comments

Comments
 (0)