From 708c39bb99c79ee834af6ba607077c57343b1b34 Mon Sep 17 00:00:00 2001 From: dijunkun Date: Tue, 28 Jul 2026 14:42:06 +0800 Subject: [PATCH] fix: keep macOS main window titlebar opaque --- src/gui/application/gui_application.cpp | 2 +- src/gui/platform/window_drag.h | 7 ++++--- src/gui/platform/window_drag_mac.mm | 13 ++++++++++++- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/gui/application/gui_application.cpp b/src/gui/application/gui_application.cpp index 40c8f48..f1bda05 100644 --- a/src/gui/application/gui_application.cpp +++ b/src/gui/application/gui_application.cpp @@ -2007,7 +2007,7 @@ void GuiApplication::SyncMainWindow() { } #if defined(__APPLE__) if (ui_->main_native_titlebar_attempts > 0) { - if (HideDisabledMainWindowZoomButton()) { + if (ConfigureMainWindowTitlebar()) { ui_->main_native_titlebar_attempts = 0; } else { --ui_->main_native_titlebar_attempts; diff --git a/src/gui/platform/window_drag.h b/src/gui/platform/window_drag.h index da15d2a..415123f 100644 --- a/src/gui/platform/window_drag.h +++ b/src/gui/platform/window_drag.h @@ -8,9 +8,10 @@ namespace crossdesk { // left-mouse-down event. Returns false when no suitable native event exists. bool StartNativeWindowDrag(); -// Hides the disabled native zoom button on CrossDesk's fixed-size main -// window. Returns true once the matching AppKit window has been configured. -bool HideDisabledMainWindowZoomButton(); +// Normalizes the native title bar and hides the disabled zoom button on +// CrossDesk's fixed-size main window. Returns true once the matching AppKit +// window has been configured. +bool ConfigureMainWindowTitlebar(); // Configures live resize and replaces the stream window's native Space // fullscreen action with an immediate, single-window fullscreen transition. diff --git a/src/gui/platform/window_drag_mac.mm b/src/gui/platform/window_drag_mac.mm index 3522c13..e85969e 100644 --- a/src/gui/platform/window_drag_mac.mm +++ b/src/gui/platform/window_drag_mac.mm @@ -79,7 +79,7 @@ bool StartNativeWindowDrag() { } } -bool HideDisabledMainWindowZoomButton() { +bool ConfigureMainWindowTitlebar() { @autoreleasepool { for (NSWindow *window in [NSApp windows]) { if (![window.title isEqualToString:@"CrossDesk"]) { @@ -94,6 +94,17 @@ bool HideDisabledMainWindowZoomButton() { continue; } + // Slint creates its winit windows with transparency enabled. That makes + // the native title-bar material depend on the SDK used to build the + // Slint runtime. The main window paints an opaque white surface, so make + // the corresponding AppKit window opaque as well and explicitly retain + // the standard, non-overlay title bar. + window.styleMask = + window.styleMask & ~NSWindowStyleMaskFullSizeContentView; + window.titleVisibility = NSWindowTitleVisible; + window.titlebarAppearsTransparent = NO; + window.backgroundColor = NSColor.whiteColor; + window.opaque = YES; zoom_button.hidden = YES; return true; }