mirror of
https://github.com/chylex/Nextcloud-Desktop.git
synced 2025-05-05 02:34:10 +02:00
Merge pull request #2677 from briankendall/fix-tray-window-spaces-bug
Fix macOS bug where tray window causes spaces to switch
This commit is contained in:
commit
7721832ee0
@ -267,6 +267,14 @@ void Systray::forceWindowInit(QQuickWindow *window) const
|
||||
// this shouldn't flicker
|
||||
window->show();
|
||||
window->hide();
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
// On macOS we need to designate the tray window as visible on all spaces and
|
||||
// at the menu bar level, otherwise showing it can cause the current spaces to
|
||||
// change, or the window could be obscured by another window that shouldn't
|
||||
// normally cover a menu.
|
||||
OCC::setTrayWindowLevelAndVisibleOnAllSpaces(window);
|
||||
#endif
|
||||
}
|
||||
|
||||
QScreen *Systray::currentScreen() const
|
||||
|
@ -23,12 +23,14 @@
|
||||
class QScreen;
|
||||
class QQmlApplicationEngine;
|
||||
class QQuickWindow;
|
||||
class QWindow;
|
||||
|
||||
namespace OCC {
|
||||
|
||||
#ifdef Q_OS_OSX
|
||||
bool canOsXSendUserNotification();
|
||||
void sendOsXUserNotification(const QString &title, const QString &message);
|
||||
void setTrayWindowLevelAndVisibleOnAllSpaces(QWindow *window);
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <QString>
|
||||
#include <QWindow>
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@interface NotificationCenterDelegate : NSObject
|
||||
@ -41,4 +42,13 @@ void sendOsXUserNotification(const QString &title, const QString &message)
|
||||
[notification release];
|
||||
}
|
||||
|
||||
void setTrayWindowLevelAndVisibleOnAllSpaces(QWindow *window)
|
||||
{
|
||||
NSView *nativeView = (NSView *)window->winId();
|
||||
NSWindow *nativeWindow = (NSWindow *)[nativeView window];
|
||||
[nativeWindow setCollectionBehavior:NSWindowCollectionBehaviorCanJoinAllSpaces | NSWindowCollectionBehaviorIgnoresCycle |
|
||||
NSWindowCollectionBehaviorTransient];
|
||||
[nativeWindow setLevel:NSMainMenuWindowLevel];
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user