File tree Expand file tree Collapse file tree 2 files changed +19
-17
lines changed
Modules/Sources/AppKitExtensions/UI Expand file tree Collapse file tree 2 files changed +19
-17
lines changed Original file line number Diff line number Diff line change @@ -12,17 +12,25 @@ public extension NSWindow {
1212 }
1313
1414 var toolbarEffectView : NSVisualEffectView ? {
15- var result : NSVisualEffectView ?
16- rootView? . enumerateChildren { ( view: NSVisualEffectView ) in
17- // Blindly consider a full-width NSVisualEffectView the toolbar,
18- // a more accurate way would be relying on NSThemeFrame, which is private.
19- if abs ( view. frame. width - frame. width) < . ulpOfOne {
20- result = view
15+ guard let rootView else {
16+ assertionFailure ( " Missing rootView from window to proceed " )
17+ return nil
18+ }
19+
20+ var stack = [ rootView]
21+ while !stack. isEmpty {
22+ let node = stack. removeLast ( )
23+ if node is NSVisualEffectView && node. superview? . className. hasPrefix ( " NSTitlebar " ) == true {
24+ // What we want is an NSVisualEffectView child of an NSTitlebarView
25+ return node as? NSVisualEffectView
2126 }
27+
28+ // Depth-first search
29+ stack. append ( contentsOf: node. subviews)
2230 }
2331
24- assert ( result != nil , " Failed to find NSVisualEffectView in toolbar " )
25- return result
32+ assertionFailure ( " Failed to find NSVisualEffectView in toolbar " )
33+ return nil
2634 }
2735
2836 /// Change the frame size, treat the top-left corner as the anchor point.
Original file line number Diff line number Diff line change @@ -47,17 +47,11 @@ final class EditorWindow: NSWindow {
4747
4848 // Slightly change the toolbar effect to match editor better
4949 if let view = toolbarEffectView {
50- // Blend the color of contents behind the window
51- view. blendingMode = . behindWindow
50+ view. alphaValue = effectiveAppearance. isDarkMode ? 0.3 : 0.7
5251 view. isHidden = reduceTransparency == true
5352
54- // When there's a dimmed view from save panel, always make it fully visible,
55- // otherwise, a layered background appears.
56- if NSApp . keyWindow is NSSavePanel {
57- view. alphaValue = 1.0
58- } else {
59- view. alphaValue = effectiveAppearance. isDarkMode ? 0.3 : 0.7
60- }
53+ // Blend the color of contents behind the window
54+ view. blendingMode = . behindWindow
6155 }
6256 }
6357}
You can’t perform that action at this time.
0 commit comments