Commit Graph

12112 Commits

Author SHA1 Message Date
Jeffrey C. Ollie
dd072d2e01 gtk-ng: add some initial notes on memory layout of GObjects 2025-08-18 09:20:40 -07:00
Jeffrey C. Ollie
f147a89b68 gtk-ng: use gitlab permalinks 2025-08-18 09:20:40 -07:00
Jeffrey C. Ollie
38e69b2e96 gtk-ng: use virtual methods to draw the inspector
Insead of signals between the ImGui widget and the Inspector widget,
make the Inspector widget a subclass of the ImGui widget and use virtual
methods to handle setup and rendering of the Inspector.
2025-08-18 09:20:40 -07:00
Mitchell Hashimoto
936577c581 Update iTerm2 colorschemes (#8259)
Upstream revision:
8b639f0c26
2025-08-18 09:15:47 -07:00
Leah Amelia Chen
0f7b559f0f gtk-ng: fix race condition when checking border bell feature (#8267) 2025-08-18 10:56:06 +08:00
Jeffrey C. Ollie
7f8d215955 gtk-ng: fix race condition when checking border bell feature
Fixes #8266

When a surface is first created, there's a race condition between when
the config is set on the surface and when the code to check if a border
should be drawn around the surface is run. Fix that by exiting early if
the bell isn't ringing, before we check to see if there's a config set
on the surface and issuing the warning message.
2025-08-17 21:32:39 -05:00
Mitchell Hashimoto
02a942cf72 deps: update z2d to 0.7.1 tagged release (#8265)
This release contains performance and memory use improvements.

Some of the sprite font test renders had to be updated due to very minor
differences in the anti-aliasing, since the default anti-aliasing method
in z2d has been changed to MSAA rather than SSAA.
2025-08-17 15:38:32 -07:00
Qwerasd
2a9ba56cdc deps: update z2d to 0.7.1 tagged release
This release contains performance and memory use improvements.

Some of the sprite font test renders had to be updated due to very minor
differences in the anti-aliasing, since the default anti-aliasing method
in z2d has been changed to MSAA rather than SSAA.
2025-08-17 14:00:20 -06:00
mitchellh
324d92ea31 deps: Update iTerm2 color schemes 2025-08-17 00:15:25 +00:00
Luzian Bieri
933543a0d2 refactor: extract clipboard setting logic into copySelectionToClipboards function 2025-08-15 23:20:43 +02:00
Qwerasd
11d56235f9 Fix use-after-free in font.Atlas.grow (#8249)
Grow needs to allocate and might fail midway. It tries to handle this
using "undo" pattern, and restoring old state on error. But this is
exactly what steps into UAF, as, on error, both errdefer and defer are
run, and the old data is freed.

Instead, use a more robust "reservation" pattern, where we first
fallibly resrve all the resources we need, without applying any changes,
and than do the actual change once we are sure that cannot fail.
2025-08-15 13:15:23 -06:00
Qwerasd
0d4e673366 font/Atlas: add test for OOM behavior of grow
Similar tests should be added throughout the codebase for any function
that's supposed to gracefully handle OOM conditions. This one was added
because grow previously had a use-after-free bug under OOM, which this
would have caught.
2025-08-15 12:49:09 -06:00
Qwerasd
37ebf212d5 font/Atlas: cleanup grow
Reordered to form a more logical sequence of steps, cleaned up and
clarified comments, fixed invalid `appendAssumeCapacity` call which
erroneously passed `alloc`, so this compiles again.
2025-08-15 12:26:01 -06:00
Leah Amelia Chen
4f3553af5b gtk-ng: set IM context's input-purpose as terminal (#8251) 2025-08-16 01:58:04 +08:00
Alex Kladov
4c4d3cfc3f fix UAF in grow
Grow needs to allocate and might fail midway. It tries to handle this
using "undo" pattern, and restoring old state on error. But this is
exactly what steps into UAF, as, on error, both errdefer and defer are
run, and the old data is freed.

Instead, use a more robust "reservation" pattern, where we first
fallibly resrve all the resources we need, without applying any changes,
and than do the actual change once we are sure that cannot fail.
2025-08-15 18:45:01 +01:00
Leah Amelia Chen
5d19b24776 gtk-ng: refactor CSD/SSD style class settings (#8250) 2025-08-16 01:39:24 +08:00
Leah Amelia Chen
ed603b07a5 gtk-ng: set IM context's input-purpose as terminal
See https://github.com/ghostty-org/ghostty/issues/7987#issuecomment-3187597026
2025-08-16 01:35:45 +08:00
Leah Amelia Chen
11ecb516d4 gtk-ng: refactor CSD/SSD style class settings
Fixes #8127
2025-08-16 01:19:18 +08:00
Mitchell Hashimoto
0930b2daff apprt/gtk-ng: actually handle color scheme events (#8248)
Fixes #8245

Verified behavior before and after, also tested under Valgrind (was
curious because of the config change).
2025-08-15 09:42:17 -07:00
Mitchell Hashimoto
4bcaac50f2 apprt/gtk-ng: actually handle color scheme events
Fixes #8245
2025-08-15 09:38:03 -07:00
Mitchell Hashimoto
ed9415c659 apprt/gtk-ng: respect window-inherit-working-directory=false (#8247)
Fixes #8244
2025-08-15 09:27:15 -07:00
Mitchell Hashimoto
997e013d7e apprt/gtk-ng: respect window-inherit-working-directory=false
Fixes #8244
2025-08-15 09:18:28 -07:00
Mitchell Hashimoto
5b4baee9fa renderer: don't assume non-zero sized grid (#8246)
Fixes #8243

This adds a check for a zero-sized grid in cursor-related functions.

As an alternate approach, I did look into simply skipping a bunch of
work on zero-sized grids, but that looked like a scarier change to make
now. That may be the better long-term solution but this was an easily
unit testable, focused fix on the crash to start.
2025-08-15 09:07:22 -07:00
Mitchell Hashimoto
30c95f3bbb ci: switch to debian 13 (#8238) 2025-08-15 09:01:44 -07:00
Mitchell Hashimoto
9ccc02b131 renderer: don't assume non-zero sized grid
Fixes #8243

This adds a check for a zero-sized grid in cursor-related functions.

As an alternate approach, I did look into simply skipping a bunch of
work on zero-sized grids, but that looked like a scarier change to make
now. That may be the better long-term solution but this was an easily
unit testable, focused fix on the crash to start.
2025-08-15 08:59:24 -07:00
Jeffrey C. Ollie
63869d8e37 ci: switch to debian 13 2025-08-14 22:42:26 -05:00
Mitchell Hashimoto
4e26bb65ae apprt/gtk-ng: implement maximize and fullscreen (#8236)
These fell through the cracks.
2025-08-14 15:06:50 -07:00
Mitchell Hashimoto
6b1dd3e441 apprt/gtk-ng: implement maximize and fullscreen
These fell through the cracks.
2025-08-14 15:01:03 -07:00
Mitchell Hashimoto
264dbf9e46 apprt: make gtk-ng the default apprt on Linux (#8235)
The journey to rewrite our legacy GTK backend to a full GObject-based
backend is complete! The full background and motivation can be found in
the original PR: #7961. ~75 PRs later, we've reached **full parity**
with the legacy GTK backend.

Throughout the process, we've tested every feature under Valgrind, and
this build is fully clean of memory leaks and undefined access. Its
impossible to test the existing GTK backend because its full of false
positives, but based on my experience working on `-ng`, I think its
impossible we got it right. This isn't a dig at any of our GTK subsystem
maintainers; I've simply found its very complicated to get all the
memory management behaviors right with GTK. There are subtle, easy to
miss, weakly documented things, such as [clearing weak refs on
dispose](7548dcfe63).[^1]
The point is, **gtk-ng is much higher quality than legacy.**

There is only regression we know of (#8208). I'm willing to swap the
default despite this because the improvements not just in memory safety
but also behavior: splits now support spatial navigation, better
equalization behavior, etc.

At this point, I think we should swap the default to see if we missed
anything else.

[^1]: This isn't a dig at Gnome developers either. Documenting these
details is hard, too.
2025-08-14 14:05:16 -07:00
Mitchell Hashimoto
a148adc5e4 apprt: make gtk-ng the default apprt on Linux 2025-08-14 12:43:15 -07:00
Mitchell Hashimoto
b7913f09ad gtk-ng: add a helper for creating GTK actions (#8228)
- Reduces boilerplate.
- Adds type safety.
- Adds comptime checks for action and group names which
  otherwise could cause panics at runtime.
2025-08-14 12:26:39 -07:00
Mitchell Hashimoto
4740242bb9 fix(renderer/generic): deinit render targets with framestate (#8234)
This was a memory leak under Metal, leaked 1 swapchain worth of targets
every time a surface was closed.

Under OpenGL I think it was all cleaned up when the GL context was
destroyed.
2025-08-14 11:52:48 -07:00
Qwerasd
add7f762a6 fix(renderer/generic): deinit render targets with framestate
This was a memory leak under Metal, leaked 1 swapchain worth of targets
every time a surface was closed.

Under OpenGL I think it was all cleaned up when the GL context was
destroyed.
2025-08-14 11:47:05 -06:00
Jeffrey C. Ollie
d251695fa2 gtk-ng: move actions helper to namespace 2025-08-14 12:23:14 -05:00
Jeffrey C. Ollie
0e3ec24d2c gtk-ng: use action helper in surface 2025-08-14 12:22:42 -05:00
Jeffrey C. Ollie
6b690e6b4e gtk-ng: use action helper in split-tree 2025-08-14 12:22:42 -05:00
Jeffrey C. Ollie
31c71c6c5a gtk-ng: use action helper in tab 2025-08-14 12:22:39 -05:00
Jeffrey C. Ollie
d66212dcce gtk-ng: use action helper in window 2025-08-14 12:21:52 -05:00
Jeffrey C. Ollie
a10b95f052 gtk-ng: use action helper in application 2025-08-14 12:21:51 -05:00
Jeffrey C. Ollie
96e252872f gtk-ng: add a helper for creating GTK actions
- Reduces boilerplate.
- Adds type safety.
- Adds comptime checks for action and group names which
  otherwise could cause panics at runtime.
2025-08-14 12:21:51 -05:00
Mitchell Hashimoto
000efba31c apprt/gtk-ng: clean up close handling of all types (#8233)
This cleans up our close handling of all types (surfaces, tabs,
windows). Surfaces no longer emit their scope; their scope is always
just the surface itself. For tab and window scope we use widget actions.

This makes `close_tab` work properly (previously broken).
2025-08-14 10:20:55 -07:00
Mitchell Hashimoto
83d1bdcfcb apprt/gtk-ng: clean up close handling of all types
This cleans up our close handling of all types (surfaces, tabs, windows).
Surfaces no longer emit their scope; their scope is always just the
surface itself. For tab and window scope we use widget actions.

This makes `close_tab` work properly (previously broken).
2025-08-14 10:07:28 -07:00
Mitchell Hashimoto
3eda14e2d6 gtk-ng: port the terminal inspector (#8212)
This is a (relatively) straightforward port of the terminal inspector
from the old GTK application runtime. It's split into three widgets. At
the lowest level is a widget designed for showing a generic Dear ImGui
application. Above that is a widget that embeds the ImGui widget and
plumbs it into the core Inspector. At the top is a custom Window widget
that embeds the Inspector widget.

And then there's all the plumbing necessary to hook everything into the
rest of Ghostty.

In theory this design _should_ allow showing the Inspector in a split or
a tab in the future, not just in a separate window. It should also make
it easier to display _other_ Dear ImGui applications if they are ever
needed.
2025-08-14 09:47:09 -07:00
Mitchell Hashimoto
68f337e398 apprt/gtk-ng: close inspector window when widget loses surface 2025-08-14 09:42:26 -07:00
Mitchell Hashimoto
7548dcfe63 apprt/gtk-ng: clear weakrefs on dispose 2025-08-14 09:31:14 -07:00
Mitchell Hashimoto
76d84ff35c valgrind supps 2025-08-14 09:27:14 -07:00
Mitchell Hashimoto
6280bd7a42 apprt/gtk-ng: far less control inspector complexity 2025-08-14 08:57:11 -07:00
Mitchell Hashimoto
3fc33089f3 apprt/gtk-ng: clean up a bunch of unused window stuff 2025-08-14 08:37:58 -07:00
Mitchell Hashimoto
48a65b05d0 apprt/gtk-ng: use a weak_ref on surface for inspector 2025-08-14 08:21:19 -07:00
Mitchell Hashimoto
43550c18c0 apprt/gtk-ng: imguiwidget uses signals instead of callbacks 2025-08-14 08:21:19 -07:00