Use explicit constraints for the titlebar bg view

Easier to reason about
This commit is contained in:
Kovid Goyal 2025-09-28 17:20:37 +05:30
parent 791902caad
commit b6f9080486
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C

View file

@ -3297,11 +3297,21 @@ void clear_title_bar_background_views(NSWindow *window) {
debug_rendering("titlebar_height used for translucent titlebar view: %f\n", height);
NSView *bgView = [[NSView alloc] initWithFrame:NSMakeRect(
0, titlebarContainer.bounds.size.height - height, titlebarContainer.bounds.size.width, height)];
bgView.autoresizingMask = NSViewWidthSizable | NSViewMinYMargin;
bgView.translatesAutoresizingMaskIntoConstraints = NO;
bgView.wantsLayer = YES;
bgView.layer.backgroundColor = backgroundColor.CGColor;
bgView.identifier = tag;
[contentView addSubview:bgView];
[NSLayoutConstraint activateConstraints:@[
// Pin to the top of the content view.
[bgView.topAnchor constraintEqualToAnchor:titlebarContainer.topAnchor],
// Pin to the leading edge of the content view.
[bgView.leadingAnchor constraintEqualToAnchor:titlebarContainer.leadingAnchor],
// Pin to the trailing edge of the content view.
[bgView.trailingAnchor constraintEqualToAnchor:titlebarContainer.trailingAnchor],
// Give it a fixed height
[bgView.heightAnchor constraintEqualToConstant:height]
]];
[bgView release];
#undef tag
}