Skip to content

Commit fac9659

Browse files
committed
fix TUI scrolling
Events must propagate as if we had the normal scrollView hierarchy
1 parent 123e151 commit fac9659

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

macos/Sources/Ghostty/SurfaceScrollView.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ class SurfaceScrollView: NSView {
4848
// We stack the surface view and scroll view as subviews of this view
4949
addSubview(surfaceView)
5050
addSubview(scrollView)
51+
52+
// In principle, surfaceView should have been a subview of
53+
// scrollView.contentView; however, we have to make it a direct subview
54+
// of this view to allow it to overlap with the scrollbar and draw a
55+
// background behind it, rather than being tiled next to it like the
56+
// contentView. However, we need events to propagate as if we had the
57+
// usual hierarchy, otherwise mouse scroll events wouldn't be passed
58+
// onto the terminal, so we wouldn't have scrolling in TUIs.
59+
nextResponder = scrollView
60+
scrollView.contentView.nextResponder = surfaceView
5161

5262
// Apply initial scrollbar settings
5363
synchronizeAppearance()
@@ -227,5 +237,8 @@ class SurfaceScrollView: NSView {
227237
// move the scrollbar.
228238
lastSentRow = Int(scrollbar.offset)
229239
}
240+
241+
// Always update our scrolled view with the latest dimensions
242+
scrollView.reflectScrolledClipView(scrollView.contentView)
230243
}
231244
}

0 commit comments

Comments
 (0)