summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/eglfs
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-05-20 13:46:21 +0200
committerOswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>2016-05-23 21:09:46 +0200
commit56d6e000f7487c59172330ebd23a718268c508f1 (patch)
tree1494432583b1569816075091a8075b31d795f77c /src/plugins/platforms/eglfs
parent9fd407fc6a29c94b4568dd042a05c208255179e0 (diff)
parentc276aa51303b7c6f8e4cd854aadf8344a906e50f (diff)
Merge remote-tracking branch 'origin/5.7' into dev
Conflicts: mkspecs/wince80colibri-armv7-msvc2012/qmake.conf qmake/generators/win32/msvc_vcproj.cpp src/corelib/global/qnamespace.h src/corelib/global/qnamespace.qdoc src/corelib/io/qfsfileengine_win.cpp src/corelib/tools/tools.pri src/network/ssl/qsslconfiguration_p.h src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp src/plugins/platforms/windows/windows.pri src/src.pro src/tools/bootstrap/bootstrap.pro src/tools/uic/cpp/cppwriteinitialization.cpp src/widgets/dialogs/qfilesystemmodel.cpp tests/auto/testlib/selftests/expected_cmptest.teamcity tests/auto/testlib/selftests/expected_cmptest.txt Change-Id: I4d2ac78f0dcc97f008186bbbc769c6fe588ab0e5
Diffstat (limited to 'src/plugins/platforms/eglfs')
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.cpp57
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.h30
-rw-r--r--src/plugins/platforms/eglfs/qeglfscontext.cpp1
-rw-r--r--src/plugins/platforms/eglfs/qeglfscontext.h2
-rw-r--r--src/plugins/platforms/eglfs/qeglfsdeviceintegration.h3
-rw-r--r--src/plugins/platforms/eglfs/qeglfsglobal.h13
-rw-r--r--src/plugins/platforms/eglfs/qeglfshooks.h2
-rw-r--r--src/plugins/platforms/eglfs/qeglfsintegration.cpp2
-rw-r--r--src/plugins/platforms/eglfs/qeglfsintegration.h3
-rw-r--r--src/plugins/platforms/eglfs/qeglfsoffscreenwindow.h3
-rw-r--r--src/plugins/platforms/eglfs/qeglfsscreen.h1
-rw-r--r--src/plugins/platforms/eglfs/qeglfswindow.h3
12 files changed, 100 insertions, 20 deletions
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.cpp
index d96c3964df..abff88b4bd 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.cpp
@@ -48,6 +48,7 @@
#include <QtCore/QJsonArray>
#include <QtCore/QLoggingCategory>
#include <QtGui/QPainter>
+#include <QtGui/private/qguiapplication_p.h>
#include <xf86drm.h>
#include <xf86drmMode.h>
@@ -69,13 +70,13 @@ QEglFSKmsGbmCursor::QEglFSKmsGbmCursor(QEglFSKmsGbmScreen *screen)
, m_cursorSize(64, 64) // 64x64 is the old standard size, we now try to query the real size below
, m_bo(Q_NULLPTR)
, m_cursorImage(0, 0, 0, 0, 0, 0)
- , m_visible(true)
+ , m_state(CursorPendingVisible)
{
QByteArray hideCursorVal = qgetenv("QT_QPA_EGLFS_HIDECURSOR");
- if (!hideCursorVal.isEmpty())
- m_visible = hideCursorVal.toInt() == 0;
- if (!m_visible)
+ if (!hideCursorVal.isEmpty() && hideCursorVal.toInt()) {
+ m_state = CursorDisabled;
return;
+ }
uint64_t width, height;
if ((drmGetCap(m_screen->device()->fd(), DRM_CAP_CURSOR_WIDTH, &width) == 0)
@@ -92,6 +93,12 @@ QEglFSKmsGbmCursor::QEglFSKmsGbmCursor(QEglFSKmsGbmScreen *screen)
initCursorAtlas();
}
+ m_deviceListener = new QEglFSKmsGbmCursorDeviceListener(this);
+ connect(QGuiApplicationPrivate::inputDeviceManager(), &QInputDeviceManager::deviceListChanged,
+ m_deviceListener, &QEglFSKmsGbmCursorDeviceListener::onDeviceListChanged);
+ if (!m_deviceListener->hasMouse())
+ m_state = CursorPendingHidden;
+
#ifndef QT_NO_CURSOR
QCursor cursor(Qt::ArrowCursor);
changeCursor(&cursor, 0);
@@ -101,6 +108,8 @@ QEglFSKmsGbmCursor::QEglFSKmsGbmCursor(QEglFSKmsGbmScreen *screen)
QEglFSKmsGbmCursor::~QEglFSKmsGbmCursor()
{
+ delete m_deviceListener;
+
Q_FOREACH (QPlatformScreen *screen, m_screen->virtualSiblings()) {
QEglFSKmsScreen *kmsScreen = static_cast<QEglFSKmsScreen *>(screen);
drmModeSetCursor(kmsScreen->device()->fd(), kmsScreen->output().crtc_id, 0, 0, 0);
@@ -113,6 +122,31 @@ QEglFSKmsGbmCursor::~QEglFSKmsGbmCursor()
}
}
+void QEglFSKmsGbmCursor::updateMouseStatus()
+{
+ const bool wasVisible = m_state == CursorVisible;
+ const bool visible = m_deviceListener->hasMouse();
+ if (visible == wasVisible)
+ return;
+
+ m_state = visible ? CursorPendingVisible : CursorPendingHidden;
+
+#ifndef QT_NO_CURSOR
+ changeCursor(nullptr, m_screen->topLevelAt(pos()));
+#endif
+}
+
+bool QEglFSKmsGbmCursorDeviceListener::hasMouse() const
+{
+ return QGuiApplicationPrivate::inputDeviceManager()->deviceCount(QInputDeviceManager::DeviceTypePointer) > 0;
+}
+
+void QEglFSKmsGbmCursorDeviceListener::onDeviceListChanged(QInputDeviceManager::DeviceType type)
+{
+ if (type == QInputDeviceManager::DeviceTypePointer)
+ m_cursor->updateMouseStatus();
+}
+
void QEglFSKmsGbmCursor::pointerEvent(const QMouseEvent &event)
{
setPos(event.screenPos().toPoint());
@@ -126,7 +160,15 @@ void QEglFSKmsGbmCursor::changeCursor(QCursor *windowCursor, QWindow *window)
if (!m_bo)
return;
- if (!m_visible)
+ if (m_state == CursorPendingHidden) {
+ m_state = CursorHidden;
+ Q_FOREACH (QPlatformScreen *screen, m_screen->virtualSiblings()) {
+ QEglFSKmsScreen *kmsScreen = static_cast<QEglFSKmsScreen *>(screen);
+ drmModeSetCursor(kmsScreen->device()->fd(), kmsScreen->output().crtc_id, 0, 0, 0);
+ }
+ }
+
+ if (m_state == CursorHidden || m_state == CursorDisabled)
return;
const Qt::CursorShape newShape = windowCursor ? windowCursor->shape() : Qt::ArrowCursor;
@@ -166,6 +208,9 @@ void QEglFSKmsGbmCursor::changeCursor(QCursor *windowCursor, QWindow *window)
uint32_t handle = gbm_bo_get_handle(m_bo).u32;
+ if (m_state == CursorPendingVisible)
+ m_state = CursorVisible;
+
Q_FOREACH (QPlatformScreen *screen, m_screen->virtualSiblings()) {
QEglFSKmsScreen *kmsScreen = static_cast<QEglFSKmsScreen *>(screen);
@@ -213,7 +258,7 @@ void QEglFSKmsGbmCursor::initCursorAtlas()
drmModeSetCursor(kmsScreen->device()->fd(), kmsScreen->output().crtc_id, 0, 0, 0);
drmModeMoveCursor(kmsScreen->device()->fd(), kmsScreen->output().crtc_id, 0, 0);
}
- m_visible = false;
+ m_state = CursorDisabled;
return;
}
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.h
index c1e3706e91..de13a058cf 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.h
@@ -43,12 +43,29 @@
#include <qpa/qplatformcursor.h>
#include <QtCore/QList>
#include <QtGui/QImage>
+#include <QtGui/private/qinputdevicemanager_p.h>
#include <gbm.h>
QT_BEGIN_NAMESPACE
class QEglFSKmsGbmScreen;
+class QEglFSKmsGbmCursor;
+
+class QEglFSKmsGbmCursorDeviceListener : public QObject
+{
+ Q_OBJECT
+
+public:
+ QEglFSKmsGbmCursorDeviceListener(QEglFSKmsGbmCursor *cursor) : m_cursor(cursor) { }
+ bool hasMouse() const;
+
+public slots:
+ void onDeviceListChanged(QInputDeviceManager::DeviceType type);
+
+private:
+ QEglFSKmsGbmCursor *m_cursor;
+};
class QEglFSKmsGbmCursor : public QPlatformCursor
{
@@ -66,15 +83,26 @@ public:
QPoint pos() const Q_DECL_OVERRIDE;
void setPos(const QPoint &pos) Q_DECL_OVERRIDE;
+ void updateMouseStatus();
+
private:
void initCursorAtlas();
+ enum CursorState {
+ CursorDisabled,
+ CursorPendingHidden,
+ CursorHidden,
+ CursorPendingVisible,
+ CursorVisible
+ };
+
QEglFSKmsGbmScreen *m_screen;
QSize m_cursorSize;
gbm_bo *m_bo;
QPoint m_pos;
QPlatformCursorImage m_cursorImage;
- bool m_visible;
+ CursorState m_state;
+ QEglFSKmsGbmCursorDeviceListener *m_deviceListener;
// cursor atlas information
struct CursorAtlas {
diff --git a/src/plugins/platforms/eglfs/qeglfscontext.cpp b/src/plugins/platforms/eglfs/qeglfscontext.cpp
index 229ac6bbd9..6acb362bf0 100644
--- a/src/plugins/platforms/eglfs/qeglfscontext.cpp
+++ b/src/plugins/platforms/eglfs/qeglfscontext.cpp
@@ -37,6 +37,7 @@
**
****************************************************************************/
+#include "qeglfsglobal.h"
#include <QtGui/QSurface>
#include <QtPlatformSupport/private/qeglconvenience_p.h>
#include <QtPlatformSupport/private/qeglpbuffer_p.h>
diff --git a/src/plugins/platforms/eglfs/qeglfscontext.h b/src/plugins/platforms/eglfs/qeglfscontext.h
index b861ae5329..91c5a7910b 100644
--- a/src/plugins/platforms/eglfs/qeglfscontext.h
+++ b/src/plugins/platforms/eglfs/qeglfscontext.h
@@ -40,9 +40,9 @@
#ifndef QEGLFSCONTEXT_H
#define QEGLFSCONTEXT_H
+#include "qeglfsglobal.h"
#include <QtPlatformSupport/private/qeglplatformcontext_p.h>
#include <QtCore/QVariant>
-#include "qeglfsglobal.h"
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/qeglfsdeviceintegration.h b/src/plugins/platforms/eglfs/qeglfsdeviceintegration.h
index cbbf2551b7..f1a5bde331 100644
--- a/src/plugins/platforms/eglfs/qeglfsdeviceintegration.h
+++ b/src/plugins/platforms/eglfs/qeglfsdeviceintegration.h
@@ -51,13 +51,12 @@
// We mean it.
//
+#include "qeglfsglobal.h"
#include <qpa/qplatformintegration.h>
#include <qpa/qplatformscreen.h>
#include <QtCore/QString>
#include <QtGui/QSurfaceFormat>
#include <QtGui/QImage>
-#include <EGL/egl.h>
-#include "qeglfsglobal.h"
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/qeglfsglobal.h b/src/plugins/platforms/eglfs/qeglfsglobal.h
index 8b6a391143..d6aba565ce 100644
--- a/src/plugins/platforms/eglfs/qeglfsglobal.h
+++ b/src/plugins/platforms/eglfs/qeglfsglobal.h
@@ -48,4 +48,17 @@
#define Q_EGLFS_EXPORT Q_DECL_IMPORT
#endif
+#include <EGL/egl.h>
+#undef Status
+#undef None
+#undef Bool
+#undef CursorShape
+#undef KeyPress
+#undef KeyRelease
+#undef FocusIn
+#undef FocusOut
+#undef FontChange
+#undef Expose
+#undef Unsorted
+
#endif
diff --git a/src/plugins/platforms/eglfs/qeglfshooks.h b/src/plugins/platforms/eglfs/qeglfshooks.h
index 745c5d479c..cc6c325b58 100644
--- a/src/plugins/platforms/eglfs/qeglfshooks.h
+++ b/src/plugins/platforms/eglfs/qeglfshooks.h
@@ -40,8 +40,8 @@
#ifndef QEGLFSHOOKS_H
#define QEGLFSHOOKS_H
-#include "qeglfsdeviceintegration.h"
#include "qeglfsglobal.h"
+#include "qeglfsdeviceintegration.h"
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.cpp b/src/plugins/platforms/eglfs/qeglfsintegration.cpp
index 29e3c5e560..6f38a96f45 100644
--- a/src/plugins/platforms/eglfs/qeglfsintegration.cpp
+++ b/src/plugins/platforms/eglfs/qeglfsintegration.cpp
@@ -86,8 +86,6 @@
#include <QtPlatformHeaders/qeglfsfunctions.h>
-#include <EGL/egl.h>
-
static void initResources()
{
#ifndef QT_NO_CURSOR
diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.h b/src/plugins/platforms/eglfs/qeglfsintegration.h
index e06d7e8876..678452a8db 100644
--- a/src/plugins/platforms/eglfs/qeglfsintegration.h
+++ b/src/plugins/platforms/eglfs/qeglfsintegration.h
@@ -40,12 +40,11 @@
#ifndef QEGLFSINTEGRATION_H
#define QEGLFSINTEGRATION_H
+#include "qeglfsglobal.h"
#include <QtCore/QVariant>
#include <qpa/qplatformintegration.h>
#include <qpa/qplatformnativeinterface.h>
#include <qpa/qplatformscreen.h>
-#include <EGL/egl.h>
-#include "qeglfsglobal.h"
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/qeglfsoffscreenwindow.h b/src/plugins/platforms/eglfs/qeglfsoffscreenwindow.h
index 6f808d8a10..673fa0d729 100644
--- a/src/plugins/platforms/eglfs/qeglfsoffscreenwindow.h
+++ b/src/plugins/platforms/eglfs/qeglfsoffscreenwindow.h
@@ -40,9 +40,8 @@
#ifndef QEGLFSOFFSCREENWINDOW_H
#define QEGLFSOFFSCREENWINDOW_H
-#include <EGL/egl.h>
-#include <qpa/qplatformoffscreensurface.h>
#include "qeglfsglobal.h"
+#include <qpa/qplatformoffscreensurface.h>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/qeglfsscreen.h b/src/plugins/platforms/eglfs/qeglfsscreen.h
index b388885186..57d68ca572 100644
--- a/src/plugins/platforms/eglfs/qeglfsscreen.h
+++ b/src/plugins/platforms/eglfs/qeglfsscreen.h
@@ -42,7 +42,6 @@
#include "qeglfsglobal.h"
#include <QtCore/QPointer>
-#include <EGL/egl.h>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/qeglfswindow.h b/src/plugins/platforms/eglfs/qeglfswindow.h
index 621890b060..d607c8bd62 100644
--- a/src/plugins/platforms/eglfs/qeglfswindow.h
+++ b/src/plugins/platforms/eglfs/qeglfswindow.h
@@ -40,13 +40,12 @@
#ifndef QEGLFSWINDOW_H
#define QEGLFSWINDOW_H
+#include "qeglfsglobal.h"
#include "qeglfsintegration.h"
#include "qeglfsscreen.h"
-#include "qeglfsglobal.h"
#include <qpa/qplatformwindow.h>
#include <QtPlatformSupport/private/qopenglcompositor_p.h>
-#include <EGL/egl.h>
QT_BEGIN_NAMESPACE