181 Commits

Author SHA1 Message Date
Jeffrey C. Ollie
f24d70b7ec gtk: add config entry to hide titlebar when the window is maximized
Fixes #3381

Note that #4936 will need to be merged or you'll need to rely on Gnome's
default keybinding for unmaximizing a window (super+down).
2025-01-13 15:53:20 -06:00
Mitchell Hashimoto
844f20d01f Handle setting _NET_WM_STATE (#4936)
As recommended in
https://github.com/ghostty-org/ghostty/pull/4927#issuecomment-2585003934,
adds a config option `maximize` for starting a window in a maximized
state in terms of window properties. Also adds a `toggle_maximize`
keybind to allow users to manually toggle this feature on and off.

It might make more sense to make this an optional config value so that
we don't toggle the state off if the WM already handles that for us, but
I'll let a reviewer decide.

Closes https://github.com/ghostty-org/ghostty/issues/4646
2025-01-13 13:14:31 -08:00
Mitchell Hashimoto
e3ced14393 fix(window): ensure last_tab action on linux navigates to last tab (#5004)
Previously, the logic navigated to the second-to-last tab instead of the
last tab due to an off-by-one error. This updates the implementation so
that the index calculation to accurately target the last tab. In the
`gotoLastTab` method there was a decrement in the number of max number
of tabs and another increment in the `goToTab` method to get the actual
tab index.
2025-01-13 13:12:49 -08:00
Jeffrey C. Ollie
7ac017b154 gtk: hide titlebar if fullscreened
Partially addresses #3381
2025-01-12 19:34:20 -06:00
Pavlos Karakalidis
5cd990bec5 fix(window): ensure last_tab action on linux navigates to last tab
Previously, the logic navigated to the second-to-last tab instead of the
last tab due to an off-by-one error. This updates the implementation so
that the index calculation to accurately target the last tab.
In the `gotoLastTab` method there was a decrement in the number of max
number of tabs and another increment in the `goToTab` method to get the
actual tab index.
2025-01-12 23:48:15 +02:00
Adam Wolf
c9636598fc chore: rename config value to maximize and move startup logic to proper location 2025-01-10 23:24:00 -06:00
Adam Wolf
8102fddceb apprt/gtk: add toggle_maximize keybind and window-maximize config option 2025-01-10 22:42:41 -06:00
Mitchell Hashimoto
c4ece2a141 GTK: refactor headerbar into separate Adwaita & GTK structs (#4850)
There's one behavioral change here. Before this patch, if
`gtk-titlebar=false` we _never_ created a headerbar. This explicitly
contradicted the comments in the source, and the documentation for
`gtk-titlebar` imply that if a window starts out without a titlebar it
can be brought back later with the `toggle_window_decorations` keybind
action.

After this patch, a headerbar is always created, but if
`gtk-titlebar=false` or `window-decoration=false` it's immediately
hidden.

I'm not sure how this interacts with the current SSD/CSD detection that
seems to happen when running Ghostty on non-Gnome DEs so it'll be
important to get #4724 merged (plus any follow ups) to enable more
explicit control of SSD/CSD.
2025-01-10 13:14:39 -08:00
Jeffrey C. Ollie
010f4d167d GTK: refactor headerbar into separate Adwaita & GTK structs 2025-01-10 13:46:29 -06:00
Mitchell Hashimoto
ed81b62ec2 apprt/gtk: winproto
Rename "protocol" to "winproto".
2025-01-10 09:39:34 -08:00
Leah Amelia Chen
03fee2ac33 gtk: unify Wayland and X11 platforms 2025-01-09 14:57:02 -08:00
Ismael Arias
ae81edfcbf feat(gtk): show menu in context menu if titlebar is disabled 2025-01-09 12:50:49 +01:00
Mitchell Hashimoto
34a0b206f8 apprt/gtk: use a subtitle to mark the current working directory (#3570)
If the title is already the current working directory, hide the
subtitle. Otherwise show the current working directory, like if a
command is running for instance.

This is a re-opening of my original PR because I had to delete my fork
and re-fork it.
2025-01-08 10:10:19 -08:00
Tristan Partin
c71da8338b apprt/gtk: continue cleanup of window-decoration code
Remove all window corner artifacting. Now we also respond to changes
when the window becomes decorated or not.

Signed-off-by: Tristan Partin <tristan@partin.io>
2025-01-06 17:44:05 -06:00
Tristan Partin
3698b37588 apprt/gtk: use a subtitle to mark the current working directory
If the title is already the current working directory, hide the
subtitle. Otherwise show the current working directory, like if
a command is running for instance.

Signed-off-by: Tristan Partin <tristan@partin.io>
2025-01-06 08:05:24 -06:00
Mitchell Hashimoto
bb83a14d7a config: minor config changes 2025-01-05 12:35:50 -08:00
Leah Amelia Chen
f2c357a209 config: allow booleans for background-blur-radius 2025-01-05 12:27:11 -08:00
Leah Amelia Chen
cd90821b93 fix(gtk): adjust background CSS class dynamically on config reload
Currently the `background` CSS class is added once on startup and never removed
or re-added. This is problematic as that if Ghostty was started with an opaque
window but then its config was reloaded with a `background-opacity` less than 1,
the window won't actually become translucent, and it would only appear as if the
background colors had become faded (because the window is still styled to be
opaque).
2025-01-05 12:27:11 -08:00
Leah Amelia Chen
9184395cba gtk(wayland): add support for background blur on KDE Plasma 2025-01-05 12:27:11 -08:00
Leah Amelia Chen
31439f311d build: add wayland 2025-01-05 12:27:11 -08:00
Tim Culverhouse
4d4b785a58 gtk: send copy_to_clipboard toast from Surface
Move the toast we send when copying to the clipboard to the Surface
implementation. Previously, we only called this from the gtk accelerator
callback which we only call when the *last set* keybind is activated.

We also only send a toast if we have copied to the standard clipboard,
as opposed to the selection clipboard. By default, we have
copy-to-clipboard true for linux, which sets the selection keyboard on
any select. This becomes *very* noisy.
2025-01-05 09:25:47 -06:00
Jeffrey C. Ollie
51c42795fc gtk: enable window-title-font-family 2025-01-04 20:20:52 -08:00
Jeffrey C. Ollie
a0de1be65f gtk: fix non-notebook separator colors 2025-01-02 17:49:15 -06:00
Mitchell Hashimoto
fb8c83e07c config: change toast config to packed struct 2025-01-02 14:15:16 -08:00
Yotam Gurfinkel
e6bb1a56eb config: Add the option toast_on_clipboard_copy
Add a config option to enable/disable the toast shown on clipboard copy
2025-01-02 14:09:29 -08:00
Jeffrey C. Ollie
0778c67429 gtk: refactor gtk & adw notebook implementations
Put GTK and libadwaita notebook implementations into separate structs/
files for clarity.
2025-01-02 15:21:11 -06:00
Jeffrey C. Ollie
f97f7e8a70 gtk: also add css window-decorated class when toggling window decorations 2024-12-30 19:40:13 -06:00
Jeffrey C. Ollie
220d40e99a gtk: make sure that window-decoration is honored on all paths 2024-12-30 16:10:14 -06:00
Jeffrey C. Ollie
ffe1b7a872 gtk: don't use gtk_window_set_titlebar if adwaita is enabled but it's older than 1.4.0 2024-12-30 14:44:56 -06:00
Mitchell Hashimoto
a7c93cdfb1 apprt/gtk: fix the combination of gtk-titlebar=false and gtk-tabs-location=hidden (#3957)
Fixes: #3178
2024-12-30 08:55:22 -08:00
Tristan Partin
31c9a2fe59 apprt/gtk: make window-decoration=false with gtk-titlebar=true look better
Before this change, there seemed to be some artifacting in the window
corners due to the window border no longer outlining the content
properly. By detecting the situation, we can turn the window border
radius off.

Signed-off-by: Tristan Partin <tristan@partin.io>
2024-12-29 22:57:48 -06:00
Tristan Partin
0fd65035c5 apprt/gtk: fix the combination of gtk-titlebar=false and gtk-tabs-location=hidden
Fixes: #3178
Signed-off-by: Tristan Partin <tristan@partin.io>
2024-12-29 22:12:37 -06:00
Tristan Partin
7256ebe13d apprt/gtk: fix website link in about window 2024-12-29 16:47:44 -06:00
Tristan Partin
27ddc2a9b2 apprt/gtk: create the tab overview even if gtk-titlebar=false
self.isAdwWindow() obscures that check a bit.

Signed-off-by: Tristan Partin <tristan@partin.io>
2024-12-29 14:45:45 -06:00
Jeffrey C. Ollie
8ecb11a602 gtk: add option to not link against libX11 2024-12-28 13:40:17 -06:00
Iain H
19e8651247 apprt/gtk: move new tab button to start of header bar
According to the GNOME human interface guidelines, buttons for the main
user actions, such as new, add, open, and back should be placed at the
start of the header bar. (https://developer.gnome.org/hig/patterns/containers/header-bars.html#header-bar-buttons)

Moving the new tab button to the start of the header bar brings Ghostty
in line with other GNOME applications such as gedit and gnome-terminal.
2024-12-23 11:48:22 -05:00
Mitchell Hashimoto
fdd330d22d apprt/gtk: stylistic changes 2024-12-15 14:01:10 -08:00
Tristan Partin
98380f3c42 apprt/gtk: abstract AdwHeaderBar and GtkHeaderBar
This will make further changes a little bit more readable.

Signed-off-by: Tristan Partin <tristan@partin.io>
2024-12-15 14:01:10 -08:00
Mitchell Hashimoto
fc6357ac70 apprt/gtk: slight style feedback 2024-12-15 13:54:06 -08:00
Tristan Partin
06ba06cfd0 apprt/gtk: unify tooltip text with AdwTabButton
AdwTabButton uses "View Open Tabs."

Signed-off-by: Tristan Partin <tristan@partin.io>
2024-12-14 12:40:11 -06:00
Tristan Partin
73bb2bb9bc apprt/gtk: add gtk-tabs-location=hidden
This is only supported on libadwaita. Instead of the normal tab overview
button, we will use an AdwTabButton[0].

Link: https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.6/class.TabButton.html [0]
Signed-off-by: Tristan Partin <tristan@partin.io>
2024-12-14 12:40:11 -06:00
Mitchell Hashimoto
b9345e8d6a try to abstract bundle ID to a zig file 2024-11-25 16:11:02 -08:00
Jeffrey C. Ollie
6d8cf55040 gtk: use correct function to destroy window
adw_application_window_destroy and gtk_application_window_destroy do not
exist. I believe that this didn't trigger a compile error because the
errdefer got compiled out because there are no potential error returns
after this code in the function.
2024-11-01 10:33:18 -05:00
Mitchell Hashimoto
28751ae5b8 Merge pull request #2485 from axdank/move_current_Tab
gui: add move_current_tab action
2024-10-25 14:15:16 -07:00
axdank
520dda65cb apply review changes 2024-10-25 08:07:11 -03:00
Mitchell Hashimoto
a793ad2f0d gtk: make goto_tab go to last tab if too large 2024-10-24 20:01:15 -07:00
axdank
465d60def8 gui: add move_current_tab action 2024-10-24 00:01:54 -03:00
Mitchell Hashimoto
c614f2b485 apprt/gtk: use stackfallback for runtime CSS, explicit errors 2024-10-16 06:19:47 -07:00
Jeffrey C. Ollie
ca42b4ca1c gtk: use CSS variables and color calcs introduced in 4.16
This takes advantage of CSS variables and color expressions to improve
the `window-theme=ghostty` support. The only visibile difference from
the previous implementation is that the header bar will darken if the
Ghostty window is in the background, which is standard for GTK apps.

This is conditional at runtime. If Ghostty detects that you're running
against GTK 4.16 or newer it will use the CSS variables and color calcs.
If you're running against older versions it will use CSS classes to
achieve nearly the same effect.
2024-10-14 18:24:05 -05:00
Mitchell Hashimoto
862bdcb92a apprt/gtk: adw about dialog introduces in libadw 1.5.0
Fixes #2433
2024-10-12 09:35:09 -07:00