367 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
Burak Yildiz
f3c6066be3 Reorder menu items (File, Edit, View ...) like most of the other apps 2023-12-28 21:43:24 +01:00
Mitchell Hashimoto
0008fb0a27 macos: set surface tree on init in restore
This prevents an unnecessary SurfaceView from being created. Creating a
SurfaceView is very expensive because this starts multiple threads,
creates the pty, starts the pty process, etc.

Additionally, this was exposing what I believe to be #497 when restoring
state: a surface view was created and destroyed very quickly causing
hangs on some machines. This still needs to be resolved but the behavior
in this commit was still a bug anyways.
2023-12-27 20:12:46 -08:00
Mitchell Hashimoto
181cfa1350 macos: notifications use surface UUID for lookups
Fixes #1162
2023-12-27 08:49:12 -08:00
Mitchell Hashimoto
789107ff1b macos: text in about window is selectable
Fixes #1163

I also fixed the AppIconImage from being 1024x1024 to much smaller so we
don't see as many artifacts in the downsize.
2023-12-27 07:53:28 -08:00
Mitchell Hashimoto
2aa7f12417 macos: increment restorable state version 2023-12-26 14:45:39 -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
20f9a3baab macos: reset state version to 1 2023-12-23 18:59:19 -08:00
Mitchell Hashimoto
c3b89fa215 macos: use securecoding for codablebridge to prevent warning
Thanks Matt Polzin!
2023-12-23 18:49:41 -08:00
Mitchell Hashimoto
a8568306c9 macos: store pwd with save/restore state 2023-12-23 17:06:34 -08:00
Mitchell Hashimoto
2390668834 macos: encode surface tree in state restore 2023-12-23 13:15:46 -08:00
Mitchell Hashimoto
a5d249eb48 config: if window-save-state is never, never restore state 2023-12-22 22:00:25 -08:00
Mitchell Hashimoto
f0bf0fd888 config: window-save-state 2023-12-22 21:51:06 -08:00
Mitchell Hashimoto
59f54a1d88 macos: initial window save/restore is working for frames only 2023-12-22 21:24:27 -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
Vivek Roy
aa75e7dfd8 macos: Implement context menu functionality to open tabs and windows. 2023-12-22 11:20:42 +05:30
Mitchell Hashimoto
0acf783700 macos: set the update URL 2023-12-19 08:04:36 -08:00
Mitchell Hashimoto
25342f545b macos: add update delegate so we can configure some behavior 2023-12-18 19:09:45 -08:00
Mitchell Hashimoto
f192ffd5bc macos: boilerplate to setup updater menu item 2023-12-18 19:09:45 -08:00
Mitchell Hashimoto
68a23e786d macos: put build numbers back into info.plist, other metadata
This adds more metadata back into the Info.plist for a build. This
metadata is used with the About window. The reason I want the build
number back is so that we have a monotonically increasing number to do
self-updating with (i.e. Sparkle).
2023-12-18 18:56:34 -08:00
Mitchell Hashimoto
9c0de96c79 Merge pull request #1116 from clebs/feature/settings-shortcut
macos: Add settings shortcut
2023-12-18 08:08:48 -08:00
Mitchell Hashimoto
7600c761ef fix callback struct ordering, use internal_os.open 2023-12-18 08:00:40 -08:00
Mitchell Hashimoto
97433d3aa1 macos: close all windows
Fixes #1052

This implements a `close_all_windows` binding in the core and implements
it for macOS specifically. This will ask for close confirmation if any
surface in any of the windows requires confirmation.

This is bound by default to option+shift+command+w to match Safari. The
binding is generall option+command+w but users may expect this to also
mean "Close All Other Tabs" which is the changed behavior if any tabs
are present in a standard macOS application. So I chose to follow Safari
instead.

This doesn't implement this feature for GTK, that's left as an exercise
for a contributor.
2023-12-17 20:54:57 -08:00
Mitchell Hashimoto
20ba6f3d78 macos: close_window binding works properly again
This binding closes the physical window and all surfaces in that window.
2023-12-17 20:29:23 -08:00
Mitchell Hashimoto
2e74a0f9d4 macos: custom about window so we can be a first responder
Fixes #1052

This implements the about window as a custom window with a view
controller. This lets us implement the proper responder chain so that
our custom close window IBActions do the right thing.

This has an additional benefit that we can easily customize this window
going forward.
2023-12-17 15:51:04 -08:00
Borja Clemente
646e3c365c Add settings shortcut on MacOS
- Settings shortcut opens the config file in the default editor.

Signed-off-by: Borja Clemente <borja.clemente@gmail.com>
2023-12-17 16:19:22 +01: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
45a4573991 macos: previous_tab/next_tab wraps
Fixes #999
2023-12-10 15:12:22 -08:00
Mitchell Hashimoto
ec989d6b46 macos: newTab needs to call Controller.showWindow 2023-12-08 08:46:05 -08:00
Mitchell Hashimoto
4b25356625 macos: manually show window to handle mission control behavior
Fixes #1018
Fixes #1020

This disables the "visibleAtLaunch" configuration in the xib and
manually shows the window when it loads. This lets us carefully control
what happens particularly when a window is full screen (native) and part
of Mission Control.

Previously, the behavior depended on the Settings.app "Prefer tabs
when opening documents" setting, but we didn't handle every behavior
correctly (see #1018 and #1020). I couldn't find a way to robustly
handle all cases because there are no published macOS APIs for
interacting with Mission Control...

Plus, terminals aren't really "documents" so it did confuse at least one
user that Ghostty would follow this configuration. We just incidently
did because we use native tabbing.

This PR takes full control into our own hands. Our behavior is now:

  - If a new window is created from a native fullscreen window, the
    new window is created into native fullscreen.

  - If a new tab is created from a native fullscreen window, the
    tab is added to the existing window and does not create a new space.

  - If a window or tab is created from a non-fullscreen window, the
    existing behaviors remain.
2023-12-07 22:44:47 -08:00
Mitchell Hashimoto
3f76094d84 macos: handle the "+" button automatically adding the window to the tabs
Fixes #1010
2023-12-07 14:39:54 -08:00
Mitchell Hashimoto
fc6def01a1 macos: new tab button creates new tab after short delay
Fixes #1010

I can't explain this. See the comment in the diff.
2023-12-07 12:35:19 -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
Mitchell Hashimoto
6fed7cde19 macos: do not open an initial window if opening from URL 2023-12-01 19:28:06 -08:00
Mitchell Hashimoto
7036676ec0 macos: relabel tabs when they're reordered with the mouse
Prior to this commit, the shortcut shown on the tab would not be updated
until a focus change occurred. There is no event for this so the way we
do it is by listening for the tab view frame to change, comparing the
window state, and then updating labels.
2023-11-22 11:43:04 -08:00
Mitchell Hashimoto
7d9eaddeb3 macos: alternate solution to ignoring "always" userTabbingPreference
Related to #642
Fixes #910

See #642 for why we want to ignore the "always" userTabbingPreference.
To do that, we'd set tabbingMode to "disallow" because we manually (in
code) handled it all.

Unfortunately, setting the tabbingMode to "disallow" introduce #910. I
still believe this is a macOS bug at heart, so I'm going to submit an
Apple Feedback item for it. However, I've found a workaround which I
also feel is the better solution, implemented here.

Instead of setting tabbingMode to "disallow" I now detect if we're in
the scenario where the user has their system tabbing preference set to
"always". In that case, we detect if the new window has been
automatically put into a tab group by macOS, and if so we remove it.

This all happens in the `windowDidLoad` controller callback. At this
phase, our Ghostty-managed windows should NEVER be in a tab group,
because "new tab" adds them to a tab _after_. So we can be certain that
if we're already in a tab group it was from the macOS system setting.

This happens to fix #910.
2023-11-18 21:09:08 -08:00
Gregory Anders
be7be538af macos: ensure all surfaces are closed when a window is closed 2023-11-18 08:40:40 -06:00
Gregory Anders
86b7442f3c macos: implement desktop notifications 2023-11-15 11:21:30 -06:00
Gregory Anders
54a489eefa macos: remove optional from Ghostty.AppState.surfaceUserdata
The return value of takeUnretainedValue() is non-optional, so this
function was never _actually_ returning an optional value, so the guard
clauses sprinkled throughout were unnecessary.
2023-11-15 10:36:45 -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