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: rework Windows and menus #4952

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

jcollie
Copy link
Collaborator

@jcollie jcollie commented Jan 11, 2025

  1. Rework the GTK Window code to clean up the if/else spaghetti. This
    should fix issues with older versions of Adwaita getting the
    titlebar and tab bar out of order.
  2. Consolidate code for menus into one file and switch to using
    GtkPopupMenus built from GTK Builder XML files. This changes menus
    so that there is one per window and one per surface. This results
    in more memory usage, but more correct behavior. Previously context
    menus would pop up at the wrong location, due to not being attached
    to the correct GTK widget. Using GTK Builder XML files reduces the
    amount of code to create the menus and will make future changes to
    the menu structure easier.
  3. Add a "top menu" that can be shown/hidden with a keybind action.
    This will be useful for people that use SSD and thus don't have the
    hamburger menu from the title bar.

Screenshot From 2025-01-12 14-06-01
Screenshot From 2025-01-12 14-06-14

@jcollie jcollie force-pushed the gtk-there-can-be-only-one-menu branch 2 times, most recently from 6187ca0 to dfdb19a Compare January 13, 2025 22:27
@tristan957
Copy link
Collaborator

tristan957 commented Jan 13, 2025

I don't agree with the premise of this PR. I think we should continue to follow patterns established by other GTK/GNOME apps. "About Ghostty" is not useful in a context menu.

@unikitty37
Copy link

I don't agree with the premise of this PR. I think we should continue to follow patterns established by other GTK/GNOME apps. "About Ghostty" is not useful in a context menu.

It is if you have gtk-titlebar set to false and can't access the hamburger menu, though, as there doesn't seem to be any other way to get to it short of adding a keybinding, which is completely excessive :)

Leaving gtk-titlebar set to true makes Ghostty completely fail to fit in with any WM that isn't Gnome.

@tristan957
Copy link
Collaborator

Imo, this is not a good solution for that problem. We should instead use a GtkPopoverMenuBar for SSD people, which can be toggled in a similar way to Firefox.

@jcollie jcollie force-pushed the gtk-there-can-be-only-one-menu branch from dfdb19a to 164349c Compare January 14, 2025 19:27
@jcollie jcollie force-pushed the gtk-there-can-be-only-one-menu branch 2 times, most recently from 22f6eb4 to 0de2748 Compare January 14, 2025 22:18
@jcollie jcollie marked this pull request as draft January 15, 2025 14:31
@jcollie jcollie force-pushed the gtk-there-can-be-only-one-menu branch from a201b78 to 66e73c8 Compare January 15, 2025 19:35
mitchellh added a commit that referenced this pull request Jan 16, 2025
Compositors can actually tell us whether they want to use CSD or SSD!

(Ignore the context menu changes — they will most likely be unified
after #4952 anyway)
@jcollie jcollie force-pushed the gtk-there-can-be-only-one-menu branch from 66e73c8 to 27057eb Compare January 21, 2025 20:53
@jcollie jcollie changed the title gtk: there can be only one: menu gtk: rework Windows and menus Jan 21, 2025
@jcollie jcollie marked this pull request as ready for review January 21, 2025 21:02
@mitchellh
Copy link
Contributor

There is a lot I like in this PR, but there are some fundamental things I don't really like and want more discussion on.

Things I like:

  • Menu showing up in the right place
  • Cleaned up main menu i.e. supporting all split directions

Things I'm indifferent about (don't care either way):

  • Increased memory usage. Its probably small given the benefit.
  • GTK builder files.

Things I don't like:

  • The context menu and hamburger menu being the same. I don't think they serve the same purpose and long term I don't think it makes sense to always have those match. I also agree with @tristan957 that some times like "About Ghostty" are nonsense in the context menu.
  • The context menu is huge (number of items). I'd prefer to make it smaller. To address the non-titlebar people, I like our current approach of nesting a "Menu" submenu.
  • "Top menu" terminology. I don't know what a "top menu" is. Maybe it's common maybe it's not, but Googling at least didn't reveal a lot of usage. To me, there's really just a menu and a context menu. No need to introduce "top".

If we can discuss or address the "don't like" list then I'd be happy to head towards merging this.

@jcollie jcollie force-pushed the gtk-there-can-be-only-one-menu branch from 27057eb to 05c2b88 Compare January 25, 2025 04:01
@jcollie
Copy link
Collaborator Author

jcollie commented Jan 25, 2025

OK, I think that I've addressed all of the feedback so far. "Top bar" was an invention of mine because I couldn't think of anything else, renamed to just "menubar". The context menu is slimmed down. I've also added compile-time checks of
the GTK builder files so it should be much harder to crash Ghostty with an invalid or missing file.

I don't like the idea of embedding the hamburger menu in the context menu, as there's a lot of duplication. It would be much easier to have section(s) of the context menu that get show/hidden based on the state of the titlebar. Not sure what is really "needed" but IMHO that can be bikeshedded later. Since the menus are declared as XML rather than code it's pretty easy to update them.

Screenshot From 2025-01-24 21-36-12

1. Rework the GTK Window code to clean up the if/else spaghetti. This
   _should_ fix issues with older versions of Adwaita getting the
   titlebar and tab bar out of order.
2. Consolidate code for menus into one file and switch to using
   GtkPopupMenus built from GTK Builder XML files. This changes menus
   so that there is one per window and one per surface. This results
   in more memory usage, but more correct behavior. Previously context
   menus would pop up at the wrong location, due to not being attached
   to the correct GTK widget. Using GTK Builder XML files reduces the
   amount of code to create the menus and will make future changes to
   the menu structure easier.
3. Add a "top menu" that can be shown/hidden with a keybind action.
   This will be useful for people that use SSD and thus don't have the
   hamburger menu from the title bar.
1. "top menu" => "menubar"
2. Slimmed down context menu.
3. More robust compile time checks of GTK builder UI files.
@jcollie jcollie force-pushed the gtk-there-can-be-only-one-menu branch from fb9283f to 4cfb088 Compare January 25, 2025 19:01
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.

4 participants