From b030bebd3f0cffebde03b864807b293317d356c3 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 16 Jan 2024 20:02:34 +0800 Subject: [PATCH] Use available gemoetry measurement rather than whole screen geometry measurement unit to define non-taskbar invading window positions, removing need for calculating taskbar geometry Signed-off-by: Claudio Cambra --- src/gui/systray.cpp | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/src/gui/systray.cpp b/src/gui/systray.cpp index f68126c6cd033..d1e0e76781b79 100644 --- a/src/gui/systray.cpp +++ b/src/gui/systray.cpp @@ -707,12 +707,10 @@ QPoint Systray::computeWindowReferencePoint() const { constexpr auto spacing = 4; const auto trayIconCenter = calcTrayIconCenter(); - const auto taskbarRect = taskbarGeometry(); const auto taskbarScreenEdge = taskbarOrientation(); - const auto screenRect = currentScreenRect(); + const auto screenRect = currentAvailableScreenRect(); qCDebug(lcSystray) << "screenRect:" << screenRect; - qCDebug(lcSystray) << "taskbarRect:" << taskbarRect; qCDebug(lcSystray) << "taskbarScreenEdge:" << taskbarScreenEdge; qCDebug(lcSystray) << "trayIconCenter:" << trayIconCenter; @@ -720,21 +718,21 @@ QPoint Systray::computeWindowReferencePoint() const case TaskBarPosition::Bottom: return { trayIconCenter.x(), - screenRect.bottom() - taskbarRect.height() - spacing + screenRect.bottom() - spacing }; case TaskBarPosition::Left: return { - screenRect.left() + taskbarRect.width() + spacing, + screenRect.left() + spacing, trayIconCenter.y() }; case TaskBarPosition::Top: return { trayIconCenter.x(), - screenRect.top() + taskbarRect.height() + spacing + screenRect.top() + spacing }; case TaskBarPosition::Right: return { - screenRect.right() - taskbarRect.width() - spacing, + screenRect.right() - spacing, trayIconCenter.y() }; } @@ -745,29 +743,23 @@ QPoint Systray::computeNotificationReferencePoint(int spacing, NotificationPosit { auto trayIconCenter = calcTrayIconCenter(); auto taskbarScreenEdge = taskbarOrientation(); - auto taskbarRect = taskbarGeometry(); - const auto screenRect = currentScreenRect(); + const auto screenRect = currentAvailableScreenRect(); if(position == NotificationPosition::TopLeft) { taskbarScreenEdge = TaskBarPosition::Top; trayIconCenter = QPoint(0, 0); - taskbarRect = QRect(0, 0, screenRect.width(), 32); } else if(position == NotificationPosition::TopRight) { taskbarScreenEdge = TaskBarPosition::Top; trayIconCenter = QPoint(screenRect.width(), 0); - taskbarRect = QRect(0, 0, screenRect.width(), 32); } else if(position == NotificationPosition::BottomLeft) { taskbarScreenEdge = TaskBarPosition::Bottom; trayIconCenter = QPoint(0, screenRect.height()); - taskbarRect = QRect(0, 0, screenRect.width(), 32); } else if(position == NotificationPosition::BottomRight) { taskbarScreenEdge = TaskBarPosition::Bottom; trayIconCenter = QPoint(screenRect.width(), screenRect.height()); - taskbarRect = QRect(0, 0, screenRect.width(), 32); } qCDebug(lcSystray) << "screenRect:" << screenRect; - qCDebug(lcSystray) << "taskbarRect:" << taskbarRect; qCDebug(lcSystray) << "taskbarScreenEdge:" << taskbarScreenEdge; qCDebug(lcSystray) << "trayIconCenter:" << trayIconCenter; @@ -775,21 +767,21 @@ QPoint Systray::computeNotificationReferencePoint(int spacing, NotificationPosit case TaskBarPosition::Bottom: return { trayIconCenter.x() < screenRect.center().x() ? screenRect.left() + spacing : screenRect.right() - spacing, - screenRect.bottom() - taskbarRect.height() - spacing + screenRect.bottom() - spacing }; case TaskBarPosition::Left: return { - screenRect.left() + taskbarRect.width() + spacing, + screenRect.left() + spacing, trayIconCenter.y() < screenRect.center().y() ? screenRect.top() + spacing : screenRect.bottom() - spacing }; case TaskBarPosition::Top: return { trayIconCenter.x() < screenRect.center().x() ? screenRect.left() + spacing : screenRect.right() - spacing, - screenRect.top() + taskbarRect.height() + spacing + screenRect.top() + spacing }; case TaskBarPosition::Right: return { - screenRect.right() - taskbarRect.width() - spacing, + screenRect.right() - spacing, trayIconCenter.y() < screenRect.center().y() ? screenRect.top() + spacing : screenRect.bottom() - spacing }; }