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.
This commit is contained in:
Mitchell Hashimoto
2024-09-26 16:18:11 -07:00
parent 84e0a05027
commit 4ae20212bf
17 changed files with 1451 additions and 948 deletions

View File

@@ -13,8 +13,18 @@ class FullScreenHandler {
var isInNonNativeFullscreen: Bool = false
var isInFullscreen: Bool = false
func toggleFullscreen(window: NSWindow, nonNativeFullscreen: ghostty_non_native_fullscreen_e) {
let useNonNativeFullscreen = nonNativeFullscreen != GHOSTTY_NON_NATIVE_FULLSCREEN_FALSE
func toggleFullscreen(window: NSWindow, mode: ghostty_action_fullscreen_e) {
let useNonNativeFullscreen = switch (mode) {
case GHOSTTY_FULLSCREEN_NATIVE:
false
case GHOSTTY_FULLSCREEN_NON_NATIVE, GHOSTTY_FULLSCREEN_NON_NATIVE_VISIBLE_MENU:
true
default:
false
}
if isInFullscreen {
if useNonNativeFullscreen || isInNonNativeFullscreen {
leaveFullscreen(window: window)
@@ -27,7 +37,7 @@ class FullScreenHandler {
isInFullscreen = false
} else {
if useNonNativeFullscreen {
let hideMenu = nonNativeFullscreen != GHOSTTY_NON_NATIVE_FULLSCREEN_VISIBLE_MENU
let hideMenu = mode != GHOSTTY_FULLSCREEN_NON_NATIVE_VISIBLE_MENU
enterFullscreen(window: window, hideMenu: hideMenu)
isInNonNativeFullscreen = true
} else {