mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-26 15:06:08 +03:00
Merge pull request #4917 from nextcloud/bugfix/macos-notch-calc
Fix menu bar height calculation on macOS
This commit is contained in:
commit
a400738b05
3 changed files with 13 additions and 5 deletions
|
@ -513,9 +513,8 @@ QRect Systray::taskbarGeometry() const
|
|||
}
|
||||
return tbRect;
|
||||
#elif defined(Q_OS_MACOS)
|
||||
// Finder bar is always 22px height on macOS (when treating as effective pixels)
|
||||
const auto screenWidth = currentScreenRect().width();
|
||||
const auto statusBarHeight = static_cast<int>(OCC::statusBarThickness());
|
||||
const auto statusBarHeight = static_cast<int>(OCC::menuBarThickness());
|
||||
return {0, 0, screenWidth, statusBarHeight};
|
||||
#else
|
||||
if (taskbarOrientation() == TaskBarPosition::Bottom || taskbarOrientation() == TaskBarPosition::Top) {
|
||||
|
|
|
@ -52,7 +52,7 @@ bool canOsXSendUserNotification();
|
|||
void sendOsXUserNotification(const QString &title, const QString &message);
|
||||
void sendOsXUpdateNotification(const QString &title, const QString &message, const QUrl &webUrl);
|
||||
void setTrayWindowLevelAndVisibleOnAllSpaces(QWindow *window);
|
||||
double statusBarThickness();
|
||||
double menuBarThickness();
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
|
|
@ -52,9 +52,18 @@ enum MacNotificationAuthorizationOptions {
|
|||
Provisional
|
||||
};
|
||||
|
||||
double statusBarThickness()
|
||||
double menuBarThickness()
|
||||
{
|
||||
return [NSStatusBar systemStatusBar].thickness;
|
||||
const NSMenu *mainMenu = [[NSApplication sharedApplication] mainMenu];
|
||||
|
||||
if (mainMenu == nil) {
|
||||
// Return this educated guess if something goes wrong.
|
||||
// As of macOS 12.4 this will always return 22, even on notched Macbooks.
|
||||
qCWarning(lcMacSystray) << "Got nil for main menu. Going with reasonable menu bar height guess.";
|
||||
return [[NSStatusBar systemStatusBar] thickness];
|
||||
}
|
||||
|
||||
return mainMenu.menuBarHeight;
|
||||
}
|
||||
|
||||
// TODO: Get this to actually check for permissions
|
||||
|
|
Loading…
Reference in a new issue