94 Commits

Author SHA1 Message Date
Mitchell Hashimoto
40e882ff48 macos: invalid restorable state when surface is closed
Fixes #1177
2023-12-28 19:39:47 -08:00
Mitchell Hashimoto
181cfa1350 macos: notifications use surface UUID for lookups
Fixes #1162
2023-12-27 08:49:12 -08:00
Mitchell Hashimoto
98041940f0 macos: restore focused split on app restore 2023-12-26 14:45:27 -08:00
Mitchell Hashimoto
a321ef515d macos: assign unique UUID per surface, store in app state 2023-12-26 14:24:05 -08:00
Mitchell Hashimoto
a8568306c9 macos: store pwd with save/restore state 2023-12-23 17:06:34 -08:00
Chris Marchesi
e1320be757 macos: handle middle click
This adds middle-click support to MacOS.

Very simple update, since everything else is in place to handle mouse
clicks in the embedded runtime already, we just needed to add the event
handlers in the UI.
2023-12-22 00:05:28 -08:00
Mitchell Hashimoto
9642dd3275 macos: proper event when sided mod released with other side pressed
Related to https://github.com/mitchellh/ghostty/issues/1082

This fixes two separate issues to follow along with the new spec changes
Kovid pushed to Kitty:

  1. When two modifiers are pressed and one is released, this shows up
     as a proper release event with the correct side. Previously, the
     correct side was shown but as a press event.

  2. When two modifiers are pressed and one is released, the Kitty event
     should not have that specific modifier set. For example, pressing
     left ctrl, then right ctrl, then releasing right ctrl should encode
     as "right ctrl released" but with NO modifiers still present.
2023-12-13 21:50:00 -08:00
Mitchell Hashimoto
9f7e53620b Merge pull request #1070 from mattrobenolt/overlay-color
Configurable unfocused dimming color
2023-12-13 19:10:22 -08:00
Mitchell Hashimoto
220da88a9a config: make unfocused-split-fill default to bg 2023-12-13 19:06:25 -08:00
Mitchell Hashimoto
fefd4ca04d macos: style changes, make equivalent not an optional 2023-12-13 13:49:39 -08:00
Gregory Anders
163ee1d75a macos: special case handling of some control keys
Some control key combinations must be handled specially by Ghostty to
prevent undesirable behavior at the OS level. For now, this includes
only Ctrl-/, which makes a "beep" sound when processed by AppKit. It is
unclear why this beep occurs and no answer was found after extensive
searching.

This solution is inspired by iTerm2, which also handles certain control
key combinations (including C-/) manually before passing them on to
Cocoa/AppKit.
2023-12-13 14:46:34 -06:00
Matt Robenolt
ae6645586e unpack rgb correctly 2023-12-12 21:56:35 -08:00
Matt Robenolt
1b039b35ac typos 2023-12-12 17:22:37 -08:00
Matt Robenolt
91937c4ada Apply feedback 2023-12-12 17:14:47 -08:00
Matt Robenolt
8e607f372b Configurable unfocused dimming color 2023-12-12 16:34:41 -08:00
Mitchell Hashimoto
ec989d6b46 macos: newTab needs to call Controller.showWindow 2023-12-08 08:46:05 -08:00
Mitchell Hashimoto
7ea0dfdd5d macos: if a preedit state is cleared, don't send key event
Fixes #992
2023-12-06 09:04:59 -08:00
Gregory Anders
86b7442f3c macos: implement desktop notifications 2023-11-15 11:21:30 -06:00
Mitchell Hashimoto
ab948f6f8f macos: reuse original event if translation mods changes nothing
Fixes #766 (again)

This is a repeat fix of 766 after fixing a number of other regressions
from the original fix. See the comment for reasons.
2023-11-14 08:14:24 -08:00
Mitchell Hashimoto
35e78939e5 macos: ignore alt key with other modifiers set
This enables shifted alt-prefixed keys, such as `shift+alt+.` on
US standard becoming `M->`. To do this, we needed to fix a few bugs:

  (1) translation mods should strip alt even if other mods are set
  (2) AppKit translation event needs to construct new characters with
      the translation mods.
  (3) Alt-prefix handling in KeyEncoder needs to allow ASCII utf8
      translations even for macOS.
2023-11-13 19:21:51 -08:00
Mitchell Hashimoto
5001e2c60c macos: filter option in AppKit when option-as-alt set
Fixes #872

In #867 we fixed macos-option-as-alt, but unfortunately AppKit ALSO does
some translation so some behaviors were not working correctly.
Specifically, when you had macos-option-as-alt set, option+e would
properly send `esc+e` to the pty but it would ALSO set the dead key
state for "`" since AppKit was still translating the option key.

This commit introduces a function to strip alt when necessary from the
translation modifiers used at the AppKit layer, preventing this
behavior.
2023-11-13 13:26:37 -08:00
Mitchell Hashimoto
dd1faf5e50 macos: handle preedit in AppKit, enables Korean input 2023-11-10 09:53:56 -08:00
Gregory Anders
582df33083 macos: use Ghostty.AppState as @EnvironmentObject
This is a small cleanup change. This provides the Ghostty.AppState
object to any view that needs it within the TerminalSplit view hierarchy
without needing to explicitly define EnvironmentKeys.
2023-11-05 20:42:59 -06:00
Gregory Anders
3b2799ce97 macos: refactor SplitNode
This commit does two things: adds a weak reference to the parent
container of each SplitNode.Container and SplitNode.Leaf and moves the
"direction" of a split out of the SplitNode enum and into the
SplitNode.Container struct as a field.

Both changes are required for supporting split resizing. A reference to
the parent in each leaf and split container is needed in order to
traverse upwards through the split tree. If the focused split is not
part of a container that is split along the direction that was requested
to be resized, then we instead try and resize the parent. If the parent
is split along the requested direction, then it is resized
appropriately; otherwise, repeat until the root of the tree is reached.

The direction is needed inside the SplitNode.Container object itself so
that the container knows whether or not it is able to resize itself in
the direction requested by the user. Once the split direction was moved
inside of SplitNode.Container, it became redundant to also have it as
part of the SplitNode enum, so this simplifies things.
2023-11-05 20:20:39 -06:00
Mitchell Hashimoto
c6ce9aea4a macos: do not set window initial size if fullscreen
Fixes #798
2023-11-03 09:06:17 -07:00
Mitchell Hashimoto
b40245f01d macos: remove old primary window stuff 2023-10-30 14:36:20 -07:00
Mitchell Hashimoto
cd18f3455b macos: add needsConfirmQuit helper to surface and split structs 2023-10-30 09:06:23 -07:00
Gregory Anders
0f73bf32e6 macos: document SurfaceView.cellSize property 2023-10-27 09:23:17 -05:00
Gregory Anders
2ee80a52df macos: set window resizeIncrements when cell size changes
The resizeIncrements property is only modified when the cell size of the
focused window changes. If two splits have the same cell size then the
property is not modified when focusing between the two splits.
2023-10-26 20:27:58 -05:00
Mitchell Hashimoto
be46bea40f macos: fix warning from xcode 2023-10-26 14:45:55 -07:00
Mitchell Hashimoto
1696cf76b6 macos: free inspector when it is hidden 2023-10-25 09:09:10 -07:00
Mitchell Hashimoto
5e2bed62b3 macos: terminal inspector control 2023-10-24 15:27:14 -07:00
Mitchell Hashimoto
92d172377e macos: don't do full surface-style key translation for imgui 2023-10-24 15:27:14 -07:00
Mitchell Hashimoto
d50ff6ece7 macos: complete cimgui events 2023-10-24 15:27:14 -07:00
Mitchell Hashimoto
2c40183c3c macos: rendering basic imgui 2023-10-24 15:27:14 -07:00
Mitchell Hashimoto
69cc6d11dc macos: MetalView, render an MTKView 2023-10-24 15:27:14 -07:00
Jon Parise
d63c0df582 macos: always apply initial size to new windows
We would previously exit early for non-transparent windows, which
skipped the call to setInitialWindowSize().
2023-10-21 08:21:58 -07:00
Mitchell Hashimoto
6990c1572a macos: insertText should not include null char 2023-10-14 21:06:34 -07:00
Mitchell Hashimoto
f987a36fce macos: escape shell-sensitive characters on filepath drop 2023-10-04 10:49:32 -07:00
Mitchell Hashimoto
2aacf6e130 macos: support dropping file urls onto surfaces 2023-10-04 08:01:13 -07:00
Mitchell Hashimoto
ee832aa361 apprt/embedded: ghostty_surface_text function, remove _char 2023-10-04 07:56:56 -07:00
Mitchell Hashimoto
e471228f6b macos: surfaceview supports dropping file URLs, just logs for now 2023-10-03 22:40:56 -07:00
Mitchell Hashimoto
6249621d71 macos: support drag and drop with no windows 2023-10-03 22:03:04 -07:00
Mitchell Hashimoto
d5299fec25 macos: use SurfaceConfiguration everywhere instead of bare c struct 2023-10-03 22:00:56 -07:00
Mitchell Hashimoto
a1a8aeb104 initial window size needs to take into account window chrome 2023-09-30 21:35:50 -07:00
Mitchell Hashimoto
cc8e1cd936 macos: support initial window size 2023-09-30 20:47:31 -07:00
Mitchell Hashimoto
300ba32ad0 macos: enum does not need to be a string 2023-09-22 15:48:41 -07:00
Mitchell Hashimoto
1eb0dbb548 macos: more robust cursor visibility handling
Fixes #519

The core issue here was that `mouseEntered` was called AFTER
`cursorUpdate` (by Cocoa) so we were messing up our NSCursor state. To
fix this more robustly, all cursor state should ONLY be handled by
cursorUpdate and mouseEntered/Exit goes through that system now.
2023-09-22 15:47:08 -07:00
Mitchell Hashimoto
7f549c5b41 macos: detect mouseEntered/Exit on frame change 2023-09-21 09:42:17 -07:00
Mitchell Hashimoto
d12f07ceda macos: mouse tracking area should always send
Without this, non-first-responder views would not receive mouse
entered/exit events. This would break some of our mouse hiding state.
See comments for more info.
2023-09-21 09:30:42 -07:00