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:
parent
3bf655e596
commit
dc6d353a29
@ -81,22 +81,34 @@ QRect QFbCursor::getCurrentRect()
|
|||||||
{
|
{
|
||||||
QRect rect = mGraphic->image()->rect().translated(-mGraphic->hotspot().x(),
|
QRect rect = mGraphic->image()->rect().translated(-mGraphic->hotspot().x(),
|
||||||
-mGraphic->hotspot().y());
|
-mGraphic->hotspot().y());
|
||||||
rect.translate(QCursor::pos());
|
rect.translate(m_pos);
|
||||||
QPoint mScreenOffset = mScreen->geometry().topLeft();
|
QPoint mScreenOffset = mScreen->geometry().topLeft();
|
||||||
rect.translate(-mScreenOffset); // global to local translation
|
rect.translate(-mScreenOffset); // global to local translation
|
||||||
return rect;
|
return rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QPoint QFbCursor::pos() const
|
||||||
void QFbCursor::pointerEvent(const QMouseEvent & e)
|
|
||||||
{
|
{
|
||||||
Q_UNUSED(e);
|
return m_pos;
|
||||||
QPoint mScreenOffset = mScreen->geometry().topLeft();
|
}
|
||||||
|
|
||||||
|
void QFbCursor::setPos(const QPoint &pos)
|
||||||
|
{
|
||||||
|
QGuiApplicationPrivate::inputDeviceManager()->setCursorPos(pos);
|
||||||
|
m_pos = pos;
|
||||||
mCurrentRect = getCurrentRect();
|
mCurrentRect = getCurrentRect();
|
||||||
// global to local translation
|
if (mOnScreen || mScreen->geometry().intersects(mCurrentRect.translated(mScreen->geometry().topLeft())))
|
||||||
if (mOnScreen || mScreen->geometry().intersects(mCurrentRect.translated(mScreenOffset))) {
|
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();
|
setDirty();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect QFbCursor::drawCursor(QPainter & painter)
|
QRect QFbCursor::drawCursor(QPainter & painter)
|
||||||
|
@ -81,9 +81,11 @@ public:
|
|||||||
virtual QRect drawCursor(QPainter &painter);
|
virtual QRect drawCursor(QPainter &painter);
|
||||||
|
|
||||||
// input methods
|
// 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
|
#ifndef QT_NO_CURSOR
|
||||||
virtual void changeCursor(QCursor *widgetCursor, QWindow *window) Q_DECL_OVERRIDE;
|
void changeCursor(QCursor *widgetCursor, QWindow *window) Q_DECL_OVERRIDE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
virtual void setDirty();
|
virtual void setDirty();
|
||||||
@ -107,6 +109,7 @@ private:
|
|||||||
bool mOnScreen;
|
bool mOnScreen;
|
||||||
QPlatformCursorImage *mGraphic;
|
QPlatformCursorImage *mGraphic;
|
||||||
QFbCursorDeviceListener *mDeviceListener;
|
QFbCursorDeviceListener *mDeviceListener;
|
||||||
|
QPoint m_pos;
|
||||||
};
|
};
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user