summaryrefslogtreecommitdiffstats
path: root/src/client/qwaylandcursor.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2016-03-22 19:05:17 +0100
committerLiang Qi <liang.qi@theqtcompany.com>2016-03-22 19:05:17 +0100
commit573fbed837e2b7281c7a828cdcda141fbbcac030 (patch)
tree8535b043edd0a06c4b01f63bbfb0ae0953cff9df /src/client/qwaylandcursor.cpp
parent6341bf99c981aa3cfbb01589e499aa4b3f6dca21 (diff)
parent3fcb77996b3e6c076d50db9ccf9da3aefd24f159 (diff)
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts: src/compositor/compositor_api/qwaylandcompositor.h src/compositor/compositor_api/qwaylandquickcompositor.h src/compositor/compositor_api/qwaylandsurfaceitem.h src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration_p.h Change-Id: I094128be314d2c3d4fe350fa7a162e37da34ae10
Diffstat (limited to 'src/client/qwaylandcursor.cpp')
-rw-r--r--src/client/qwaylandcursor.cpp29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/client/qwaylandcursor.cpp b/src/client/qwaylandcursor.cpp
index f96b5c1e1..e3e3469be 100644
--- a/src/client/qwaylandcursor.cpp
+++ b/src/client/qwaylandcursor.cpp
@@ -91,7 +91,8 @@ struct wl_cursor_image *QWaylandCursor::cursorImage(Qt::CursorShape newShape)
if (newShape < Qt::BitmapCursor) {
waylandCursor = requestCursor((WaylandCursor)newShape);
} else if (newShape == Qt::BitmapCursor) {
- //TODO: Bitmap cursor logic
+ // cannot create a wl_cursor_image for a CursorShape
+ return Q_NULLPTR;
} else {
//TODO: Custom cursor logic (for resize arrows)
}
@@ -111,12 +112,28 @@ struct wl_cursor_image *QWaylandCursor::cursorImage(Qt::CursorShape newShape)
return image;
}
+QSharedPointer<QWaylandBuffer> QWaylandCursor::cursorBitmapImage(const QCursor *cursor)
+{
+ if (cursor->shape() != Qt::BitmapCursor)
+ return QSharedPointer<QWaylandShmBuffer>();
+
+ const QImage &img = cursor->pixmap().toImage();
+ QSharedPointer<QWaylandShmBuffer> buffer(new QWaylandShmBuffer(mDisplay, img.size(), img.format()));
+ memcpy(buffer->image()->bits(), img.bits(), img.byteCount());
+ return buffer;
+}
+
void QWaylandCursor::changeCursor(QCursor *cursor, QWindow *window)
{
Q_UNUSED(window)
const Qt::CursorShape newShape = cursor ? cursor->shape() : Qt::ArrowCursor;
+ if (newShape == Qt::BitmapCursor) {
+ mDisplay->setCursor(cursorBitmapImage(cursor), cursor->hotSpot());
+ return;
+ }
+
struct wl_cursor_image *image = cursorImage(newShape);
if (!image) {
return;
@@ -136,6 +153,16 @@ void QWaylandDisplay::setCursor(struct wl_buffer *buffer, struct wl_cursor_image
}
}
+void QWaylandDisplay::setCursor(const QSharedPointer<QWaylandBuffer> &buffer, const QPoint &hotSpot)
+{
+ /* Qt doesn't tell us which input device we should set the cursor
+ * for, so set it for all devices. */
+ for (int i = 0; i < mInputDevices.count(); i++) {
+ QWaylandInputDevice *inputDevice = mInputDevices.at(i);
+ inputDevice->setCursor(buffer, hotSpot);
+ }
+}
+
QWaylandInputDevice *QWaylandDisplay::defaultInputDevice() const
{
return mInputDevices.isEmpty() ? 0 : mInputDevices.first();