432 Commits

Author SHA1 Message Date
Bryan Lee
423bc1971b Make equalize_splits action only affect current window 2025-03-04 22:37:32 +08:00
Mitchell Hashimoto
8d395c094b macos: set title of terminal window immediately if configured
Fixes #5934 for macOS

If a `title` config is set, this change sets the title immediately on
windowDidLoad to ensure that the window appears with the correct title
right away.

If there is any reason to set another title, the `set_title` apprt
action will come on another event loop tick (due to our usage of
notifications) but that's okay since that's already how it works. This
is just to say that setting this here won't break any shell integration
or anything.
2025-03-02 13:27:40 -08:00
Mitchell Hashimoto
17cae57f51 Introduce reset_window_size keybinding and apprt action
Related to #6035

This implements the keybind/action portion of #5974 so that this can
have a binding and so that other apprts can respond to this and
implement it this way.
2025-02-28 15:31:17 -08:00
Mitchell Hashimoto
afb154ee5d macos: store default size as computed property 2025-02-28 14:51:56 -08:00
Mikhail Borisov
8838ebf02a Refactor to use height/width from ghostty configuration 2025-02-28 14:17:46 -08:00
Mitchell Hashimoto
1cfe7027e5 Fix Terminal Inspector option turns inactive if toggled in the Quick Terminal (#6024)
Fixed: [2475](https://github.com/ghostty-org/ghostty/issues/2475)

The problem actually existed because of the responder chain, as
previously pointed out in the report (thanks to @mitchellh).

When we first click on Toggle Terminal Inspector:
* the responder chain goes to _toggleTerminalInspector_
(_SurfaceView_AppKit_ implementation).
When we click the second toggleTerminalInspector:
* it tries to find the next responder, but the one available is
_TerminalController_. (if we remove this method from there, the bug will
reproduce even without quick mode)

**Problem**:
TerminalController not available during quick terminal, so there's no
way to toggle inspector
**Solution**:
We add toggleTerminalInspector to the _QuickTerminalController_:
selector, as we did with other similar methods.
2025-02-28 07:09:00 -08:00
Mikhail Borisov
744240c009 Fix Terminal Inspector option turns inactive if toggled in the Quick Terminal 2025-02-28 00:38:29 +01:00
Mitchell Hashimoto
ef88d1cba9 feat: respect maximize config on macOS (#5962)
Resolve #5928
2025-02-27 15:25:17 -08:00
Aaron Ruan
5a5478abe1 feat: respect maximize config on macOS
Signed-off-by: Aaron Ruan <i@ar212.com>
2025-02-27 15:10:39 -08:00
McNight
b4349d3226 fix(macos): make showNoNewTabAlert method private #5939 2025-02-25 00:18:02 +01:00
McNight
1254c6b981 fix(macos): address MR feedback #5939 2025-02-25 00:17:01 +01:00
McNight
aa4aaa200f fix(macos): prevent performing newTab shortcut on QuickTerminalWindow #5939 2025-02-23 19:34:27 +01:00
Mitchell Hashimoto
870b74f4da macOS: Fix new window focus when created from quick terminal (#5834)
## Root Cause

The issue has two aspects:

1. The window creation process didn't explicitly force focus on the new
window after showing it.
2. More fundamentally, we were relying on `NSApp.isActive` to determine
whether to activate the application, which is problematic because:
- When creating a window from quick terminal, the application is already
"active" but this active state is owned by the quick terminal
- The [`NSApp.isActive`
check](4cfe5522db/macos/Sources/Features/Terminal/TerminalManager.swift (L100))
doesn't accurately reflect our intent - creating a new window is an
explicit user action that should always result in that window gaining
focus

## Solution

Removing the `NSApp.isActive` check.

```swift
// Before
if !NSApp.isActive {
    NSApp.activate(ignoringOtherApps: true)
}

// After
NSApp.activate(ignoringOtherApps: true)
```

Fixes #5688
2025-02-21 15:50:00 -08:00
Aaron Ruan
4291e1c5d7 fix: use surfaceConfig.backgroundColor to determine if the theme is light or dark
Signed-off-by: Aaron Ruan <i@ar212.com>
2025-02-21 15:32:24 -08:00
Bryan Lee
c9f8732e5c Fix new window focus when quick terminal is open 2025-02-18 10:50:01 +08:00
Aaron Ruan
830a117555 fix: vertically center toolbar title more accurately
Signed-off-by: Aaron Ruan <i@ar212.com>
2025-02-17 07:30:14 -08:00
mbrown379
b1df97b33f Add Split Left and Split Up to menu 2025-02-16 15:14:02 -05:00
Mitchell Hashimoto
ac7aa757bd macos: add padded-notch option for macos-non-native-fullscreen
Finishes #378
Supercedes #4159

This adds a new enum value for `macos-non-native-fullscreen`:
`padded-notch`. This value will add padding to the top of the window to
account for the notch on applicable devices while still hiding the
menu.

This value is preferred over "visible-menu" by some people because for
screens without a notch, the window will take up the full height.

The plan in the future is that we may color the padded area when a notch
is present. In this commit it appears as transparent.
2025-02-13 20:27:42 -08:00
Bryan Lee
f72fd32bf0 Eliminate tab content flickering during tab movement on macOS 2025-02-13 14:59:14 +08:00
Bryan Lee
31273aaabc Remember last focused window position for next startup 2025-02-11 12:33:29 -08:00
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
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
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
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
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
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
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
f0c2d3d75a macos: fix retain cycle preventing window from freeing 2025-01-06 07:02:04 -08:00
acehinnnqru
b0404867b7 fix: macos incorrect quick terminal position 2025-01-03 22:44:26 +08:00
Mitchell Hashimoto
b65c26966a macos: fix window borders on dark mode (#4308)
After updating to 1.0.1 I noticed something different in the terminal,
which turned out being the window borders - it appeared as if Ghostty
was using light-mode style borders (dark/black outline with a thin light
stroke at the top) instead of the entire light outline from before:

| 1.0.0 | 1.0.1 |
| - | - |
| <img width="308" alt="Screenshot 2025-01-01 at 2 28 12 PM"
src="https://github.com/user-attachments/assets/d8bc5bdd-c3b2-401c-a8ed-9da0b768cb3d"
/> | <img width="308" alt="Screenshot 2025-01-01 at 2 29 07 PM"
src="https://github.com/user-attachments/assets/fd710bed-1756-4f66-8402-bfbdd25218ab"
/> |

After digging a bit, I found #3834, which fixes fullscreen background
colors through alpha channels by appending a `withAlphaComponent(0.0)`
to `backgroundColor` - for reasons I may be entirely unaware of (since
I'm not a Swift developer), this seems to cause the dark-mode border
style to go away.

Some lines above that, I noticed the `.clear` callout from line 266,
which talks about matching Terminal.app's styles, and it _also_ has a
`withAlphaComponent` but set to `0.001` - if I understand correctly, and
the fix from #3834 works by setting the alpha component to a
_practically_ zero value, then I thought perhaps a really small number
like `0.001` could do the trick as well. This ended up working and
bringing back the right borders again.

Not sure again if this may make a difference anywhere else in the app or
bring any undesired behavior, but if anyone who is well-versed in Swift
would like chime in with more details or perhaps a better approach, I'd
greatly appreciate it!
2025-01-02 15:41:57 -08:00
Gabriel Moreno
82695edaff macos: fix window borders on dark mode 2025-01-02 15:27:01 -08:00
Mitchell Hashimoto
29b96be84f tweaks to window position 2025-01-02 13:18:53 -08:00
Adam Wolf
f9250e28b5 chore: rename window-position-{x,y} to window-initial-position-{x,y} 2025-01-02 12:58:40 -08:00
Adam Wolf
200d0d642b macos: handle setting initial window position when window is created 2025-01-02 12:58:40 -08:00