From: Kevin Ottens Date: Mon, 25 May 2020 17:02:10 +0000 (+0200) Subject: Try make taskbar position heuristic more readable X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~222^2^2~160^2~3 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=f15a9cfc82ff4fe29c68707708ec768a334c0b51;p=nextcloud-desktop.git Try make taskbar position heuristic more readable Signed-off-by: Kevin Ottens --- diff --git a/src/gui/systray.cpp b/src/gui/systray.cpp index 5bc9e1479..97f19765c 100644 --- a/src/gui/systray.cpp +++ b/src/gui/systray.cpp @@ -191,16 +191,18 @@ Systray::TaskBarPosition Systray::taskbarOrientation() const const auto screenRect = currentScreenRect(); const auto trayIconCenter = calcTrayIconCenter(); - auto distBottom = screenRect.bottom() - trayIconCenter.y(); - auto distRight = screenRect.right() - trayIconCenter.x(); - auto distLeft = trayIconCenter.x() - screenRect.left(); - auto distTop = trayIconCenter.y() - screenRect.top(); + const auto distBottom = screenRect.bottom() - trayIconCenter.y(); + const auto distRight = screenRect.right() - trayIconCenter.x(); + const auto distLeft = trayIconCenter.x() - screenRect.left(); + const auto distTop = trayIconCenter.y() - screenRect.top(); - if (distBottom < distRight && distBottom < distTop && distBottom < distLeft) { + const auto minDist = std::min({distRight, distTop, distBottom}); + + if (minDist == distBottom) { return TaskBarPosition::Bottom; - } else if (distLeft < distTop && distLeft < distRight && distLeft < distBottom) { + } else if (minDist == distLeft) { return TaskBarPosition::Left; - } else if (distTop < distRight && distTop < distBottom && distTop < distLeft) { + } else if (minDist == distTop) { return TaskBarPosition::Top; } else { return TaskBarPosition::Right;