Skip to content
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

gtk: add resize overlay #2071

Merged
merged 5 commits into from
Aug 10, 2024
Merged

gtk: add resize overlay #2071

merged 5 commits into from
Aug 10, 2024

Conversation

jcollie
Copy link
Member

@jcollie jcollie commented Aug 10, 2024

This adds a transient overlay that shows the size of the surface while you are resizing the window or the surfaces.

Screencast.from.2024-08-09.21-20-20.webm

This adds a transient overlay that shows the size of the surface
while you are resizing the window or the surfaces.
@neurocyte
Copy link
Contributor

I think the default should be resize-overlay = never. It's a nice feature, but I don't think most users care and it's a bit noisy to have on by default.

Also, it'd be nice to have the option to turn off pixel dimentions. Those are rarely interesting.

@jcollie
Copy link
Member Author

jcollie commented Aug 10, 2024

The other terminals that I've checked (admittedly not many) were a mixed bag. XTerm, Kitty, Gnome Console, Ptyxis have them on by default. Gnome Terminal didn't. Alacritty, Foot, and Wezterm didn't allow resizing the window by mouse and I was too lazy to figure out why or to look and see if they had a keybind for resizing the window.

So the default is really a matter of taste. I like having them on, but if there's a consensus to have them off by default I'm OK with that as I can easily change it on my config.

Having the pixel dimensions I thought was fun but I'm OK turning them off.

Copy link
Contributor

@mitchellh mitchellh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really awesome. I didn't dig into the GTK APIs but did a high level review with some requests but this is exciting to see!

@mitchellh
Copy link
Contributor

I think the default should be resize-overlay = never. It's a nice feature, but I don't think most users care and it's a bit noisy to have on by default.

I noted in my review I think it should be after-first. I think it is a bit noisy when every new window/tab/etc. shows it, but seeing it by default on physical resize events feels pretty typical in the terminals I've used and I do like it.

Change the default to `after-first` and change `resize-overlay-delay` →
`resize-overlay-duration`.
Keepin´ the code clean by gathering all of the resize overlay
related data and code into a struct.
// When updating a widget, do so from GTK's thread, but not if there's
// already an update queued up.
if (self.idler != null) return;
self.idler = c.g_idle_add(gtkUpdateOverlayWidget, @ptrCast(self));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this function only ever be called from the main GTK thread? Do we need this at all, can we call gtkUpdateOverlayWidget directly?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried that at first, but I got dozens of warnings being spit out by GTK while resizing and the overlay flickered horribly. Doing some searching indicated that it was caused because I was manipulating a GTK widget wrongly and putting the code behind g_idle_add was the way to fix it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's so interesting. I wonder if its because modifying a widget in the widget tree while its being actively resized is a bad idea...

@mitchellh mitchellh merged commit 451cf69 into ghostty-org:main Aug 10, 2024
5 of 7 checks passed
@mitchellh mitchellh deleted the resize-overlay branch August 10, 2024 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants