Clean up QFbCursor
Task-number: QTBUG-56306 Change-Id: If0cccbf20d4956c19622651864f42f854247b54b Reviewed-by: Andy Nichols <andy.nichols@qt.io>
This commit is contained in:
parent
daf5d3cf13
commit
e6dd52f836
@ -60,8 +60,8 @@ QFbCursor::QFbCursor(QFbScreen *screen)
|
|||||||
mScreen(screen),
|
mScreen(screen),
|
||||||
mDirty(false),
|
mDirty(false),
|
||||||
mOnScreen(false),
|
mOnScreen(false),
|
||||||
mGraphic(0),
|
mCursorImage(nullptr),
|
||||||
mDeviceListener(0)
|
mDeviceListener(nullptr)
|
||||||
{
|
{
|
||||||
QByteArray hideCursorVal = qgetenv("QT_QPA_FB_HIDECURSOR");
|
QByteArray hideCursorVal = qgetenv("QT_QPA_FB_HIDECURSOR");
|
||||||
if (!hideCursorVal.isEmpty())
|
if (!hideCursorVal.isEmpty())
|
||||||
@ -69,7 +69,7 @@ QFbCursor::QFbCursor(QFbScreen *screen)
|
|||||||
if (!mVisible)
|
if (!mVisible)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mGraphic = new QPlatformCursorImage(0, 0, 0, 0, 0, 0);
|
mCursorImage = new QPlatformCursorImage(0, 0, 0, 0, 0, 0);
|
||||||
setCursor(Qt::ArrowCursor);
|
setCursor(Qt::ArrowCursor);
|
||||||
|
|
||||||
mDeviceListener = new QFbCursorDeviceListener(this);
|
mDeviceListener = new QFbCursorDeviceListener(this);
|
||||||
@ -85,8 +85,8 @@ QFbCursor::~QFbCursor()
|
|||||||
|
|
||||||
QRect QFbCursor::getCurrentRect()
|
QRect QFbCursor::getCurrentRect()
|
||||||
{
|
{
|
||||||
QRect rect = mGraphic->image()->rect().translated(-mGraphic->hotspot().x(),
|
QRect rect = mCursorImage->image()->rect().translated(-mCursorImage->hotspot().x(),
|
||||||
-mGraphic->hotspot().y());
|
-mCursorImage->hotspot().y());
|
||||||
rect.translate(m_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
|
||||||
@ -133,7 +133,7 @@ QRect QFbCursor::drawCursor(QPainter & painter)
|
|||||||
return QRect();
|
return QRect();
|
||||||
|
|
||||||
mPrevRect = mCurrentRect;
|
mPrevRect = mCurrentRect;
|
||||||
painter.drawImage(mPrevRect, *mGraphic->image());
|
painter.drawImage(mPrevRect, *mCursorImage->image());
|
||||||
mOnScreen = true;
|
mOnScreen = true;
|
||||||
return mPrevRect;
|
return mPrevRect;
|
||||||
}
|
}
|
||||||
@ -149,17 +149,17 @@ QRect QFbCursor::dirtyRect()
|
|||||||
|
|
||||||
void QFbCursor::setCursor(Qt::CursorShape shape)
|
void QFbCursor::setCursor(Qt::CursorShape shape)
|
||||||
{
|
{
|
||||||
mGraphic->set(shape);
|
mCursorImage->set(shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QFbCursor::setCursor(const QImage &image, int hotx, int hoty)
|
void QFbCursor::setCursor(const QImage &image, int hotx, int hoty)
|
||||||
{
|
{
|
||||||
mGraphic->set(image, hotx, hoty);
|
mCursorImage->set(image, hotx, hoty);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QFbCursor::setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY)
|
void QFbCursor::setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY)
|
||||||
{
|
{
|
||||||
mGraphic->set(data, mask, width, height, hotX, hotY);
|
mCursorImage->set(data, mask, width, height, hotX, hotY);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef QT_NO_CURSOR
|
#ifndef QT_NO_CURSOR
|
||||||
|
@ -87,11 +87,11 @@ public:
|
|||||||
virtual QRect drawCursor(QPainter &painter);
|
virtual QRect drawCursor(QPainter &painter);
|
||||||
|
|
||||||
// input methods
|
// input methods
|
||||||
void pointerEvent(const QMouseEvent &event) Q_DECL_OVERRIDE;
|
void pointerEvent(const QMouseEvent &event) override;
|
||||||
QPoint pos() const Q_DECL_OVERRIDE;
|
QPoint pos() const override;
|
||||||
void setPos(const QPoint &pos) Q_DECL_OVERRIDE;
|
void setPos(const QPoint &pos) override;
|
||||||
#ifndef QT_NO_CURSOR
|
#ifndef QT_NO_CURSOR
|
||||||
void changeCursor(QCursor *widgetCursor, QWindow *window) Q_DECL_OVERRIDE;
|
void changeCursor(QCursor *widgetCursor, QWindow *window) override;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
virtual void setDirty();
|
virtual void setDirty();
|
||||||
@ -113,7 +113,7 @@ private:
|
|||||||
QRect mPrevRect; // last place the cursor was drawn
|
QRect mPrevRect; // last place the cursor was drawn
|
||||||
bool mDirty;
|
bool mDirty;
|
||||||
bool mOnScreen;
|
bool mOnScreen;
|
||||||
QPlatformCursorImage *mGraphic;
|
QPlatformCursorImage *mCursorImage;
|
||||||
QFbCursorDeviceListener *mDeviceListener;
|
QFbCursorDeviceListener *mDeviceListener;
|
||||||
QPoint m_pos;
|
QPoint m_pos;
|
||||||
};
|
};
|
||||||
@ -121,4 +121,3 @@ private:
|
|||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
#endif // QFBCURSOR_P_H
|
#endif // QFBCURSOR_P_H
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user