No longer assume status bar height, calculate, fixing notch borking
authorClaudio Cambra <claudio.cambra@gmail.com>
Thu, 3 Feb 2022 15:37:17 +0000 (16:37 +0100)
committerClaudio Cambra <claudio.cambra@gmail.com>
Wed, 2 Mar 2022 12:22:55 +0000 (13:22 +0100)
Signed-off-by: Claudio Cambra <claudio.cambra@gmail.com>
src/gui/systray.cpp
src/gui/systray.h
src/gui/systray.mm

index 707609612342c29c4e79622e4134e7cb7515c845..263a919725b8e66a21243799a0006580610c6e7b 100644 (file)
@@ -389,8 +389,9 @@ QRect Systray::taskbarGeometry() const
     return tbRect;
 #elif defined(Q_OS_MACOS)
     // Finder bar is always 22px height on macOS (when treating as effective pixels)
-    auto screenWidth = currentScreenRect().width();
-    return {0, 0, screenWidth, 22};
+    const auto screenWidth = currentScreenRect().width();
+    const auto statusBarHeight = static_cast<int>(OCC::statusBarThickness());
+    return {0, 0, screenWidth, statusBarHeight};
 #else
     if (taskbarOrientation() == TaskBarPosition::Bottom || taskbarOrientation() == TaskBarPosition::Top) {
         auto screenWidth = currentScreenRect().width();
index 31251d01e2886f7799f6adac5004736f99683cd4..6b63d6797cb6303d38438884b8767781bae2e040 100644 (file)
@@ -42,6 +42,7 @@ public:
 bool canOsXSendUserNotification();
 void sendOsXUserNotification(const QString &title, const QString &message);
 void setTrayWindowLevelAndVisibleOnAllSpaces(QWindow *window);
+double statusBarThickness();
 #endif
 
 /**
index a4d35eb23773005697034b72842bc917eba7ee38..544455c16e6402122a90fca97857c12aa3077bb8 100644 (file)
 
 namespace OCC {
 
+double statusBarThickness()
+{
+    return [NSStatusBar systemStatusBar].thickness;
+}
+
 bool canOsXSendUserNotification()
 {
     return NSClassFromString(@"NSUserNotificationCenter") != nil;