linuxfb: Add support for QCursor::setPos()

Task-number: QTBUG-44856
Change-Id: I102137b3ccdfbea23eb470c38a47c807572d232d
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Reviewed-by: Andy Nichols <andy.nichols@theqtcompany.com>
This commit is contained in:
Laszlo Agocs 2015-03-10 15:21:48 +01:00
parent 3bf655e596
commit dc6d353a29
2 changed files with 25 additions and 10 deletions

View File

@ -81,22 +81,34 @@ QRect QFbCursor::getCurrentRect()
{
QRect rect = mGraphic->image()->rect().translated(-mGraphic->hotspot().x(),
-mGraphic->hotspot().y());
rect.translate(QCursor::pos());
rect.translate(m_pos);
QPoint mScreenOffset = mScreen->geometry().topLeft();
rect.translate(-mScreenOffset); // global to local translation
return rect;
}
void QFbCursor::pointerEvent(const QMouseEvent & e)
QPoint QFbCursor::pos() const
{
Q_UNUSED(e);
QPoint mScreenOffset = mScreen->geometry().topLeft();
return m_pos;
}
void QFbCursor::setPos(const QPoint &pos)
{
QGuiApplicationPrivate::inputDeviceManager()->setCursorPos(pos);
m_pos = pos;
mCurrentRect = getCurrentRect();
// global to local translation
if (mOnScreen || mScreen->geometry().intersects(mCurrentRect.translated(mScreenOffset))) {
if (mOnScreen || mScreen->geometry().intersects(mCurrentRect.translated(mScreen->geometry().topLeft())))
setDirty();
}
void QFbCursor::pointerEvent(const QMouseEvent &e)
{
if (e.type() != QEvent::MouseMove)
return;
m_pos = e.screenPos().toPoint();
mCurrentRect = getCurrentRect();
if (mOnScreen || mScreen->geometry().intersects(mCurrentRect.translated(mScreen->geometry().topLeft())))
setDirty();
}
}
QRect QFbCursor::drawCursor(QPainter & painter)

View File

@ -81,9 +81,11 @@ public:
virtual QRect drawCursor(QPainter &painter);
// input methods
virtual void pointerEvent(const QMouseEvent &event) Q_DECL_OVERRIDE;
void pointerEvent(const QMouseEvent &event) Q_DECL_OVERRIDE;
QPoint pos() const Q_DECL_OVERRIDE;
void setPos(const QPoint &pos) Q_DECL_OVERRIDE;
#ifndef QT_NO_CURSOR
virtual void changeCursor(QCursor *widgetCursor, QWindow *window) Q_DECL_OVERRIDE;
void changeCursor(QCursor *widgetCursor, QWindow *window) Q_DECL_OVERRIDE;
#endif
virtual void setDirty();
@ -107,6 +109,7 @@ private:
bool mOnScreen;
QPlatformCursorImage *mGraphic;
QFbCursorDeviceListener *mDeviceListener;
QPoint m_pos;
};
QT_END_NAMESPACE