Commit Graph

43 Commits (aa6c349545c1674f4fb0f0fad1c636bb034a006d)

Author SHA1 Message Date
Mitchell Hashimoto d1f1be8833
macos: fix small memory leak in surface tree when closing splits
This fixes a small memory leak I found where the `SplitNode.Leaf` was
not being deinitialized properly when closing a split. It would get
deinitialized the next time a split was made or the window was closed,
so the leak wasn't big. The surface view underneath the split was also
properly deinitialized because we forced it, so again, the leak was
quite small.

But conceptually this is a big problem, because when we change the
surface tree we expect the deinit chain to propagate properly through
the whole thing, _including_ to the SurfaceView.

This fixes that by removing the `id(node)` call. I don't find this to be
necessary anymore. I don't know when that happened but we've changed
quite a lot in our split system since it was introduced. I'm also not
100% sure why the `id(node)` was causing a strong reference to begin
with... which bothers me a bit.

AI note: While I manually hunted this down, I started up Claude Code and
Codex in separate tabs to also hunt for the memory leak. They both
failed to find it and offered solutions that didn't work.
2025-06-02 14:12:26 -07:00
Mitchell Hashimoto fd7132db71
macos: quick terminal can equalize splits
Fixes #7480
2025-05-30 15:13:30 -07:00
Mitchell Hashimoto 2caa8a3fe1
macOS: move window title handling fully to AppKit
Fixes #7236
Supersedes #7249

This removes all of our `focusedValue`-based tracking of the surface
title and moves it completely to the window controller. The window
controller now sets up event listeners (via Combine) when the focused
surface changes and updates the window title accordingly.

There is some complicated logic here to handle when we lose focus to
something other than a surface. In this case, we want our title to be
the last focused surface so long as it exists.
2025-05-06 14:57:19 -07:00
Mitchell Hashimoto 732500b418
feat: implement toggleMaximize for macOS (#7191)
Resolve #7030
2025-05-06 13:43:57 -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
Aaron Ruan 13f776d483
Rename maximize notification and refine handler 2025-04-28 10:20:29 +08:00
Aaron Ruan 1ec3e331de
Refactor toggleMaximize to use notifications 2025-04-27 08:48:06 +08:00
Mitchell Hashimoto 63b4cb4ead
macOS: fix responder chain 2025-04-21 10:17:02 -07:00
Mitchell Hashimoto 6d2685b5a2
add toggle command palette binding 2025-04-21 10:05:30 -07:00
Mitchell Hashimoto 8bd91e7104
macOS: hook up full action execution 2025-04-21 09:40:08 -07:00
Mitchell Hashimoto 0915a7af46
macOS: extract TerminalCommandPalette 2025-04-21 09:18:46 -07: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
mbrown379 b1df97b33f Add Split Left and Split Up to menu 2025-02-16 15:14:02 -05: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
Wes Campaigne e86b9a112e Implement "Paste Selection" on macOS like Terminal.app 2025-01-08 09:26:13 -08:00
Mitchell Hashimoto 9503c9fe50
Rename `goto_split` top/bottom directions to up/down. (#3427)
Renames the top/bottom directions of `goto_split` to up/down. I have
tested this on linux (nixos) but given that `goto_split` is broken on
linux anyway (#2866) there's not a whole lot to test.

I have no way to build on macOS so I can't verify that I've changed
everything correctly for that.

Closes #3237
2025-01-02 07:08:16 -08:00
Mitchell Hashimoto dd41a9447d
macOS: weak self for event monitor to avoid retain cycle for controllers
Fixes #3219

We were holding a reference cycle to the base terminal controller. This
was preventing the window from ever being fully deallocated.
2024-12-30 13:45:14 -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
Caleb Norton 8607b1f844
macos: correctly save terminal fullscreen style 2024-12-29 21:24:48 -06:00
Daniel Patterson a4daabb28a Rename `goto_split` top/bottom directions to up/down. 2024-12-27 14:56:48 +00: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 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 9dfe1fc7a0
Merge pull request #2553 from ghostty-org/push-zxvmpvrlxusn
macos: rectangle select only requires option + drag
2024-10-30 20:50:57 -04:00
Mitchell Hashimoto c97c0858be
macos: rectangle select only requires option + drag
Fixes #2537

This matches Terminal.app. iTerm2 requires cmd+option (our old
behavior). Kitty doesn't seem to support rectangle select or I couldn't
figure out how to make it work. WezTerm matches Terminal.app too.
Outside of terminal emulators, this is also the rectangular select
binding for neovim.
2024-10-30 20:47:24 -04: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 756755c052
comment 2024-10-30 16:45:55 -04:00
Marvin A. Ruder b454f90a1a
Replace check
* Check whether window is fullscreen before clamping
2024-10-30 21:42:25 +01:00
Marvin A. Ruder 7db9528aca
fix(macOS): Fix visual glitch when switching between full-screen apps
* Check whether window is on active space before clamping

Fixes #2527
2024-10-30 19:56:01 +01:00
Mitchell Hashimoto 67bc9fa0bc
macos: nuke the titlebar from orbit when hidden 2024-10-24 21:06:45 -07:00
johnseth97 e11fb62627
Fixed type conversion garbage 2024-10-24 23:47:34 -04:00
johnseth97 6c37fe2c26
Fixed conversion error between string and enum 2024-10-24 23:06:18 -04:00
johnseth97 f78ddabc15
refactored proxyIconURLDidChange to pwdDidChange 2024-10-24 23:01:54 -04:00
johnseth97 8e223fdcd9
Reworked proxy icon, added config options. 2024-10-24 21:54:08 -04: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
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
Mitchell Hashimoto a2ba7b4948
macos: don't swallow flagsChanged events, breaks system bindings
Fixes #2419
2024-10-09 10:17:39 -07:00
Mitchell Hashimoto e3dd0edc4f
macos: use local event listener to propagate modifier changes to all
Related to #1547

Concretely, if you are highlighting a link and then release the
modifier, the other surfaces will be notified of this change.
2024-10-05 10:33:15 -10: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 1977e220f5
macos: slide terminal exit and close window don't kill the window 2024-09-28 10:51:40 -07:00
Mitchell Hashimoto 50fb7331af
macos: base class for terminal controller 2024-09-28 10:41:51 -07:00