Skip to content

Commit

Permalink
macOS: Fix a regression that caused the titlebar to be translucent ev…
Browse files Browse the repository at this point in the history
…en for non-translucent windows

Fixes #6450
  • Loading branch information
kovidgoyal committed Jul 12, 2023
1 parent dc8b615 commit 9e0e23a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
10 changes: 6 additions & 4 deletions glfw/cocoa_window.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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];
Expand Down

0 comments on commit 9e0e23a

Please sign in to comment.