Simplify currentScreen
authorClaudio Cambra <claudio.cambra@gmail.com>
Mon, 14 Feb 2022 11:12:45 +0000 (12:12 +0100)
committerClaudio Cambra (Rebase PR Action) <claudio.cambra@gmail.com>
Wed, 2 Mar 2022 13:37:30 +0000 (13:37 +0000)
Signed-off-by: Claudio Cambra <claudio.cambra@gmail.com>
src/gui/systray.cpp

index 263a919725b8e66a21243799a0006580610c6e7b..b5c8d6556ac36da6e1e00eba042165062bf270f7 100644 (file)
@@ -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();