5818 Commits

Author SHA1 Message Date
Qwerasd
b1becb12c0 fix(Metal): handle non-extended padding color transparency
We were returning bg colors when we shouldn't have since when we have
background color transparency we need to return any bg color cells as
fully transparent rather than their actual color.
2025-01-15 18:08:11 -05:00
Mitchell Hashimoto
ff9414d9ea fix(macos): prevent transparency leakage/flash in new/resized surfaces (#5083)
Fixes #4516

By using the `CAMetalLayer`'s `backgroundColor` property instead of
drawing the background color in our shader, it is always stretched to
cover the full surface, even when live-resizing, and it doesn't require
us to draw a frame for it to be initialized so there's no transparent
flash when a new surface is created (as in a new split/tab).

This commit also allows for hot reload of `background-opacity`,
`window-vsync`, and `window-colorspace`.
2025-01-14 19:20:12 -08:00
Qwerasd
34abe2ceba fix(macos): prevent transparency leakage/flash in new/resized surfaces
By using the `CAMetalLayer`'s `backgroundColor` property instead of
drawing the background color in our shader, it is always stretched to
cover the full surface, even when live-resizing, and it doesn't require
us to draw a frame for it to be initialized so there's no transparent
flash when a new surface is created (as in a new split/tab).

This commit also allows for hot reload of `background-opacity`,
`window-vsync`, and `window-colorspace`.
2025-01-14 20:23:21 -05:00
Mitchell Hashimoto
f5670d81d4 config: fix window-decoration enum parsing to allow client, none 2025-01-14 15:40:52 -08:00
Michael Himing
08a0423b78 fix: building on systems with older adwaita 2025-01-15 08:33:48 +11:00
Leah Amelia Chen
4e0d9b1b27 gtk(wayland): implement server-side decorations 2025-01-14 09:57:59 -08:00
Mitchell Hashimoto
5081e65570 Metal alpha blending fixes + color handling improvements (#4913)
This PR addresses #2125 for the Metal renderer. Both options are
available: "Apple-style" blending where colors are blended in a wide
gamut color space, which reduces but does not eliminate artifacts; and
linear blending where colors are blended in linear RGB.

Because this doesn't add support for linear blending on Linux, I don't
know whether the issue should be closed or not.

### List of changes in no particular order
- We now set the layer's color space in the renderer not in the apprt
- We always set the layer to Display P3 color spaces
- If the user hasn't configured their `window-colorspace` to
`display-p3` then terminal colors are automatically converted from sRGB
to the corresponding Display P3 color in the shader
- Background color is not set with the clear color anymore, instead we
explicitly set all bg cell colors since this is needed for minimum
contrast to not break with dark text on the default bg color (try it
out, it forces it fully white right now), and we just draw the
background as a part of the bg cells shader. Note: We may want to move
the main background color to be the `backgroundColor` property on the
`CAMetalLayer`, because this should fix the flash of transparency during
startup (#4516) and the weirdness at the edge of the window when
resizing. I didn't make that a part of this PR because it requires
further changes and my changes are already pretty significant, but I can
make it a follow-up.
- Added a config option for changing alpha blending between "native"
blending, where colors are just blended directly in sRGB (or Display P3)
and linear blending, where colors are blended in linear space.
- Added a config option for an experimental technique that I think works
pretty well which compensates for the perceptual thinning and thickening
of dark and light text respectively when using linear blending.
- Custom shaders can now be hot reloaded with config reloads.
- Fixed a bug that was revealed when I changed how we handle
backgrounds, page widths weren't being set while cloning the screen.

### Main takeaways
Color blending now matches nearly identically to Apple apps like
Terminal.app and TextEdit, not *quite* identical in worst case
scenarios, off by the tiniest bit, because the default color space is
*slightly* different than Display P3.

Linear alpha blending is now available for mac users who prefer more
accurate color reproduction, and personally I think it looks very nice
with the alpha correction turned on, I will be daily driving that
configuration.

### Future work
- Handle primary background color with `CALayer.backgroundColor` instead
of in shader, to avoid issues around edges when resizing.
- Parse color space info directly from ICC profiles and compute the
color conversion matrix dynamically, and pass it as a uniform to the
shaders.
- Port linear blending option to OpenGL.
- Maybe support wide gamut images (right now all images are assumed to
be sRGB).
2025-01-13 14:12:37 -08:00
Mitchell Hashimoto
a8b9c5bea5 config: remove experimental linear and merge into text-blending 2025-01-13 13:59:37 -08:00
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
Qwerasd
fca336c32d Metal: blend in Display P3 color space, add option for linear blending
This commit is quite large because it's fairly interconnected and can't
be split up in a logical way. The main part of this commit is that alpha
blending is now always done in the Display P3 color space, and depending
on the configured `window-colorspace` colors will be converted from sRGB
or assumed to already be Display P3 colors. In addition, a config option
`text-blending` has been added which allows the user to configure linear
blending (AKA "gamma correction"). Linear alpha blending also applies to
images and makes custom shaders receive linear colors rather than sRGB.

In addition, an experimental option has been added which corrects linear
blending's tendency to make dark text look too thin and bright text look
too thick. Essentially it's a correction curve on the alpha channel that
depends on the luminance of the glyph being drawn.
2025-01-13 13:50:29 -08:00
Qwerasd
5cf7575967 fix(PageList): when cloning, explicitly set cols
Otherwise pages may have the wrong width if they were resized down with
a fast path that just chanes the size without adjusting capacity at all.
2025-01-13 13:50:29 -08: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
Mitchell Hashimoto
592efb4b97 terminal: keep track of colon vs semicolon state in CSI params (#5033)
Fixes #5022

The CSI SGR sequence (CSI m) is unique in that its the only CSI sequence
that allows colons as delimiters between some parameters, and the colon
vs. semicolon changes the semantics of the parameters.

Previously, Ghostty assumed that an SGR sequence was either all colons
or all semicolons, and would change its behavior based on the first
delimiter it encountered.

This is incorrect. It is perfectly valid for an SGR sequence to have
both colons and semicolons as delimiters. For example, Kakoune sends the
following:

    ;4:3;38;2;175;175;215;58:2::190:80:70m

This is equivalent to:

  - unset (0)
  - curly underline (4:3)
  - foreground color (38;2;175;175;215)
  - underline color (58:2::190:80:70)

This commit changes the behavior of Ghostty to track the delimiter per
parameter, rather than per sequence. It also updates the SGR parser to
be more robust and handle the various edge cases that can occur. Tests
were added for the new cases.
2025-01-13 13:00:28 -08:00
Mitchell Hashimoto
7aed08be40 terminal: keep track of colon vs semicolon state in CSI params
Fixes #5022

The CSI SGR sequence (CSI m) is unique in that its the only CSI sequence
that allows colons as delimiters between some parameters, and the colon
vs. semicolon changes the semantics of the parameters.

Previously, Ghostty assumed that an SGR sequence was either all colons
or all semicolons, and would change its behavior based on the first
delimiter it encountered.

This is incorrect. It is perfectly valid for an SGR sequence to have
both colons and semicolons as delimiters. For example, Kakoune sends
the following:

    ;4:3;38;2;175;175;215;58:2::190:80:70m

This is equivalent to:

  - unset (0)
  - curly underline (4:3)
  - foreground color (38;2;175;175;215)
  - underline color (58:2::190:80:70)

This commit changes the behavior of Ghostty to track the delimiter per
parameter, rather than per sequence. It also updates the SGR parser to
be more robust and handle the various edge cases that can occur. Tests
were added for the new cases.
2025-01-13 12:47:07 -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
Mitchell Hashimoto
caddf59db5 For GTK runtime, don't call cursorPosCallback if cursor pos didn't actually change. (#4973)
Fixes #3345

Piggybacking on the logic introduced PR
https://github.com/ghostty-org/ghostty/pull/3997, this patch prevents
mouse motion events with the same cursor position triggered by the
window title updating from un-hiding the mouse even when
`mouse-hide-while-typing` config item is true.
2025-01-12 07:21:39 -08:00
james
faea09bbde for GTK runtime, don't call cursorPosCallback in mouse motion callback if the cursor hasn't actually moved 2025-01-11 23:53:19 -05:00
Michael Himing
a3bb2df94f fix(gtk): fix segfault on ctrl-d on older adw 2025-01-12 14:46:05 +11:00
Mitchell Hashimoto
bdbd0263a1 Correct IME position calculation with window padding (#4949)
This PR addresses two IME-related issues:

1. Fix IME position calculation with window padding, fixed
https://github.com/ghostty-org/ghostty/issues/4933

- Add padding offset to IME position calculation to correctly position
the IME window
   
- This ensures IME window appears at the right position when
`window-padding-x/window-padding-y` are set

2. Clear selection when IME input starts

- Previously, when using CJK IME with text selected, the IME window
would appear near the selection
   
   - Now it clears selection and shows IME window at cursor position
   
   - This matches the behavior of iTerm2 and Terminal.app


## Before


https://github.com/user-attachments/assets/cd5c7b55-2083-40ce-a528-9a98898a6498

## After


https://github.com/user-attachments/assets/9f2c17c6-e885-45f3-9ab1-a9c3858690ec
2025-01-11 14:19:04 -08:00
Mitchell Hashimoto
6c5c5b2ec0 core: clear selection whenever preedit is changed 2025-01-11 14:06:42 -08:00
Damien Mehala
fc99c99b74 code review 2025-01-11 22:19:42 +01:00
Bryan Lee
af5e423ea5 Clear selection when IME input starts 2025-01-12 01:48:48 +08:00
Bryan Lee
2409d46600 Correct IME position calculation with window padding 2025-01-12 01:15:53 +08:00
Damien Mehala
95fc1d64c8 parse ConEmu OSC9;5 2025-01-11 17:24:13 +01: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
Jeffrey C. Ollie
0a26321e9d gtk: add some comments about closing the last tab invaldating self pointer 2025-01-10 19:19:11 -06:00
Jeffrey C. Ollie
16233b16e7 gtk: fix crash due to accessing invalidated pointer to adwaita notebook 2025-01-10 19:12:08 -06:00
Mitchell Hashimoto
00137c4189 apprt/gtk: adw tab view close confirmation 2025-01-10 15:32:32 -08:00
Leigh Oliver
8c1ad59de7 remove unnecessary struct 2025-01-10 15:05:11 -08:00
Leigh Oliver
b7b5b9bbf5 fix(gtk): add close confirmation for tabs 2025-01-10 15:05:11 -08:00
Mitchell Hashimoto
200aee9acf macos: rework toggle_visibility to better match iTerm2
Two major changes:

1. Hiding uses `NSApp.hide` which hides all windows, preserves tabs, and
   yields focus to the next app.

2. Unhiding manually tracks and brings forward only the windows we hid.
   Proper focus should be retained.
2025-01-10 14:40:02 -08:00
Jeffrey C. Ollie
96e427cd6a gtk: default to opengl debugging only on debug builds 2025-01-10 15:48:20 -06:00
Jeffrey C. Ollie
cd638588c4 gtk: better method for setting GDK env vars 2025-01-10 15:21:24 -06:00
Jeffrey C. Ollie
06a57842af gtk: add config option to control GSK_RENDERER env var 2025-01-10 15:21:24 -06:00
Jeffrey C. Ollie
13e96c7ec8 gtk: add config option to disable GTK OpenGL debug logging 2025-01-10 15:21:21 -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
Mitchell Hashimoto
96b3db0b8c docs: update copy-on-select documentation (#4909)
As per discussion in
https://github.com/ghostty-org/ghostty/discussions/4898, this updates
the docs for `copy-on-select` to correct the middle-click paste behavior
change as per https://github.com/ghostty-org/ghostty/pull/4733. I also
opted to remove the multiple "if supported by OS/ for supported systems"
statements since it's supported everywhere now, AFAIK.
2025-01-10 13:13:12 -08:00
Mitchell Hashimoto
e475560af0 vim: update configuration to include theme files (#4893)
Extends vim validation and file type detection to theme files

cc @gpanders @beaumccartney (as you were involved on the previous vim
PR)
2025-01-10 13:12:25 -08:00
Mitchell Hashimoto
d26c114b5d apprt/gtk: make sure noop winproto never initializes 2025-01-10 12:10:59 -08:00
Jeffrey C. Ollie
010f4d167d GTK: refactor headerbar into separate Adwaita & GTK structs 2025-01-10 13:46:29 -06:00
Mitchell Hashimoto
2f81c360bd ci: typos 2025-01-10 09:42:41 -08:00
Mitchell Hashimoto
ed81b62ec2 apprt/gtk: winproto
Rename "protocol" to "winproto".
2025-01-10 09:39:34 -08:00
Onno Siemens
19cfd99439 docs: update copy-on-select documentation 2025-01-10 18:11:57 +01:00
Anund
c03828e032 vim: work with theme config files 2025-01-11 02:45:47 +11:00
Leah Amelia Chen
405a897230 gtk(x11): implement background blur for KDE/KWin on X11 2025-01-09 14:57:02 -08:00
Leah Amelia Chen
03fee2ac33 gtk: unify Wayland and X11 platforms 2025-01-09 14:57:02 -08:00
Mitchell Hashimoto
6ef757a8f8 Revert "termio/exec: fix SIGPIPE crash when reader exits early"
This reverts commit 3e24e96af51fe308705a1f1695e3b9045c54482e.
2025-01-09 12:43:41 -08:00