Changeset View
Changeset View
Standalone View
Standalone View
plugins/platforms/drm/drm_output.cpp
Show First 20 Lines • Show All 151 Lines • ▼ Show 20 Line(s) | |||||
152 | QMatrix4x4 DrmOutput::matrixDisplay(const QSize &s) const | 152 | QMatrix4x4 DrmOutput::matrixDisplay(const QSize &s) const | ||
153 | { | 153 | { | ||
154 | QMatrix4x4 matrix; | 154 | QMatrix4x4 matrix; | ||
155 | const int angle = transformToRotation(transform()); | 155 | const int angle = transformToRotation(transform()); | ||
156 | if (angle) { | 156 | if (angle) { | ||
157 | const QSize center = s / 2; | 157 | const QSize center = s / 2; | ||
158 | 158 | | |||
159 | matrix.translate(center.width(), center.height()); | 159 | matrix.translate(center.width(), center.height()); | ||
160 | matrix.rotate(angle, 0, 0, 1); | 160 | matrix.rotate(-angle, 0, 0, 1); | ||
161 | matrix.translate(-center.width(), -center.height()); | 161 | matrix.translate(-center.width(), -center.height()); | ||
162 | } | 162 | } | ||
163 | matrix.scale(scale()); | 163 | matrix.scale(scale()); | ||
164 | return matrix; | 164 | return matrix; | ||
165 | } | 165 | } | ||
166 | 166 | | |||
167 | void DrmOutput::updateCursor() | 167 | void DrmOutput::updateCursor() | ||
168 | { | 168 | { | ||
Show All 11 Lines | |||||
180 | p.drawImage(QPoint(0, 0), cursorImage); | 180 | p.drawImage(QPoint(0, 0), cursorImage); | ||
181 | p.end(); | 181 | p.end(); | ||
182 | } | 182 | } | ||
183 | 183 | | |||
184 | void DrmOutput::moveCursor(const QPoint &globalPos) | 184 | void DrmOutput::moveCursor(const QPoint &globalPos) | ||
185 | { | 185 | { | ||
186 | const QMatrix4x4 hotspotMatrix = matrixDisplay(m_backend->softwareCursor().size()); | 186 | const QMatrix4x4 hotspotMatrix = matrixDisplay(m_backend->softwareCursor().size()); | ||
187 | 187 | | |||
188 | QPoint p = globalPos - AbstractWaylandOutput::globalPos(); | 188 | const QPoint localPos = globalPos - AbstractWaylandOutput::globalPos(); | ||
189 | QPoint pos = localPos; | ||||
189 | 190 | | |||
190 | // TODO: Do we need to handle the flipped cases differently? | 191 | // TODO: Do we need to handle the flipped cases differently? | ||
191 | switch (transform()) { | 192 | switch (transform()) { | ||
192 | case Transform::Normal: | 193 | case Transform::Normal: | ||
193 | case Transform::Flipped: | 194 | case Transform::Flipped: | ||
194 | break; | 195 | break; | ||
195 | case Transform::Rotated90: | 196 | case Transform::Rotated90: | ||
196 | case Transform::Flipped90: | 197 | case Transform::Flipped90: | ||
197 | p = QPoint(p.y(), pixelSize().height() - p.x()); | 198 | pos = QPoint(localPos.y(), pixelSize().width() / scale() - localPos.x()); | ||
198 | break; | 199 | break; | ||
199 | case Transform::Rotated270: | 200 | case Transform::Rotated270: | ||
200 | case Transform::Flipped270: | 201 | case Transform::Flipped270: | ||
201 | p = QPoint(pixelSize().width() - p.y(), p.x()); | 202 | pos = QPoint(pixelSize().height() / scale() - localPos.y(), localPos.x()); | ||
202 | break; | 203 | break; | ||
203 | case Transform::Rotated180: | 204 | case Transform::Rotated180: | ||
204 | case Transform::Flipped180: | 205 | case Transform::Flipped180: | ||
205 | p = QPoint(pixelSize().width() - p.x(), pixelSize().height() - p.y()); | 206 | pos = QPoint(pixelSize().width() / scale() - localPos.x(), | ||
207 | pixelSize().height() / scale() - localPos.y()); | ||||
206 | break; | 208 | break; | ||
207 | default: | 209 | default: | ||
208 | Q_UNREACHABLE(); | 210 | Q_UNREACHABLE(); | ||
209 | } | 211 | } | ||
210 | p *= scale(); | 212 | pos *= scale(); | ||
211 | p -= hotspotMatrix.map(m_backend->softwareCursorHotspot()); | 213 | pos -= hotspotMatrix.map(m_backend->softwareCursorHotspot()); | ||
212 | drmModeMoveCursor(m_backend->fd(), m_crtc->id(), p.x(), p.y()); | 214 | drmModeMoveCursor(m_backend->fd(), m_crtc->id(), pos.x(), pos.y()); | ||
213 | } | 215 | } | ||
214 | 216 | | |||
215 | static QHash<int, QByteArray> s_connectorNames = { | 217 | static QHash<int, QByteArray> s_connectorNames = { | ||
216 | {DRM_MODE_CONNECTOR_Unknown, QByteArrayLiteral("Unknown")}, | 218 | {DRM_MODE_CONNECTOR_Unknown, QByteArrayLiteral("Unknown")}, | ||
217 | {DRM_MODE_CONNECTOR_VGA, QByteArrayLiteral("VGA")}, | 219 | {DRM_MODE_CONNECTOR_VGA, QByteArrayLiteral("VGA")}, | ||
218 | {DRM_MODE_CONNECTOR_DVII, QByteArrayLiteral("DVI-I")}, | 220 | {DRM_MODE_CONNECTOR_DVII, QByteArrayLiteral("DVI-I")}, | ||
219 | {DRM_MODE_CONNECTOR_DVID, QByteArrayLiteral("DVI-D")}, | 221 | {DRM_MODE_CONNECTOR_DVID, QByteArrayLiteral("DVI-D")}, | ||
220 | {DRM_MODE_CONNECTOR_DVIA, QByteArrayLiteral("DVI-A")}, | 222 | {DRM_MODE_CONNECTOR_DVIA, QByteArrayLiteral("DVI-A")}, | ||
▲ Show 20 Lines • Show All 918 Lines • Show Last 20 Lines |