Skip to content

Commit 30629c5

Browse files
committed
macos: explicitly enable modern window corners on macOS 26
Use an explicit runtime check to apply the newer corner styling on macOS 26 while leaving behavior unchanged on older macOS versions for compatibility. Also add the required QuartzCore framework for linking the corner curve API.
1 parent 2d18b88 commit 30629c5

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

glfw/cocoa_window.m

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3918,6 +3918,29 @@ void clear_title_bar_background_views(NSWindow *window) {
39183918
#undef tc
39193919
}
39203920

3921+
static bool
3922+
should_use_latest_macos_window_corner_curve(void) {
3923+
if (@available(macOS 26.0, *)) {
3924+
} else return false;
3925+
static bool checked = false, ans = false;
3926+
if (!checked) {
3927+
NSOperatingSystemVersion v = {26, 0, 0};
3928+
ans = [[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion:v];
3929+
checked = true;
3930+
}
3931+
return ans;
3932+
}
3933+
3934+
static void
3935+
apply_window_corner_curve_if_needed(_GLFWwindow *window) {
3936+
if (!window || !window->decorated || !should_use_latest_macos_window_corner_curve()) return;
3937+
GLFWWindow *nsw = window->ns.object;
3938+
NSView *frame_view = nsw.contentView.superview;
3939+
CALayer *layer = frame_view.layer;
3940+
if (!layer) return;
3941+
layer.cornerCurve = kCACornerCurveContinuous;
3942+
}
3943+
39213944

39223945

39233946
GLFWAPI void glfwCocoaSetWindowChrome(GLFWwindow *w, unsigned int color, bool use_system_color, unsigned int system_color, int background_blur, unsigned int hide_window_decorations, bool show_text_in_titlebar, int color_space, float background_opacity, bool resizable) { @autoreleasepool {
@@ -4033,6 +4056,7 @@ GLFWAPI void glfwCocoaSetWindowChrome(GLFWwindow *w, unsigned int color, bool us
40334056
}
40344057
#undef tc
40354058
apply_titlebar_color_settings(window);
4059+
apply_window_corner_curve_if_needed(window);
40364060

40374061
// HACK: Changing the style mask can cause the first responder to be cleared
40384062
[nsw makeFirstResponder:window->ns.view];

glfw/glfw.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def init_env(
175175

176176
elif module == 'cocoa':
177177
ans.cppflags.append('-DGL_SILENCE_DEPRECATION')
178-
for f_ in 'Cocoa IOKit CoreFoundation CoreVideo UniformTypeIdentifiers'.split():
178+
for f_ in 'Cocoa IOKit CoreFoundation CoreVideo QuartzCore UniformTypeIdentifiers'.split():
179179
ans.ldpaths.extend(('-framework', f_))
180180

181181
elif module == 'wayland':

0 commit comments

Comments
 (0)