Skip to content

Commit b6f9080

Browse files
committed
Use explicit constraints for the titlebar bg view
Easier to reason about
1 parent 791902c commit b6f9080

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

glfw/cocoa_window.m

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3297,11 +3297,21 @@ void clear_title_bar_background_views(NSWindow *window) {
32973297
debug_rendering("titlebar_height used for translucent titlebar view: %f\n", height);
32983298
NSView *bgView = [[NSView alloc] initWithFrame:NSMakeRect(
32993299
0, titlebarContainer.bounds.size.height - height, titlebarContainer.bounds.size.width, height)];
3300-
bgView.autoresizingMask = NSViewWidthSizable | NSViewMinYMargin;
3300+
bgView.translatesAutoresizingMaskIntoConstraints = NO;
33013301
bgView.wantsLayer = YES;
33023302
bgView.layer.backgroundColor = backgroundColor.CGColor;
33033303
bgView.identifier = tag;
33043304
[contentView addSubview:bgView];
3305+
[NSLayoutConstraint activateConstraints:@[
3306+
// Pin to the top of the content view.
3307+
[bgView.topAnchor constraintEqualToAnchor:titlebarContainer.topAnchor],
3308+
// Pin to the leading edge of the content view.
3309+
[bgView.leadingAnchor constraintEqualToAnchor:titlebarContainer.leadingAnchor],
3310+
// Pin to the trailing edge of the content view.
3311+
[bgView.trailingAnchor constraintEqualToAnchor:titlebarContainer.trailingAnchor],
3312+
// Give it a fixed height
3313+
[bgView.heightAnchor constraintEqualToConstant:height]
3314+
]];
33053315
[bgView release];
33063316
#undef tag
33073317
}

0 commit comments

Comments
 (0)