Changeset View
Changeset View
Standalone View
Standalone View
plugins/platforms/drm/drm_output.cpp
Show All 18 Lines | |||||
19 | *********************************************************************/ | 19 | *********************************************************************/ | ||
20 | #include "drm_output.h" | 20 | #include "drm_output.h" | ||
21 | #include "drm_backend.h" | 21 | #include "drm_backend.h" | ||
22 | #include "drm_object_plane.h" | 22 | #include "drm_object_plane.h" | ||
23 | #include "drm_object_crtc.h" | 23 | #include "drm_object_crtc.h" | ||
24 | #include "drm_object_connector.h" | 24 | #include "drm_object_connector.h" | ||
25 | 25 | | |||
26 | #include "composite.h" | 26 | #include "composite.h" | ||
27 | #include "cursor.h" | ||||
27 | #include "logind.h" | 28 | #include "logind.h" | ||
28 | #include "logging.h" | 29 | #include "logging.h" | ||
29 | #include "main.h" | 30 | #include "main.h" | ||
30 | #include "screens_drm.h" | 31 | #include "screens_drm.h" | ||
31 | #include "wayland_server.h" | 32 | #include "wayland_server.h" | ||
32 | // KWayland | 33 | // KWayland | ||
33 | #include <KWayland/Server/output_interface.h> | 34 | #include <KWayland/Server/output_interface.h> | ||
34 | // KF5 | 35 | // KF5 | ||
▲ Show 20 Lines • Show All 125 Lines • ▼ Show 20 Line(s) | 156 | if (angle) { | |||
160 | matrix.translate(-center.width(), -center.height()); | 161 | matrix.translate(-center.width(), -center.height()); | ||
161 | } | 162 | } | ||
162 | matrix.scale(scale()); | 163 | matrix.scale(scale()); | ||
163 | return matrix; | 164 | return matrix; | ||
164 | } | 165 | } | ||
165 | 166 | | |||
166 | void DrmOutput::updateCursor() | 167 | void DrmOutput::updateCursor() | ||
167 | { | 168 | { | ||
168 | QImage cursorImage = m_backend->softwareCursor(); | 169 | QImage cursorImage = Cursors::self()->currentCursor()->image(); | ||
169 | if (cursorImage.isNull()) { | 170 | if (cursorImage.isNull()) { | ||
170 | return; | 171 | return; | ||
171 | } | 172 | } | ||
172 | m_hasNewCursor = true; | 173 | m_hasNewCursor = true; | ||
173 | QImage *c = m_cursor[m_cursorIndex]->image(); | 174 | QImage *c = m_cursor[m_cursorIndex]->image(); | ||
174 | c->fill(Qt::transparent); | 175 | c->fill(Qt::transparent); | ||
175 | 176 | | |||
176 | QPainter p; | 177 | QPainter p; | ||
177 | p.begin(c); | 178 | p.begin(c); | ||
178 | p.setWorldTransform(matrixDisplay(QSize(cursorImage.width(), cursorImage.height())).toTransform()); | 179 | p.setWorldTransform(matrixDisplay(QSize(cursorImage.width(), cursorImage.height())).toTransform()); | ||
179 | p.drawImage(QPoint(0, 0), cursorImage); | 180 | p.drawImage(QPoint(0, 0), cursorImage); | ||
180 | p.end(); | 181 | p.end(); | ||
181 | } | 182 | } | ||
182 | 183 | | |||
183 | void DrmOutput::moveCursor(const QPoint &globalPos) | 184 | void DrmOutput::moveCursor(Cursor* cursor, const QPoint &globalPos) | ||
184 | { | 185 | { | ||
185 | const QMatrix4x4 hotspotMatrix = matrixDisplay(m_backend->softwareCursor().size()); | 186 | const QMatrix4x4 hotspotMatrix = matrixDisplay(cursor->image().size()); | ||
186 | 187 | | |||
187 | const QPoint localPos = globalPos - AbstractWaylandOutput::globalPos(); | 188 | const QPoint localPos = globalPos - AbstractWaylandOutput::globalPos(); | ||
188 | QPoint pos = localPos; | 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: | ||
Show All 10 Lines | |||||
204 | case Transform::Flipped180: | 205 | case Transform::Flipped180: | ||
205 | pos = QPoint(pixelSize().width() / scale() - localPos.x(), | 206 | pos = QPoint(pixelSize().width() / scale() - localPos.x(), | ||
206 | pixelSize().height() / scale() - localPos.y()); | 207 | pixelSize().height() / scale() - localPos.y()); | ||
207 | break; | 208 | break; | ||
208 | default: | 209 | default: | ||
209 | Q_UNREACHABLE(); | 210 | Q_UNREACHABLE(); | ||
210 | } | 211 | } | ||
211 | pos *= scale(); | 212 | pos *= scale(); | ||
212 | pos -= hotspotMatrix.map(m_backend->softwareCursorHotspot()); | 213 | pos -= hotspotMatrix.map(cursor->hotspot()); | ||
213 | drmModeMoveCursor(m_backend->fd(), m_crtc->id(), pos.x(), pos.y()); | 214 | drmModeMoveCursor(m_backend->fd(), m_crtc->id(), pos.x(), pos.y()); | ||
214 | } | 215 | } | ||
215 | 216 | | |||
216 | static QHash<int, QByteArray> s_connectorNames = { | 217 | static QHash<int, QByteArray> s_connectorNames = { | ||
217 | {DRM_MODE_CONNECTOR_Unknown, QByteArrayLiteral("Unknown")}, | 218 | {DRM_MODE_CONNECTOR_Unknown, QByteArrayLiteral("Unknown")}, | ||
218 | {DRM_MODE_CONNECTOR_VGA, QByteArrayLiteral("VGA")}, | 219 | {DRM_MODE_CONNECTOR_VGA, QByteArrayLiteral("VGA")}, | ||
219 | {DRM_MODE_CONNECTOR_DVII, QByteArrayLiteral("DVI-I")}, | 220 | {DRM_MODE_CONNECTOR_DVII, QByteArrayLiteral("DVI-I")}, | ||
220 | {DRM_MODE_CONNECTOR_DVID, QByteArrayLiteral("DVI-D")}, | 221 | {DRM_MODE_CONNECTOR_DVID, QByteArrayLiteral("DVI-D")}, | ||
▲ Show 20 Lines • Show All 870 Lines • Show Last 20 Lines |