diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2016-08-08 11:37:43 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2016-08-10 09:04:47 +0000 |
commit | b305702d1e38d72765325dd7b1f2a7fde14e5529 (patch) | |
tree | 701309886d8d34a74b025a2b8de2633fc36e0f7b /src/plugins/platforms/eglfs/deviceintegration | |
parent | e93042522817003f35402adea83b8a537dba7c87 (diff) |
eglfs: Support virtual desktops in the OpenGL cursor
The GBM-based hardware cursor already has this. Let's implement it
in the commonly used OpenGL cursor too. The main user will be the
EGLDevice backend which does not currently have a hardware cursor
but supports multiple screens.
This also means QEglFSCursor must be capable of operating on different
contexts (and what's more, non-sharing contexts).
Task-number: QTBUG-55161
Change-Id: Ie23bba1e6aab34b04d689f26a84c19a2bde518da
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/plugins/platforms/eglfs/deviceintegration')
6 files changed, 78 insertions, 3 deletions
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevice.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevice.cpp index 743f714cf0..f45b947fa6 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevice.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevice.cpp @@ -40,11 +40,15 @@ #include "qeglfskmsegldevice.h" #include "qeglfskmsegldevicescreen.h" #include "qeglfskmsegldeviceintegration.h" +#include "private/qeglfscursor_p.h" #include <QtCore/private/qcore_unix_p.h> +QT_BEGIN_NAMESPACE + QEglFSKmsEglDevice::QEglFSKmsEglDevice(QEglFSKmsIntegration *integration, const QString &path) - : QEglFSKmsDevice(integration, path) + : QEglFSKmsDevice(integration, path), + m_globalCursor(nullptr) { } @@ -52,6 +56,8 @@ bool QEglFSKmsEglDevice::open() { Q_ASSERT(fd() == -1); + qCDebug(qLcEglfsKmsDebug, "Opening DRM device %s", qPrintable(devicePath())); + int fd = drmOpen(devicePath().toLocal8Bit().constData(), Q_NULLPTR); if (Q_UNLIKELY(fd < 0)) qFatal("Could not open DRM device"); @@ -63,6 +69,8 @@ bool QEglFSKmsEglDevice::open() void QEglFSKmsEglDevice::close() { + qCDebug(qLcEglfsKmsDebug, "Closing DRM device"); + if (qt_safe_close(fd()) == -1) qErrnoWarning("Could not close DRM device"); @@ -74,7 +82,26 @@ EGLNativeDisplayType QEglFSKmsEglDevice::nativeDisplay() const return static_cast<QEglFSKmsEglDeviceIntegration *>(m_integration)->eglDevice(); } -QEglFSKmsScreen *QEglFSKmsEglDevice::createScreen(QEglFSKmsIntegration *integration, QEglFSKmsDevice *device, QEglFSKmsOutput output, QPoint position) +QEglFSKmsScreen *QEglFSKmsEglDevice::createScreen(QEglFSKmsIntegration *integration, QEglFSKmsDevice *device, + QEglFSKmsOutput output, QPoint position) { - return new QEglFSKmsEglDeviceScreen(integration, device, output, position); + QEglFSKmsScreen *screen = new QEglFSKmsEglDeviceScreen(integration, device, output, position); + + if (!m_globalCursor && !integration->separateScreens()) { + qCDebug(qLcEglfsKmsDebug, "Creating new global mouse cursor"); + m_globalCursor = new QEglFSCursor(screen); + } + + return screen; } + +void QEglFSKmsEglDevice::destroyGlobalCursor() +{ + if (m_globalCursor) { + qCDebug(qLcEglfsKmsDebug, "Destroying global mouse cursor"); + delete m_globalCursor; + m_globalCursor = nullptr; + } +} + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevice.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevice.h index b1c98f3fe6..a27112fb4f 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevice.h +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevice.h @@ -42,6 +42,10 @@ #include <qeglfskmsdevice.h> +QT_BEGIN_NAMESPACE + +class QPlatformCursor; + class QEglFSKmsEglDevice: public QEglFSKmsDevice { public: @@ -56,6 +60,14 @@ public: QEglFSKmsDevice *device, QEglFSKmsOutput output, QPoint position) Q_DECL_OVERRIDE; + + QPlatformCursor *globalCursor() { return m_globalCursor; } + void destroyGlobalCursor(); + +private: + QPlatformCursor *m_globalCursor; }; +QT_END_NAMESPACE + #endif // QEGLFSKMSEGLDEVICE_H diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp index cbf7cfe7d0..0120c0726d 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp @@ -41,6 +41,7 @@ #include "qeglfskmsegldeviceintegration.h" #include <QtPlatformSupport/private/qeglconvenience_p.h> #include "private/qeglfswindow_p.h" +#include "private/qeglfscursor_p.h" #include "qeglfskmsegldevice.h" #include "qeglfskmsscreen.h" #include <QLoggingCategory> @@ -258,4 +259,9 @@ bool QEglFSKmsEglDeviceIntegration::query_egl_device() return true; } +QPlatformCursor *QEglFSKmsEglDeviceIntegration::createCursor(QPlatformScreen *screen) const +{ + return separateScreens() ? new QEglFSCursor(screen) : nullptr; +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.h index af6b3f81ce..375c388548 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.h +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.h @@ -65,6 +65,7 @@ public: protected: QEglFSKmsDevice *createDevice(const QString &devicePath) Q_DECL_OVERRIDE; + QPlatformCursor *createCursor(QPlatformScreen *screen) const Q_DECL_OVERRIDE; private: bool setup_kms(); diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp index da1b577801..b0deabe834 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp @@ -39,12 +39,32 @@ #include "qeglfskmsegldevicescreen.h" #include "qeglfskmsegldevice.h" +#include <QGuiApplication> + +QT_BEGIN_NAMESPACE QEglFSKmsEglDeviceScreen::QEglFSKmsEglDeviceScreen(QEglFSKmsIntegration *integration, QEglFSKmsDevice *device, QEglFSKmsOutput output, QPoint position) : QEglFSKmsScreen(integration, device, output, position) { } +QEglFSKmsEglDeviceScreen::~QEglFSKmsEglDeviceScreen() +{ + const int remainingScreenCount = qGuiApp->screens().count(); + qCDebug(qLcEglfsKmsDebug, "Screen dtor. Remaining screens: %d", remainingScreenCount); + if (!remainingScreenCount && !m_integration->separateScreens()) + static_cast<QEglFSKmsEglDevice *>(device())->destroyGlobalCursor(); +} + +QPlatformCursor *QEglFSKmsEglDeviceScreen::cursor() const +{ + // The base class creates a cursor via integration->createCursor() + // in its ctor. With separateScreens just use that. Otherwise + // there's a virtual desktop and the device has a global cursor + // and the base class has no dedicated cursor at all. + return m_integration->separateScreens() ? QEglFSScreen::cursor() : static_cast<QEglFSKmsEglDevice *>(device())->globalCursor(); +} + void QEglFSKmsEglDeviceScreen::waitForFlip() { if (!output().mode_set) { @@ -76,3 +96,5 @@ void QEglFSKmsEglDeviceScreen::waitForFlip() } } + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.h index 0cd46e9f9d..7fceae4978 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.h +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.h @@ -42,6 +42,8 @@ #include <qeglfskmsscreen.h> +QT_BEGIN_NAMESPACE + class QEglFSKmsEglDeviceScreen : public QEglFSKmsScreen { public: @@ -49,8 +51,13 @@ public: QEglFSKmsDevice *device, QEglFSKmsOutput output, QPoint position); + ~QEglFSKmsEglDeviceScreen(); + + QPlatformCursor *cursor() const Q_DECL_OVERRIDE; void waitForFlip() Q_DECL_OVERRIDE; }; +QT_END_NAMESPACE + #endif // QEGLFSKMSEGLDEVICESCREEN_H |