-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Fix minimal UI terminal top-row hit testing #6073
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
2685f38
test: cover minimal terminal titlebar hit testing
austinywang eaa049e
fix: keep minimal terminal top row clickable
austinywang 45049b3
Merge remote-tracking branch 'origin/main' into issue-6066-minimal-ui…
austinywang 4a0cbc1
test: move titlebar hit test out of large suite
austinywang 31df166
fix: preserve titlebar control hit testing
austinywang b6198ed
test: guard titlebar band preconditions
austinywang 7a74b84
test: use Swift Testing for titlebar hit tests
austinywang 293b605
fix: defer titlebar double-clicks over terminal
austinywang cedb2fa
perf: reuse terminal hit in titlebar routing
austinywang 44e1711
chore: normalize project file
austinywang 2fa0b9f
fix: defer app titlebar double-clicks over terminal
austinywang 227c6dc
fix: bound terminal titlebar hit lookup
austinywang 2b98ced
fix: align chrome titlebar terminal routing
austinywang 891801b
Merge origin/main into issue-6066-minimal-ui-toolbar-hittest
austinywang 0288a7f
perf: lazily resolve terminal titlebar hits
austinywang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| import AppKit | ||
|
|
||
| extension WindowTerminalHostView { | ||
| func hostedTerminalHitView(at point: NSPoint) -> NSView? { | ||
| for subview in subviews.reversed() { | ||
| guard let hostedView = subview as? GhosttySurfaceScrollView, | ||
| !hostedView.isHidden, | ||
| hostedView.alphaValue > 0, | ||
| hostedView.frame.contains(point) else { continue } | ||
|
|
||
| return hostedView.hitTest(point) ?? hostedView | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func hostedTerminalHitViewResolver(at point: NSPoint) -> () -> NSView? { | ||
| var cachedHitView: NSView? | ||
| var didResolve = false | ||
| return { | ||
| if !didResolve { | ||
| cachedHitView = self.hostedTerminalHitView(at: point) | ||
| didResolve = true | ||
| } | ||
| return cachedHitView | ||
| } | ||
| } | ||
|
|
||
| func hasHostedTerminal(at point: NSPoint) -> Bool { | ||
| hasHostedTerminal(at: point, in: self) | ||
| } | ||
|
|
||
| private func hasHostedTerminal(at point: NSPoint, in view: NSView) -> Bool { | ||
| guard !view.isHidden, view.alphaValue > 0 else { return false } | ||
| let pointInView = view.convert(point, from: self) | ||
| guard view.bounds.contains(pointInView) else { return false } | ||
| if view is GhosttySurfaceScrollView { return true } | ||
| for subview in view.subviews.reversed() { | ||
| if hasHostedTerminal(at: point, in: subview) { return true } | ||
| } | ||
| return false | ||
| } | ||
|
|
||
| static func hasHostedTerminal(atWindowPoint windowPoint: NSPoint, in window: NSWindow) -> Bool { | ||
| guard let rootView = window.contentView?.superview ?? window.contentView else { return false } | ||
| return hasHostedTerminal(atWindowPoint: windowPoint, in: rootView) | ||
| } | ||
|
|
||
| private static func hasHostedTerminal(atWindowPoint windowPoint: NSPoint, in view: NSView) -> Bool { | ||
| guard !view.isHidden, view.alphaValue > 0 else { return false } | ||
| let pointInView = view.convert(windowPoint, from: nil) | ||
| guard view.bounds.contains(pointInView) else { return false } | ||
|
|
||
| if let hostView = view as? WindowTerminalHostView { | ||
| let pointInHost = hostView.convert(windowPoint, from: nil) | ||
| if hostView.hasHostedTerminal(at: pointInHost) { | ||
| return true | ||
| } | ||
| } | ||
|
|
||
| for subview in view.subviews.reversed() { | ||
| if hasHostedTerminal(atWindowPoint: windowPoint, in: subview) { | ||
| return true | ||
| } | ||
| } | ||
|
|
||
| return false | ||
| } | ||
| } | ||
|
|
||
| func minimalModeTitlebarDoubleClickShouldDefer( | ||
| window: NSWindow, | ||
| locationInWindow: NSPoint | ||
| ) -> Bool { | ||
| isMinimalModeTitlebarControlHit(window: window, locationInWindow: locationInWindow) | ||
| || WindowTerminalHostView.hasHostedTerminal(atWindowPoint: locationInWindow, in: window) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.