Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/desktop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorClaudio Cambra <claudio.cambra@gmail.com>2022-09-09 15:23:39 +0300
committerMatthieu Gallien <matthieu_gallien@yahoo.fr>2022-09-10 12:52:29 +0300
commitb1caa459290df7279061b4e5d8124ade93195d38 (patch)
tree199ac78a0d481f91cf5a4622b58a394fab7766cf /src
parentd91415e41ddd511eb803d7bb258982a41d09a339 (diff)
Fix menu bar height calculation on macOS
Signed-off-by: Claudio Cambra <claudio.cambra@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/gui/systray.cpp3
-rw-r--r--src/gui/systray.h2
-rw-r--r--src/gui/systray.mm13
3 files changed, 13 insertions, 5 deletions
diff --git a/src/gui/systray.cpp b/src/gui/systray.cpp
index 05ced5e36..6f6189dd1 100644
--- a/src/gui/systray.cpp
+++ b/src/gui/systray.cpp
@@ -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) {
diff --git a/src/gui/systray.h b/src/gui/systray.h
index 522ae1730..945f5999b 100644
--- a/src/gui/systray.h
+++ b/src/gui/systray.h
@@ -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
/**
diff --git a/src/gui/systray.mm b/src/gui/systray.mm
index 8798e125e..ddcd4f362 100644
--- a/src/gui/systray.mm
+++ b/src/gui/systray.mm
@@ -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