linuxfb: Make the mouse cursor visible and working

Change-Id: I58bae7235ae714da551da1337ee6340fc712aaa5
Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
This commit is contained in:
Laszlo Agocs 2013-10-11 14:42:14 +02:00 committed by The Qt Project
parent a662d42125
commit 4ba1072f3f
5 changed files with 41 additions and 11 deletions

View File

@ -137,5 +137,12 @@ void QFbCursor::changeCursor(QCursor * widgetCursor, QWindow *window)
}
#endif
QT_END_NAMESPACE
void QFbCursor::setDirty()
{
if (!mDirty) {
mDirty = true;
mScreen->scheduleUpdate();
}
}
QT_END_NAMESPACE

View File

@ -63,7 +63,7 @@ public:
virtual void changeCursor(QCursor *widgetCursor, QWindow *window);
#endif
virtual void setDirty() { mDirty = true; /* screen->setDirty(QRect()); */ }
virtual void setDirty();
virtual bool isDirty() const { return mDirty; }
virtual bool isOnScreen() const { return mOnScreen; }
virtual QRect lastPainted() const { return mPrevRect; }

View File

@ -149,9 +149,13 @@ void QFbScreen::setDirty(const QRect &rect)
QRect intersection = rect.intersected(mGeometry);
QPoint screenOffset = mGeometry.topLeft();
mRepaintRegion += intersection.translated(-screenOffset); // global to local translation
if (!mRedrawTimer.isActive()) {
scheduleUpdate();
}
void QFbScreen::scheduleUpdate()
{
if (!mRedrawTimer.isActive())
mRedrawTimer.start();
}
}
void QFbScreen::setPhysicalSize(const QSize &size)

View File

@ -45,6 +45,7 @@
#include <qpa/qplatformscreen.h>
#include <QtCore/QTimer>
#include <QtCore/QSize>
#include "qfbcursor_p.h"
QT_BEGIN_NAMESPACE
@ -60,13 +61,14 @@ public:
QFbScreen();
~QFbScreen();
virtual QRect geometry() const { return mGeometry; }
virtual int depth() const { return mDepth; }
virtual QImage::Format format() const { return mFormat; }
virtual QSizeF physicalSize() const { return mPhysicalSize; }
QRect geometry() const Q_DECL_OVERRIDE { return mGeometry; }
int depth() const Q_DECL_OVERRIDE { return mDepth; }
QImage::Format format() const Q_DECL_OVERRIDE { return mFormat; }
QSizeF physicalSize() const Q_DECL_OVERRIDE { return mPhysicalSize; }
QPlatformCursor *cursor() const Q_DECL_OVERRIDE { return mCursor; }
QWindow *topWindow() const;
virtual QWindow *topLevelAt(const QPoint & p) const;
QWindow *topLevelAt(const QPoint & p) const Q_DECL_OVERRIDE;
// compositor api
virtual void addWindow(QFbWindow *window);
@ -77,6 +79,8 @@ public:
void addBackingStore(QFbBackingStore *bs) {mBackingStores << bs;}
void scheduleUpdate();
public slots:
virtual void setDirty(const QRect &rect);
void setPhysicalSize(const QSize &size);
@ -114,4 +118,3 @@ private:
QT_END_NAMESPACE
#endif // QFBSCREEN_P_H

View File

@ -62,6 +62,10 @@
#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)
@ -394,7 +398,19 @@ bool QLinuxFbScreen::initialize(const QStringList &args)
QFbScreen::initializeCompositor();
mFbScreenImage = QImage(mMmap.data, geometry.width(), geometry.height(), mBytesPerLine, mFormat);
mCursor = new QFbCursor(this);
QByteArray hideCursorVal = qgetenv("QT_QPA_FB_HIDECURSOR");
bool hideCursor = true; // default to true to prevent the cursor showing up with the subclass on Android
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);
mTtyFd = openTtyDevice(ttyDevice);
if (mTtyFd == -1)