summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/wayland
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.p.agocs@nokia.com>2012-06-18 16:53:07 +0300
committerLaszlo Agocs <laszlo.p.agocs@nokia.com>2012-06-19 07:43:35 +0200
commit46ff754410d4747c1a1b72f9e9d519645aebbe6a (patch)
tree4dae8bf812b9370a6688ae8b2a89f50ecee40929 /src/plugins/platforms/wayland
parentdeecb4b8544bfc17bbc42f22709969ed70448bb4 (diff)
Follow protocol changes in pointer attach
Change-Id: I68b480b7feea814f79997c6a39e4567c3a990f47 Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'src/plugins/platforms/wayland')
-rw-r--r--src/plugins/platforms/wayland/qwaylandcursor.cpp43
-rw-r--r--src/plugins/platforms/wayland/qwaylandcursor.h5
-rw-r--r--src/plugins/platforms/wayland/qwaylanddisplay.h2
-rw-r--r--src/plugins/platforms/wayland/qwaylandinputdevice.cpp4
-rw-r--r--src/plugins/platforms/wayland/qwaylandinputdevice.h2
5 files changed, 38 insertions, 18 deletions
diff --git a/src/plugins/platforms/wayland/qwaylandcursor.cpp b/src/plugins/platforms/wayland/qwaylandcursor.cpp
index 560ec4ef4..7c6e8cae2 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 ef37050d9..1c9855876 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 1c6c41187..a24b9074a 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 4dc202240..e04ba3e44 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 9e51b6380..8ea73b833 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);