10644 Commits

Author SHA1 Message Date
dependabot[bot]
037d4732a6 build(deps): bump namespacelabs/nscloud-cache-action from 1.2.7 to 1.2.8
Bumps [namespacelabs/nscloud-cache-action](https://github.com/namespacelabs/nscloud-cache-action) from 1.2.7 to 1.2.8.
- [Release notes](https://github.com/namespacelabs/nscloud-cache-action/releases)
- [Commits](https://github.com/namespacelabs/nscloud-cache-action/compare/v1.2.7...v1.2.8)

---
updated-dependencies:
- dependency-name: namespacelabs/nscloud-cache-action
  dependency-version: 1.2.8
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-04 00:46:01 +00:00
Leorize
4e39144d39 gtk/TabView: do not closeTab within close-page signal handler
`TabView` assumes to be the sole owner of all `Tab`s within a Window.
As such, it could close the managed `Window` once all tabs are removed
from its widget.

However, during `AdwTabView::close-page` signal triggered by libadwaita,
the `Tab` to be closed will gain an another reference for the duration
of the signal, breaking `TabView.closeTab` (called via
`Tab.closeWithConfirmation`) assumptions that having no tabs meant they
are all destroyed.

This commit solves the issue by scheduling `Tab.closeWithConfirmation`
to be run after `AdwTabView::close-page` signal has finished processing.
2025-06-03 03:19:13 -05:00
Leah Amelia Chen
108fab11a5 gtk/GlobalShortcuts: don't request session with no shortcuts (#7510) 2025-06-03 09:22:20 +02:00
Mitchell Hashimoto
d993588263 flatpak: rename .Devel variant to .ghostty-debug (#7511)
This is done to match against the default application id when Ghostty is
built using debug configuration, preparing the Flatpak version for D-Bus
activation support (#7433).
2025-06-02 20:09:16 -07:00
Leorize
1183ac8972 flatpak: rename .Devel variant to .ghostty-debug
This is done to match against the default application id when Ghostty is
built using debug configuration, done to prepare the Flatpak version for
D-Bus activation support.
2025-06-02 21:11:58 -05:00
Leorize
58cece07f0 gtk/GlobalShortcuts: don't request session with no shortcuts
There aren't any reason to pay the D-Bus tax if you don't use global
shortcuts.
2025-06-02 20:55:04 -05:00
Jon Parise
652f551bec macos: simplify some ServiceProvider code
First, remove the always-inlined openTerminalFromPasteboard code and
combine it with openTerminal. Now that we're doing a bit of work inside
openTerminal, there's little better to having an intermediate, inlined
function.

Second, combine some type-casting operations (saving a .map() call).

Lastly, adjust some variable names because a generic `objs` or `urls`
was a little ambiguous now that we're all in one function scope.
2025-06-02 20:11:18 -04:00
Mitchell Hashimoto
aa6c349545 macos: fix small memory leak in surface tree when closing splits (#7507)
This fixes a small memory leak I found where the `SplitNode.Leaf` was
not being deinitialized properly when closing a split. It would get
deinitialized the next time a split was made or the window was closed,
so the leak wasn't big. The surface view underneath the split was also
properly deinitialized because we forced it, so again, the leak was
quite small.

But conceptually this is a big problem, because when we change the
surface tree we expect the deinit chain to propagate properly through
the whole thing, _including_ to the SurfaceView.

This fixes that by removing the `id(node)` call. I don't find this to be
necessary anymore. I don't know when that happened but we've changed
quite a lot in our split system since it was introduced. I'm also not
100% sure why the `id(node)` was causing a strong reference to begin
with... which bothers me a bit.

AI note: While I manually hunted this down, I started up Claude Code and
Codex in separate tabs to also hunt for the memory leak. They both
failed to find it and offered solutions that didn't work.
2025-06-02 14:50:02 -07:00
Mitchell Hashimoto
d1f1be8833 macos: fix small memory leak in surface tree when closing splits
This fixes a small memory leak I found where the `SplitNode.Leaf` was
not being deinitialized properly when closing a split. It would get
deinitialized the next time a split was made or the window was closed,
so the leak wasn't big. The surface view underneath the split was also
properly deinitialized because we forced it, so again, the leak was
quite small.

But conceptually this is a big problem, because when we change the
surface tree we expect the deinit chain to propagate properly through
the whole thing, _including_ to the SurfaceView.

This fixes that by removing the `id(node)` call. I don't find this to be
necessary anymore. I don't know when that happened but we've changed
quite a lot in our split system since it was introduced. I'm also not
100% sure why the `id(node)` was causing a strong reference to begin
with... which bothers me a bit.

AI note: While I manually hunted this down, I started up Claude Code and
Codex in separate tabs to also hunt for the memory leak. They both
failed to find it and offered solutions that didn't work.
2025-06-02 14:12:26 -07:00
Mitchell Hashimoto
957ddd00dd Follow-up to #7462: var -> let (#7505)
Just a quick follow-up to #7462: I noticed Swift was admonishing me
about a `var` that could be a `let`, and realized that it was I who had
failed to make that change. Apologies for the noise.
2025-06-02 12:16:41 -07:00
Daniel Wennberg
5244f8d6ac Follow-up to #7462: var -> let 2025-06-02 10:14:52 -07:00
Daniel Wennberg
232a46d2dc Add option to hide macOS traffic lights 2025-06-02 09:22:01 -07:00
Mitchell Hashimoto
3638916819 Enable reset zoom button when macos-titlebar-style = tabs and only one tab (#7502)
This is the conversion of #7496 into a PR. The problem was discussed in
#3288: When `macos-titlebar-style = tabs`, the reset zoom button doesn't
appear with only a single tab, i.e., no tab bar.

This fix was simply to remove an unnecessary branch, as the titlebar
style doesn't make any difference for the required logic. If the tab bar
is visible, you should unconditionally hide the titlebar's button and
rely on the per-tab buttons. If the tab bar is not visible, you should
hide or show the titlebar button depending on `surfaceIsZoomed`.

One wrinkle was that the main toolbar title started showing on top of
the tabs. Turns out it was previously not showing only because it would
always be pushed into the hidden overflow menu. With the reset zoom
button present (either hidden or visible, but always there), this no
longer happens reliably, presumably due to some cascading change in the
overflow calculations. In any case, it seems brittle to rely on this way
of concealing the main title, so I added a few lines of code to properly
hide it when the tab bar is visible.

Screenshots:
![Screenshot 2025-06-01 at 15 42
37](https://github.com/user-attachments/assets/893ba88e-a7e0-4d2f-8d08-45af4a2ba11b)
![Screenshot 2025-06-01 at 15 42
51](https://github.com/user-attachments/assets/f45db556-15a9-4655-96df-c41a34a80ec2)
![Screenshot 2025-06-01 at 15 42
58](https://github.com/user-attachments/assets/645cfe42-014c-4259-afd4-489b8ccdb311)
2025-06-02 09:18:09 -07:00
Daniel Wennberg
12a01c0460 Hide main title when covered by tabs 2025-06-02 09:10:22 -07:00
Daniel Wennberg
85beda9c49 Fix reset zoom button visibility in macOS "tabs" mode when no tabs 2025-06-02 09:09:04 -07:00
Mitchell Hashimoto
70a3d9e895 config: add launched-from to specify launch source (#7503)
Related to #7433

This extracts our "launched from desktop" logic into a config option.
The default value is detection using the same logic as before, but now
this can be overridden by the user.

This also adds the systemd and dbus activation sources from #7433.

There are a number of reasons why we decided to do this:

1. It automatically gets us caching since the configuration is only
loaded once (per reload, a rare occurrence).

2. It allows us to override the logic when testing. Previously, we had
to do more complex environment faking to get the same behavior.

3. It forces exhaustive switches in any desktop handling code, which
will make it easier to ensure valid behaviors if we introduce new launch
sources (as we are in #7433).

4. It lowers code complexity since callsites don't need to have N
`launchedFromX()` checks and can use a single value.
2025-06-02 09:07:28 -07:00
Mitchell Hashimoto
5306e7cf56 config: add launched-from to specify launch source
Related to #7433

This extracts our "launched from desktop" logic into a config option.
The default value is detection using the same logic as before, but now
this can be overridden by the user.

This also adds the systemd and dbus activation sources from #7433.

There are a number of reasons why we decided to do this:

  1. It automatically gets us caching since the configuration is only
     loaded once (per reload, a rare occurrence).

  2. It allows us to override the logic when testing. Previously, we
     had to do more complex environment faking to get the same
     behavior.

  3. It forces exhaustive switches in any desktop handling code, which
     will make it easier to ensure valid behaviors if we introduce new
     launch sources (as we are in #7433).

  4. It lowers code complexity since callsites don't need to have N
     `launchedFromX()` checks and can use a single value.
2025-06-02 08:45:02 -07:00
Leah Amelia Chen
1ff9162598 gtk(wayland,x11): refactors (#7485) 2025-05-31 08:17:11 +02:00
Mitchell Hashimoto
7e85ca3a16 gtk: clean up per-surface cgroup on close (#7487)
Fixes #6766

This ensures that during surface deinit the cgroup is removed. By the
time the surface is deinitialized, the subprocess should already be dead
so the cgroup can be safely removed. If the cgroup cannot be removed for
any reason we log a warning.

I'm still investigating whether we also need to remove the transient
cgroup we create per app but that's a lot less noisy since app startup
and shutdown is a lot more rare.
2025-05-30 19:32:32 -07:00
Mitchell Hashimoto
2b9e781933 gtk: clean up per-surface cgroup on close
Fixes #6766

This ensures that during surface deinit the cgroup is removed. By the
time the surface is deinitialized, the subprocess should already be
dead so the cgroup can be safely removed. If the cgroup cannot be
removed for any reason we log a warning.
2025-05-30 19:31:04 -07:00
Mitchell Hashimoto
84aa359984 font: rework coretext discovery sorting (#7483)
This should make the sorting more robust to fonts with questionable
metadata or atypical style names.

I was originally just going to change the scoring slightly to account
for fonts whose regular italic style is named "Regular Italic" - which
previously resulted in the Bold Italic or Thin Italic style being chosen
instead because they're shorter names, but I decided to do some better
inspection of the metadata and looser style name matching while I was
changing code here anyway.

Also adds a unit test to verify the sorting works correctly, though a
more comprehensive set of tests may be desirable in the future.

(Feel free to make any changes to the PR you feel necessary before
merging while I'm gone over the weekend.)
2025-05-30 19:30:19 -07:00
Mitchell Hashimoto
6e69893f29 font/sprite: rework yQuads and friends for better alignment with draw_block (#7488)
This improves "outer edge" alignment of octants and other elements drawn
using `yQuads` and friends with blocks drawn with `draw_block` -- this
should guarantee alignment along a continuous edge, but may result in a
1px overlap of opposing edges (such as a top half block followed by a
bottom half block with an odd cell height, they will both have the
center row filled).

This is very necessary since several block elements are needed to
complete the set of octants, since dedicated octant characters aren't
included when they would be redundant.

Fixes #7479 

<details>
<summary><b><code>Box.ppm</code> diff</b></summary>


![image](https://github.com/user-attachments/assets/aea667fd-446f-4b60-a220-cdd636093d05)

</details>

> [!NOTE]
> In the future I think we should have a unified single source of truth
for grid positions (divisions of the cell) to ensure this type of thing
can't happen with other characters, and also it would make a lot of the
code cleaner. For now this works though.
2025-05-30 19:29:45 -07:00
Qwerasd
dd670f5107 font/sprite: rework yQuads and friends for better alignment with draw_block
This improves "outer edge" alignment of octants and other elements drawn
using `yQuads` and friends with blocks drawn with `draw_block` -- this
should guarantee alignment along a continuous edge, but may result in a
1px overlap of opposing edges (such as a top half block followed by a
bottom half block with an odd cell height, they will both have the
center row filled).

This is very necessary since several block elements are needed to
complete the set of octants, since dedicated octant characters aren't
included when they would be redundant.
2025-05-30 17:53:52 -06:00
Mitchell Hashimoto
5667b83328 macos: quick terminal can equalize splits (#7486)
Fixes #7480

I regret to inform the haters that an AI agent did this while I was out
getting a coffee. I only had to follow up once to ask it rename the
method to be more idiomatic. I absolutely didn't need AI to do this, but
I was leaving the office _anyways_ and figured why not. Got back and it
was done. What a time to be alive.
2025-05-30 15:24:04 -07:00
Mitchell Hashimoto
fd7132db71 macos: quick terminal can equalize splits
Fixes #7480
2025-05-30 15:13:30 -07:00
Leah Amelia Chen
f99c988b27 gtk(wayland): automatically bind globals 2025-05-30 23:42:48 +02:00
Leah Amelia Chen
9ded668819 gtk(wayland,x11): remove even more redundant checks 2025-05-30 23:42:42 +02:00
Leah Amelia Chen
157f50e2de gtk: request user attention on bell (#7482)
I'm not sure if this should be enabled by default like the tab
animation, but on KDE at least this is unintrusive enough for me to
always enable by default. Alacritty appears to agree with me as well.

Fixes #7124
2025-05-30 23:33:12 +02:00
Qwerasd
34f08a450e font: rework coretext discovery sorting
This should make the sorting more robust to fonts with questionable
metadata or atypical style names.

I was originally just going to change the scoring slightly to account
for fonts whose regular italic style is named "Regular Italic" - which
previously resulted in the Bold Italic or Thin Italic style being chosen
instead because they're shorter names, but I decided to do some better
inspection of the metadata and looser style name matching while I was
changing code here anyway.

Also adds a unit test to verify the sorting works correctly, though a
more comprehensive set of tests may be desirable in the future.
2025-05-30 15:27:39 -06:00
Mitchell Hashimoto
445d88346d config: more robust handling of font-family overwrite for CLI args (#7484)
Fixes #7481

We unfortunately don't have a great way to unit test this since our
logic relies on argv and I'm too lazy to extract it out right now.

The core issue is that we previously detected if font-families changed
by comparing lengths. This doesn't work because the CLI args can reset
and add families back to a lesser length. This caused an integer
overflow.

We can fix this by not being clever and introducing the overwrite logic
directly into the config type. I unit tested that.
2025-05-30 14:26:56 -07:00
Mitchell Hashimoto
8be5a78585 config: more robust handling of font-family overwrite for CLI args
Fixes #7481

We unfortunately don't have a great way to unit test this since our
logic relies on argv and I'm too lazy to extract it out right now.

The core issue is that we previously detected if font-families changed
by comparing lengths. This doesn't work because the CLI args can reset
and add families back to a lesser length. This caused an integer
overflow.

We can fix this by not being clever and introducing the overwrite logic
directly into the config type. I unit tested that.
2025-05-30 14:15:24 -07:00
Leah Amelia Chen
bdcbb9fd42 gtk(wayland): customize keyboard interactivity for quick terminal (#7477)
Fixes #7476
2025-05-30 22:50:56 +02:00
Leah Amelia Chen
90f431005b gtk: request user attention on bell
I'm not sure if this should be enabled by default like the tab
animation, but on KDE at least this is unintrusive enough for me to
always enable by default. Alacritty appears to agree with me as well.
2025-05-30 22:43:07 +02:00
Mitchell Hashimoto
2ad86cde69 OSC: allow multiple set/reset/report operations per OSC (#7429) 2025-05-30 13:16:57 -07:00
Leah Amelia Chen
6959fa8438 gtk(wayland): explicitly set layer name
Even though gtk4-layer-shell's documentation claims that "nobody quite
knows what it's for", some compositors (like Niri) can define custom
rules based on the layer name and it's beneficial in those cases to
define a distinct name just for our quick terminals.
2025-05-30 19:26:18 +02:00
Leah Amelia Chen
dee7c835de gtk(wayland): remove redundant check 2025-05-30 19:26:18 +02:00
Leah Amelia Chen
71a1ece7e9 gtk(wayland): gtk4-layer-shell -> layer-shell
It was getting a bit too unwieldy.
2025-05-30 19:26:18 +02:00
Leah Amelia Chen
6fac355363 gtk(wayland): fallback when on-demand mode isn't supported
This shouldn't be a real problem anymore since as of now (May 2025)
all major compositors support at least version 4, but let's do this
just in case.
2025-05-30 19:26:18 +02:00
Leah Amelia Chen
4d18c06804 gtk(wayland): customize keyboard interactivity for quick terminal
Fixes #7476
2025-05-30 19:26:11 +02:00
Mitchell Hashimoto
2f88b3bcfa GTK: add action to show the GTK inspector (#7468)
The default keybinds for showing the GTK inspector (`ctrl+shift+i` and
`ctrl+shift+d`) don't work reliably in Ghostty due to the way Ghostty
handles input. You can show the GTK inspector by setting the environment
variable `GTK_DEBUG` to `interactive` before starting Ghostty but that's
not always convenient.

This adds a keybind action that will show the GTK inspector. Due to API
limitations toggling the GTK inspector using the keybind action is
impractical because GTK does not provide a convenient API to determine
if the GTK inspector is already showing. Thus we limit ourselves to
strictly showing the GTK inspector. To close the GTK inspector the user
must click the close button on the GTK inspector window. If the GTK
inspector window is already visible but is hidden, calling the keybind
action will not bring the GTK inspector window to the front.
2025-05-30 07:13:34 -07:00
Mitchell Hashimoto
c4088f0c73 terminal: bring alt screen behaviors much closer in line with xterm (#7471)
This brings the behavior of mode 47, 1047, and 1049 much closer to
xterm's behavior. I found that our prior implementation had many
deficiencies.

For example, we weren't properly copying the cursor state back to the
primary screen from the alternate screen for modes 47 and 1047. And we
weren't saving/restoring cursor state unconditionally for mode 1049 even
if we were already in the alternate screen.

I also found that we were dangling hyperlink state on the primary screen
when we switched to alternate. xterm doesn't support hyperlinks but we
did the opposite behavior for going from alternate to primary. So one
way or the other its a bug. I'm worried this one could've maybe led to
memory corruption under the right circumstances but I wasn't able to
prove it.

These are weird, edgy behaviors that I don't think anyone expected
(evidence by there being no bug reports about them), but they are bugs
nontheless.

Many tests added.

(Btw: this flew under the radar of our "xterm audit" because that only
included sequences and not modes. I noted this in the audit issue itself
but just an FYI.)
2025-05-29 20:33:40 -07:00
Mitchell Hashimoto
9b45638c15 input: "ignore" binding action are still be processed by the OS/GUI (#7474)
Related to #7468

This changes the behavior of "ignore". Previously, Ghostty would
consider "ignore" actions consumed but do nothing. They were like a
black hole. Now, Ghostty returns `ignored` which lets the apprt forward
the event to the OS/GUI.

This enables keys that would otherwise be pty-encoded to be processed
later, such as for GTK to show the GTK inspector.
2025-05-29 16:34:03 -07:00
Mitchell Hashimoto
891b23917b input: "ignore" binding action are still be processed by the OS/GUI
Related to #7468

This changes the behavior of "ignore". Previously, Ghostty would
consider "ignore" actions consumed but do nothing. They were like a
black hole. Now, Ghostty returns `ignored` which lets the apprt forward
the event to the OS/GUI.

This enables keys that would otherwise be pty-encoded to be processed
later, such as for GTK to show the GTK inspector.
2025-05-29 16:03:03 -07:00
Mitchell Hashimoto
c5e5d61438 terminal: bring alt screen behaviors much closer in line with xterm
This brings the behavior of mode 47, 1047, and 1049 much closer to
xterm's behavior. I found that our prior implementation had many
deficiencies.

For example, we weren't properly copying the cursor state back to the
primary screen from the alternate screen for modes 47 and 1047. And we
weren't saving/restoring cursor state unconditionally for mode 1049 even
if we were already in the alternate screen.

These are weird, edgy behaviors that I don't think anyone expected
(evidence by there being no bug reports about them), but they are bugs
nontheless.

Many tests added.
2025-05-29 15:43:27 -07:00
Mitchell Hashimoto
d94bcda778 build: use a libc txt file to point to correct Apple SDK (#7469)
This fixes an issue where Ghostty would not build against the macOS 15.5
SDK.

What was happening was that Zig was adding its embedded libc paths to
the clang command line, which included old headers that were
incompatible with the latest (macOS 15.5) SDK. Ghostty was adding the
newer paths but they were being overridden by the embedded libc paths.

The reason this was happening is because Zig was using its own logic to
find the libc paths and this was colliding with the paths we were
setting manually. To fix this, we now use a `libc.txt` file that
explicitly tells Zig where to find libc, and we base this on our own SDK
search logic.
2025-05-29 15:20:42 -07:00
Mitchell Hashimoto
0f1860f066 build: use a libc txt file to point to correct Apple SDK
This fixes an issue where Ghostty would not build against the macOS 15.5 SDK.

What was happening was that Zig was adding its embedded libc paths to
the clang command line, which included old headers that were
incompatible with the latest (macOS 15.5) SDK. Ghostty was adding the
newer paths but they were being overridden by the embedded libc paths.

The reason this was happening is because Zig was using its own logic to
find the libc paths and this was colliding with the paths we were
setting manually. To fix this, we now use a `libc.txt` file that
explicitly tells Zig where to find libc, and we base this on our own SDK
search logic.
2025-05-29 15:04:05 -07:00
Jeffrey C. Ollie
d3cb6d0d41 GTK: add action to show the GTK inspector
The default keybinds for showing the GTK inspector (`ctrl+shift+i` and
`ctrl+shift+d`) don't work reliably in Ghostty due to the way Ghostty
handles input. You can show the GTK inspector by setting the environment
variable `GTK_DEBUG` to `interactive` before starting Ghostty but that's
not always convenient.

This adds a keybind action that will show the GTK inspector. Due to
API limitations toggling the GTK inspector using the keybind action is
impractical because GTK does not provide a convenient API to determine
if the GTK inspector is already showing. Thus we limit ourselves to
strictly showing the GTK inspector. To close the GTK inspector the user
must click the close button on the GTK inspector window. If the GTK
inspector window is already visible but is hidden, calling the keybind
action will not bring the GTK inspector window to the front.
2025-05-29 16:07:57 -05:00
Jeffrey C. Ollie
1104993c94 OSC: move some processing back inside the OSC state machine 2025-05-29 11:37:09 -05:00
Jeffrey C. Ollie
f0fc82c80f OSC: account for 32-bit systems in comptime Command size check 2025-05-29 11:37:09 -05:00
Jeffrey C. Ollie
5fb32fd8a0 OSC: add comptime check for size of OSC Command 2025-05-29 11:37:09 -05:00