diff options
author | Jørgen Lind <jorgen.lind@nokia.com> | 2012-01-10 08:06:45 +0100 |
---|---|---|
committer | Samuel Rødal <samuel.rodal@nokia.com> | 2012-01-10 15:55:40 +0100 |
commit | bdabd7cc79709c8fb9c2c0187c5d6ac11ae85c5b (patch) | |
tree | 009875381a6f958f8e27f1c3d55a63e45f53d528 /src/compositor/wayland_wrapper/wlsurface.cpp | |
parent | e35d1a00541f3f2a1ed692a910b86f9344d12085 (diff) |
Cleanup Wayland::Surface's client handle logic
This is code which is either fairly old or where the api has changed.
Anyway, Surfaces allways have a client handle in the resource, so no
need to check it or store it.
Change-Id: If0be4bed177d42f168b5384a820b8e681e6d9539
Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'src/compositor/wayland_wrapper/wlsurface.cpp')
-rw-r--r-- | src/compositor/wayland_wrapper/wlsurface.cpp | 68 |
1 files changed, 29 insertions, 39 deletions
diff --git a/src/compositor/wayland_wrapper/wlsurface.cpp b/src/compositor/wayland_wrapper/wlsurface.cpp index 591619d3f..324b94a28 100644 --- a/src/compositor/wayland_wrapper/wlsurface.cpp +++ b/src/compositor/wayland_wrapper/wlsurface.cpp @@ -225,9 +225,8 @@ class SurfacePrivate { Q_DECLARE_PUBLIC(Surface) public: - SurfacePrivate(Surface *surface, struct wl_client *client, Compositor *compositor) - : client(client) - , compositor(compositor) + SurfacePrivate(Surface *surface, Compositor *compositor) + : compositor(compositor) , qtSurface(new WaylandSurface(surface)) , surfaceBuffer(0) , textureBuffer(0) @@ -334,7 +333,6 @@ public: return false; } - struct wl_client *client; Compositor *compositor; WaylandSurface *qtSurface; @@ -364,10 +362,14 @@ private: Surface *q_ptr; }; +void destroy_surface(struct wl_resource *resource) +{ + Surface *surface = wayland_cast<Surface *>((wl_surface *)resource); + delete surface; +} void Surface::surface_destroy(struct wl_client *, struct wl_resource *surface_resource) { - //Surface *surface = reinterpret_cast<Surface *>(surface_resource); wl_resource_destroy(surface_resource,Compositor::currentTimeMsecs()); } @@ -396,11 +398,11 @@ void Surface::surface_frame(struct wl_client *client, wl_list_insert(&d->frame_callback_list,&frame_callback->link); } -Surface::Surface(struct wl_client *client, Compositor *compositor) - : d_ptr(new SurfacePrivate(this,client,compositor)) +Surface::Surface(struct wl_client *client, uint32_t id, Compositor *compositor) + : d_ptr(new SurfacePrivate(this,compositor)) { - base()->resource.client = client; - + addClientResource(client, &base()->resource, id, &wl_surface_interface, + &Surface::surface_interface, destroy_surface); } Surface::~Surface() @@ -559,12 +561,6 @@ WaylandSurface * Surface::handle() const return d->qtSurface; } -wl_client *Surface::clientHandle() const -{ - Q_D(const Surface); - return d->client; -} - qint64 Surface::processId() const { Q_D(const Surface); @@ -580,7 +576,7 @@ void Surface::setProcessId(qint64 processId) QByteArray Surface::authenticationToken() const { Q_D(const Surface); - return d->compositor->windowManagerIntegration()->managedClient(d->client)->authenticationToken(); + return d->compositor->windowManagerIntegration()->managedClient(base()->resource.client)->authenticationToken(); } QVariantMap Surface::windowProperties() const @@ -671,13 +667,11 @@ void Surface::sendMousePressEvent(int x, int y, Qt::MouseButton button) { Q_D(Surface); sendMouseMoveEvent(x, y); - if (d->client) { - uint32_t time = d->compositor->currentTimeMsecs(); - struct wl_resource *pointer_focus_resource = d->compositor->defaultInputDevice()->base()->pointer_focus_resource; - if (pointer_focus_resource) { - wl_resource_post_event(d->compositor->defaultInputDevice()->base()->pointer_focus_resource, - WL_INPUT_DEVICE_BUTTON, time, toWaylandButton(button), 1); - } + uint32_t time = d->compositor->currentTimeMsecs(); + struct wl_resource *pointer_focus_resource = d->compositor->defaultInputDevice()->base()->pointer_focus_resource; + if (pointer_focus_resource) { + wl_resource_post_event(d->compositor->defaultInputDevice()->base()->pointer_focus_resource, + WL_INPUT_DEVICE_BUTTON, time, toWaylandButton(button), 1); } } @@ -685,28 +679,24 @@ void Surface::sendMouseReleaseEvent(int x, int y, Qt::MouseButton button) { Q_D(Surface); sendMouseMoveEvent(x, y); - if (d->client) { - uint32_t time = d->compositor->currentTimeMsecs(); - struct wl_resource *pointer_focus_resource = d->compositor->defaultInputDevice()->base()->pointer_focus_resource; - if (pointer_focus_resource) { - wl_resource_post_event(pointer_focus_resource, - WL_INPUT_DEVICE_BUTTON, time, toWaylandButton(button), 0); - } + uint32_t time = d->compositor->currentTimeMsecs(); + struct wl_resource *pointer_focus_resource = d->compositor->defaultInputDevice()->base()->pointer_focus_resource; + if (pointer_focus_resource) { + wl_resource_post_event(pointer_focus_resource, + WL_INPUT_DEVICE_BUTTON, time, toWaylandButton(button), 0); } } void Surface::sendMouseMoveEvent(int x, int y) { Q_D(Surface); - if (d->client) { - d->lastMousePos = QPoint(x, y); - uint32_t time = d->compositor->currentTimeMsecs(); - d->compositor->setPointerFocus(this, QPoint(x, y)); - struct wl_resource *pointer_focus_resource = d->compositor->defaultInputDevice()->base()->pointer_focus_resource; - if (pointer_focus_resource) { - wl_resource_post_event(pointer_focus_resource, - WL_INPUT_DEVICE_MOTION, time, x, y, x, y); - } + d->lastMousePos = QPoint(x, y); + uint32_t time = d->compositor->currentTimeMsecs(); + d->compositor->setPointerFocus(this, QPoint(x, y)); + struct wl_resource *pointer_focus_resource = d->compositor->defaultInputDevice()->base()->pointer_focus_resource; + if (pointer_focus_resource) { + wl_resource_post_event(pointer_focus_resource, + WL_INPUT_DEVICE_MOTION, time, x, y, x, y); } } |