mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-09-29 06:28:37 +00:00
Use shallow search to improve performance
This commit is contained in:
@@ -37,9 +37,9 @@ class TerminalWindow: NSWindow {
|
|||||||
override func updateConstraintsIfNeeded() {
|
override func updateConstraintsIfNeeded() {
|
||||||
super.updateConstraintsIfNeeded()
|
super.updateConstraintsIfNeeded()
|
||||||
|
|
||||||
guard let titlebarContainer = contentView?.superview?.firstSubview(withClassName: "NSTitlebarContainerView") else {
|
guard let titlebarContainer = contentView?.superview?.subviews.first(where: {
|
||||||
return
|
$0.className == "NSTitlebarContainerView"
|
||||||
}
|
}) else { return }
|
||||||
|
|
||||||
for v in titlebarContainer.subviews(withClassName: "NSTitlebarSeparatorView") {
|
for v in titlebarContainer.subviews(withClassName: "NSTitlebarSeparatorView") {
|
||||||
v.isHidden = true
|
v.isHidden = true
|
||||||
@@ -82,9 +82,9 @@ class TerminalWindow: NSWindow {
|
|||||||
func setTitlebarBackground(_ color: CGColor) {
|
func setTitlebarBackground(_ color: CGColor) {
|
||||||
storedTitlebarBackgroundColor = color
|
storedTitlebarBackgroundColor = color
|
||||||
|
|
||||||
guard let titlebarContainer = contentView?.superview?.firstSubview(withClassName: "NSTitlebarContainerView") else {
|
guard let titlebarContainer = contentView?.superview?.subviews.first(where: {
|
||||||
return
|
$0.className == "NSTitlebarContainerView"
|
||||||
}
|
}) else { return }
|
||||||
|
|
||||||
titlebarContainer.wantsLayer = true
|
titlebarContainer.wantsLayer = true
|
||||||
titlebarContainer.layer?.backgroundColor = color
|
titlebarContainer.layer?.backgroundColor = color
|
||||||
@@ -146,10 +146,9 @@ class TerminalWindow: NSWindow {
|
|||||||
guard let accessoryClipView = accessoryView.superview else { return }
|
guard let accessoryClipView = accessoryView.superview else { return }
|
||||||
guard let titlebarView = accessoryClipView.superview else { return }
|
guard let titlebarView = accessoryClipView.superview else { return }
|
||||||
guard titlebarView.className == "NSTitlebarView" else { return }
|
guard titlebarView.className == "NSTitlebarView" else { return }
|
||||||
|
guard let toolbarView = titlebarView.subviews.first(where: {
|
||||||
guard let toolbarView = titlebarView.firstSubview(withClassName: "NSToolbarView") else {
|
$0.className == "NSToolbarView"
|
||||||
return
|
}) else { return }
|
||||||
}
|
|
||||||
|
|
||||||
addWindowButtonsBackdrop(titlebarView: titlebarView, toolbarView: toolbarView)
|
addWindowButtonsBackdrop(titlebarView: titlebarView, toolbarView: toolbarView)
|
||||||
guard let windowButtonsBackdrop = windowButtonsBackdrop else { return }
|
guard let windowButtonsBackdrop = windowButtonsBackdrop else { return }
|
||||||
|
@@ -1,17 +1,6 @@
|
|||||||
import AppKit
|
import AppKit
|
||||||
|
|
||||||
extension NSView {
|
extension NSView {
|
||||||
func firstSubview(withClassName name: String) -> NSView? {
|
|
||||||
for subview in subviews {
|
|
||||||
if String(describing: type(of: subview)) == name {
|
|
||||||
return subview
|
|
||||||
} else if let found = subview.firstSubview(withClassName: name) {
|
|
||||||
return found
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func subviews(withClassName name: String) -> [NSView] {
|
func subviews(withClassName name: String) -> [NSView] {
|
||||||
var result = [NSView]()
|
var result = [NSView]()
|
||||||
|
Reference in New Issue
Block a user