From f6b377ab17fb56d2035d6ba4cef0a5c5190e7d3d Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 14 Feb 2022 12:12:45 +0100 Subject: [PATCH] Simplify currentScreen Signed-off-by: Claudio Cambra --- src/gui/systray.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/gui/systray.cpp b/src/gui/systray.cpp index 263a91972..b5c8d6556 100644 --- a/src/gui/systray.cpp +++ b/src/gui/systray.cpp @@ -308,15 +308,11 @@ void Systray::forceWindowInit(QQuickWindow *window) const QScreen *Systray::currentScreen() const { - const auto screens = QGuiApplication::screens(); - const auto cursorPos = QCursor::pos(); + const auto screen = QGuiApplication::screenAt(QCursor::pos()); - for (const auto screen : screens) { - if (screen->geometry().contains(cursorPos)) { - return screen; - } + if(screen) { + return screen; } - // Didn't find anything matching the cursor position, // falling back to the primary screen return QGuiApplication::primaryScreen();