From 54c14bc812035b89ae7bcb7c1257b377e879da10 Mon Sep 17 00:00:00 2001 From: Severus Date: Fri, 5 Apr 2024 14:34:21 +0700 Subject: [PATCH 1/5] Add note about GTK 4.14 --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 1f0c246e8..04be976fa 100644 --- a/README.md +++ b/README.md @@ -563,6 +563,11 @@ on the search path for a lot of software (such as Gnome and KDE) and installing into a prefix with `-p` sets up a directory structure to ensure all features of Ghostty work. +#### GTK 4.14 on Wayland's GL + +After upgrading to 4.14, many users got crashed. There is [open issue](https://gitlab.gnome.org/GNOME/gtk/-/issues/6589/note_2072039). +Workaround is running ghostty with `GDK_DEBUG=gl-disable-gles ghostty` + ### Mac `.app` To build the official, fully featured macOS application, you must From 51bfde69ba35cae91ee7ddf286f6cf0d419f1bac Mon Sep 17 00:00:00 2001 From: rok Date: Fri, 5 Apr 2024 19:55:17 +0900 Subject: [PATCH 2/5] input: do not emit sequence on when their's UTF-8 text --- src/input/KeyEncoder.zig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/input/KeyEncoder.zig b/src/input/KeyEncoder.zig index 26eea2907..0eb875b28 100644 --- a/src/input/KeyEncoder.zig +++ b/src/input/KeyEncoder.zig @@ -245,6 +245,10 @@ fn legacy( // If we're in a dead key state then we never emit a sequence. if (self.event.composing) return ""; + // When pressed backspace and have UTF-8 text, do not emit sequence. + // This prevents backspace emitted twice on macOS with korean input method. + if (self.event.key == .backspace and self.event.utf8.len > 0) return ""; + // If we match a PC style function key then that is our result. if (pcStyleFunctionKey( self.event.key, From d298186d5eb21baf6abc3d8b453e1a2f689156d3 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 5 Apr 2024 08:16:36 -0700 Subject: [PATCH 3/5] update README --- README.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 04be976fa..c9c2da43d 100644 --- a/README.md +++ b/README.md @@ -529,6 +529,13 @@ $ sudo apt install libgtk-4-dev libadwaita-1-dev git > Ubuntu 23.10 is 6.5.0 which has a bug which > [causes zig to fail its hash check for packages](https://github.com/ziglang/zig/issues/17282). +> [!WARNING] +> +> GTK 4.14 on Wayland has a bug which may cause an immediate crash. +> There is an [open issue](https://gitlab.gnome.org/GNOME/gtk/-/issues/6589/note_2072039) +> to track this GTK bug. You can workaround this issue by running ghostty with +> `GDK_DEBUG=gl-disable-gles ghostty` + On Arch Linux, use ``` @@ -563,11 +570,6 @@ on the search path for a lot of software (such as Gnome and KDE) and installing into a prefix with `-p` sets up a directory structure to ensure all features of Ghostty work. -#### GTK 4.14 on Wayland's GL - -After upgrading to 4.14, many users got crashed. There is [open issue](https://gitlab.gnome.org/GNOME/gtk/-/issues/6589/note_2072039). -Workaround is running ghostty with `GDK_DEBUG=gl-disable-gles ghostty` - ### Mac `.app` To build the official, fully featured macOS application, you must From 91ba47af1fa94bd1198ac8ae00fd6a171a703ff6 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 5 Apr 2024 08:25:14 -0700 Subject: [PATCH 4/5] input: add test for backspace change --- src/input/KeyEncoder.zig | 45 ++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/src/input/KeyEncoder.zig b/src/input/KeyEncoder.zig index 0eb875b28..266a32413 100644 --- a/src/input/KeyEncoder.zig +++ b/src/input/KeyEncoder.zig @@ -245,10 +245,6 @@ fn legacy( // If we're in a dead key state then we never emit a sequence. if (self.event.composing) return ""; - // When pressed backspace and have UTF-8 text, do not emit sequence. - // This prevents backspace emitted twice on macOS with korean input method. - if (self.event.key == .backspace and self.event.utf8.len > 0) return ""; - // If we match a PC style function key then that is our result. if (pcStyleFunctionKey( self.event.key, @@ -258,20 +254,23 @@ fn legacy( self.ignore_keypad_with_numlock, self.modify_other_keys_state_2, )) |sequence| pc_style: { - // If we're pressing enter or escape and have UTF-8 text, we probably - // are clearing a dead key state. This happens specifically on macOS. - // "Clearing" a dead key state may or may not commit the dead key - // state; this differs by language: + // If we have UTF-8 text, then we never emit PC style function + // keys. Many function keys (escape, enter, backspace) have + // a specific meaning when dead keys are active and so we don't + // want to send that to the terminal. Examples: // - // - Japanese clears and does not write the characters. - // - Korean clears and writes the characters. + // - Japanese: escape clears the dead key state + // - Korean: escape commits the dead key state + // - Korean: backspace should delete a single preedit char // - // We have a unit test for this. - if ((self.event.key == .enter or - self.event.key == .escape) and - self.event.utf8.len > 0) - { - break :pc_style; + if (self.event.utf8.len > 0) { + switch (self.event.key) { + else => {}, + .enter, + .escape, + .backspace, + => break :pc_style, + } } return copyToBuf(buf, sequence); @@ -1648,6 +1647,20 @@ test "kitty: keypad number" { try testing.expectEqualStrings("[57400;;49u", actual[1..]); } +test "legacy: backspace with utf8 (dead key state)" { + var buf: [128]u8 = undefined; + var enc: KeyEncoder = .{ + .event = .{ + .key = .backspace, + .utf8 = "A", + .unshifted_codepoint = 0x0D, + }, + }; + + const actual = try enc.legacy(&buf); + try testing.expectEqualStrings("A", actual); +} + test "legacy: enter with utf8 (dead key state)" { var buf: [128]u8 = undefined; var enc: KeyEncoder = .{ From dd0ec492e48bd5d6d2b51766af29f5f2b65421ea Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 5 Apr 2024 10:00:38 -0700 Subject: [PATCH 5/5] macos: wrap syncAppearance in async call Fixes #1656 When called as part of window restoration AppKit has a lock, so NSAppearance changes need to be called async. See deadlock: ``` Thread 1 Queue : com.apple.main-thread (serial) 0 0x000000018fd63fac in __ulock_wait () 1 0x00000001069bf720 in _dlock_wait () 2 0x00000001069bfaec in _dispatch_group_wait_slow () 3 0x0000000106b5f5c4 in interposed_dispatch_group_wait () 4 0x00000001937fb1f0 in NSCGSTransactionRunPreCommitActions_ () 5 0x00000001938f1230 in -[_NSCGSTransaction synchronize] () 6 0x00000001938f11ac in NSCGSTransactionSynchronize () 7 0x000000019382ad30 in +[NSCGSWindow(NSCGSSpace) isAnyWindowOnAVisibleSpace:] () 8 0x000000019382a968 in -[NSWindow _isInSomeVisibleSpace] () 9 0x000000019382a8e4 in -[NSWindow isOnActiveSpace] () 10 0x0000000193db8d98 in -[NSApplication(NSApplicationAppearance_Internal) _invalidateWindowAppearances] () 11 0x00000001938f44d4 in -[NSApplication(NSAppearanceCustomization) setAppearance:] () 12 0x0000000102c48050 in AppDelegate.syncAppearance() at /Users/mitchellh/code/go/src/github.com/mitchellh/ghostty/macos/Sources/App/macOS/AppDelegate.swift:412 13 0x0000000102c47840 in AppDelegate.configDidReload(_:) at /Users/mitchellh/code/go/src/github.com/mitchellh/ghostty/macos/Sources/App/macOS/AppDelegate.swift:380 14 0x0000000102c43c7c in AppDelegate.applicationDidFinishLaunching(_:) at /Users/mitchellh/code/go/src/github.com/mitchellh/ghostty/macos/Sources/App/macOS/AppDelegate.swift:110 ``` --- macos/Sources/App/macOS/AppDelegate.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/macos/Sources/App/macOS/AppDelegate.swift b/macos/Sources/App/macOS/AppDelegate.swift index 5f70c6ce6..34b4ba2b8 100644 --- a/macos/Sources/App/macOS/AppDelegate.swift +++ b/macos/Sources/App/macOS/AppDelegate.swift @@ -374,8 +374,10 @@ class AppDelegate: NSObject, syncMenuShortcuts() terminalManager.relabelAllTabs() - // Config could change window appearance - syncAppearance() + // Config could change window appearance. We wrap this in an async queue because when + // this is called as part of application launch it can deadlock with an internal + // AppKit mutex on the appearance. + DispatchQueue.main.async { self.syncAppearance() } // Update all of our windows terminalManager.windows.forEach { window in