Commit Graph

226 Commits (bcb5112b243ee075e43d4dad3a3d7a27a02bd979)

Author SHA1 Message Date
Mitchell Hashimoto 19a9156ae1
macos: address remaining todos 2025-06-05 07:05:13 -07:00
Mitchell Hashimoto 77458ef308
macos: rename surfaceTree2 to surfaceTree 2025-06-05 07:05:13 -07:00
Mitchell Hashimoto f1ed07caf4
macos: Remove the legacy SurfaceTree 2025-06-05 07:05:13 -07:00
Mitchell Hashimoto 22819f8a29
macos: transfer doesBorderTop 2025-06-05 07:05:12 -07:00
Mitchell Hashimoto 8b979d6dce
macos: handle surfaceTreeDidChange 2025-06-05 07:05:12 -07:00
Mitchell Hashimoto a389926ca7
macos: use surfaceTree2 needsConfirmQuit 2025-06-05 07:05:12 -07:00
Mitchell Hashimoto aef61661a0
macos: fix up command palette, focusing 2025-06-05 07:05:12 -07:00
Mitchell Hashimoto b84b715ddb
macos: unify confirm close in our terminal controllers 2025-06-05 07:05:11 -07:00
Mitchell Hashimoto d1dce1e372
macos: restoration for new split tree 2025-06-05 07:05:11 -07:00
Mitchell Hashimoto e3bc3422dc
macos: handle split resizing 2025-06-05 07:05:11 -07:00
Mitchell Hashimoto 1707159441
new SplitTree 2025-06-05 07:05:11 -07:00
Daniel Wennberg 232a46d2dc Add option to hide macOS traffic lights 2025-06-02 09:22:01 -07:00
Mitchell Hashimoto fd7132db71
macos: quick terminal can equalize splits
Fixes #7480
2025-05-30 15:13:30 -07:00
Mitchell Hashimoto e2a0f439c6
macOS: save/restore firstResponder on non-native fullscreen
Fixes #6999

It appears that at some point one of the operations causes focus to move
away for non-native fullscreen. We previously relied on the delegate
method to restore this but a better approach appears to handle this
directly in the fullscreen implementations. This fixes the linked issue.

I still think long term all the `Ghostty.moveFocus` stuff is a code
smell and we should be auditing all that code to see if we can
eliminate it. But this is a step in the right direction, and removes one
of those uses.
2025-05-06 12:59:31 -07:00
Mitchell Hashimoto b05826ac9d
macOS: use KeyboardShortcut rather than homegrown KeyEquivalent
This replaces the use of our custom `Ghostty.KeyEquivalent` with
the SwiftUI `KeyboardShortcut` type. This is a more standard way to
represent keyboard shortcuts and lets us more tightly integrate with
SwiftUI/AppKit when necessary over our custom type.

Note that not all Ghostty triggers can be represented as
KeyboardShortcut values because macOS itself does not support
binding keys such as function keys (e.g. F1-F12) to KeyboardShortcuts.

This isn't an issue since all input also passes through a lower level
libghostty API which can handle all key events, we just can't show these
keyboard shortcuts on things like the menu bar. This was already true
before this commit.
2025-04-19 14:39:48 -07:00
Bryan Lee 9144f4db58
Fix macOS shortcut binding for `close_window` action 2025-04-08 00:44:53 +08:00
Bryan Lee 423bc1971b
Make `equalize_splits` action only affect current window 2025-03-04 22:37:32 +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
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
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 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
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
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 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 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 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
Christoffer Tønnessen 88674a1957 Restore hidden titlebar after fullscreen
This fixes https://github.com/ghostty-org/ghostty/issues/3535 .

There exists an issue in ghostty on mac where if you have hidden your
titlebar, then enter fullscreen, the titlebar will reappear after
exiting fullscreen.

The reason for this is that after exiting fullscreen macos reapplies
some styling on the new window created after exiting fullscreen. To
combat this we will reapply the styling to hide the titlebar after
exiting fullscreen.

Required config:
```
macos-titlebar-style = hidden
macos-non-native-fullscreen = true
```

Steps to reproduce:

- Open Ghostty
- Enter fullscreen (non-native)
- Exit fullscreen

On main you will see the titlebar reappearing after exiting fullscreen,
while that does not happen with this patch.
2025-01-02 12:25:02 -08:00
Mitchell Hashimoto f8c3dc1bbf
fix: quick terminal `focus-follows-mouse` behaviour (#3814)
# Description

Quick Terminal now focuses on the surface under the mouse pointer when
`focus-follows-mouse` is enabled.

Fixes #3337
2024-12-30 11:10:38 -08:00
Damien Mehala ade07c4c3c fix: quick terminal `focus-follows-mouse` behaviour
Quick Terminal now focuses on the surface under the mouse
pointer when `focus-follows-mouse` is enabled.

Fixes #3337
2024-12-30 11:04:21 -08:00
Zein Hajj-Ali fa83140585 Set alpha component for fullscreen background colour 2024-12-28 21:07:43 -05:00
Mitchell Hashimoto 9d6b9d78d8
macos: set NSAppearance on windowDidLoad
Fixes #3072

Previously, when `window-theme = auto`, the appearance was delayed
enough on the DispatchQueue that the window was already visible. This
would result in the window appearing with the wrong appearance before
switching to the correct one.

For annoying reasons, we can't set the NSApplication.shared.appearance
in `applicationDidFinishLaunching` because it results in a deadlock with
AppKit.

This commit moves to set the `NSWindow.appearance` in `windowDidLoad`
(and any config sync) to ensure that the appearance is set before the
window is visible.

This is probably the right solution anyways because this allows windows
with different background colors to each have their own distinct
appearance.
2024-12-22 19:33:01 -08:00
Mitchell Hashimoto f384fd038b
macos: trigger fullscreenDidChange on any fullscreen event
Fixes #2840
Related to #2842

This builds on #2842 by missing a key situation: when native fullscreen
is toggled using the menu bar items it doesn't go through our
`FullscreenStyle` machinery so we don't trigger fullscreen change
events.

This commit makes it so that our FullscreenStyle always listens for
native fullscreen change (even in non-native modes) to fire a fullscreen
did change event. This way we can always rely on the event to be fired
when fullscreen changes no matter what.
2024-12-01 11:37:04 -08:00
Mitchell Hashimoto ba4185f6b7
macos: disable background opacity/blur in native fullscreen
See #2840
2024-11-27 08:35:13 -08:00
Mitchell Hashimoto 1aa77837eb
macos: use correct title background if top surface 2024-11-21 14:20:31 -08: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 7fb86a3c9c
macos: listen for color change property to update window appearance 2024-11-21 13:37:54 -08:00
Mitchell Hashimoto f722e30bf5
macos: terminal controller reacts to surface config changes 2024-11-21 12:46:46 -08:00
Mitchell Hashimoto 35fcb1a29b
macos: change config access to evented, derived config like libghostty
Previously, we would access the `ghostty.config` object from anywhere.
The issue with this is that memory lifetime access to the underlying
`ghostty_config_t` was messy. It was easy when the apprt owned every
reference but since automatic theme changes were implemented, this isn't
always true anymore.

To fix this, we move to the same pattern we use internally in the core
of ghostty: whenever the config changes, we handle an event, derive our
desired values out of the config (copy them), and then let the caller
free the config if they want to. This way, we can be sure that any
information we need from the config is always owned by us.
2024-11-21 11:36:51 -08:00
Mitchell Hashimoto 30e95e4b9a
Revert "macos: setup colorspace in base terminal controller"
This reverts commit e64b231248.
2024-10-31 09:28:08 -07:00
Mitchell Hashimoto e64b231248
macos: setup colorspace in base terminal controller
Fixes #2519

This sets up the colorspace for terminal windows in the base controller.

This also modifies some of our logic so its easier for subclasses of
base controllers to specify custom logic when the configuration reloads,
since that's likely to be a common thing.
2024-10-30 20:35:13 -04:00
Mitchell Hashimoto 28751ae5b8
Merge pull request #2485 from axdank/move_current_Tab
gui: add move_current_tab action
2024-10-25 14:15:16 -07:00
Mitchell Hashimoto de5ec5d83e
macos: make move_tab work 2024-10-25 11:54:07 -07:00
Mitchell Hashimoto 582b8d039a
Merge pull request #2492 from johnseth97/macos-proxy-icon-fix
Macos proxy icon fix
2024-10-24 21:08:15 -07:00
Mitchell Hashimoto 67bc9fa0bc
macos: nuke the titlebar from orbit when hidden 2024-10-24 21:06:45 -07:00
Mitchell Hashimoto a651dbf3bf
macos: fix goto last tab 2024-10-24 19:58:13 -07:00
johnseth97 7301afa83e
Removed uneeded code 2024-10-24 22:12:29 -04:00
johnseth97 8e223fdcd9
Reworked proxy icon, added config options. 2024-10-24 21:54:08 -04:00
Max 553687b5e2 feat: make too big tab indices go to last tab 2024-10-23 20:27:13 +02:00
johnseth97 7f898ce01f
Basic proxy icons showing
Removed changes that accidentally carried over from another local
branch.

Basic Proxy Icons showing
2024-10-23 00:40:38 -04:00
Ethan Johnson a53b4f684e
Merge branch 'ghostty-org:main' into macos-window-deocrations-rework 2024-10-19 20:40:44 -04:00
Mitchell Hashimoto 70acb0d76e
macos: clamp window size to screen size on screen parameter changes
Fixes #2462

This sets up a listener for screen parameter changes. This only triggers
when a screen is added, removed, or a parameter such as its resolution
changes. This doesn't trigger when a window is simply moved from one
screen to another.

On parameter change, we ensure that the window is within the bounds of
the screen. As an exception, if the window was previously already
outside the bounds of the screen, we don't move it back in.
2024-10-19 10:13:16 -07:00
johnseth97 def3a62fb9
Modified `window-decorations = none` option on macos 2024-10-19 01:03:05 -04:00
Mitchell Hashimoto 46cbe59076
macos: quick terminal supports fullscreen
Fixes #2330

The quick terminal now supports fullscreen. The fullscreen mode is
always non-native due to the quick terminal being a titleless, floating
window.

When the quick terminal loses focus and animates out, it will always
exit fullscreen mode.
2024-09-30 21:07:16 -07:00
Mitchell Hashimoto 408c33e174
macos: handle non-native fullscreen changing screens 2024-09-30 14:14:01 -07:00
Mitchell Hashimoto 045ecacd8c
macos: fullscreen mode can be changed at runtime 2024-09-30 10:31:11 -07:00
Mitchell Hashimoto 5f9d4f9733
macos: fullscreen=true with non-native fullscreen works
Fixes #1377
2024-09-30 10:02:50 -07:00
Mitchell Hashimoto 332e1a1494
macos: new FullscreenMode/Style architecture for fullscreen impls 2024-09-29 21:31:58 -07:00
Mitchell Hashimoto 50fb7331af
macos: base class for terminal controller 2024-09-28 10:41:51 -07:00
Mitchell Hashimoto 7befb5a418
macos: fix previous/next tab bindings, improve action logging 2024-09-27 12:24:11 -07:00
Mitchell Hashimoto 4ae20212bf
libghostty: unified action dispatch
First, this commit modifies libghostty to use a single unified action
dispatch system based on a tagged union versus the one-off callback
system that was previously in place. This change simplifies the code on
both the core and consumer sides of the library. Importantly, as we
introduce new actions, we can now maintain ABI compatibility so long as
our union size does not change (something I don't promise yet).

Second, this moves a lot more of the functions call on a surface into
the action system. This affects all apprts and continues the previous
work of introducing a more unified API for optional surface features.
2024-09-26 22:00:11 -07:00
Mitchell Hashimoto c6bbdfb7bf
macos: remove EventSinkHostingView
This was breaking various other features:

  - Popovers stopped working
  - Split divider drag gestures stopped working

For now we document the top part of the window is draggable... we
can look into removing that limitation later.
2024-09-20 22:01:01 -07:00
Mitchell Hashimoto 962aa49a45
macos: remove nstitlecontainerview hidden 2024-09-20 19:18:01 -07:00
Qwerasd 16919488da macOS: add `macos-titlebar-style = hidden`
Hides titlebar without removing the other typical window frame elements
2024-09-20 16:11:51 -06:00
Qwerasd 2852c771b1 macos: fix various titlebar tabs problems in macOS 15.0
- Toolbar overflow indicator showing
- Doubled title on single-tab windows
- Tabs not properly placed in bar on restore of saved window
2024-09-16 22:54:00 -06:00
Mitchell Hashimoto 80327402b8
Merge pull request #2120 from edmz/last_tab
macos: jump to last_tab
2024-08-26 20:22:52 -07:00
Mitchell Hashimoto 18419d3589
Clamp initial window size configurations to screen size
Fixes #2145
2024-08-26 10:09:05 -07:00
pnodet 7ff9af1520
style(macos): cleanup trailing spaces 2024-08-21 21:53:09 +02:00
Eduardo Dominguez 262902a28d macos: jump to last_tab 2024-08-19 12:19:00 -06:00
Łukasz Niemier f9be02a20f chore: clean up typos 2024-08-05 13:56:57 +02:00
Mitchell Hashimoto 9785130c03
macos: add "Reset Terminal" context menu option 2024-08-01 14:58:03 -07:00
Mitchell Hashimoto 5268780f00
macos: comment on clearing tab 2024-07-21 10:09:18 -07:00
Justin Su f57f9f2ec9
Use 1-indexed values when dealing with tabs 2024-07-21 03:32:43 -04:00
Justin Su 823e073795
Relabel all tabs and clear labels for tabs with no key equivalent 2024-07-21 02:27:51 -04:00
Justin Su 7919cb266e
Update comment 2024-07-21 02:12:47 -04:00
Cameron Dart fc52acd47a update config in TerminalController.windowDidLoad and TerminalController.configDidReload 2024-06-10 18:22:28 -07:00
Cameron Dart 29fb70197c macos: surface focus follow mouse 2024-06-10 16:07:33 -07:00
Mitchell Hashimoto 5092cb55ad
Merge pull request #1837 from ghostty-org/titlebar-style
macos: macos-titlebar-style, remove titlebar-tabs option
2024-06-07 13:15:14 -07:00
Mitchell Hashimoto 550a9be241
config: introduce macos-window-shadow 2024-06-07 12:46:14 -07:00
Mitchell Hashimoto 5a026cf1a2
macos: set background color on transparency that matches Terminal.app 2024-06-07 12:35:57 -07:00
Mitchell Hashimoto 25484d2ccc
macos: set background opacity/blur on window controller not surface 2024-06-07 12:31:45 -07:00
Mitchell Hashimoto 4dde7edfab
config: macos-titlebar-style, remove titlebar-tabs option
Fixes #1833

This is an attempt to simplify the logic that has organically grown
convoluted over time with regards to how the titlebar and tab bar is
styled.

This field is one unified field that ONLY addresses titlebar and tab bar
styling. It can be one of "native", "transparent", or "tabs". The
"native" field is the new behavior in this commit: it makes the titlebar
and tab bar appearance be absolutely native. We do not color anything
(if we do its a bug).

The "transparent" option is the previous `macos-titlebar-tabs = false`
setting where the titlebar/tab bar is native but colored according to
the window background color.

The "tabs" option is `macos-titlebar-tabs = true`.

The `window-theme = auto` affect on titlebar appearance has been
removed. Now, the titlebar will NEVER be styled with "native" and MAY be
styled with "transparent" and will ALWAYS be styled with "tabs" (since
that's a totally custom look anyways).
2024-06-07 12:12:48 -07:00
Troels Thomsen f79674097f Avoid coloring when using native tabs 2024-05-21 08:58:51 +02:00
Troels Thomsen 242858b963 Color after setting window theme and tab mode 2024-05-21 08:05:55 +02:00
Mitchell Hashimoto 92d551a3c1
macos: only set bg color and titlebar color if opaque
Fixes #1771

I'm not convinced this fix won't regress some other behavior, but in my
titlebar tab and native tab modes with and without transparency, this
has looked okay to me.
2024-05-17 17:05:21 -04:00
Mitchell Hashimoto 69a3137956
macos: use enum for window theme 2024-05-17 16:31:18 -04:00
Pete Schaffner c437416014 Make title/tab bar respect `window-theme` setting 2024-05-14 20:17:28 -04:00
cryptocode 2faa0c9bee
Rename Split Horizontally/Vertically to Split Right/Down
I make the following suggestion through a PR since I already tried this locally and have a branch ready:

- Rename Split Horizontally to Split Right
- Rename Split Vertically to Split Down

Rationale:

The terms horizontal and vertical are ambiguous in the context of splitting (does it mean the splitter is vertical, or are the panes organized vertically?)
Different apps pick different interpretations, so people get confused.

IntelliJ made the same change as above based on user feedback: https://youtrack.jetbrains.com/issue/IJPL-130991/Split-Vertically-and-Split-Horizontally-are-ambiguous-and-should-be-renamed

Ghostty is using the left/right nomenclature in other menu items. In the codebase, SplitDirection is already left/right.
2024-05-10 11:17:11 +02:00
Mitchell Hashimoto 45eecf801e
macos: show alert when creating new tab in non-native fs
Fixes #1683

The root issue is #392 and we can likely find a way to fix it, but for
now let's prevent the full program hang by showing an alert.
2024-04-16 09:34:10 -07:00
Pete Schaffner b947ed0070 Update titlebar tabs when config changes 2024-04-05 16:40:04 +02:00
Pete Schaffner 4ede25dd00 Update standard title/tab bar when config changes 2024-04-05 15:19:55 +02:00
Pete Schaffner ab26863088 Merge remote-tracking branch 'upstream/main' into titlebar-unzoom-button 2024-04-03 15:25:51 +02:00
Pete Schaffner bbe35ee02e Revert luminance check from commit f7129880f5
This fixes the issues reporting wrong toolbar colors:
https://github.com/mitchellh/ghostty/pull/1550#issuecomment-2021538747
2024-03-28 10:51:00 +01:00
Pete Schaffner cf6017e777 Revert "Revert "Merge pull request #1550 from peteschaffner/titlebar-unzoom-button""
This reverts commit 7f59d844c0.
2024-03-28 10:48:05 +01:00