-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add scrollbar margin to surfaces #9291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't read the full thing yet, but I think we don't need to introduce a dedicated scroller width awareness into core. I'd rather allow the apprt to document "safe areas" similar to macOS and let the core reuse that concept. This would cover more than just one side (right) and allow padding any side.
Not exactly sure what that API looks like yet.
a7da61b to
fac9659
Compare
I take this back. Playing around I realize that by far the simplest way of keeping this in sync is use a sentinel value in the scrollbar state, EDIT: This can be done completely independently of this PR, so I submitted #9295 separately. |
740f478 to
fac9659
Compare
|
I factored out the pure bugfix part of this PR into #9296. Converting this to draft for now. |
421c61c to
176f737
Compare
|
OK, I've pushed a revised approach. Here are some key points, probably repeating a few things from earlier, but that way you don't have to scroll(!) back and reread.
The macOS app uses this API to make room for the legacy scroller overlaid on the surface. For this to work properly,
The solution is for Moving Naming is hard. Looking forward to the bikeshedding. Btw. this includes the fix from #9296 because it would conflict anyway. |
Fixes a bug described in #9291, where resizing an empty window causes the scrollbar to appear even though the window remains larger than the total content, because the relayouting fails to account for the change in padding around the cell grid. To reproduce the issue: 1. Enable legacy scrollbars (System Settings -> Appearance -> Show scroll bars -> Always) 2. Open Ghostty 3. Vertically resize the window to make it smaller. The scrollbar will pop up, and as you drag the window edge, it will cycle between a maximum offset and zero depending on how far the resize is from an integer multiple of the cell height. With this PR you'll still see the scrollbar flicker while resizing, but when you stop it will always disappear. Haven't figured out how to get rid of the flickering yet. I tried to condition various updates on the window not being in a live resize, but so far no luck.
176f737 to
30c59f9
Compare
|
Pushed a rebase after the #9296 merge |
52af597 to
05c31c2
Compare
05c31c2 to
f5f2a47
Compare



Alright, second attempt to fix #9248. This gives surfaces a right-hand margin that is distinct from padding, solely for keeping the terminal content out of the way of scrollbars. That way, the surface itself can fill the whole SurfaceScrollView and keep drawing the background behind the transparent scrollbar.
On the macOS app side, this means that
surfaceViewcannot be a child view ofdocumentView, since the latter is automatically resized to avoid overlap with the scrollbar. Instead,surfaceViewis now a direct subview of theSurfaceScrollView, stacked behindscrollView. This actually simplifies the scrollbar implementation quite a bit, since the origin of thesurfaceViewframe no longer has to change as we scroll, as it's relative to the fixedSurfaceScrollViewrather than the movingdocumentView. That means we no longer have to listen and synchronize to bounds changes on thecontentView. The only time we need to worry about thesurfaceViewframe is when there are layout changes.This also provides #9255 for free. It would be more work to condition the margin on whether the legacy scrollbar is visible or hidden.
Along the way, I fixed a bug where the layout recalculation wasn't taking into account the change of padding around the terminal grid when the surface is resized. This change must be reflected in the height of the
documentVieweven if the number of rows haven't changed, otherwise the scrollbar will pop up out of nowhere when resizing an empty surface (see #9241).Also committed some drive-by simplification of the padding math from #9241.
I hope this can be a step towards addressing the concern I voiced here: #9254 (reply in thread). Basically, I think the terminal/surface should ignore the scrollbar margin for the alternate screen (or, more generally, when max scrollback is zero). With this PR, all that could be done in the core without the macOS app's involvement. But that's a future PR.