fix: keep macOS main window titlebar opaque

This commit is contained in:
dijunkun
2026-07-28 14:42:06 +08:00
parent cee249a25b
commit 708c39bb99
3 changed files with 17 additions and 5 deletions
+1 -1
View File
@@ -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;
+4 -3
View File
@@ -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.
+12 -1
View File
@@ -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;
}