diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-05-10 11:38:05 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-05-11 09:06:43 +0200 |
commit | 30be6c41d5bb8ff4f42dd7ac26a763444be71c5a (patch) | |
tree | 8f0691064516fa6dadd35f3148270a57e31c48f8 /src/plugins/platforms | |
parent | 36e5a9d025ce7132c65fae0bf6ce59e179950b88 (diff) |
eglfs: Send proper enter/leave events when multiple screens are in use
Given that there is only one mouse (which might change some day, but
hasn't yet), there can only be one window containing the mouse,
regardless of which screen it's on. The implementation before was only
able to send enter/leave events when moving from one window to another
on the same screen; but we need the enter/leave events to be sent when
moving between two full-screen windows on two screens as well.
Also send an enter event the first time the mouse moves, to whichever
window that happens to be. A Wayland compositor that renders its own
cursor will need to know which screen is in use at the beginning.
Pick-to: 5.15
Fixes: QTBUG-83973
Task-number: QTBUG-55161
Task-number: QTBUG-79924
Change-Id: Ie6f36cd33b103955a70bac73c1485bf475c08468
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r-- | src/plugins/platforms/eglfs/api/qeglfsintegration_p.h | 6 | ||||
-rw-r--r-- | src/plugins/platforms/eglfs/api/qeglfsscreen.cpp | 19 | ||||
-rw-r--r-- | src/plugins/platforms/eglfs/api/qeglfsscreen_p.h | 1 |
3 files changed, 19 insertions, 7 deletions
diff --git a/src/plugins/platforms/eglfs/api/qeglfsintegration_p.h b/src/plugins/platforms/eglfs/api/qeglfsintegration_p.h index b293651ce7..7df1aa3c2c 100644 --- a/src/plugins/platforms/eglfs/api/qeglfsintegration_p.h +++ b/src/plugins/platforms/eglfs/api/qeglfsintegration_p.h @@ -52,7 +52,9 @@ // #include "qeglfsglobal_p.h" +#include <QtCore/QPointer> #include <QtCore/QVariant> +#include <QtGui/QWindow> #include <qpa/qplatformintegration.h> #include <qpa/qplatformnativeinterface.h> #include <qpa/qplatformscreen.h> @@ -106,6 +108,9 @@ public: QFbVtHandler *vtHandler() { return m_vtHandler.data(); } + QPointer<QWindow> pointerWindow() { return m_pointerWindow; } + void setPointerWindow(QWindow *pointerWindow) { m_pointerWindow = pointerWindow; } + private: EGLNativeDisplayType nativeDisplay() const; void createInputHandlers(); @@ -118,6 +123,7 @@ private: QScopedPointer<QPlatformServices> m_services; QScopedPointer<QFbVtHandler> m_vtHandler; QEvdevKeyboardManager *m_kbdMgr; + QPointer<QWindow> m_pointerWindow; bool m_disableInputHandlers; }; diff --git a/src/plugins/platforms/eglfs/api/qeglfsscreen.cpp b/src/plugins/platforms/eglfs/api/qeglfsscreen.cpp index 8a8e8cd563..1d3e5ca6af 100644 --- a/src/plugins/platforms/eglfs/api/qeglfsscreen.cpp +++ b/src/plugins/platforms/eglfs/api/qeglfsscreen.cpp @@ -39,6 +39,7 @@ #include <QtCore/qtextstream.h> #include <QtGui/qwindow.h> +#include <QtGui/private/qguiapplication_p.h> #include <qpa/qwindowsysteminterface.h> #include <qpa/qplatformcursor.h> #ifndef QT_NO_OPENGL @@ -149,6 +150,7 @@ void QEglFSScreen::handleCursorMove(const QPoint &pos) #ifndef QT_NO_OPENGL const QOpenGLCompositor *compositor = QOpenGLCompositor::instance(); const QList<QOpenGLCompositorWindow *> windows = compositor->windows(); + QEglFSIntegration *platformIntegration = static_cast<QEglFSIntegration *>(QGuiApplicationPrivate::platformIntegration()); // Generate enter and leave events like a real windowing system would do. if (windows.isEmpty()) @@ -157,8 +159,8 @@ void QEglFSScreen::handleCursorMove(const QPoint &pos) // First window is always fullscreen. if (windows.count() == 1) { QWindow *window = windows[0]->sourceWindow(); - if (m_pointerWindow != window) { - m_pointerWindow = window; + if (platformIntegration->pointerWindow() != window) { + platformIntegration->setPointerWindow(window); QWindowSystemInterface::handleEnterEvent(window, window->mapFromGlobal(pos), pos); } return; @@ -169,17 +171,22 @@ void QEglFSScreen::handleCursorMove(const QPoint &pos) QWindow *window = windows[i]->sourceWindow(); const QRect geom = window->geometry(); if (geom.contains(pos)) { - if (m_pointerWindow != window) { - leave = m_pointerWindow; - m_pointerWindow = window; + if (platformIntegration->pointerWindow() != window) { + leave = platformIntegration->pointerWindow(); + platformIntegration->setPointerWindow(window); enter = window; } break; } } - if (enter && leave) + if (enter && leave) { QWindowSystemInterface::handleEnterLeaveEvent(enter, leave, enter->mapFromGlobal(pos), pos); + } else if (enter) { + QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(pos), pos); + } else if (leave) { + QWindowSystemInterface::handleLeaveEvent(leave); + } #else Q_UNUSED(pos); #endif diff --git a/src/plugins/platforms/eglfs/api/qeglfsscreen_p.h b/src/plugins/platforms/eglfs/api/qeglfsscreen_p.h index bea7b4c8ef..cf4a7afc33 100644 --- a/src/plugins/platforms/eglfs/api/qeglfsscreen_p.h +++ b/src/plugins/platforms/eglfs/api/qeglfsscreen_p.h @@ -94,7 +94,6 @@ private: void setPrimarySurface(EGLSurface surface); EGLDisplay m_dpy; - QPointer<QWindow> m_pointerWindow; EGLSurface m_surface; QPlatformCursor *m_cursor; |