| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/platformsupport/fbconvenience/qfbcursor.cpp | 
| Switch to Source code | Preprocessed file | 
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | - | |||||||||||||
| 3 | - | |||||||||||||
| 4 | bool QFbCursorDeviceListener::hasMouse() const | - | ||||||||||||
| 5 | { | - | ||||||||||||
| 6 |     return never executed:   QGuiApplicationPrivate::inputDeviceManager()->deviceCount(QInputDeviceManager::DeviceTypePointer) > 0;return QGuiApplicationPrivate::inputDeviceManager()->deviceCount(QInputDeviceManager::DeviceTypePointer) > 0;never executed:  return QGuiApplicationPrivate::inputDeviceManager()->deviceCount(QInputDeviceManager::DeviceTypePointer) > 0; | 0 | ||||||||||||
| 7 | } | - | ||||||||||||
| 8 | - | |||||||||||||
| 9 | void QFbCursorDeviceListener::onDeviceListChanged(QInputDeviceManager::DeviceType type) | - | ||||||||||||
| 10 | { | - | ||||||||||||
| 11 |     if (type == QInputDeviceManager::DeviceTypePointer
  | 0 | ||||||||||||
| 12 |         m_cursor->updateMouseStatus(); never executed:  m_cursor->updateMouseStatus(); | 0 | ||||||||||||
| 13 | } never executed:  end of block | 0 | ||||||||||||
| 14 | - | |||||||||||||
| 15 | QFbCursor::QFbCursor(QFbScreen *screen) | - | ||||||||||||
| 16 | : mVisible(true), | - | ||||||||||||
| 17 | mScreen(screen), | - | ||||||||||||
| 18 | mDirty(false), | - | ||||||||||||
| 19 | mOnScreen(false), | - | ||||||||||||
| 20 | mGraphic(0), | - | ||||||||||||
| 21 | mDeviceListener(0) | - | ||||||||||||
| 22 | { | - | ||||||||||||
| 23 | QByteArray hideCursorVal = qgetenv("QT_QPA_FB_HIDECURSOR"); | - | ||||||||||||
| 24 |     if (!hideCursorVal.isEmpty()
  | 0 | ||||||||||||
| 25 |         mVisible = hideCursorVal.toInt() == 0; never executed:  mVisible = hideCursorVal.toInt() == 0; | 0 | ||||||||||||
| 26 |     if (!mVisible
  | 0 | ||||||||||||
| 27 |         return; never executed:  return; | 0 | ||||||||||||
| 28 | - | |||||||||||||
| 29 | mGraphic = new QPlatformCursorImage(0, 0, 0, 0, 0, 0); | - | ||||||||||||
| 30 | setCursor(Qt::ArrowCursor); | - | ||||||||||||
| 31 | - | |||||||||||||
| 32 | mDeviceListener = new QFbCursorDeviceListener(this); | - | ||||||||||||
| 33 | connect(QGuiApplicationPrivate::inputDeviceManager(), &QInputDeviceManager::deviceListChanged, | - | ||||||||||||
| 34 | mDeviceListener, &QFbCursorDeviceListener::onDeviceListChanged); | - | ||||||||||||
| 35 | updateMouseStatus(); | - | ||||||||||||
| 36 | } never executed:  end of block | 0 | ||||||||||||
| 37 | - | |||||||||||||
| 38 | QFbCursor::~QFbCursor() | - | ||||||||||||
| 39 | { | - | ||||||||||||
| 40 | delete mDeviceListener; | - | ||||||||||||
| 41 | } never executed:  end of block | 0 | ||||||||||||
| 42 | - | |||||||||||||
| 43 | QRect QFbCursor::getCurrentRect() | - | ||||||||||||
| 44 | { | - | ||||||||||||
| 45 | QRect rect = mGraphic->image()->rect().translated(-mGraphic->hotspot().x(), | - | ||||||||||||
| 46 | -mGraphic->hotspot().y()); | - | ||||||||||||
| 47 | rect.translate(m_pos); | - | ||||||||||||
| 48 | QPoint mScreenOffset = mScreen->geometry().topLeft(); | - | ||||||||||||
| 49 | rect.translate(-mScreenOffset); | - | ||||||||||||
| 50 |     return never executed:   rect;return rect;never executed:  return rect; | 0 | ||||||||||||
| 51 | } | - | ||||||||||||
| 52 | - | |||||||||||||
| 53 | QPoint QFbCursor::pos() const | - | ||||||||||||
| 54 | { | - | ||||||||||||
| 55 |     return never executed:   m_pos;return m_pos;never executed:  return m_pos; | 0 | ||||||||||||
| 56 | } | - | ||||||||||||
| 57 | - | |||||||||||||
| 58 | void QFbCursor::setPos(const QPoint &pos) | - | ||||||||||||
| 59 | { | - | ||||||||||||
| 60 | QGuiApplicationPrivate::inputDeviceManager()->setCursorPos(pos); | - | ||||||||||||
| 61 | m_pos = pos; | - | ||||||||||||
| 62 | mCurrentRect = getCurrentRect(); | - | ||||||||||||
| 63 |     if (mOnScreen
 
  | 0 | ||||||||||||
| 64 |         setDirty(); never executed:  setDirty(); | 0 | ||||||||||||
| 65 | } never executed:  end of block | 0 | ||||||||||||
| 66 | - | |||||||||||||
| 67 | void QFbCursor::pointerEvent(const QMouseEvent &e) | - | ||||||||||||
| 68 | { | - | ||||||||||||
| 69 |     if (e.type() != QEvent::MouseMove
  | 0 | ||||||||||||
| 70 |         return; never executed:  return; | 0 | ||||||||||||
| 71 | m_pos = e.screenPos().toPoint(); | - | ||||||||||||
| 72 | mCurrentRect = getCurrentRect(); | - | ||||||||||||
| 73 |     if (mOnScreen
 
  | 0 | ||||||||||||
| 74 |         setDirty(); never executed:  setDirty(); | 0 | ||||||||||||
| 75 | } never executed:  end of block | 0 | ||||||||||||
| 76 | - | |||||||||||||
| 77 | QRect QFbCursor::drawCursor(QPainter & painter) | - | ||||||||||||
| 78 | { | - | ||||||||||||
| 79 |     if (!mVisible
  | 0 | ||||||||||||
| 80 |         return never executed:   QRect();return QRect();never executed:  return QRect(); | 0 | ||||||||||||
| 81 | - | |||||||||||||
| 82 | mDirty = false; | - | ||||||||||||
| 83 |     if (mCurrentRect.isNull()
  | 0 | ||||||||||||
| 84 |         return never executed:   QRect();return QRect();never executed:  return QRect(); | 0 | ||||||||||||
| 85 | - | |||||||||||||
| 86 | - | |||||||||||||
| 87 | QPoint mScreenOffset = mScreen->geometry().topLeft(); | - | ||||||||||||
| 88 | - | |||||||||||||
| 89 |     if (!mCurrentRect.translated(mScreenOffset).intersects(mScreen->geometry())
  | 0 | ||||||||||||
| 90 |         return never executed:   QRect();return QRect();never executed:  return QRect(); | 0 | ||||||||||||
| 91 | - | |||||||||||||
| 92 | mPrevRect = mCurrentRect; | - | ||||||||||||
| 93 | painter.drawImage(mPrevRect, *mGraphic->image()); | - | ||||||||||||
| 94 | mOnScreen = true; | - | ||||||||||||
| 95 |     return never executed:   mPrevRect;return mPrevRect;never executed:  return mPrevRect; | 0 | ||||||||||||
| 96 | } | - | ||||||||||||
| 97 | - | |||||||||||||
| 98 | QRect QFbCursor::dirtyRect() | - | ||||||||||||
| 99 | { | - | ||||||||||||
| 100 |     if (mOnScreen
  | 0 | ||||||||||||
| 101 | mOnScreen = false; | - | ||||||||||||
| 102 |         return never executed:   mPrevRect;return mPrevRect;never executed:  return mPrevRect; | 0 | ||||||||||||
| 103 | } | - | ||||||||||||
| 104 |     return never executed:   QRect();return QRect();never executed:  return QRect(); | 0 | ||||||||||||
| 105 | } | - | ||||||||||||
| 106 | - | |||||||||||||
| 107 | void QFbCursor::setCursor(Qt::CursorShape shape) | - | ||||||||||||
| 108 | { | - | ||||||||||||
| 109 | mGraphic->set(shape); | - | ||||||||||||
| 110 | } never executed:  end of block | 0 | ||||||||||||
| 111 | - | |||||||||||||
| 112 | void QFbCursor::setCursor(const QImage &image, int hotx, int hoty) | - | ||||||||||||
| 113 | { | - | ||||||||||||
| 114 | mGraphic->set(image, hotx, hoty); | - | ||||||||||||
| 115 | } never executed:  end of block | 0 | ||||||||||||
| 116 | - | |||||||||||||
| 117 | void QFbCursor::setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY) | - | ||||||||||||
| 118 | { | - | ||||||||||||
| 119 | mGraphic->set(data, mask, width, height, hotX, hotY); | - | ||||||||||||
| 120 | } never executed:  end of block | 0 | ||||||||||||
| 121 | - | |||||||||||||
| 122 | - | |||||||||||||
| 123 | void QFbCursor::changeCursor(QCursor * widgetCursor, QWindow *window) | - | ||||||||||||
| 124 | { | - | ||||||||||||
| 125 | (void)window;; | - | ||||||||||||
| 126 |     const Qt::CursorShape shape = widgetCursor
  | 0 | ||||||||||||
| 127 | - | |||||||||||||
| 128 |     if (shape == Qt::BitmapCursor
  | 0 | ||||||||||||
| 129 | - | |||||||||||||
| 130 | QPoint spot = widgetCursor->hotSpot(); | - | ||||||||||||
| 131 | setCursor(widgetCursor->pixmap().toImage(), spot.x(), spot.y()); | - | ||||||||||||
| 132 |     } never executed:   else {end of block | 0 | ||||||||||||
| 133 | - | |||||||||||||
| 134 | setCursor(shape); | - | ||||||||||||
| 135 |     } never executed:  end of block | 0 | ||||||||||||
| 136 | mCurrentRect = getCurrentRect(); | - | ||||||||||||
| 137 | QPoint mScreenOffset = mScreen->geometry().topLeft(); | - | ||||||||||||
| 138 |     if (mOnScreen
 
  | 0 | ||||||||||||
| 139 |         setDirty(); never executed:  setDirty(); | 0 | ||||||||||||
| 140 | } never executed:  end of block | 0 | ||||||||||||
| 141 | - | |||||||||||||
| 142 | - | |||||||||||||
| 143 | void QFbCursor::setDirty() | - | ||||||||||||
| 144 | { | - | ||||||||||||
| 145 |     if (!mVisible
  | 0 | ||||||||||||
| 146 |         return; never executed:  return; | 0 | ||||||||||||
| 147 | - | |||||||||||||
| 148 |     if (!mDirty
  | 0 | ||||||||||||
| 149 | mDirty = true; | - | ||||||||||||
| 150 | mScreen->scheduleUpdate(); | - | ||||||||||||
| 151 |     } never executed:  end of block | 0 | ||||||||||||
| 152 | } never executed:  end of block | 0 | ||||||||||||
| 153 | - | |||||||||||||
| 154 | void QFbCursor::updateMouseStatus() | - | ||||||||||||
| 155 | { | - | ||||||||||||
| 156 | mVisible = mDeviceListener->hasMouse(); | - | ||||||||||||
| 157 | mScreen->setDirty(mVisible ? getCurrentRect() : lastPainted()); | - | ||||||||||||
| 158 | } never executed:  end of block | 0 | ||||||||||||
| 159 | - | |||||||||||||
| 160 | - | |||||||||||||
| Switch to Source code | Preprocessed file |