ghostty/macos/Sources/Helpers/EventSinkHostingView.swift
Qwerasd 16919488da macOS: add macos-titlebar-style = hidden
Hides titlebar without removing the other typical window frame elements
2024-09-20 16:11:51 -06:00

34 lines
796 B
Swift

import SwiftUI
/// Custom subclass of NSHostingView which sinks events so that we can
/// stop the window from receiving events originating from within this view.
class EventSinkHostingView<Content: View>: NSHostingView<Content> {
override var acceptsFirstResponder: Bool {
return true
}
override func becomeFirstResponder() -> Bool {
return true
}
override func acceptsFirstMouse(for event: NSEvent?) -> Bool {
return true
}
override func mouseDown(with event: NSEvent) {
// Do nothing
}
override func mouseDragged(with event: NSEvent) {
// Do nothing
}
override func mouseUp(with event: NSEvent) {
// Do nothing
}
override var mouseDownCanMoveWindow: Bool {
return false
}
}