mirror of
https://github.com/kunkundi/crossdesk.git
synced 2026-07-30 03:38:41 +08:00
fix: keep macOS main window titlebar opaque
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user