This commit is contained in:
ivaquero
2026-04-18 06:13:30 +08:00
parent 49b39b74d2
commit ec341ddba2
36 changed files with 1941 additions and 273 deletions
+36
View File
@@ -0,0 +1,36 @@
#import "window_helper_macos.h"
#import <QWidget>
#ifdef Q_OS_MAC
#import <AppKit/AppKit.h>
#import <CoreGraphics/CGWindowLevel.h>
void MacOSWindowHelper::setupAlwaysOnTopForFullscreen(QWidget *widget)
{
if (!widget) return;
// Get the native NSView and NSWindow
NSView *nativeView = (NSView *)widget->winId();
NSWindow *nativeWindow = [nativeView window];
if (nativeWindow) {
// Set window level to be above everything, including fullscreen apps
[nativeWindow setLevel:NSScreenSaverWindowLevel - 1];
// Allow window to appear on all spaces (including fullscreen spaces)
[nativeWindow setCollectionBehavior:NSWindowCollectionBehaviorCanJoinAllSpaces |
NSWindowCollectionBehaviorFullScreenAuxiliary |
NSWindowCollectionBehaviorStationary];
// Make it a floating panel that won't steal focus
[nativeWindow setHidesOnDeactivate:NO];
// Note: setFloatingPanel is deprecated, but we keep it for compatibility
// The key is setting the proper window level and collection behavior
// Ensure it stays above dock and menu bar
[nativeWindow setLevel:CGWindowLevelForKey(kCGFloatingWindowLevelKey)];
}
}
#endif // Q_OS_MAC