197 Commits

Author SHA1 Message Date
Will Pragnell
f6e2b50732 macos: fix non-native-fullscreen menu & dock visibility bugs 2023-09-01 21:45:45 -07:00
Will Pragnell
86122624e0 macos: add visible-menu non-native-fullscreen option 2023-09-01 21:45:45 -07:00
Mitchell Hashimoto
e0015a0d00 macos: hacks to grab surface focus on macOS 12
See comment in code.
2023-09-01 16:23:30 -07:00
Karol Bakunowski
d7072cd29e macos: default to sRGB color space 2023-09-01 15:05:16 -07:00
Mitchell Hashimoto
d945640401 macos: break reference cycle to window to allow window to free memory
Fixes #366

The comment in the Swift code explains what was happening here:

> I don't know if this is the right place, but because of WindowAccessor in our
> SwiftUI hierarchy, we have a reference cycle between view and window and windows
> are never freed. When the window is closed, the window controller is deinitialized,
> so we can use this opportunity detach the view from the window and break the cycle.

An alternate solution would be to make our reference back to the window
"weak" but we appear to not be able to do that with SwiftUI property
wrappers such as `@State` and `@Binding` and so on.
2023-09-01 09:12:03 -07:00
Mitchell Hashimoto
b7508cdc66 macos: setup delegate for app state, config reload callback 2023-08-31 11:56:15 -07:00
Mitchell Hashimoto
10aaf8bd35 macos: sync all remaining menu items 2023-08-31 11:44:43 -07:00
Mitchell Hashimoto
76053460d5 macos: sync File menu 2023-08-31 11:40:21 -07:00
Mitchell Hashimoto
22b925223a macos: sync many more menu items 2023-08-31 11:33:58 -07:00
Mitchell Hashimoto
c7071a1da2 macos: complete lookup table for key equivalents 2023-08-31 11:14:07 -07:00
Mitchell Hashimoto
52396304ff macos: begin syncing menuitem key equivalents 2023-08-30 22:45:29 -07:00
Mitchell Hashimoto
c71979804e apprt/embedded: ghostty_surface_binding_action can now run any action 2023-08-30 21:46:38 -07:00
Will Pragnell
55d5350a65 macos: fix non-native fullscreen dock/menubar bugs 2023-08-26 19:35:19 -07:00
Thorsten Ball
be114e792f macOS: fix cascading windows when using tabs and closing windows
This fixes two things:

1. Issue #294: cascade point for new windows is set when creating new tabs
2. Cascade point was *not* reset when closing windows, which lead to a
   big "gap" appearing when, say, opening 5 windows, closing 4, opening
   a new window.
2023-08-19 20:21:20 +02:00
Thorsten Ball
a76aea4d0a macOS: new split can inherit font size 2023-08-19 09:59:04 +02:00
Thorsten Ball
2e9b787668 macOS: new window can inherit font size
This is the second part of #281 and adds the same mechanism that was
added for tabs in #296 for windows.

It works exactly the same way.
2023-08-19 09:29:56 +02:00
Mitchell Hashimoto
4f5460475c Merge pull request #296 from mitchellh/mrn/macos-inherit-font-size
macOS: inherit font size when creating new tab
2023-08-18 09:22:06 -07:00
Mitchell Hashimoto
a18503fc01 macos: can always set base config on new tab 2023-08-18 09:21:47 -07:00
Mitchell Hashimoto
79971c62a6 macos: pass around a base surface_config_s rather than a new tab 2023-08-18 09:09:43 -07:00
Thorsten Ball
cda87a6963 embedded: use separate struct to pass options to new_tab_cb 2023-08-18 06:50:47 +02:00
Thorsten Ball
12311e9707 macOS: simplify code for new tab 2023-08-18 06:26:15 +02:00
Thorsten Ball
3e7c4475a1 macOS: move newTab code to PrimaryWindowManager 2023-08-17 20:57:00 +02:00
Thorsten Ball
d2dae7a696 macOS: inherit font size when creating new tab
This is one part of #281.
2023-08-17 20:56:56 +02:00
Thorsten Ball
0597b03fa2 macOS: remove dead code from PrimaryWindowController
I think this is a left-over from the refactor that moved this field to
the `PrimaryWindowManager`.
2023-08-17 07:04:46 +02:00
Mitchell Hashimoto
721087be76 macos: send the left/right status of modifier keys 2023-08-14 12:40:48 -07:00
Mitchell Hashimoto
d5df8aea9a apprt/embedded: handle repeat events 2023-08-11 12:02:00 -07:00
Mitchell Hashimoto
1e1ad7deb9 macos: use the new self-hosted translation 2023-08-11 12:02:00 -07:00
Mitchell Hashimoto
57a527b0c9 macos: detect keyboard layout change and reload the keymap 2023-08-11 12:01:59 -07:00
Mitchell Hashimoto
3d23f26326 input, macos: initial work on keymapper and macos usage of it 2023-08-11 12:01:58 -07:00
Mitchell Hashimoto
688ab84661 apprt/embedded: allow noting that selection clipboard is not supported 2023-08-09 14:52:22 -07:00
Mitchell Hashimoto
afc6a9976f apprt/embedded: support selection clipboard 2023-08-09 14:29:39 -07:00
Kevin Hovsäter
22b8173164 Fix typos 2023-08-08 14:27:34 +02:00
Mitchell Hashimoto
22296b377a Revert "Merge pull request #244 from mitchellh/alt-as-esc"
This reverts commit c139279d479682c17f63d9b57c2d56608d09d16a, reversing
changes made to 4ed21047a734d7c586debe0026e3b6ea90ed1622.

We do want to do this but this broke bindings.
2023-08-07 17:06:40 -07:00
Mitchell Hashimoto
67cbabd605 make keyboard modifiers left/right-aware throughout core 2023-08-07 14:33:56 -07:00
Mitchell Hashimoto
5f5a23acc4 macos: help menu goes to the github repo 2023-08-05 15:03:17 -07:00
Mitchell Hashimoto
d895887361 macos: enable copy/paste menu items in "Edit" 2023-08-05 14:50:18 -07:00
Mitchell Hashimoto
2f6159b16d macos: quit menu should say "Ghostty" 2023-08-05 13:04:06 -07:00
Mitchell Hashimoto
bbe171f314 macos: remove unimplemented menu items 2023-08-05 11:59:57 -07:00
Thorsten Ball
1908895303 macos: re-add Edit submenu to main menu
This menu got list in #215 and with it we lost the ability to use the
macOS emoji picker via the `Cmd+Ctrl Space` shortcut, for example.

This adds a standard Edit menu back to the main menu.
2023-08-05 20:51:43 +02:00
Mitchell Hashimoto
2752995ec5 macos: Cmd-Q without any window focus works
Previously, this would crash. Once the crash was fixed, it would hang
because we would only show confirmation if the terminal window had
focus.

This introduces some medium complexity logic to work around this:

  1. If we are the key window, then show the confirmation dialog. Done.
  2. Otherwise, if any other window is a terminal window and is key,
     they're going to take it so we do nothing.
  3. Otherwise, if we are the first terminal window in the application
     windows list, we show it even if we're not focused.
2023-08-05 10:43:56 -07:00
Mitchell Hashimoto
7c98f991db macos: new tab menu/shortcut works even if no windows are present 2023-08-04 17:45:57 -07:00
Mitchell Hashimoto
8c01160afa macos: "+" button ensures tab is added to same window group 2023-08-04 17:39:40 -07:00
Mitchell Hashimoto
bb7c67b967 macos: implement newWindowForTab for "+" button 2023-08-04 17:35:57 -07:00
Mitchell Hashimoto
994d456223 set the title of the window 2023-08-04 17:24:28 -07:00
Mitchell Hashimoto
9105637697 macos: reorganize, rename, put files in groups 2023-08-04 17:17:18 -07:00
Mitchell Hashimoto
bf190ba442 macos: merge AppController and AppDelegate, organize groups 2023-08-04 17:05:52 -07:00
Thorsten Ball
b56ffa6285 Add config setting to turn non-native fullscreen on or off 2023-08-04 14:12:33 -07:00
Thorsten Ball
850bf3e945 macos: add support for non-native fullscreen mode
This adds support for what's commonly referred to as "non-native
fullscreen": a fullscreen-mode that doesn't use macOS' native fullscreen
mechanism and thus doesn't use animations and a separate space on which
to display the fullscreen window. Instead it's really fast and it allows
the user to `Cmd+tab` to other windows, with the fullscreen-ed window
staying in the background.

Another name for it is "traditional fullscreen" since it was the default
pre Mac OS X Lion, if I remember correctly.

Other applications that offer macOS non-native fullscreen:

- Kitty: https://sw.kovidgoyal.net/kitty/conf/#opt-kitty.macos_traditional_fullscreen
- wezterm: https://wezfurlong.org/wezterm/config/lua/config/native_macos_fullscreen_mode.html
- MacVim
- IINA: fc66b27d50/iina/MainWindowController.swift (L1401-L1423)
- mpv: https://mpv.io/manual/stable/#options-native-fs
- iTerm2

Adding this wasn't straightforward, as it turned out. Mainly because
SwiftUI's app lifecycle management doesn't allow one to use a custom
class for the windows it creates. And without custom classes we'd always
get a warning when entering/leaving fullscreen mode.

So what I did here is the following:

- remove SwiftUI app lifecycle management
- introduce `MainMenu.xib` to define the main menu via interface builder
- add `GhosttyAppController` to handle requests from the app
- add a `main.swift` file to boot up the app without a storyboard and
  without SwiftUI lifecycle management
- introduce the `FullScreenHandler` to manage non-native fullscreen -
  this is where the "magic" is

But since removing the SwiftUI lifecycle management also means removing
the top-level `App` that means I had to introduce the menu (which I
mentioned), but also tab and window management.

So I also added the `WindowService` which manages open tabs and windows.
It's based on the ideas presented in

    https://christiantietze.de/posts/2019/07/nswindow-tabbing-multiple-nswindowcontroller/

and essentially keeps tracks of windows.

Then there's some auxilliary changes: `CustomWindow` and `WindowController` and so on.

Now everything still works, in addition to non-native fullscreen:

* opening/closing of tabs
* opening/closing of windows
* splits
* `gotoTab`

Worthy of note: when toggling back from non-native fullscreen to
non-fullscreen I had to manually implement the logic to re-add the
window back to a tabgroup. The only other app that supports tabs with
non-native FS is iTerm2 and they have implemented their own tab
management to keep the tab bar even in non-native FS -- that's a bit too
much for me. Every other app has non-native apps and doesn't have to
wory about it.
2023-08-04 14:12:30 -07:00
Mitchell Hashimoto
b11734bd67 default the title to the ghostty emoji
This only happens if the shell hasn't reported a pwd AND title.
2023-08-04 11:11:15 -07:00
Mitchell Hashimoto
9a079bb5b9 background-blur-radius for macOS 2023-07-03 20:43:53 -07:00