Commit Graph

931 Commits (facda0c3fb1310c7698fc77ba193165ef38cd58e)

Author SHA1 Message Date
Mitchell Hashimoto a58b1998a9
macos: hide dock globally if the dock conflicts
Related to #5361

The fix in 5361 wasn't sufficient since it only applied if our app was
in the foreground. Our quick terminal is a non-activating NSPanel to
allow it to work on any space (fullscreen included). This means that
Ghostty doesn't become the active app when the quick terminal is shown
and another app is in the foreground.

To work around this, we now hide the dock globally when the quick
terminal is shown AND the dock is in a conflicting position. We restore
this state when the quick terminal is hidden, loses focus, or Ghostty is
quit.
2025-01-24 20:18:44 -08:00
Mitchell Hashimoto a5a73f8352
macos: autohide dock if quick terminal would conflict with it
Fixes #5328

The dock sits above the level of the quick terminal, and the quick
terminal frame typical includes the dock. Hence, if the dock is visible
and the quick terminal would conflict with it, then part of the terminal
is obscured.

This commit makes the dock autohide if the quick terminal would conflict
with it. The autohide is disabled when the quick terminal is closed.

We can't set our window level above the dock, as this would prevent
things such as input methods from rendering properly in the quick
terminal window.

iTerm2 (the only other macOS terminal I know of that supports a dropdown
mode) frames the terminal around the dock. I think this looks less
aesthetically pleasing and I prefer autohiding the dock instead.

We can introduce a setting to change this behavior if desired later.

Additionally, this commit introduces a mechanism to safely set
app-global presentation options from multiple sources without stepping
on each other.
2025-01-24 14:51:17 -08:00
Mitchell Hashimoto e854b38872
cli: allow renaming config fields to maintain backwards compatibility
Fixes #4631

This introduces a mechanism by which parsed config fields can be renamed
to maintain backwards compatibility. This already has a use case --
implemented in this commit -- for `background-blur-radius` to be renamed
to `background-blur`.

The remapping is comptime-known which lets us do some comptime
validation. The remap check isn't done unless no fields match which
means for well-formed config files, there's no overhead.

For future improvements:

- We should update our config help generator to note renamed fields.
- We could offer automatic migration of config files be rewriting them.
- We can enrich the value type with more metadata to help with
  config gen or other tooling.
2025-01-23 14:16:37 -08:00
Qwerasd 5477eb87c1 macOS: prevent native window drag by top region when titlebar hidden
The native window drag region is driven ultimately by the window's
`contentLayoutRect`, so we can just override it in `TerminalWindow`
to return a rect the size of the full window, disabling the gesture
without causing any side effects by altering the responder chain.
2025-01-23 13:35:52 -08:00
Mitchell Hashimoto b82c70fd3c
fix: quick terminal hidden by macos menu bar (#5222)
ghostty#5000 changed the window level from `.popupMenu` to `.floating`
to improve IME support. However, this introduced a side effect which
render the Quick Terminal (QT) below the macOS menu bar, whereas
previously it would cover it.

When positioned on `right` and `left`, the top of the QT becomes
partially hidden. This PR adjust the size of the QT to ensure it remains
fully visible and stays below the menu bar.

Before #5000:
![Screen Recording 2025-01-19 at 11 14
48](https://github.com/user-attachments/assets/70565c28-783f-4a2a-a8c9-a2eb16ea50e9)
With #5000:
![Screen Recording 2025-01-19 at 11 13
27](https://github.com/user-attachments/assets/184a1205-0a68-4fa0-a0d8-cc37701529af)
This branch:
![Screen Recording 2025-01-19 at 11 17
32](https://github.com/user-attachments/assets/f589d9e1-c5a0-4ed1-9f9b-651f3cb22f58)
2025-01-20 11:12:11 -08:00
Damien Mehala 4956d36ee6
fix: quick terminal hidden by macos menu bar
ghostty#5000 changed the window level from `.popupMenu` to `.floating`
to improve IME support. However, this introduced a side effect which
render the Quick Terminal (QT) below the macOS menu bar, whereas
previously it would cover it.

When positioned on `right` and `left`, the top of the QT becomes
partially hidden. This PR adjust the size of the QT to ensure it remains
fully visible and stays below the menu bar.
2025-01-19 11:04:01 +01:00
Albert Dong da5ac6aeeb Set alert to nil when modal interacted with 2025-01-16 20:57:41 -08:00
Albert Dong 860f1f635c Manually call orderOut on terminal close alert
Allowing the alert to be automatically closed after the completion handler finishes doesn't seem to play well when the completion handler closes the window on which the alert is attached
2025-01-16 14:14:48 -08:00
Mitchell Hashimoto a5853c4de8
macos: respect the "auto" window decoration setting 2025-01-16 14:03:04 -07:00
Leah Amelia Chen 4e0d9b1b27 gtk(wayland): implement server-side decorations 2025-01-14 09:57:59 -08:00
Alexandre Antonio Juca 39bb949973 fix: Ensure file paths derived from pasteboard operations are properly escaped 2025-01-14 00:18:28 +01: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
Bryan Lee 08314d414f
Preserve full URL when pasting from clipboard 2025-01-14 00:48:56 +08:00
Mitchell Hashimoto ea0704148d
macos: only set quick terminal level to popUpMenu during animation
Fixes #4999

We need to set the level to popUpMenu so that we can move the window
offscreen and animate it over the main menu, but we must reset it back
to floating after the animation is complete so that other higher-level
windows can be shown on top of it such as IME windows.
2025-01-12 12:49:43 -08:00
Mitchell Hashimoto a2d2cfea59
macos: move drop implementation to separate extension 2025-01-11 19:27:36 -08:00
Alexandre Antonio Juca a06fc4ff11 feat: ensure text, files and URLs can be drag and dropped to terminal window 2025-01-11 19:04:45 -08:00
Mitchell Hashimoto 0811b1d5ac
macos: paste multiple files separated by space
https://github.com/ghostty-org/ghostty/discussions/4892#discussioncomment-11808631
2025-01-11 13:58:09 -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
Alexandre Antonio Juca 61a78efa83 chore: revert on TerminalManager changes 2025-01-10 14:16:47 -08:00
Alexandre Antonio Juca 3a5aecc216 fix: hide windows without calling orderOut API 2025-01-10 14:16:47 -08:00
Alexandre Antonio Juca 4dd9fe5cfd fix: ensure terminal tabs are reconstructed in main window after toggling visibility 2025-01-10 14:16:47 -08:00
Mitchell Hashimoto 8e52c6d12b
Reduce ghost emoji flash in title bar (#4804)
Fixes #4799

This PR attempts to reduce the flash caused by the ghost emoji in the
title bar when opening new windows.

## Changes:

- Initialize `SurfaceView.title` with empty string instead of ghost
emoji

- Simplify title computation logic in `TerminalView`

- Adding a 500ms fallback timer for "👻"

	- Canceling timer if title is set

## Current Status:

While these changes reduce the initial ghost emoji flash, there's still
a brief moment where a folder emoji appears alone in the title bar when
opening a new window. This suggests there might be a race condition or
timing issue with how the title is being set and updated.


https://github.com/user-attachments/assets/3688c9f3-1727-4379-b04d-0bd6ac105728

Would appreciate feedback on the remaining flash issue and suggestions
for further improvements.
2025-01-10 13:46:45 -08:00
Mitchell Hashimoto 2d7706ec4f
macos: Handle ctrl characters in IME input (#4854)
Fixes:
https://github.com/ghostty-org/ghostty/issues/4634#issuecomment-2573469532

This commit fixes two issues:

1. `libghostty` must not override ctrl+key inputs if we are in a preedit
state. This allows thigs like `ctrl+h` to work properly in an IME.

2. On macOS, when an IME commits text, we strip the control modifier
from the key event we send to libghostty. This is a bit of a hack but
this avoids triggering special ctrl+key handling.
2025-01-08 22:07:15 -08:00
Mitchell Hashimoto 1636ac88fc
macos: Handle ctrl characters in IME input
Fixes: https://github.com/ghostty-org/ghostty/issues/4634#issuecomment-2573469532

This commit fixes two issues:

1. `libghostty` must not override ctrl+key inputs if we are in a preedit
   state. This allows thigs like `ctrl+h` to work properly in an IME.

2. On macOS, when an IME commits text, we strip the control modifier
   from the key event we send to libghostty. This is a bit of a hack but
   this avoids triggering special ctrl+key handling.
2025-01-08 21:54:34 -08:00
Mitchell Hashimoto aafe7deae7
macos: improve initial size calculation
Fixes #4801

Our size calculation before improperly used a screens frame instead of
its visibleFrame. Additionally, we didn't properly account for origin
needing to move in order to fit the window on the screen.

Apparently, setting a frame height to high crashes AppKit. The width
gets clamped by AppKit but the height does not. Fun!
2025-01-08 21:20:58 -08:00
Bryan Lee 5bfb3925ba
Add fallback timer for empty window title 2025-01-09 06:30:47 +08:00
Bryan Lee ea7c54d79d
Simplify let binding in `TerminalView` title logic 2025-01-09 06:30:47 +08:00
Bryan Lee 0651586339
Reduce ghost emoji flash in title bar 2025-01-09 06:30:46 +08:00
Bryan Lee 140ac93884 Add `close_tab` keybinding action for macOS
Implement `close_tab` keybinding action to close the current tab and all splits within that tab.
2025-01-08 12:04:40 -08:00
Mitchell Hashimoto 6ebc02b68d
macos: animate in even if remain on another space 2025-01-08 11:30:26 -08:00
Mitchell Hashimoto 6e54589db4
misc cleanups 2025-01-08 11:28:09 -08:00
Soh Satoh 37db4578c8 Fix the issue that the quick term not shown on first call 2025-01-08 11:03:18 -08:00
Soh Satoh 0ddc1a21a6 fix the comment (quick-terminal-space-behavior) 2025-01-08 11:03:18 -08:00
Soh Satoh 7bb3c31cee Move the quick terminal to active space if toggle() called while opening on another space 2025-01-08 11:03:18 -08:00
Soh Satoh 1493c55348 Merge branch 'main' into show-quick-term-on-another-app 2025-01-08 11:03:18 -08:00
Soh Satoh e2523c25cb Add quick-terminal-space-behavior option 2025-01-08 11:02:19 -08:00
Soh Satoh 2206c509be Show quick terminal on another full-screen app 2025-01-08 10:59:56 -08:00
Wes Campaigne e86b9a112e Implement "Paste Selection" on macOS like Terminal.app 2025-01-08 09:26:13 -08:00
Mitchell Hashimoto 29c2f095a6
macOS: Add Bluetooth permission description. (#4668)
Adds the missing Bluetooth permission to Ghostty's application playlist
manifest file, as it was missing. Tweaks have also been made to existing
permission descriptions to be more readable. Should fix an abrupt crash
in Fastfetch and any other apps that may request Bluetooth permissions.
2025-01-07 20:53:12 -08:00
Mitchell Hashimoto ae0c4d927a
macos: halt NSEvent processing at app scope only if event is handled
Fixes #4677
2025-01-06 07:27:44 -08:00
Mitchell Hashimoto f0c2d3d75a
macos: fix retain cycle preventing window from freeing 2025-01-06 07:02:04 -08:00
Evelyn Harthbrooke dc4774c147 macOS: fixup Photo Library description to make more sense. 2025-01-06 07:13:53 -07:00
Evelyn Harthbrooke ae0248b5bc macOS: Add Bluetooth permission description; fixup other descs.
Adds the missing Bluetooth permission description to ghostty's Xcode
project description, and fixes up existing permissions to be clearer.

Closes #3995 and #4512.
2025-01-06 07:10:50 -07:00
Mitchell Hashimoto ed221f32fe
macos: ignore modifier changes while IM is active
Fixes #4634
2025-01-05 13:30:50 -08:00
Mitchell Hashimoto 4ffd281de3
macos: detect IME input source change as part of keyDown event
Fixes #4539

AquaSKK is a Japanese IME (Input Method Editor) for macOS. It uses
keyboard inputs to switch between input modes. I don't know any other
IMEs that do this, but it's possible that there are others. Prior to
this change, the keyboard inputs to switch between input modes were
being sent to the terminal, resulting in erroneous characters being
written.

This change adds a check during keyDown events to see if the input
source changed _during the event_. If it did, we assume an IME captured
it and we don't pass the event to the terminal.

This makes AquaSKK functional in Ghostty.
2025-01-04 21:45:25 -08:00
Mitchell Hashimoto 5d523116bf
macos: alphabetize resources in xcode project (#4607) 2025-01-04 20:45:35 -08:00
Mitchell Hashimoto 8f5cbed46f
fix: macos incorrect quick terminal position (#4501)
As this discussion: #4353
2025-01-04 20:41:53 -08:00
Mitchell Hashimoto e05c3b6fd7
macos: alphabetize resources in xcode project 2025-01-04 20:30:42 -08:00
Christian Schneider a670836d7a Remove outdated comment 2025-01-04 20:18:00 -08:00
Christian Schneider da80531c22 Implement configuration option split-divider-color for macOS 2025-01-04 20:18:00 -08:00