5828 Commits

Author SHA1 Message Date
Mitchell Hashimoto
abafb81a1b apprt/gtk: update app color scheme state
Fixes #2781

This commit contains two separate changes but very related:

1. We update the color scheme state of the app on app start. This is
   necessary so that the configuration properly reflects the conditional
   state of the theme at the app level (i.e. the window headerbar).

2. We take ownership of the new config when it changes, matching macOS.
   This ensures that things like our GTK headerbar update when the theme
   changes but more generally whenever any config changes.

And some housekeeping:

- We remove runtime CSS setup from init. We can do it on the first tick
  of `run` instead. This will probably save some CPU cycles especially
  when we're just notifying a single instance to create a new window.

- I moved dbus event setup to `run` as well. We don't need to know these
  events unless we're actually running the app. Similar to the above,
  should save some CPU time on single instance runs.
2024-11-26 19:13:36 -08:00
Mitchell Hashimoto
a482224da8 renderer: set QoS class of the renderer thread on macOS
This sets the macOS QoS class of the renderer thread. Apple
recommends[1] that all threads should have a QoS class set, and there
are many benefits[2] to that, mainly around power management moreso than
performance I'd expect.

In this commit, I start by setting the QoS class of the renderer thread.
By default, the renderer thread is set to user interactive, because it
is a UI thread after all. But under some conditions we downgrade:

  - If the surface is not visible at all (i.e. another window is fully
    covering it or its minimized), we set the QoS class to utility. This
    is lower than the default, previous QoS and should help macOS
    unschedule the workload or move it to a different core.

  - If the surface is visible but not focused, we set the QoS class to
    user initiated. This is lower than user interactive but higher than
    default. The renderer should remain responsive but not consume as
    much time as it would if it was user interactive.

I'm unable to see any noticable difference in anything from these
changes. Unfortunately it doesn't seem like Apple provides good tools to
play around with this.

We should continue to apply QoS classes to our other threads on macOS.

[1]: https://developer.apple.com/documentation/apple-silicon/tuning-your-code-s-performance-for-apple-silicon?preferredLanguage=occl
[2]: https://blog.xoria.org/macos-tips-threading/
2024-11-26 15:43:35 -08:00
Mitchell Hashimoto
2e939b617e config: clone should copy diagnostics
Fixes #2800
2024-11-26 15:13:32 -08:00
Mitchell Hashimoto
e20b27de84 terminal: eraseChars was checking wide char split boundary on wrong cell
Fixes #2817

The test is pretty explanatory. I also renamed `end` to `count` since I
think this poor naming was the reason for the bug. In `eraseChars`, the
`count` (nee `end`) is the number of cells to erase, not the index of
the last cell to erase.
2024-11-26 14:29:58 -08:00
Mitchell Hashimoto
204c5796a7 Merge pull request #2825 from StratusFearMe21/gtk-startup
Prevent GTK from initializing Vulkan. This improves startup time
2024-11-26 13:24:16 -08:00
Mitchell Hashimoto
e3621e81b7 apprt/gtk: use proper env var for vulkan disable on <= 4.14 2024-11-26 13:18:05 -08:00
Mitchell Hashimoto
9171cb5c29 config: implement clone for RepeatableLink
Fixes #2819
2024-11-26 10:50:13 -08:00
Isaac Mills
39fbd7db4b Prevent GTK from initializing Vulkan. This improves startup time 2024-11-26 11:10:00 -07:00
Gregory Anders
2cbc2833d1 termio: fixes to kitty color reporting
The kitty color report response is an OSC, not a CSI, so change `[` to
`]`. Colors which are unset should be reported with `{key}=`.
2024-11-26 09:01:31 -06:00
Mitchell Hashimoto
518f8b1048 Merge pull request #2797 from kyswtn/application-support-dir
Support loading config from "Application Support" directory on macOS
2024-11-25 16:15:59 -08:00
Mitchell Hashimoto
b9345e8d6a try to abstract bundle ID to a zig file 2024-11-25 16:11:02 -08:00
Mitchell Hashimoto
adc59be977 os: more error handling on reading the app support dir 2024-11-25 16:04:41 -08:00
Mitchell Hashimoto
a39aa7e89d apprt/gtk: only show config reload toast if app config changes
This resolves the toast showing up every time the surface config changes
which can be relatively frequent under certain circumstances such as
theme changes.
2024-11-25 15:13:23 -08:00
Mitchell Hashimoto
6c615046ba config: only change conditional state if there are relevant changes
Related to #2775

This makes it so that `changeConditionalState` only does something if
the conditional state (1) has changes and (2) those changes are relevant
to the current conditional state.

By "relevant" we mean that the conditional state being changed is state
that is actually used by the configuration.
2024-11-25 13:55:16 -08:00
Mitchell Hashimoto
4c2d462000 Merge pull request #2796 from anmolw/fish-completions-themes
Strip theme location in fish completions
2024-11-24 09:44:56 -08:00
Kyaw
10e37a3dee config: support loading from "Application Support" directory on macOS 2024-11-24 17:08:07 +07:00
Anmol Wadhwani
2d3709f354 Strip theme location in fish completions
Co-authored-by: trag1c <trag1cdev@yahoo.com>
2024-11-24 12:11:41 +05:30
Gregory Anders
4042041b61 termio: track whether fg/bg color is explicitly set
Make the foreground_color and background_color fields in the Terminal
struct optional values so that we can determine if a foreground or
background color was explicitly set with an OSC 10 or OSC 11 sequence.
This makes the logic a bit simpler to reason about (i.e.
`foreground_color` is now always "the color set by an OSC 10 sequence"
while `default_foreground_color` is always "the color set by the config
file") and also fixes an issue where an OSC 10 or OSC 11 query would not
report the correct color after a config update changed the foreground or
background color.

The `cursor_color` field was already optional, with the same semantics
(it is only non-null when explicitly set with an OSC 12) so this brings
all three of these fields into alignment.
2024-11-23 19:48:24 -06:00
Mitchell Hashimoto
e031eb17f4 config: clone() needs to preserve conditionals of replay steps
Fixes #2791

This goes back to the previous implementation of clone that directly
cloned values rather than using replay steps, because replay steps don't
preserve conditionals on the iterator.

This works.

Another fix will be when we support some sort of conditional syntax and
the replay iterator can yield that information. We have a unit test here
so we can verify that then.
2024-11-23 15:22:05 -08:00
Mitchell Hashimoto
f7e1d0b83b apprt/embedded: update our cached config on config_change action
Fixes #2784
2024-11-23 10:22:11 -08:00
Mitchell Hashimoto
dca3cd7c10 Merge pull request #2788 from ghostty-org/push-rxpmmzxptqwt
surface needs to preserve original config working-directory
2024-11-23 10:05:16 -08:00
Mitchell Hashimoto
2b30186259 surface needs to preserve original config working-directory
Fixes #2785
2024-11-23 09:54:19 -08:00
Mitchell Hashimoto
6658aae21f Merge pull request #2771 from ghostty-org/push-quwzwysosskr
mode 2031 should send updates on any color palette change
2024-11-23 09:53:53 -08:00
Mitchell Hashimoto
70cc2d9793 termio: copy input command to avoid memory corruption
Fixes #2779
2024-11-23 09:40:18 -08:00
Mitchell Hashimoto
1e16f30309 config: clone must preserve conditional state
This fixes an issue where once the app config is updated, it'd revert
back to the default state.
2024-11-22 20:02:35 -08:00
Mitchell Hashimoto
b04f31f5c6 config: clone() should run the replay steps
This preserves replay steps for future use. Previously, clone copied
values but failed to copy the replay steps.
2024-11-22 15:10:44 -08:00
Mitchell Hashimoto
cd49015243 App applies conditional state, supports theme setting
The prior light/dark mode awareness work works on surface-level APIs. As
a result, configurations used at the app-level (such as split divider
colors, inactive split opacity, etc.) are not aware of the current theme
configurations and default to the "light" theme.

This commit adds APIs to specify app-level color scheme changes. This
changes the configuration for the app and sets the default conditional
state to use that new theme. This latter point makes it so that future
surfaces use the correct theme on load rather than requiring some apprt
event loop ticks. Some users have already reported a short "flicker" to
load the correct theme, so this should help alleviate that.
2024-11-22 14:08:35 -08:00
Mitchell Hashimoto
1c6adf4065 mode 2031 should send updates on any color palette change
Related #2755

From the mode 2031 spec[1]:

> Send CSI ? 2031 h to the terminal to enable unsolicited DSR (device status
> report) messages for color palette updates and CSI ? 2031 l respectively to
> disable it again.
>
> The sent out DSR looks equivalent to the already above mentioned. This
> notification is not just sent when dark/light mode has been changed by the
> operating system / desktop, but also if the user explicitly changed color
> scheme, e.g. by configuration.

My reading of this paired with the original discussion is that this is
meant to be sent out for anything that could possibly change terminal
colors.

Previous to this commit, we only sent out the DSR when the actual system
light/dark mode changed. This commit changes it to send out the DSR on
any operation that _may_ change the terminal colors.

[1]: https://contour-terminal.org/vt-extensions/color-palette-update-notifications/#example-source-code
2024-11-22 13:14:12 -08:00
Mitchell Hashimoto
f20b20bd6a apprt/gtk: fix build 2024-11-22 11:52:34 -08:00
Mitchell Hashimoto
00c62708d3 apprt: remove change conditional state action 2024-11-22 11:52:34 -08:00
Mitchell Hashimoto
266e4781fb apprt/gtk: update for new reload config API 2024-11-22 11:52:34 -08:00
Mitchell Hashimoto
0a794addf1 apprt/glfw: update to new reload config action 2024-11-22 11:52:34 -08:00
Mitchell Hashimoto
a191f3c396 apprt: switch to reload_config action that calls update_config API 2024-11-22 11:52:34 -08:00
Mitchell Hashimoto
6371af0d8e config: need to apply window-theme for light/dark after loading theme 2024-11-22 11:52:34 -08:00
Mitchell Hashimoto
7bae9e1d20 Merge pull request #2768 from ghostty-org/push-pzzwlvwumwpq
config: fix invalid memory access on theme loading
2024-11-22 09:48:08 -08:00
Mitchell Hashimoto
048d4c80dc Merge pull request #2765 from trag1c/doc-proxy-icon
docs: include valid values for `macos-titlebar-proxy-icon`
2024-11-22 09:46:01 -08:00
Mitchell Hashimoto
e53eb9bd6f config: fix invalid memory access on theme loading
Fixes GHOSTTY-1X in Sentry

The comment explains.
2024-11-22 09:45:32 -08:00
Vincent Prigent
96bda270a2 Add two edge cases to the url regex 2024-11-22 22:57:45 +13:00
trag1c
03f06431a7 docs: include valid values for macos-titlebar-proxy-icon 2024-11-22 01:07:56 +01:00
Mitchell Hashimoto
36a57826a6 macos: only color the titlebar of surfaces that border the top 2024-11-21 14:07:39 -08:00
Mitchell Hashimoto
f722e30bf5 macos: terminal controller reacts to surface config changes 2024-11-21 12:46:46 -08:00
Mitchell Hashimoto
037d4364e5 config: C API ghostty_config_clone 2024-11-21 10:41:48 -08:00
Mitchell Hashimoto
fadfb08efe apprt: add config_change action 2024-11-21 10:30:27 -08:00
Mitchell Hashimoto
e187a412fa input: Binding set clone must deep clone actions
Fixes a crash found in Discord.

Cloning the keybinding set previously shallow copied the actions, but
actions may contain pointers. These pointer values must be deep copied
to avoid dangling references when the underlying memory is freed.
2024-11-21 10:07:44 -08:00
Mitchell Hashimoto
4ef2240618 cli: parseCLI for optionals should not be null in release modes
Fixes #2747

I admit I don't fully understand this. But somehow, doing `var x: ?T =
undefined` in release fast mode makes `x` act as if its unset. I am
guessing since undefined does nothing to the memory, the memory layout
is such that it looks null for zeroed stack memory. This is a guess.

To fix this, I now initialize the type `T` and set it onto the optional
later. This commit also fixes an issue where calling `parseCLI` multiple
times on an optional would not modify the previous value if set.
2024-11-20 19:05:52 -08:00
Mitchell Hashimoto
3392659e1f Revert "macos: enable Metal shader logging"
This reverts commit aad101565abff3368af76e8c2e93cbe7c278a89f.
2024-11-20 15:01:27 -08:00
Mitchell Hashimoto
7aeee06471 apprt/gtk: set inherited working directory manually
Fixes #2745

GTK uses a delayed surface initialization since we initialize on
GTKGLArea realize not on the actual callback. Because of that, our
inherited directory doesn't always work since that depends on a
previously focused widget.

This copies our desired inherited directory to an allocation so that we
can set it during realize.
2024-11-20 14:49:01 -08:00
Mitchell Hashimoto
53dba182bf Merge pull request #2735 from ghostty-org/theme
Configuration to specify separate light/dark mode theme
2024-11-20 14:12:36 -08:00
Mitchell Hashimoto
f8a8b0464c renderer/opengl: fix memory leak when copying font features 2024-11-20 14:08:00 -08:00
Mitchell Hashimoto
aad101565a macos: enable Metal shader logging
This enables the compile options and Xcode configuration so that logging
in Metal shaders shows up in our Xcode debug console. This doesn't add
any log messages, but makes it so that when we iterate on the shaders in
the future, we can add and see logs to help us out.
2024-11-19 18:59:41 -08:00