10757 Commits

Author SHA1 Message Date
Qwerasd
8b9e6641f2 style(renderer): explicit result type
In case of future breaking changes to `options`
2025-06-20 15:48:44 -06:00
Qwerasd
3e7d64b5ce style(renderer): explicit empty error set for OpenGL init 2025-06-20 15:45:43 -06:00
Qwerasd
ea7a91e2ba style(renderer): explicit error sets 2025-06-20 15:18:41 -06:00
Qwerasd
9d00018f8b renderer: minimize initial size of GPU resources
These will all be resized anyway on the first frame, so there's no point
in preallocating sizes that will be too small.
2025-06-20 15:18:41 -06:00
Qwerasd
2f10caec8f renderer: clarify why SwapChain.defunct is required 2025-06-20 15:18:41 -06:00
Qwerasd
6b7d751007 renderer: make GraphicsAPI.swap_chain_count required 2025-06-20 15:18:41 -06:00
Qwerasd
dccbec2283 style(renderer): capture generic consts as decls in returned struct
Out of an abundance of caution, since there have been issues in the past
relating to consts outside of the returned struct.
2025-06-20 15:18:41 -06:00
Qwerasd
b9e35c5970 renderer: uncomment resize message handling
We need this to get info about the padding, even if we do derive the
grid and screen size separately.

In the future this should possibly be changed to a message that only
sends the padding info and nothing else.
2025-06-20 15:18:41 -06:00
Qwerasd
8b23e73d20 metal: retain IOSurfaceLayer ourselves instead of relying on the view
If this was Swift code, we'd be using a strong reference, which would
retain the layer for us and release it when the object is deallocated,
but this is Zig land so we have to do that manually.

NOTE: We don't *have* to do this, but it fits much better with Zig idiom
and hopefully avoids potential future footguns. We should do this to any
autoreleased objects that we persist a reference to in a Zig struct.
2025-06-20 15:18:41 -06:00
Qwerasd
e8460e80b2 docs: update info about runtime change of custom-shader
Also removes incorrect information about OpenGL requirement, since the
minimum required OpenGL is now unconditionally 4.3
2025-06-20 15:18:41 -06:00
Qwerasd
541bb0d4d9 fix window cross-compilation 2025-06-20 15:18:41 -06:00
Qwerasd
ea1e507af7 unwrap unnecessary @"" identifiers 2025-06-20 15:18:41 -06:00
Qwerasd
6dc5ae7a00 format (remove empty lines) 2025-06-20 15:18:41 -06:00
Qwerasd
ac2eef9aeb renderer: disable multi-buffering for OpenGL
Frames are sequential for OpenGL since the completion handler always
calls `glFinish`, so the extra buffers do nothing but waste memory.
2025-06-20 15:18:41 -06:00
Qwerasd
371d62a82c renderer: big rework, graphics API abstraction layers, unified logic
This commit is very large, representing about a month of work with many
interdependent changes that don't separate cleanly in to atomic commits.

The main change here is unifying the renderer logic to a single generic
renderer, implemented on top of an abstraction layer over OpenGL/Metal.

I'll write a more complete summary of the changes in the description of
the PR.
2025-06-20 15:18:41 -06:00
Qwerasd
521872442a vendor: update glad to OpenGL 4.3 2025-06-20 15:18:41 -06:00
Qwerasd
7cfc906c60 debug: properly set thread names on macOS 2025-06-20 15:18:41 -06:00
Qwerasd
77c050c156 refactor(Metal): make pipeline handling DRYer 2025-06-20 15:18:41 -06:00
Qwerasd
f40cd3cae3 chore: improve Metal API definitions a bit 2025-06-20 15:18:41 -06:00
Mitchell Hashimoto
f55c77bc81 build: Use correct SDK for iOS Simulator shader build (#7636)
This PR makes the build script use the correct SDK and version flag for
the iOS Simulator.

Without this PR, the terminal fails to initialize on the iOS Simulator:

```
Compiler failed to build request
metal error=Target OS is incompatible: library was not compiled for the simulator
error initializing surface err=error.MetalFailed
```


<details>
<summary>With the PR</summary>


![image](https://github.com/user-attachments/assets/13735334-1321-42d5-8f01-4d5f6a7660ba)
</details>

Fixes #7635.
2025-06-20 14:01:54 -07:00
Zhaofeng Li
fda08a6999 build: Use correct SDK for iOS Simulator shader build 2025-06-20 14:02:07 -06:00
Mário Victor Ribeiro Silva
b89cb59d79 translation(pt_BR): add missing translation 2025-06-20 10:23:10 -03:00
Mitchell Hashimoto
d0e145292e snap: vendor libgtk4-layer-shell.so (#7623)
vendor libgtk4-layer-shell.so to ensure it's available at runtime
regardless of host system.
2025-06-18 08:38:43 -07:00
Ken VanDine
7d2da23021 snap: vendor libgtk4-layer-shell.so 2025-06-18 10:06:35 -04:00
Mitchell Hashimoto
5a788bfa90 build: use xcrun --sdk <sdk> metal for metal paths (#7619)
This wasn't working before but it just requires a restart of the machine
for the changes to take effect. The namespace runners have this prebuilt
so this should work now.

The other workaround was flaky for unknown reasons so I'd prefer to go
back to this.
2025-06-17 16:36:43 -07:00
Mitchell Hashimoto
30a8ba1bf6 macos: disambiguate close tab vs close window for confirmation (#7618)
This fixes an issue where pressing the red close button in a window or
the "x" button on a tab couldn't differentiate and would always close
the tab or close the window (depending on tab counts).

It seems like in both cases, AppKit triggers the `windowShouldClose`
delegate method on the controller, but for the close window case it
triggers this on ALL the windows in the group, not just the one that was
clicked.

I implemented a kind of silly coordinator that debounces
`windowShouldClose` calls over 100ms and uses that to differentiate
between the two cases.
2025-06-17 16:24:46 -07:00
Mitchell Hashimoto
559fd92295 build: use xcrun --sdk <sdk> metal for metal paths
This wasn't working before but it just requires a restart of the machine
for the changes to take effect. The namespace runners have this prebuilt
so this should work now.

The other workaround was flaky for unknown reasons so I'd prefer to go
back to this.
2025-06-17 16:23:29 -07:00
Mitchell Hashimoto
51b9fa751a macos: disambiguate close tab vs close window for confirmation
This fixes an issue where pressing the red close button in a window or
the "x" button on a tab couldn't differentiate and would always close
the tab or close the window (depending on tab counts).

It seems like in both cases, AppKit triggers the `windowShouldClose`
delegate method on the controller, but for the close window case it
triggers this on ALL the windows in the group, not just the one
that was clicked.

I implemented a kind of silly coordinator that debounces
`windowShouldClose` calls over 100ms and uses that to differentiate
between the two cases.
2025-06-17 16:16:14 -07:00
Mitchell Hashimoto
7d01332574 macOS tip regression: Confirm close on window close (#7617)
Fixes #7615

We were incorrectly closing the window without confirmation when there
were no tabs.

This was part of the undo/redo PR.
2025-06-17 15:20:53 -07:00
Mitchell Hashimoto
e6c77789d3 macOS: Confirm close on window close
Fixes #7615

We were incorrectly closing the window without confirmation when there
were no tabs.
2025-06-17 15:03:10 -07:00
Mitchell Hashimoto
676d11fd06 ci: build macOS releases with Xcode 26 (#7616)
Resolves #7591

This moves our CI to build macOS on Sequoia (macOS 15) with Xcode 26,
including the new macOS 26 beta SDK. This includes tip releases. Stable
releases continue to use Xcode 15 and the stable SDK, in case we need to
make a release before macOS Tahoe is stable (though, if its late enough
in the cycle, we may even cut a full release with it).

Importantly, this will make our builds on macOS 26 use the new styling.

I've added a new job that ensures we can continue to build with Xcode 16
and the macOS 15 SDK, as well, although I think that might come to an
end when we switch over to an IconComposer-based icon. I'll verify then.
For now, we continue to support both.

I've also removed our `hasLiquidGlass` check, since this will now always
be true for macOS 26 builds.
2025-06-17 14:04:57 -07:00
Mitchell Hashimoto
6d283c012e ci: build macOS releases with Xcode 26
Resolves #7591

This moves our CI to build macOS on Sequoia (macOS 15) with Xcode 26,
including the new macOS 26 beta SDK.

Importantly, this will make our builds on macOS 26 use the new styling.

I've added a new job that ensures we can continue to build with Xcode 16 and
the macOS 15 SDK, as well, although I think that might come to an end
when we switch over to an IconComposer-based icon. I'll verify then. For
now, we continue to support both.

I've also removed our `hasLiquidGlass` check, since this will now always
be true for macOS 26 builds.
2025-06-17 13:44:13 -07:00
Mitchell Hashimoto
f794693bdc bash: remove dependency on $GHOSTTY_RESOURCES_DIR (#7611)
We were depending on $GHOSTTY_RESOURCES_DIR for two reasons:

1. To locate our script-adjacent bash-preexec.sh script
2. To restrict our script's execution to environments in which
$GHOSTTY_RESOURCES_DIR is available (i.e. Ghostty-only shells)

For (1), we can instead determine our directory using $BASH_SOURCE[0].
This is slightly differently than our previous behavior, where we'd
always load bash-preexec.sh from the $GHOSTTY_RESOURCES_DIR hierarchy,
even if ghostty.bash from source from somewhere else on the file system
... but we never relied on that behavior, even in development.

For (2), there's no harm in source'ing this script outside of Ghostty,
and if that does become a concern, we can restore this condition or use
something more targeted based on those specific cases.

Historically, I believe (2) was in place to enable (1), so addressing
(1) removes the need for (2).

And lastly, none of the other shell integration scripts depend on
$GHOSTTY_RESOURCES_DIR.
2025-06-17 06:48:54 -07:00
Jon Parise
b629f3337a bash: remove dependency on $GHOSTTY_RESOURCES_DIR
We were depending on $GHOSTTY_RESOURCES_DIR for two reasons:

1. To locate our script-adjacent bash-preexec.sh script
2. To restrict our script's execution to environments in which
   $GHOSTTY_RESOURCES_DIR is available (i.e. Ghostty-only shells)

For (1), we can instead determine our directory using $BASH_SOURCE[0].
This is slightly differently than our previous behavior, where we'd
always load bash-preexec.sh from the $GHOSTTY_RESOURCES_DIR hierarchy,
even if ghostty.bash from source from somewhere else on the file system
... but we never relied on that behavior, even in development.

For (2), there's no harm in source'ing this script outside of Ghostty,
and if that does become a concern, we can restore this condition or use
something more targeted based on those specific cases.

Historically, I believe (2) was in place to enable (1), so addressing
(1) removes the need for (2).

And lastly, none of the other shell integration scripts depend on
$GHOSTTY_RESOURCES_DIR.
2025-06-16 19:54:27 -04:00
Mitchell Hashimoto
d0f116da35 macOS: Basic Read-Only Accessibility Integration (#7601)
This integrates with macOS accessibility APIs to expose Ghostty terminal
structure and content.

This is a very, very bare implementation and the terminal contents
currently reported are the _full screen and scrollback_ which is way too
much for realistic human accessibility use. The target use case for this
PR is to enable automated tooling (namely, AI screen readers). However,
this is all groundwork we'll need to iterate and improve the
accessibility work anyways.

To make this work, I also replatformed some of our hacky C APIs onto a
more robust `ghostty_surface_read_text` API that can now read arbitrary
ranges of the screen into C strings for consumers to use. This will be
useful in more places going forward (hint hint).

## Before

Accessibility tooling can't read anything, Ghostty has no attributes, no
contents, just shows up as a square.

![CleanShot 2025-06-15 at 14 06
55@2x](https://github.com/user-attachments/assets/55eba1b4-6fd4-4d78-9434-5d672f374c67)

## After

A lot of metadata, including the screen contents as text.

![CleanShot 2025-06-15 at 14 07
25@2x](https://github.com/user-attachments/assets/e14cb7df-e4e2-4cc4-a214-004a8459f353)

Also, split hierarchies are navigable:



https://github.com/user-attachments/assets/a7b2ffb7-dbeb-41b2-8705-9c3200812c4d
2025-06-15 15:10:27 -07:00
Mitchell Hashimoto
a2b4a2c0e4 macos: complete more ax APIs for terminal accessibility 2025-06-15 14:00:39 -07:00
Mitchell Hashimoto
e69c756c89 macos: auto-expire cached screen contents 2025-06-15 13:55:06 -07:00
Mitchell Hashimoto
839d89f2dc macos: simple cache of screen contents for ax 2025-06-15 13:46:40 -07:00
Mitchell Hashimoto
e1ee180172 apprt/embedded: API to read text can get top left/bottom right coords 2025-06-15 13:06:38 -07:00
Mitchell Hashimoto
c5f921bb06 apprt/embedded: improve text reading APIs (selection, random points) 2025-06-15 07:59:19 -07:00
Mitchell Hashimoto
b46673e631 macos: Tahoe menu item icons, missed the "Ghostty" menu entirely (#7599)
This is a follow up to #7594, I missed an entire menu.
2025-06-15 07:57:11 -07:00
Mitchell Hashimoto
be437f5b64 macos: bare minimum terminal ax 2025-06-15 07:56:05 -07:00
Mitchell Hashimoto
c90eb2e952 macos: AX for debug warning 2025-06-15 07:56:05 -07:00
Mitchell Hashimoto
4237dad240 macOS: simple SplitView AX
Proper labels, action to move the divider
2025-06-15 07:56:05 -07:00
Mitchell Hashimoto
57c79fa357 macos: Tahoe menu item icons, missed the "Ghostty" menu entirely
This is a follow up to #7594, I missed an entire menu.
2025-06-15 07:48:20 -07:00
Mitchell Hashimoto
db28ab4340 macos 15 regression: transparent style shouldn't draw border (#7597)
This fixes a regression from our Tahoe window styling changes on
earlier, stable versions of macOS. We need to set
"titlebarAppearsTransparent" to true in order to hide the bottom border.
2025-06-15 06:57:05 -07:00
Mitchell Hashimoto
7cc7f6cb06 macos 15 regression: transparent style shouldn't draw border
This fixes a regression from our Tahoe window styling changes on
earlier, stable versions of macOS. We need to set 
"titlebarAppearsTransparent" to true in order to hide the bottom
border.
2025-06-15 06:51:11 -07:00
Mitchell Hashimoto
9e45da17d0 macos: menu item symbols for Tahoe (#7594)
This is recommended for macOS Tahoe and all standard menu items now have
associated images. This makes our app look more polished and native for
macOS Tahoe.

On earlier versions of macOS (macOS 15 and earlier), we _do not_ set the
menu item image. Cocoa has supported menu item images for a long time
but it isn't idiomatic to show them in earlier versions, so we only do
this for later macOS versions.

For icon choice, I tried to copy other native macOS apps as much as
possible, mostly from Xcode. It looks like a lot of apps aren't updated
yet. I'm absolutely open to suggestions for better icons but I think
these are a good starting point.

One menu change is I moved "reset font size" above "increase font size"
which better matches other apps (e.g. Terminal.app).


https://github.com/user-attachments/assets/50a68326-221f-454f-9a9c-078878010a63
2025-06-14 19:50:58 -07:00
Mitchell Hashimoto
202020cd7d macos: menu item symbols for Tahoe
This is recommended for macOS Tahoe and all standard menu items now have
associated images. This makes our app look more polished and native for
macOS Tahoe.

For icon choice, I tried to copy other native macOS apps as much as
possible, mostly from Xcode. It looks like a lot of apps aren't updated
yet. I'm absolutely open to suggestions for better icons but I think
these are a good starting point.

One menu change is I moved "reset font size" above "increase font size"
which better matches other apps (e.g. Terminal.app).
2025-06-14 19:44:24 -07:00
Mitchell Hashimoto
bfb1daffbe macos: set toolbar title isBordered to avoid glass view (#7593)
This was recommended by the WWDC25 session on AppKit updates. My hack
was not the right approach.
2025-06-14 15:04:49 -07:00