From: Laszlo Agocs Date: Mon, 18 Jun 2012 13:53:07 +0000 (+0300) Subject: Follow protocol changes in pointer attach X-Git-Tag: 071012132158~17 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=46ff754410d4747c1a1b72f9e9d519645aebbe6a;p=profile%2Fivi%2Fqtwayland.git Follow protocol changes in pointer attach Change-Id: I68b480b7feea814f79997c6a39e4567c3a990f47 Reviewed-by: Samuel Rødal --- diff --git a/src/plugins/platforms/wayland/qwaylandcursor.cpp b/src/plugins/platforms/wayland/qwaylandcursor.cpp index 560ec4e..7c6e8ca 100644 --- a/src/plugins/platforms/wayland/qwaylandcursor.cpp +++ b/src/plugins/platforms/wayland/qwaylandcursor.cpp @@ -105,9 +105,32 @@ static const struct pointer_image { QWaylandCursor::QWaylandCursor(QWaylandScreen *screen) : mBuffer(0) , mDisplay(screen->display()) + , mSurface(0) { } +QWaylandCursor::~QWaylandCursor() +{ + if (mSurface) + wl_surface_destroy(mSurface); + + delete mBuffer; +} + +void QWaylandCursor::ensureSurface(const QSize &size) +{ + if (!mBuffer || mBuffer->size() != size) { + delete mBuffer; + mBuffer = new QWaylandShmBuffer(mDisplay, size, + QImage::Format_ARGB32); + } + + if (!mSurface) + mSurface = mDisplay->createSurface(0); + + wl_surface_attach(mSurface, mBuffer->buffer(), 0, 0); +} + void QWaylandCursor::changeCursor(QCursor *cursor, QWindow *window) { const struct pointer_image *p; @@ -174,13 +197,9 @@ void QWaylandCursor::changeCursor(QCursor *cursor, QWindow *window) QImageReader reader(p->filename); if (!reader.canRead()) return; - if (mBuffer == NULL || mBuffer->size() != reader.size()) { - delete mBuffer; - mBuffer = new QWaylandShmBuffer(mDisplay, reader.size(), - QImage::Format_ARGB32); - } + ensureSurface(reader.size()); reader.read(mBuffer->image()); - mDisplay->setCursor(mBuffer, p->hotspot_x, p->hotspot_y); + mDisplay->setCursor(mSurface, p->hotspot_x, p->hotspot_y); } } @@ -191,24 +210,20 @@ void QWaylandCursor::setupPixmapCursor(QCursor *cursor) mBuffer = 0; return; } - if (!mBuffer || mBuffer->size() != cursor->pixmap().size()) { - delete mBuffer; - mBuffer = new QWaylandShmBuffer(mDisplay, cursor->pixmap().size(), - QImage::Format_ARGB32); - } + ensureSurface(cursor->pixmap().size()); QImage src = cursor->pixmap().toImage().convertToFormat(QImage::Format_ARGB32); for (int y = 0; y < src.height(); ++y) qMemCopy(mBuffer->image()->scanLine(y), src.scanLine(y), src.bytesPerLine()); - mDisplay->setCursor(mBuffer, cursor->hotSpot().x(), cursor->hotSpot().y()); + mDisplay->setCursor(mSurface, cursor->hotSpot().x(), cursor->hotSpot().y()); } -void QWaylandDisplay::setCursor(QWaylandBuffer *buffer, int32_t x, int32_t y) +void QWaylandDisplay::setCursor(wl_surface *surface, int32_t x, int32_t y) { /* 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->attach(buffer, x, y); + inputDevice->setCursor(surface, x, y); } } diff --git a/src/plugins/platforms/wayland/qwaylandcursor.h b/src/plugins/platforms/wayland/qwaylandcursor.h index ef37050..1c98558 100644 --- a/src/plugins/platforms/wayland/qwaylandcursor.h +++ b/src/plugins/platforms/wayland/qwaylandcursor.h @@ -47,11 +47,13 @@ class QWaylandShmBuffer; class QWaylandDisplay; class QWaylandScreen; +struct wl_surface; class QWaylandCursor : public QPlatformCursor { public: QWaylandCursor(QWaylandScreen *screen); + ~QWaylandCursor(); void changeCursor(QCursor *cursor, QWindow *window); void pointerEvent(const QMouseEvent &event); @@ -62,8 +64,11 @@ public: QWaylandShmBuffer *mBuffer; QWaylandDisplay *mDisplay; + wl_surface *mSurface; private: + void ensureSurface(const QSize &size); + QPoint mLastPos; }; diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.h b/src/plugins/platforms/wayland/qwaylanddisplay.h index 1c6c411..a24b907 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.h +++ b/src/plugins/platforms/wayland/qwaylanddisplay.h @@ -86,7 +86,7 @@ public: QWaylandWindowManagerIntegration *windowManagerIntegration(); #endif - void setCursor(QWaylandBuffer *buffer, int32_t x, int32_t y); + void setCursor(wl_surface *surface, int32_t x, int32_t y); struct wl_display *wl_display() const { return mDisplay; } struct wl_compositor *wl_compositor() const { return mCompositor; } diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp index 4dc2022..e04ba3e 100644 --- a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp +++ b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp @@ -198,10 +198,10 @@ void QWaylandInputDevice::removeMouseButtonFromState(Qt::MouseButton button) mButtons = mButtons & !button; } -void QWaylandInputDevice::attach(QWaylandBuffer *buffer, int x, int y) +void QWaylandInputDevice::setCursor(wl_surface *surface, int x, int y) { if (mCaps & WL_SEAT_CAPABILITY_POINTER) - wl_pointer_attach(mDeviceInterfaces.pointer, mTime, buffer->buffer(), x, y); + wl_pointer_set_cursor(mDeviceInterfaces.pointer, mTime, surface, x, y); } void QWaylandInputDevice::pointer_enter(void *data, diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice.h b/src/plugins/platforms/wayland/qwaylandinputdevice.h index 9e51b63..8ea73b8 100644 --- a/src/plugins/platforms/wayland/qwaylandinputdevice.h +++ b/src/plugins/platforms/wayland/qwaylandinputdevice.h @@ -72,7 +72,7 @@ public: struct wl_seat *wl_seat() const { return mSeat; } - void attach(QWaylandBuffer *buffer, int x, int y); + void setCursor(wl_surface *surface, int x, int y); void handleWindowDestroyed(QWaylandWindow *window); void setTransferDevice(struct wl_data_device *device); diff --git a/wayland_sha1.txt b/wayland_sha1.txt index 1880621..24bcbc9 100644 --- a/wayland_sha1.txt +++ b/wayland_sha1.txt @@ -1,3 +1,3 @@ This version of Qt-Compositor is checked against the following sha1 from the Wayland repository: -dff84e563896566e952f8a6704eadb8c09f27830 +b576443a0eb848085d0fcdf2b2d2987bcfb58a7f