From 1ba321b7332b0a462f04c4d1f921cefcb337f325 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Wed, 27 Sep 2023 15:12:37 +0200 Subject: [PATCH] fix: rounded corners on vibrant macOS modals (#39979) Co-authored-by: John Kleinschmidt --- shell/browser/native_window_mac.mm | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/shell/browser/native_window_mac.mm b/shell/browser/native_window_mac.mm index be27cd8a5821..b8f660b6a0d8 100644 --- a/shell/browser/native_window_mac.mm +++ b/shell/browser/native_window_mac.mm @@ -1420,11 +1420,21 @@ void NativeWindowMac::UpdateVibrancyRadii(bool fullscreen) { if (vibrantView != nil && !vibrancy_type_.empty()) { const bool no_rounded_corner = !HasStyleMask(NSWindowStyleMaskTitled); - if (!has_frame() && !is_modal() && !no_rounded_corner) { + const int macos_version = base::mac::MacOSMajorVersion(); + + // Modal window corners are rounded on macOS >= 11 or higher if the user + // hasn't passed noRoundedCorners. + bool should_round_modal = + !no_rounded_corner && (macos_version >= 11 ? true : !is_modal()); + // Nonmodal window corners are rounded if they're frameless and the user + // hasn't passed noRoundedCorners. + bool should_round_nonmodal = !no_rounded_corner && !has_frame(); + + if (should_round_nonmodal || should_round_modal) { CGFloat radius; if (fullscreen) { radius = 0.0f; - } else if (@available(macOS 11.0, *)) { + } else if (macos_version >= 11) { radius = 9.0f; } else { // Smaller corner radius on versions prior to Big Sur.