}
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) {
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
/**
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