summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergio Martins <sergio.martins@kdab.com>2022-08-01 16:16:45 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-08-05 10:31:53 +0000
commitad2a55f8df66c191d750366c5dc8d8eab0c7d506 (patch)
tree645699462c3077787086f2782d1aac3a706182f7
parente1b6d9e4fc246b41fdcef4d9f5a18b8352a848b0 (diff)
eglfs: Fix mouse events not being delivered to the frontmost window
Since QPlatformScreen::topLevelAt() wasn't implemented it would just fallback to use QGuiApplication's window list. Possibly fixes any other bug that relied on QApplication::topLevelAt(). The fix is to consult the compositor, which has proper z-order information, unlike QGuiApplicationPrivate::window_list. Task-Id: QTBUG-105256 Change-Id: I4202dd5d87e41b69c461c808d29b809af5b52d09 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> (cherry picked from commit 40d781b7b5e7925e4559cd725ddbfef307d5f455) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfsscreen.cpp18
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfsscreen_p.h2
2 files changed, 20 insertions, 0 deletions
diff --git a/src/plugins/platforms/eglfs/api/qeglfsscreen.cpp b/src/plugins/platforms/eglfs/api/qeglfsscreen.cpp
index b081406258..a6345f693d 100644
--- a/src/plugins/platforms/eglfs/api/qeglfsscreen.cpp
+++ b/src/plugins/platforms/eglfs/api/qeglfsscreen.cpp
@@ -212,4 +212,22 @@ QPixmap QEglFSScreen::grabWindow(WId wid, int x, int y, int width, int height) c
return QPixmap();
}
+QWindow *QEglFSScreen::topLevelAt(const QPoint &point) const
+{
+#ifndef QT_NO_OPENGL
+ QOpenGLCompositor *compositor = QOpenGLCompositor::instance();
+ const QList<QOpenGLCompositorWindow *> windows = compositor->windows();
+ const int windowCount = windows.size();
+
+ // Higher z-order is at the end of the list
+ for (int i = windowCount - 1; i >= 0; i--) {
+ QWindow *window = windows[i]->sourceWindow();
+ if (window->isVisible() && window->geometry().contains(point))
+ return window;
+ }
+#endif
+
+ return QPlatformScreen::topLevelAt(point);
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/api/qeglfsscreen_p.h b/src/plugins/platforms/eglfs/api/qeglfsscreen_p.h
index 8f1eb91206..bbfc9a9259 100644
--- a/src/plugins/platforms/eglfs/api/qeglfsscreen_p.h
+++ b/src/plugins/platforms/eglfs/api/qeglfsscreen_p.h
@@ -54,6 +54,8 @@ public:
void handleCursorMove(const QPoint &pos);
+ QWindow *topLevelAt(const QPoint &point) const override;
+
private:
void setPrimarySurface(EGLSurface surface);