From 9e0e23ae993ff9c577ee37e51803208a653674db Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 12 Jul 2023 10:24:51 +0530 Subject: [PATCH] macOS: Fix a regression that caused the titlebar to be translucent even for non-translucent windows Fixes #6450 --- docs/changelog.rst | 2 ++ glfw/cocoa_window.m | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 9dbd3cf8a..1b4175126 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -46,6 +46,8 @@ Detailed list of changes - macOS: Fix a regression in the previous release that caused :opt:`hide_window_decorations` = ``yes`` to prevent window from being resizable (:iss:`6436`) +- macOS: Fix a regression that caused the titlebar to be translucent even for non-translucent windows (:iss:`6450`) + - Remote control launch: Fix ``--env`` not implemented when using ``--cwd=current`` with the SSH kitten (:iss:`6438`) 0.29.0 [2023-07-10] diff --git a/glfw/cocoa_window.m b/glfw/cocoa_window.m index 0eea87209..890bad574 100644 --- a/glfw/cocoa_window.m +++ b/glfw/cocoa_window.m @@ -2977,16 +2977,18 @@ GLFWAPI void glfwCocoaSetWindowChrome(GLFWwindow *w, unsigned int color, bool us bool titlebar_transparent = false; NSWindowStyleMask current_style_mask = [window->ns.object styleMask]; bool in_fullscreen = ((current_style_mask & NSWindowStyleMaskFullScreen) != 0) || window->ns.in_traditional_fullscreen; + NSAppearance *light_appearance = is_transparent ? [NSAppearance appearanceNamed:NSAppearanceNameVibrantLight] : [NSAppearance appearanceNamed:NSAppearanceNameAqua]; + NSAppearance *dark_appearance = is_transparent ? [NSAppearance appearanceNamed:NSAppearanceNameVibrantDark] : [NSAppearance appearanceNamed:NSAppearanceNameDarkAqua]; if (use_system_color || background_opacity < 1.0) { if (is_transparent) { // prevent blurring of shadows at window corners with desktop background by setting a low alpha background background = background_blur > 0 ? [NSColor colorWithWhite: 0 alpha: 0.001f] : [NSColor clearColor]; - } else background = [NSColor clearColor]; + } else background = [NSColor windowBackgroundColor]; switch (system_color) { case 1: - appearance = [NSAppearance appearanceNamed:NSAppearanceNameVibrantLight]; break; + appearance = light_appearance; break; case 2: - appearance = [NSAppearance appearanceNamed:NSAppearanceNameVibrantDark]; break; + appearance = dark_appearance; break; } } else { // set a background color and make the title bar transparent so the background color is visible @@ -2995,7 +2997,7 @@ GLFWAPI void glfwCocoaSetWindowChrome(GLFWwindow *w, unsigned int color, bool us double blue = (color & 0xFF) / 255.0; double luma = 0.2126 * red + 0.7152 * green + 0.0722 * blue; background = [NSColor colorWithSRGBRed:red green:green blue:blue alpha:1.f]; - appearance = [NSAppearance appearanceNamed:(luma < 0.5 ? NSAppearanceNameVibrantDark : NSAppearanceNameVibrantLight)]; + appearance = luma < 0.5 ? dark_appearance : light_appearance; titlebar_transparent = true; } [window->ns.object setBackgroundColor:background];