From b6f90804865de7676c17624a67f5d7c5e783d855 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 28 Sep 2025 17:20:37 +0530 Subject: [PATCH] Use explicit constraints for the titlebar bg view Easier to reason about --- glfw/cocoa_window.m | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/glfw/cocoa_window.m b/glfw/cocoa_window.m index af9bcac17..fee91d1dd 100644 --- a/glfw/cocoa_window.m +++ b/glfw/cocoa_window.m @@ -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 }