Commit Graph

1928 Commits

Author SHA1 Message Date
Mitchell Hashimoto
962a060c86 macOS: fix title bar clipping custom font (#14217)
Fixes https://github.com/ghostty-org/ghostty/issues/14135.

<img width="1398" height="652" alt="image"
src="https://github.com/user-attachments/assets/6901a05e-9d23-4e25-89a7-c16c1694a0f9"
/>


> The #9168 fix is no longer needed, since the frame is now higher than
the actual glyph.

The frame change observation only affects those who have a custom window
title font set in their config. I asked Claude to run some main thread
benchmarking compared to `main`; it will gain some delays for rapid
title changes and window resizing. The additional cost is brought by the
frequent frame updates which are done by AppKit. But that's necessary
for updating the title to the correct style.

> I tried to do some diffing and removing duplicates, but it will add
too many changes too, and I didn't think it's worth doing so.

The amount looks ok to me.

### `window-title-font-family = PT Mono`

| Phase | Metric | base | branch | Δ | ratio |
|---|---|---:|---:|---:|---:|
| Idle, 3 s | main-thread CPU | 2.8 ms | 2.8 ms | -0.0 | 1.00 |
|  | process CPU | 11.3 ms | 11.2 ms | -0.1 | 0.99 |
| Paced title updates, 150 × 100 ms | main-thread CPU | 878.5 ms |
**946.7 ms** | **+68.3** | **1.08** |
|  | process CPU | 1219.9 ms | 1335.0 ms | +115.1 | 1.09 |
|  | wall | 17.24 s | 17.34 s | +0.1 | 1.01 |
| Title burst, 5000 back-to-back | main-thread CPU | 180.7 ms | 181.4 ms
| +0.7 | 1.00 |
|  | process CPU | 254.2 ms | 254.8 ms | +0.6 | 1.00 |
|  | wall | 2.31 s | 2.32 s | +0.0 | 1.00 |
| `toggle_maximize` × 16 (animated resize) | main-thread CPU | 1947.8 ms
| **2178.0 ms** | **+230.2** | **1.12** |
|  | process CPU | 4166.8 ms | 4403.2 ms | +236.4 | 1.06 |
|  | wall | 16.68 s | 16.72 s | +0.0 | 1.00 |
| Native fullscreen enter/exit × 2 | main-thread CPU | 196.8 ms | 195.9
ms | -0.9 | 1.00 |
|  | process CPU | 360.8 ms | 361.5 ms | +0.7 | 1.00 |
|  | wall | 8.47 s | 8.47 s | +0.0 | 1.00 |

### AI Disclosure

Asked Claude to generate the harness to run the benchmark and review my
changes. I did the changes myself.
2026-09-14 12:05:47 -07:00
Lukas
74e47a706f macOS: fix title bar clipping custom font
The #9168 fix is no longer needed, since the frame is now higher than the actual glyph.
2026-09-13 00:41:20 +08:00
Pedro Augusto
1a8f331f16 macOS: implement move_tab_to_new_window
The action and its keybind exist, and GTK implements them, but macOS had no
handler so the binding did nothing there. AppKit already has the command for
window tabs, so this forwards to it.

A window that isn't in a tab group, or is alone in one, is already a window of
its own, so there is nothing to move and the action reports it did nothing.

Implements the remaining macOS half of #2630.
2026-09-12 04:53:30 +01:00
Mitchell Hashimoto
09ff85b2ac macOS: fix find previous action when search is focused (#14131)
Typo found by @lrytz.
2026-09-03 08:38:09 -07:00
Lukas
e8936b8969 macOS: follow up cascading fix for #14118
Didn't respect the comment above before when reverting and testing hidden title 🫪
2026-09-03 09:22:36 +02:00
Lukas
e347482fba macOS: fix find previous action when search is focused 2026-09-03 08:13:21 +02:00
Mitchell Hashimoto
084316aa82 macOS: fix cascading without affecting other new-window behaviours (#14118)
Found another regression when investigating #14107 after the last fix.
This regression appears on macOS 15 and 26 as well: **New window by
Shortcuts.app or service menu while a window is visible would create a
tab**.

It appears that for `new-window` triggered by Shortcuts/Service, a small
delay is needed to avoid automatic tabbing. It's either removing
`NSWindow.userTabbingPreference == .always` completely or adding another
"delay" for cascading. The latter should be better.

Also fixes another cascading for `macos-titlebar-style = hidden`
previously missed.
2026-09-02 08:10:02 -07:00
Lukas
aafacb1cb9 macOS: fix flickering when creating new tab with glass style
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-02 16:18:30 +02:00
Lukas
a8b0855b63 macOS: fix cascading for HiddenTitlebarTerminalWindow 2026-09-02 11:16:41 +02:00
Lukas
310797df1d macOS: fix cascading without affecting other new-window behaviours 2026-09-02 11:05:48 +02:00
Lukas
451e224c64 macOS: clean up for #14106 2026-09-01 19:18:44 +02:00
Lukas
d4a5ff58b6 macOS: fix window cascading 2026-09-01 16:56:28 +02:00
Lukas
777929a8fe macOS: review windows when closing multiple tabs 2026-08-28 19:32:27 +02:00
Mitchell Hashimoto
fac595c741 macos: normalize action working directory paths (#14051)
Discussion #14048

Directory URLs no longer export a trailing slash through PWD, which
keeps zsh's %1~ prompt expansion from resolving to an empty string.

A shared URL helper removes trailing separators while preserving the
filesystem root and percent-decoding behavior. Tests cover normal,
repeated, encoded, and root paths.
2026-08-27 15:22:38 -07:00
Mitchell Hashimoto
1c3a4a8314 Update macos/Sources/Helpers/Extensions/URL+Extension.swift
Co-authored-by: Lukas <134181853+bo2themax@users.noreply.github.com>
2026-08-27 14:58:06 -07:00
Mitchell Hashimoto
07abbd1e7e Update macos/Sources/Helpers/Extensions/URL+Extension.swift
Co-authored-by: Lukas <134181853+bo2themax@users.noreply.github.com>
2026-08-27 14:57:59 -07:00
Mitchell Hashimoto
2de1596115 macos: normalize action working directory paths
Discussion #14048

Directory URLs no longer export a trailing slash through PWD, which
keeps zsh's %1~ prompt expansion from resolving to an empty string.

A shared URL helper removes trailing separators while preserving the
filesystem root and percent-decoding behavior. Tests cover normal,
repeated, encoded, and root paths.
2026-08-27 14:35:01 -07:00
Lukas
572fd58377 macOS: use the same default BellFeatures as config 2026-08-27 23:17:17 +02:00
Mitchell Hashimoto
e9ad4b1d63 macOS: fix non control keys are not working for AppleScript (#13205)
`send key` only works for control keys like `enter` currently; this adds
(fixes) the support for other keys listed as available. Found by
@paaloeye in #13180

The core of this fix is relying on `UCKeyTranslate` to get the
corresponding character and code point from a key code using
`KeyboardLayout.character(for:modifiers:)`.

ScriptKeyEventCommand now respects `macos-option-as-alt`, and attach
`text`, `unshifted_codepoint` and `consumed_mods` under the same
condition as a manual input events like in `performKeyEquivalent` and
`localEventKeyDown`.

## AI Disclosure

Claude did the heavy lifting, I reviewed and rephrased some of the
comments it generated. And ofc reviewed and tested myself.
2026-08-27 09:33:24 -07:00
Lukas
0a9f47cae0 macOS: update note about tab accessory view 2026-08-26 22:45:56 +02:00
Lukas
b6ac6e1d47 Revert "macOS: use same ResetZoomAccessoryView (#14028)"
This reverts commit 15ff186f65, reversing
changes made to 1abd53ee53.
2026-08-26 22:44:12 +02:00
Mitchell Hashimoto
15ff186f65 macOS: use same ResetZoomAccessoryView (#14028) 2026-08-26 06:52:39 -07:00
Lukas
7a15898bc8 macOS: use same ResetZoomAccessoryView 2026-08-26 13:28:11 +02:00
Lukas
851751a116 macOS: clean up deprecated toolbar button 2026-08-26 10:21:40 +02:00
Lukas
6229d4eb62 macOS: fix AppleScript send key for non-control keys
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-25 17:49:02 +02:00
Mitchell Hashimoto
6d2b436529 macos: replace legacy aspectRatio with scaledToFit in clipboard preview (#14006)
Fixes the swiftlint legacy_swiftui_aspect_ratio violation.

### AI Disclosure

By Claude, but it's really simple.
2026-08-25 05:41:28 -07:00
Mitchell Hashimoto
1c739350c3 macOS: add test cases for ScriptKeyEventCommand (#14008)
Partial changes for #13205, known issues are marked as warnings.

### AI Disclosure

Claude generated these tests from linked pr, I cherrypicked and reviewed
myself.
2026-08-25 05:41:14 -07:00
Lukas
f1b9efed80 macOS: update default behaviour of KeyboardLayout.character(for:modifiers:) 2026-08-25 13:56:21 +02:00
Lukas
d7f5ba3b4f macOS: add test cases for ScriptKeyEventCommand
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-25 13:37:58 +02:00
Lukas
a2212a5b12 macos: replace legacy aspectRatio with scaledToFit in clipboard preview
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-25 10:22:27 +02:00
Mitchell Hashimoto
13b9857a25 macos: restore paste semantics for dropped text (#13999)
Discussion #13979

Dropped paths and text once again honor bracketed paste mode. IME,
dictation, emoji picker, and character viewer commits remain typed
input.

sendText calls ghostty_surface_text, which applies the clipboard paste
pipeline and bracketed paste framing when enabled. Separating the paths
at the drag-and-drop caller preserves the input-method behavior
introduced by #13817.
2026-08-24 13:25:53 -07:00
Mitchell Hashimoto
1334cc213e macos: answer ENOSYS for Kitty clipboard writes to primary
A Kitty clipboard protocol (OSC 5522) write transaction targeting
`loc=primary` replied `type=write:status=DONE` in the macOS app even
though macOS has no primary selection and the data was silently
discarded. 

The spec requires ENOSYS when the requested location is not
available on the system, which the read path already answers correctly:
https://sw.kovidgoyal.net/kitty/clipboard/
2026-08-24 13:11:23 -07:00
Mitchell Hashimoto
550151882a macos: restore paste semantics for dropped text
Discussion #13979

Dropped paths and text once again honor bracketed paste mode.
IME, dictation, emoji picker, and character viewer commits remain typed input.

sendText calls ghostty_surface_text, which applies the clipboard paste
pipeline and bracketed paste framing when enabled. Separating the
paths at the drag-and-drop caller preserves the input-method behavior
introduced by #13817.
2026-08-24 12:49:42 -07:00
Mitchell Hashimoto
25c61e852f macos: implement Kitty clipboard protocol writes
Programs can now write the system clipboard through the Kitty
clipboard protocol in the macOS app. This also does all the hard work
plumbing through core termio/apprt so GTK should be an easy follow.

This functionality lets clients copy arbitrary representations (images, 
HTML, etc.) into the clipboard. Writes honor `clipboard-write`: allow 
applies silently, deny answers EPERM up front before any data is used, 
and ask shows the standard confirmation prompt.
2026-08-24 12:18:46 -07:00
Mitchell Hashimoto
c2c0db68aa macOS: enable mode 5522 paste events
Advertise Kitty clipboard protocol mode 5522 on macOS and route
clipboard paste requests through the protocol when it is enabled.
2026-08-24 09:37:57 -07:00
Mitchell Hashimoto
df14efaf33 macos: preview images in the clipboard read confirmation dialog 2026-08-24 08:33:37 -07:00
Mitchell Hashimoto
c1f0ef73a9 macos: serve copied files as text/uri-list in Kitty clipboard reads 2026-08-24 08:18:36 -07:00
Mitchell Hashimoto
af9470b19b macos: Kitty clipboard reads support pw/name session grants 2026-08-24 08:18:36 -07:00
Mitchell Hashimoto
8c7a34d4c9 macos: Kitty clipboard reads serve all clipboard content types 2026-08-24 08:18:36 -07:00
Mitchell Hashimoto
0ce9054bf9 macos: implement Kitty clipboard protocol reads (OSC 5522) 2026-08-24 08:18:36 -07:00
Mitchell Hashimoto
7a9bca6a6e macOS: fix responsiveness for repeated new tab action (#13985)
Fixes #13725
2026-08-24 06:58:12 -07:00
Lukas
1d24eecb20 macOS: fix responsiveness for repeated new tab action 2026-08-24 11:37:34 +02:00
Lukas
6cf7e0cc54 macOS: fix swiftlint warnings
swiftlint 0.63.3 introduced a new rule called [`legacy_swiftui_aspect_ratio`](76363aa4d7/CHANGELOG.md (L314))
2026-08-24 11:34:38 +02:00
Lukas
6a508fd5e3 macos: translate physical menu shortcuts (#13888)
Translate printable physical keybindings through the current macOS
keyboard layout before assigning menu key equivalents. Previously these
bindings could not be represented because SwiftUI shortcuts are
character-based, so actions such as `super+backquote` had no native menu
shortcut.

Keep native keycodes as dispatch identity so translated display
characters do not change physical semantics or precedence over Unicode
bindings. Refresh shortcuts when the input source changes, and prevent
AppKit from transforming equivalents that are already localized.

**AI Usage:** The approach was suggested by GPT 5.6 Sol, but I wrote
most of the code and understand it all.
2026-08-24 09:55:02 +02:00
Lukas
10d7326889 macOS: clean up GlassViewModel 2026-08-21 11:17:54 +02:00
Lukas
fd17869d15 macOS: rework for #10943
Keep the background color as it is and apply glass effect on top of it
2026-08-20 13:30:33 +02:00
Jon Parise
f5ad3a0a4a macos: use AppKit for shortcut translation
Translate synthetic physical-key events with characters(byApplyingModifiers:).
This preserves current-layout and Command-table behavior while avoiding a
duplicate direct UCKeyTranslate implementation in Swift.
2026-08-19 14:14:12 -04:00
Lukas
043abc7b60 macOS: group settings menu in a separate group 2026-08-19 15:03:15 +02:00
Lukas
f6990690f0 Revert "macOS: hide settings menu icon on macOS 27 (#13664)"
This reverts commit 99c483f477, reversing
changes made to 33bdeed1cb.
2026-08-19 15:02:01 +02:00
Jon Parise
9886f4817c macos: enforce keyboard layout actor isolation
Text Input Sources APIs are not thread-safe, but shortcut translation could
be called outside a declared main-actor context.

Mark keyboard layout and shortcut conversion as main-actor isolated, update
their tests, and dispatch key-sequence UI notifications to the main queue
before translating their shortcuts.
2026-08-18 12:40:28 -04:00