Unify input device hotplugging support for embedded
On embedded the mouse cursor will now appear and reappear regardless of how the input handling code is loaded (via a generic plugin or compiled-in to the platform plugin). Instead of passing around QDeviceDiscovery instances that only works when compiling-in the code into the platform plugin, introduce a new internal central QInputDeviceManager. The single instance of this provides a place to store any future input device related signals and properties. Also introduce mouse hotplugging support to linuxfb. [ChangeLog][QtGui] The mouse cursor on Embedded Linux is now handling hotplugging correctly with eglfs and linuxfb regardless of how the input handling code is loaded (via a generic plugin or built in to the platform plugin). Change-Id: I147c1b04a193baf216598015264f2c06e1b20f84 Reviewed-by: Andy Nichols <andy.nichols@theqtcompany.com>bb10
parent
f93c04e44a
commit
10472dce92
|
|
@ -74,7 +74,9 @@ HEADERS += \
|
|||
kernel/qpaintdevicewindow_p.h \
|
||||
kernel/qrasterwindow.h \
|
||||
kernel/qplatformgraphicsbuffer.h \
|
||||
kernel/qplatformgraphicsbufferhelper.h
|
||||
kernel/qplatformgraphicsbufferhelper.h \
|
||||
kernel/qinputdevicemanager_p.h \
|
||||
kernel/qinputdevicemanager_p_p.h
|
||||
|
||||
SOURCES += \
|
||||
kernel/qgenericpluginfactory.cpp \
|
||||
|
|
@ -130,7 +132,8 @@ SOURCES += \
|
|||
kernel/qrasterwindow.cpp \
|
||||
kernel/qplatformgraphicsbuffer.cpp \
|
||||
kernel/qplatformgraphicsbufferhelper.cpp \
|
||||
kernel/qplatformhardwarecompositor.cpp
|
||||
kernel/qplatformhardwarecompositor.cpp \
|
||||
kernel/qinputdevicemanager.cpp
|
||||
|
||||
contains(QT_CONFIG, opengl)|contains(QT_CONFIG, opengles2) {
|
||||
HEADERS += \
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@
|
|||
#include "private/qwindow_p.h"
|
||||
#include "private/qcursor_p.h"
|
||||
#include "private/qopenglcontext_p.h"
|
||||
#include "private/qinputdevicemanager_p.h"
|
||||
|
||||
#include "private/qdnd_p.h"
|
||||
#include <qpa/qplatformthemefactory_p.h>
|
||||
|
|
@ -164,6 +165,8 @@ static QBasicMutex applicationFontMutex;
|
|||
QFont *QGuiApplicationPrivate::app_font = 0;
|
||||
bool QGuiApplicationPrivate::obey_desktop_settings = true;
|
||||
|
||||
QInputDeviceManager *QGuiApplicationPrivate::m_inputDeviceManager = 0;
|
||||
|
||||
static qreal fontSmoothingGamma = 1.7;
|
||||
|
||||
extern void qRegisterGuiVariant();
|
||||
|
|
@ -3470,6 +3473,16 @@ void QGuiApplicationPrivate::setMouseEventFlags(QMouseEvent *event, Qt::MouseEve
|
|||
event->caps |= (value & Qt::MouseEventFlagMask) << MouseFlagsShift;
|
||||
}
|
||||
|
||||
QInputDeviceManager *QGuiApplicationPrivate::inputDeviceManager()
|
||||
{
|
||||
Q_ASSERT(QGuiApplication::instance());
|
||||
|
||||
if (!m_inputDeviceManager)
|
||||
m_inputDeviceManager = new QInputDeviceManager(QGuiApplication::instance());
|
||||
|
||||
return m_inputDeviceManager;
|
||||
}
|
||||
|
||||
#include "moc_qguiapplication.cpp"
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ struct QDrawHelperGammaTables;
|
|||
#ifndef QT_NO_DRAGANDDROP
|
||||
class QDrag;
|
||||
#endif // QT_NO_DRAGANDDROP
|
||||
class QInputDeviceManager;
|
||||
|
||||
class Q_GUI_EXPORT QGuiApplicationPrivate : public QCoreApplicationPrivate
|
||||
{
|
||||
|
|
@ -272,6 +273,8 @@ public:
|
|||
|
||||
static Qt::MouseEventSource wheelEventSource(const QWheelEvent *event);
|
||||
|
||||
static QInputDeviceManager *inputDeviceManager();
|
||||
|
||||
const QDrawHelperGammaTables *gammaTables();
|
||||
|
||||
// hook reimplemented in QApplication to apply the QStyle function on the QIcon
|
||||
|
|
@ -301,6 +304,8 @@ private:
|
|||
QAtomicPointer<QDrawHelperGammaTables> m_gammaTables;
|
||||
|
||||
bool ownGlobalShareContext;
|
||||
|
||||
static QInputDeviceManager *m_inputDeviceManager;
|
||||
};
|
||||
|
||||
Q_GUI_EXPORT uint qHash(const QGuiApplicationPrivate::ActiveTouchPointsKey &k);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,64 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL21$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qinputdevicemanager_p.h"
|
||||
#include "qinputdevicemanager_p_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QInputDeviceManager::QInputDeviceManager(QObject *parent)
|
||||
: QObject(*new QInputDeviceManagerPrivate, parent)
|
||||
{
|
||||
}
|
||||
|
||||
int QInputDeviceManager::deviceCount(DeviceType type) const
|
||||
{
|
||||
Q_D(const QInputDeviceManager);
|
||||
return d->deviceCount(type);
|
||||
}
|
||||
|
||||
int QInputDeviceManagerPrivate::deviceCount(QInputDeviceManager::DeviceType type) const
|
||||
{
|
||||
return m_deviceCount.value(type);
|
||||
}
|
||||
|
||||
void QInputDeviceManagerPrivate::setDeviceCount(QInputDeviceManager::DeviceType type, int count)
|
||||
{
|
||||
Q_Q(QInputDeviceManager);
|
||||
if (m_deviceCount.value(type) != count) {
|
||||
m_deviceCount[type] = count;
|
||||
emit q->deviceListChanged(type);
|
||||
}
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL21$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QINPUTDEVICEMANAGER_P_H
|
||||
#define QINPUTDEVICEMANAGER_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <QtCore/qobject.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QInputDeviceManagerPrivate;
|
||||
|
||||
class Q_GUI_EXPORT QInputDeviceManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PRIVATE(QInputDeviceManager)
|
||||
|
||||
public:
|
||||
enum DeviceType {
|
||||
DeviceTypeUnknown,
|
||||
DeviceTypePointer,
|
||||
DeviceTypeKeyboard,
|
||||
DeviceTypeTouch
|
||||
};
|
||||
|
||||
QInputDeviceManager(QObject *parent = 0);
|
||||
|
||||
int deviceCount(DeviceType type) const;
|
||||
|
||||
signals:
|
||||
void deviceListChanged(DeviceType type);
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QINPUTDEVICEMANAGER_P_H
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL21$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QINPUTDEVICEMANAGER_P_P_H
|
||||
#define QINPUTDEVICEMANAGER_P_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <QtCore/qmap.h>
|
||||
#include <private/qobject_p.h>
|
||||
#include "qinputdevicemanager_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class Q_GUI_EXPORT QInputDeviceManagerPrivate : public QObjectPrivate
|
||||
{
|
||||
Q_DECLARE_PUBLIC(QInputDeviceManager)
|
||||
|
||||
public:
|
||||
static QInputDeviceManagerPrivate *get(QInputDeviceManager *mgr) { return mgr->d_func(); }
|
||||
|
||||
int deviceCount(QInputDeviceManager::DeviceType type) const;
|
||||
void setDeviceCount(QInputDeviceManager::DeviceType type, int count);
|
||||
|
||||
QMap<QInputDeviceManager::DeviceType, int> m_deviceCount;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QINPUTDEVICEMANAGER_P_P_H
|
||||
|
|
@ -39,7 +39,7 @@
|
|||
#include <QtCore/QJsonObject>
|
||||
#include <QtDebug>
|
||||
|
||||
#include <QtPlatformSupport/private/qdevicediscovery_p.h>
|
||||
#include <QtGui/private/qguiapplication_p.h>
|
||||
|
||||
#include "qeglplatformcursor_p.h"
|
||||
#include "qeglplatformintegration_p.h"
|
||||
|
|
@ -79,6 +79,11 @@ QEGLPlatformCursor::QEGLPlatformCursor(QPlatformScreen *screen)
|
|||
QCursor cursor(Qt::ArrowCursor);
|
||||
setCurrentCursor(&cursor);
|
||||
#endif
|
||||
|
||||
m_deviceListener = new QEGLPlatformCursorDeviceListener(this);
|
||||
connect(QGuiApplicationPrivate::inputDeviceManager(), &QInputDeviceManager::deviceListChanged,
|
||||
m_deviceListener, &QEGLPlatformCursorDeviceListener::onDeviceListChanged);
|
||||
updateMouseStatus();
|
||||
}
|
||||
|
||||
QEGLPlatformCursor::~QEGLPlatformCursor()
|
||||
|
|
@ -87,42 +92,20 @@ QEGLPlatformCursor::~QEGLPlatformCursor()
|
|||
delete m_deviceListener;
|
||||
}
|
||||
|
||||
void QEGLPlatformCursor::setMouseDeviceDiscovery(QDeviceDiscovery *dd)
|
||||
{
|
||||
if (m_visible && dd) {
|
||||
m_deviceListener = new QEGLPlatformCursorDeviceListener(dd, this);
|
||||
updateMouseStatus();
|
||||
}
|
||||
}
|
||||
|
||||
void QEGLPlatformCursor::updateMouseStatus()
|
||||
{
|
||||
m_visible = m_deviceListener->hasMouse();
|
||||
}
|
||||
|
||||
QEGLPlatformCursorDeviceListener::QEGLPlatformCursorDeviceListener(QDeviceDiscovery *dd, QEGLPlatformCursor *cursor)
|
||||
: m_cursor(cursor)
|
||||
{
|
||||
m_mouseCount = dd->scanConnectedDevices().count();
|
||||
connect(dd, SIGNAL(deviceDetected(QString)), SLOT(onDeviceAdded()));
|
||||
connect(dd, SIGNAL(deviceRemoved(QString)), SLOT(onDeviceRemoved()));
|
||||
}
|
||||
|
||||
bool QEGLPlatformCursorDeviceListener::hasMouse() const
|
||||
{
|
||||
return m_mouseCount > 0;
|
||||
return QGuiApplicationPrivate::inputDeviceManager()->deviceCount(QInputDeviceManager::DeviceTypePointer) > 0;
|
||||
}
|
||||
|
||||
void QEGLPlatformCursorDeviceListener::onDeviceAdded()
|
||||
void QEGLPlatformCursorDeviceListener::onDeviceListChanged(QInputDeviceManager::DeviceType type)
|
||||
{
|
||||
++m_mouseCount;
|
||||
m_cursor->updateMouseStatus();
|
||||
}
|
||||
|
||||
void QEGLPlatformCursorDeviceListener::onDeviceRemoved()
|
||||
{
|
||||
--m_mouseCount;
|
||||
m_cursor->updateMouseStatus();
|
||||
if (type == QInputDeviceManager::DeviceTypePointer)
|
||||
m_cursor->updateMouseStatus();
|
||||
}
|
||||
|
||||
void QEGLPlatformCursor::resetResources()
|
||||
|
|
|
|||
|
|
@ -48,11 +48,11 @@
|
|||
#include <qpa/qplatformcursor.h>
|
||||
#include <qpa/qplatformscreen.h>
|
||||
#include <QtGui/QOpenGLFunctions>
|
||||
#include <QtGui/private/qinputdevicemanager_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QOpenGLShaderProgram;
|
||||
class QDeviceDiscovery;
|
||||
class QEGLPlatformCursor;
|
||||
|
||||
class QEGLPlatformCursorDeviceListener : public QObject
|
||||
|
|
@ -60,16 +60,14 @@ class QEGLPlatformCursorDeviceListener : public QObject
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QEGLPlatformCursorDeviceListener(QDeviceDiscovery *dd, QEGLPlatformCursor *cursor);
|
||||
QEGLPlatformCursorDeviceListener(QEGLPlatformCursor *cursor) : m_cursor(cursor) { }
|
||||
bool hasMouse() const;
|
||||
|
||||
private slots:
|
||||
void onDeviceAdded();
|
||||
void onDeviceRemoved();
|
||||
public slots:
|
||||
void onDeviceListChanged(QInputDeviceManager::DeviceType type);
|
||||
|
||||
private:
|
||||
QEGLPlatformCursor *m_cursor;
|
||||
int m_mouseCount;
|
||||
};
|
||||
|
||||
class QEGLPlatformCursorUpdater : public QObject
|
||||
|
|
@ -108,7 +106,6 @@ public:
|
|||
void paintOnScreen();
|
||||
void resetResources();
|
||||
|
||||
void setMouseDeviceDiscovery(QDeviceDiscovery *dd);
|
||||
void updateMouseStatus();
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -352,12 +352,7 @@ void QEGLPlatformIntegration::createInputHandlers()
|
|||
{
|
||||
#if !defined(QT_NO_EVDEV) && (!defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID_NO_SDK))
|
||||
m_kbdMgr = new QEvdevKeyboardManager(QLatin1String("EvdevKeyboard"), QString() /* spec */, this);
|
||||
QEvdevMouseManager *mouseMgr = new QEvdevMouseManager(QLatin1String("EvdevMouse"), QString() /* spec */, this);
|
||||
Q_FOREACH (QScreen *screen, QGuiApplication::screens()) {
|
||||
QEGLPlatformCursor *cursor = qobject_cast<QEGLPlatformCursor *>(screen->handle()->cursor());
|
||||
if (cursor)
|
||||
cursor->setMouseDeviceDiscovery(mouseMgr->deviceDiscovery());
|
||||
}
|
||||
new QEvdevMouseManager(QLatin1String("EvdevMouse"), QString() /* spec */, this);
|
||||
#ifndef QT_NO_TSLIB
|
||||
const bool useTslib = qEnvironmentVariableIntValue("QT_QPA_EGLFS_TSLIB");
|
||||
if (useTslib)
|
||||
|
|
|
|||
|
|
@ -34,14 +34,47 @@
|
|||
#include "qfbcursor_p.h"
|
||||
#include "qfbscreen_p.h"
|
||||
#include <QtGui/QPainter>
|
||||
#include <QtGui/private/qguiapplication_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QFbCursor::QFbCursor(QFbScreen *screen)
|
||||
: mScreen(screen), mDirty(false), mOnScreen(false)
|
||||
bool QFbCursorDeviceListener::hasMouse() const
|
||||
{
|
||||
return QGuiApplicationPrivate::inputDeviceManager()->deviceCount(QInputDeviceManager::DeviceTypePointer) > 0;
|
||||
}
|
||||
|
||||
void QFbCursorDeviceListener::onDeviceListChanged(QInputDeviceManager::DeviceType type)
|
||||
{
|
||||
if (type == QInputDeviceManager::DeviceTypePointer)
|
||||
m_cursor->updateMouseStatus();
|
||||
}
|
||||
|
||||
QFbCursor::QFbCursor(QFbScreen *screen)
|
||||
: mVisible(true),
|
||||
mScreen(screen),
|
||||
mDirty(false),
|
||||
mOnScreen(false),
|
||||
mGraphic(0),
|
||||
mDeviceListener(0)
|
||||
{
|
||||
QByteArray hideCursorVal = qgetenv("QT_QPA_FB_HIDECURSOR");
|
||||
if (!hideCursorVal.isEmpty())
|
||||
mVisible = hideCursorVal.toInt() == 0;
|
||||
if (!mVisible)
|
||||
return;
|
||||
|
||||
mGraphic = new QPlatformCursorImage(0, 0, 0, 0, 0, 0);
|
||||
setCursor(Qt::ArrowCursor);
|
||||
|
||||
mDeviceListener = new QFbCursorDeviceListener(this);
|
||||
connect(QGuiApplicationPrivate::inputDeviceManager(), &QInputDeviceManager::deviceListChanged,
|
||||
mDeviceListener, &QFbCursorDeviceListener::onDeviceListChanged);
|
||||
updateMouseStatus();
|
||||
}
|
||||
|
||||
QFbCursor::~QFbCursor()
|
||||
{
|
||||
delete mDeviceListener;
|
||||
}
|
||||
|
||||
QRect QFbCursor::getCurrentRect()
|
||||
|
|
@ -68,6 +101,9 @@ void QFbCursor::pointerEvent(const QMouseEvent & e)
|
|||
|
||||
QRect QFbCursor::drawCursor(QPainter & painter)
|
||||
{
|
||||
if (!mVisible)
|
||||
return QRect();
|
||||
|
||||
mDirty = false;
|
||||
if (mCurrentRect.isNull())
|
||||
return QRect();
|
||||
|
|
@ -131,15 +167,19 @@ void QFbCursor::changeCursor(QCursor * widgetCursor, QWindow *window)
|
|||
|
||||
void QFbCursor::setDirty()
|
||||
{
|
||||
if (!mVisible)
|
||||
return;
|
||||
|
||||
if (!mDirty) {
|
||||
mDirty = true;
|
||||
mScreen->scheduleUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
void QFbCursor::setMouseDeviceDiscovery(QDeviceDiscovery *dd)
|
||||
void QFbCursor::updateMouseStatus()
|
||||
{
|
||||
Q_UNUSED(dd);
|
||||
mVisible = mDeviceListener->hasMouse();
|
||||
mScreen->setDirty(mVisible ? getCurrentRect() : lastPainted());
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -46,11 +46,27 @@
|
|||
//
|
||||
|
||||
#include <qpa/qplatformcursor.h>
|
||||
#include <QtGui/private/qinputdevicemanager_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QFbScreen;
|
||||
class QDeviceDiscovery;
|
||||
class QFbCursor;
|
||||
|
||||
class QFbCursorDeviceListener : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QFbCursorDeviceListener(QFbCursor *cursor) : m_cursor(cursor) { }
|
||||
bool hasMouse() const;
|
||||
|
||||
public slots:
|
||||
void onDeviceListChanged(QInputDeviceManager::DeviceType type);
|
||||
|
||||
private:
|
||||
QFbCursor *m_cursor;
|
||||
};
|
||||
|
||||
class QFbCursor : public QPlatformCursor
|
||||
{
|
||||
|
|
@ -58,6 +74,7 @@ class QFbCursor : public QPlatformCursor
|
|||
|
||||
public:
|
||||
QFbCursor(QFbScreen *screen);
|
||||
~QFbCursor();
|
||||
|
||||
// output methods
|
||||
QRect dirtyRect();
|
||||
|
|
@ -74,7 +91,7 @@ public:
|
|||
virtual bool isOnScreen() const { return mOnScreen; }
|
||||
virtual QRect lastPainted() const { return mPrevRect; }
|
||||
|
||||
void setMouseDeviceDiscovery(QDeviceDiscovery *dd);
|
||||
void updateMouseStatus();
|
||||
|
||||
private:
|
||||
void setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY);
|
||||
|
|
@ -82,12 +99,14 @@ private:
|
|||
void setCursor(const QImage &image, int hotx, int hoty);
|
||||
QRect getCurrentRect();
|
||||
|
||||
bool mVisible;
|
||||
QFbScreen *mScreen;
|
||||
QRect mCurrentRect; // next place to draw the cursor
|
||||
QRect mPrevRect; // last place the cursor was drawn
|
||||
bool mDirty;
|
||||
bool mOnScreen;
|
||||
QPlatformCursorImage *mGraphic;
|
||||
QFbCursorDeviceListener *mDeviceListener;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -37,6 +37,9 @@
|
|||
#include <QCoreApplication>
|
||||
#include <QLoggingCategory>
|
||||
|
||||
#include <private/qguiapplication_p.h>
|
||||
#include <private/qinputdevicemanager_p_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
Q_DECLARE_LOGGING_CATEGORY(qLcEvdevKey)
|
||||
|
|
@ -97,10 +100,13 @@ void QEvdevKeyboardManager::addKeyboard(const QString &deviceNode)
|
|||
qCDebug(qLcEvdevKey) << "Adding keyboard at" << deviceNode;
|
||||
QEvdevKeyboardHandler *keyboard;
|
||||
keyboard = QEvdevKeyboardHandler::create(deviceNode, m_spec, m_defaultKeymapFile);
|
||||
if (keyboard)
|
||||
if (keyboard) {
|
||||
m_keyboards.insert(deviceNode, keyboard);
|
||||
else
|
||||
QInputDeviceManagerPrivate::get(QGuiApplicationPrivate::inputDeviceManager())->setDeviceCount(
|
||||
QInputDeviceManager::DeviceTypeKeyboard, m_keyboards.count());
|
||||
} else {
|
||||
qWarning("Failed to open keyboard device %s", qPrintable(deviceNode));
|
||||
}
|
||||
}
|
||||
|
||||
void QEvdevKeyboardManager::removeKeyboard(const QString &deviceNode)
|
||||
|
|
@ -109,6 +115,8 @@ void QEvdevKeyboardManager::removeKeyboard(const QString &deviceNode)
|
|||
qCDebug(qLcEvdevKey) << "Removing keyboard at" << deviceNode;
|
||||
QEvdevKeyboardHandler *keyboard = m_keyboards.value(deviceNode);
|
||||
m_keyboards.remove(deviceNode);
|
||||
QInputDeviceManagerPrivate::get(QGuiApplicationPrivate::inputDeviceManager())->setDeviceCount(
|
||||
QInputDeviceManager::DeviceTypeKeyboard, m_keyboards.count());
|
||||
delete keyboard;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,9 @@
|
|||
#include <QScreen>
|
||||
#include <QLoggingCategory>
|
||||
#include <qpa/qwindowsysteminterface.h>
|
||||
#include <QtPlatformSupport/private/qdevicediscovery_p.h>
|
||||
#include <private/qguiapplication_p.h>
|
||||
#include <private/qinputdevicemanager_p_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
|
@ -141,6 +144,8 @@ void QEvdevMouseManager::addMouse(const QString &deviceNode)
|
|||
connect(handler, SIGNAL(handleMouseEvent(int,int,bool,Qt::MouseButtons)), this, SLOT(handleMouseEvent(int,int,bool,Qt::MouseButtons)));
|
||||
connect(handler, SIGNAL(handleWheelEvent(int,Qt::Orientation)), this, SLOT(handleWheelEvent(int,Qt::Orientation)));
|
||||
m_mice.insert(deviceNode, handler);
|
||||
QInputDeviceManagerPrivate::get(QGuiApplicationPrivate::inputDeviceManager())->setDeviceCount(
|
||||
QInputDeviceManager::DeviceTypePointer, m_mice.count());
|
||||
} else {
|
||||
qWarning("evdevmouse: Failed to open mouse device %s", qPrintable(deviceNode));
|
||||
}
|
||||
|
|
@ -152,6 +157,8 @@ void QEvdevMouseManager::removeMouse(const QString &deviceNode)
|
|||
qCDebug(qLcEvdevMouse) << "Removing mouse at" << deviceNode;
|
||||
QEvdevMouseHandler *handler = m_mice.value(deviceNode);
|
||||
m_mice.remove(deviceNode);
|
||||
QInputDeviceManagerPrivate::get(QGuiApplicationPrivate::inputDeviceManager())->setDeviceCount(
|
||||
QInputDeviceManager::DeviceTypePointer, m_mice.count());
|
||||
delete handler;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,14 +47,14 @@
|
|||
|
||||
#include "qevdevmousehandler_p.h"
|
||||
|
||||
#include <QtPlatformSupport/private/qdevicediscovery_p.h>
|
||||
|
||||
#include <QObject>
|
||||
#include <QHash>
|
||||
#include <QSocketNotifier>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QDeviceDiscovery;
|
||||
|
||||
class QEvdevMouseManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
@ -62,8 +62,6 @@ public:
|
|||
QEvdevMouseManager(const QString &key, const QString &specification, QObject *parent = 0);
|
||||
~QEvdevMouseManager();
|
||||
|
||||
QDeviceDiscovery *deviceDiscovery() { return m_deviceDiscovery; }
|
||||
|
||||
public slots:
|
||||
void handleMouseEvent(int x, int y, bool abs, Qt::MouseButtons buttons);
|
||||
void handleWheelEvent(int delta, Qt::Orientation orientation);
|
||||
|
|
|
|||
|
|
@ -41,6 +41,8 @@
|
|||
#include <QtCore/QLoggingCategory>
|
||||
#include <QtCore/QSocketNotifier>
|
||||
#include <QtCore/private/qcore_unix_p.h>
|
||||
#include <private/qguiapplication_p.h>
|
||||
#include <private/qinputdevicemanager_p_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
|
@ -146,8 +148,25 @@ void QLibInputHandler::processEvent(libinput_event *ev)
|
|||
const char *sysname = libinput_device_get_sysname(dev); // node name without path
|
||||
const char *name = libinput_device_get_name(dev);
|
||||
emit deviceAdded(QString::fromUtf8(sysname), QString::fromUtf8(name));
|
||||
if (libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_TOUCH))
|
||||
|
||||
QInputDeviceManagerPrivate *inputManagerPriv = QInputDeviceManagerPrivate::get(
|
||||
QGuiApplicationPrivate::inputDeviceManager());
|
||||
if (libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_TOUCH)) {
|
||||
m_touch->registerDevice(dev);
|
||||
int &count(m_devCount[QInputDeviceManager::DeviceTypeTouch]);
|
||||
++count;
|
||||
inputManagerPriv->setDeviceCount(QInputDeviceManager::DeviceTypeTouch, count);
|
||||
}
|
||||
if (libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_POINTER)) {
|
||||
int &count(m_devCount[QInputDeviceManager::DeviceTypePointer]);
|
||||
++count;
|
||||
inputManagerPriv->setDeviceCount(QInputDeviceManager::DeviceTypePointer, count);
|
||||
}
|
||||
if (libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_KEYBOARD)) {
|
||||
int &count(m_devCount[QInputDeviceManager::DeviceTypeKeyboard]);
|
||||
++count;
|
||||
inputManagerPriv->setDeviceCount(QInputDeviceManager::DeviceTypeKeyboard, count);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case LIBINPUT_EVENT_DEVICE_REMOVED:
|
||||
|
|
@ -155,8 +174,25 @@ void QLibInputHandler::processEvent(libinput_event *ev)
|
|||
const char *sysname = libinput_device_get_sysname(dev);
|
||||
const char *name = libinput_device_get_name(dev);
|
||||
emit deviceRemoved(QString::fromUtf8(sysname), QString::fromUtf8(name));
|
||||
if (libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_TOUCH))
|
||||
|
||||
QInputDeviceManagerPrivate *inputManagerPriv = QInputDeviceManagerPrivate::get(
|
||||
QGuiApplicationPrivate::inputDeviceManager());
|
||||
if (libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_TOUCH)) {
|
||||
m_touch->unregisterDevice(dev);
|
||||
int &count(m_devCount[QInputDeviceManager::DeviceTypeTouch]);
|
||||
--count;
|
||||
inputManagerPriv->setDeviceCount(QInputDeviceManager::DeviceTypeTouch, count);
|
||||
}
|
||||
if (libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_POINTER)) {
|
||||
int &count(m_devCount[QInputDeviceManager::DeviceTypePointer]);
|
||||
--count;
|
||||
inputManagerPriv->setDeviceCount(QInputDeviceManager::DeviceTypePointer, count);
|
||||
}
|
||||
if (libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_KEYBOARD)) {
|
||||
int &count(m_devCount[QInputDeviceManager::DeviceTypeKeyboard]);
|
||||
--count;
|
||||
inputManagerPriv->setDeviceCount(QInputDeviceManager::DeviceTypeKeyboard, count);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case LIBINPUT_EVENT_POINTER_BUTTON:
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@
|
|||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QScopedPointer>
|
||||
#include <QtCore/QMap>
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
|
|
@ -84,6 +85,7 @@ private:
|
|||
QScopedPointer<QLibInputPointer> m_pointer;
|
||||
QScopedPointer<QLibInputKeyboard> m_keyboard;
|
||||
QScopedPointer<QLibInputTouch> m_touch;
|
||||
QMap<int, int> m_devCount;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -130,12 +130,7 @@ void QLinuxFbIntegration::createInputHandlers()
|
|||
{
|
||||
#if !defined(QT_NO_EVDEV) && (!defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID_NO_SDK))
|
||||
new QEvdevKeyboardManager(QLatin1String("EvdevKeyboard"), QString(), this);
|
||||
QEvdevMouseManager *mouseMgr = new QEvdevMouseManager(QLatin1String("EvdevMouse"), QString(), this);
|
||||
Q_FOREACH (QScreen *screen, QGuiApplication::screens()) {
|
||||
QFbCursor *cursor = qobject_cast<QFbCursor *>(screen->handle()->cursor());
|
||||
if (cursor)
|
||||
cursor->setMouseDeviceDiscovery(mouseMgr->deviceDiscovery());
|
||||
}
|
||||
new QEvdevMouseManager(QLatin1String("EvdevMouse"), QString(), this);
|
||||
#ifndef QT_NO_TSLIB
|
||||
const bool useTslib = qEnvironmentVariableIntValue("QT_QPA_FB_TSLIB");
|
||||
if (useTslib)
|
||||
|
|
|
|||
|
|
@ -55,10 +55,6 @@
|
|||
|
||||
#include <linux/fb.h>
|
||||
|
||||
#if !defined(QT_NO_EVDEV) && (!defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID_NO_SDK))
|
||||
#include <QtPlatformSupport/private/qdevicediscovery_p.h>
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
static int openFramebufferDevice(const QString &dev)
|
||||
|
|
@ -393,22 +389,7 @@ bool QLinuxFbScreen::initialize()
|
|||
QFbScreen::initializeCompositor();
|
||||
mFbScreenImage = QImage(mMmap.data, geometry.width(), geometry.height(), mBytesPerLine, mFormat);
|
||||
|
||||
QByteArray hideCursorVal = qgetenv("QT_QPA_FB_HIDECURSOR");
|
||||
#if !defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID_NO_SDK)
|
||||
bool hideCursor = false;
|
||||
#else
|
||||
bool hideCursor = true; // default to true to prevent the cursor showing up with the subclass on Android
|
||||
#endif
|
||||
if (hideCursorVal.isEmpty()) {
|
||||
#if !defined(QT_NO_EVDEV) && (!defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID_NO_SDK))
|
||||
QScopedPointer<QDeviceDiscovery> dis(QDeviceDiscovery::create(QDeviceDiscovery::Device_Mouse));
|
||||
hideCursor = dis->scanConnectedDevices().isEmpty();
|
||||
#endif
|
||||
} else {
|
||||
hideCursor = hideCursorVal.toInt() != 0;
|
||||
}
|
||||
if (!hideCursor)
|
||||
mCursor = new QFbCursor(this);
|
||||
mCursor = new QFbCursor(this);
|
||||
|
||||
mTtyFd = openTtyDevice(ttyDevice);
|
||||
if (mTtyFd == -1)
|
||||
|
|
|
|||
Loading…
Reference in New Issue