diff options
19 files changed, 152 insertions, 178 deletions
diff --git a/src/compositor/global/qwaylandobject.h b/src/compositor/global/qwaylandobject.h index 6d93297a1..9b3450397 100644 --- a/src/compositor/global/qwaylandobject.h +++ b/src/compositor/global/qwaylandobject.h @@ -60,38 +60,8 @@ public: const T *base() const { return this; } T *base() { return this; } - - template <typename Implementation> - void addClientResource(wl_client *client, - wl_resource *resource, - int id, const struct wl_interface *interface, - Implementation implementation, - void (*destroy)(struct wl_resource *resource)) - { - resource->object.id = id; - resource->object.interface = interface; - resource->object.implementation = (void (**)(void))implementation; - resource->data = this; - resource->destroy = destroy; - - wl_client_add_resource(client, resource); - } }; -template <typename T> -T *resolve(wl_resource *from) -{ - Object<typename T::Base> *object = reinterpret_cast<Object<typename T::Base> *>(from->data); - return static_cast<T *>(object); -} - -template <typename T> -T *wayland_cast(typename T::Base *from) -{ - Object<typename T::Base> *object = reinterpret_cast<Object<typename T::Base> *>(from); - return static_cast<T *>(object); -} - } QT_END_NAMESPACE diff --git a/src/compositor/wayland_wrapper/qwlcompositor.cpp b/src/compositor/wayland_wrapper/qwlcompositor.cpp index ee7fe796b..96aad809d 100644 --- a/src/compositor/wayland_wrapper/qwlcompositor.cpp +++ b/src/compositor/wayland_wrapper/qwlcompositor.cpp @@ -250,7 +250,7 @@ struct wl_client *Compositor::getClientFromWinId(uint winId) const { Surface *surface = getSurfaceFromWinId(winId); if (surface) - return surface->base()->resource.client; + return surface->resource()->client(); return 0; } @@ -414,7 +414,7 @@ QList<struct wl_client *> Compositor::clients() const { QList<struct wl_client *> list; foreach (Surface *surface, m_surfaces) { - struct wl_client *client = surface->base()->resource.client; + struct wl_client *client = surface->resource()->client(); if (!list.contains(client)) list.append(client); } @@ -490,7 +490,7 @@ QList<QtWayland::Surface *> Compositor::surfacesForClient(wl_client *client) QList<QtWayland::Surface *> ret; for (int i=0; i < m_surfaces.count(); ++i) { - if (m_surfaces.at(i)->base()->resource.client == client) { + if (m_surfaces.at(i)->resource()->client() == client) { ret.append(m_surfaces.at(i)); } } @@ -503,7 +503,7 @@ wl_resource *Compositor::resourceForSurface(wl_list *resourceList, Surface *surf return 0; wl_resource *r; - wl_client *surfaceClient = surface->base()->resource.client; + wl_client *surfaceClient = surface->resource()->client(); wl_list_for_each(r, resourceList, link) { if (r->client == surfaceClient) diff --git a/src/compositor/wayland_wrapper/qwldatadevicemanager.cpp b/src/compositor/wayland_wrapper/qwldatadevicemanager.cpp index 03baa16bd..c27aa514f 100644 --- a/src/compositor/wayland_wrapper/qwldatadevicemanager.cpp +++ b/src/compositor/wayland_wrapper/qwldatadevicemanager.cpp @@ -243,7 +243,7 @@ void DataDeviceManager::overrideSelection(const QMimeData &mimeData) Surface *focusSurface = dev->keyboardFocus(); if (focusSurface) offerFromCompositorToClient( - dev->dataDevice(focusSurface->base()->resource.client)->dataDeviceResource()); + dev->dataDevice(focusSurface->resource()->client())->dataDeviceResource()); } bool DataDeviceManager::offerFromCompositorToClient(wl_resource *clientDataDeviceResource) diff --git a/src/compositor/wayland_wrapper/qwlextendedsurface.cpp b/src/compositor/wayland_wrapper/qwlextendedsurface.cpp index 5cbff2701..9f2260fce 100644 --- a/src/compositor/wayland_wrapper/qwlextendedsurface.cpp +++ b/src/compositor/wayland_wrapper/qwlextendedsurface.cpp @@ -73,7 +73,7 @@ void SurfaceExtensionGlobal::get_extended_surface(struct wl_client *client, struct wl_resource *surface_resource) { Q_UNUSED(surface_extension_resource); - Surface *surface = resolve<Surface>(surface_resource); + Surface *surface = Surface::fromResource(surface_resource); new ExtendedSurface(client,id,surface); } diff --git a/src/compositor/wayland_wrapper/qwlinputdevice.cpp b/src/compositor/wayland_wrapper/qwlinputdevice.cpp index eba2caf5b..e75d98334 100644 --- a/src/compositor/wayland_wrapper/qwlinputdevice.cpp +++ b/src/compositor/wayland_wrapper/qwlinputdevice.cpp @@ -222,7 +222,7 @@ void InputDevice::pointer_set_cursor(wl_pointer::Resource *resource, Q_UNUSED(resource); Q_UNUSED(serial); - QtWayland::Surface *surface = reinterpret_cast<QtWayland::Surface *>(surface_resource->data); + QtWayland::Surface *surface = QtWayland::Surface::fromResource(surface_resource); surface->setCursorSurface(true); m_compositor->waylandCompositor()->setCursorSurface(surface->waylandSurface(), hotspot_x, hotspot_y); @@ -464,7 +464,7 @@ void InputDevice::sendFullTouchEvent(QTouchEvent *event) Surface *InputDevice::keyboardFocus() const { - return wayland_cast<Surface>(keyboardDevice()->focus); + return static_cast<Surface *>(keyboardDevice()->focus); } /*! @@ -476,13 +476,13 @@ bool InputDevice::setKeyboardFocus(Surface *surface) return false; sendSelectionFocus(surface); - wl_keyboard_set_focus(keyboardDevice(), surface ? surface->base() : 0); + wl_keyboard_set_focus(keyboardDevice(), surface); return true; } Surface *InputDevice::mouseFocus() const { - return wayland_cast<Surface>(pointerDevice()->focus); + return static_cast<Surface *>(pointerDevice()->focus); } void InputDevice::setMouseFocus(Surface *surface, const QPointF &localPos, const QPointF &globalPos) @@ -490,17 +490,16 @@ void InputDevice::setMouseFocus(Surface *surface, const QPointF &localPos, const ::wl_pointer *pointer = pointerDevice(); pointer->x = wl_fixed_from_double(globalPos.x()); pointer->y = wl_fixed_from_double(globalPos.y()); - pointer->current = surface ? surface->base() : 0; + pointer->current = surface; pointer->current_x = wl_fixed_from_double(localPos.x()); pointer->current_y = wl_fixed_from_double(localPos.y()); - pointer->grab->interface->focus(pointer->grab, - surface ? surface->base() : 0, + pointer->grab->interface->focus(pointer->grab, surface, wl_fixed_from_double(localPos.x()), wl_fixed_from_double(localPos.y())); // We have no separate touch focus management so make it match the pointer focus always. // No wl_touch_set_focus() is available so set it manually. ::wl_touch *touch = touchDevice(); - touch->focus = surface ? surface->base() : 0; + touch->focus = surface; touch->focus_resource = Compositor::resourceForSurface(&touch->resource_list, surface); } @@ -529,7 +528,7 @@ void InputDevice::sendSelectionFocus(Surface *surface) { if (!surface) return; - DataDevice *device = dataDevice(surface->base()->resource.client); + DataDevice *device = dataDevice(surface->resource()->client()); if (device) { device->sendSelectionFocus(); } diff --git a/src/compositor/wayland_wrapper/qwlqtkey.cpp b/src/compositor/wayland_wrapper/qwlqtkey.cpp index 0c9c136ea..7a9e8586e 100644 --- a/src/compositor/wayland_wrapper/qwlqtkey.cpp +++ b/src/compositor/wayland_wrapper/qwlqtkey.cpp @@ -57,7 +57,7 @@ QtKeyExtensionGlobal::QtKeyExtensionGlobal(Compositor *compositor) bool QtKeyExtensionGlobal::postQtKeyEvent(QKeyEvent *event, Surface *surface) { - wl_client *surfaceClient = surface->base()->resource.client; + wl_client *surfaceClient = surface->resource()->client(); uint32_t time = m_compositor->currentTimeMsecs(); diff --git a/src/compositor/wayland_wrapper/qwlregion.cpp b/src/compositor/wayland_wrapper/qwlregion.cpp index c9e452528..69f382404 100644 --- a/src/compositor/wayland_wrapper/qwlregion.cpp +++ b/src/compositor/wayland_wrapper/qwlregion.cpp @@ -46,45 +46,38 @@ QT_BEGIN_NAMESPACE namespace QtWayland { -void destroy_region(struct wl_resource *resource) +Region::Region(struct wl_client *client, uint32_t id) + : QtWaylandServer::wl_region(client, id) { - delete resolve<Region>(resource); } -Region::Region(struct wl_client *client, uint32_t id) +Region::~Region() { - addClientResource(client, base(), id, &wl_region_interface, - ®ion_interface, destroy_region); } -Region::~Region() +Region *Region::fromResource(struct ::wl_resource *resource) { + return static_cast<Region *>(Resource::fromResource(resource)->region); } -const struct wl_region_interface Region::region_interface = { - region_destroy, - region_add, - region_subtract -}; +void Region::region_destroy_resource(Resource *) +{ + delete this; +} -void Region::region_destroy(wl_client *client, wl_resource *region) +void Region::region_destroy(Resource *resource) { - Q_UNUSED(client); - wl_resource_destroy(region); + wl_resource_destroy(resource->handle); } -void Region::region_add(wl_client *client, wl_resource *region, - int32_t x, int32_t y, int32_t w, int32_t h) +void Region::region_add(Resource *, int32_t x, int32_t y, int32_t w, int32_t h) { - Q_UNUSED(client); - resolve<Region>(region)->m_region += QRect(x, y, w, h); + m_region += QRect(x, y, w, h); } -void Region::region_subtract(wl_client *client, wl_resource *region, - int32_t x, int32_t y, int32_t w, int32_t h) +void Region::region_subtract(Resource *, int32_t x, int32_t y, int32_t w, int32_t h) { - Q_UNUSED(client); - resolve<Region>(region)->m_region -= QRect(x, y, w, h); + m_region -= QRect(x, y, w, h); } } diff --git a/src/compositor/wayland_wrapper/qwlregion_p.h b/src/compositor/wayland_wrapper/qwlregion_p.h index 2002e7370..f905d96b6 100644 --- a/src/compositor/wayland_wrapper/qwlregion_p.h +++ b/src/compositor/wayland_wrapper/qwlregion_p.h @@ -42,38 +42,38 @@ #define WL_REGION_H #include <QtCompositor/qwaylandexport.h> -#include <QtCompositor/qwaylandobject.h> #include <QRegion> #include <wayland-util.h> +#include "qwayland-server-wayland.h" QT_BEGIN_NAMESPACE namespace QtWayland { -class Q_COMPOSITOR_EXPORT Region : public Object<wl_resource> +class Q_COMPOSITOR_EXPORT Region : public QtWaylandServer::wl_region { public: Region(struct wl_client *client, uint32_t id); ~Region(); - uint id() const { return base()->object.id; } + static Region *fromResource(struct ::wl_resource *resource); - QRegion region() const { return m_region; } + uint id() const { return resource()->handle->object.id; } - static const struct wl_region_interface region_interface; + QRegion region() const { return m_region; } private: Q_DISABLE_COPY(Region) QRegion m_region; - static void region_destroy(wl_client *client, wl_resource *region); - static void region_add(wl_client *client, wl_resource *region, - int32_t x, int32_t y, int32_t w, int32_t h); - static void region_subtract(wl_client *client, wl_resource *region, - int32_t x, int32_t y, int32_t w, int32_t h); + void region_destroy_resource(Resource *) Q_DECL_OVERRIDE; + + void region_destroy(Resource *resource) Q_DECL_OVERRIDE; + void region_add(Resource *resource, int32_t x, int32_t y, int32_t w, int32_t h) Q_DECL_OVERRIDE; + void region_subtract(Resource *resource, int32_t x, int32_t y, int32_t w, int32_t h) Q_DECL_OVERRIDE; }; } diff --git a/src/compositor/wayland_wrapper/qwlshellsurface.cpp b/src/compositor/wayland_wrapper/qwlshellsurface.cpp index 061faccdc..18ee0431b 100644 --- a/src/compositor/wayland_wrapper/qwlshellsurface.cpp +++ b/src/compositor/wayland_wrapper/qwlshellsurface.cpp @@ -69,7 +69,7 @@ void Shell::get_shell_surface(struct wl_client *client, struct wl_resource *surface_super) { Q_UNUSED(shell_resource); - Surface *surface = resolve<Surface>(surface_super); + Surface *surface = Surface::fromResource(surface_super); new ShellSurface(client,id,surface); } @@ -223,7 +223,7 @@ void ShellSurface::shell_surface_set_transient(Resource *resource, Q_UNUSED(resource); Q_UNUSED(flags); - Surface *parent_surface = static_cast<Surface *>(parent_surface_resource->data); + Surface *parent_surface = Surface::fromResource(parent_surface_resource); m_transientParent = parent_surface->shellSurface(); m_xOffset = x; m_yOffset = y; @@ -304,7 +304,7 @@ ShellSurfaceGrabber::ShellSurfaceGrabber(ShellSurface *shellSurface, const struc : shell_surface(shellSurface) { base()->interface = interface; - base()->focus = shell_surface->surface()->base(); + base()->focus = shell_surface->surface(); } ShellSurfaceGrabber::~ShellSurfaceGrabber() diff --git a/src/compositor/wayland_wrapper/qwlshellsurface_p.h b/src/compositor/wayland_wrapper/qwlshellsurface_p.h index 92820adb6..4c296a97c 100644 --- a/src/compositor/wayland_wrapper/qwlshellsurface_p.h +++ b/src/compositor/wayland_wrapper/qwlshellsurface_p.h @@ -41,9 +41,8 @@ #ifndef WLSHELLSURFACE_H #define WLSHELLSURFACE_H -#include <QtCompositor/qwaylandobject.h> - #include <wayland-server.h> +#include <qwaylandobject.h> #include <QPoint> #include <qwayland-server-wayland.h> @@ -137,7 +136,7 @@ private: const QString &class_) Q_DECL_OVERRIDE; }; -class ShellSurfaceGrabber : public Object<wl_pointer_grab> +class ShellSurfaceGrabber : public Object<struct ::wl_pointer_grab> { public: ShellSurfaceGrabber(ShellSurface *shellSurface, const struct wl_pointer_grab_interface *interface); diff --git a/src/compositor/wayland_wrapper/qwlsubsurface.cpp b/src/compositor/wayland_wrapper/qwlsubsurface.cpp index f482cde6d..060a7f0e5 100644 --- a/src/compositor/wayland_wrapper/qwlsubsurface.cpp +++ b/src/compositor/wayland_wrapper/qwlsubsurface.cpp @@ -65,7 +65,7 @@ void SubSurfaceExtensionGlobal::bind_func(wl_client *client, void *data, uint32_ void SubSurfaceExtensionGlobal::get_sub_surface_aware_surface(wl_client *client, wl_resource *sub_surface_extension_resource, uint32_t id, wl_resource *surface_resource) { Q_UNUSED(sub_surface_extension_resource); - Surface *surface = resolve<Surface>(surface_resource); + Surface *surface = Surface::fromResource(surface_resource); new SubSurface(client,id,surface); } diff --git a/src/compositor/wayland_wrapper/qwlsurface.cpp b/src/compositor/wayland_wrapper/qwlsurface.cpp index 976dc27a0..f5e6db38a 100644 --- a/src/compositor/wayland_wrapper/qwlsurface.cpp +++ b/src/compositor/wayland_wrapper/qwlsurface.cpp @@ -71,15 +71,9 @@ QT_BEGIN_NAMESPACE namespace QtWayland { -void destroy_surface(struct wl_resource *resource) -{ - Surface *surface = resolve<Surface>(resource); - surface->compositor()->surfaceDestroyed(surface); - delete surface; -} - Surface::Surface(struct wl_client *client, uint32_t id, Compositor *compositor) - : m_compositor(compositor) + : QtWaylandServer::wl_surface(client, &base()->resource, id) + , m_compositor(compositor) , m_waylandSurface(new QWaylandSurface(this)) , m_backBuffer(0) , m_frontBuffer(0) @@ -91,11 +85,9 @@ Surface::Surface(struct wl_client *client, uint32_t id, Compositor *compositor) , m_isCursorSurface(false) { wl_list_init(&m_frame_callback_list); - addClientResource(client, &base()->resource, id, &wl_surface_interface, - &Surface::surface_interface, destroy_surface); - for (int i = 0; i < buffer_pool_size; i++) { + + for (int i = 0; i < buffer_pool_size; i++) m_bufferPool[i] = new SurfaceBuffer(this); - } } Surface::~Surface() @@ -110,6 +102,11 @@ Surface::~Surface() } } +Surface *Surface::fromResource(struct ::wl_resource *resource) +{ + return static_cast<Surface *>(Resource::fromResource(resource)->surface); +} + QWaylandSurface::Type Surface::type() const { SurfaceBuffer *surfaceBuffer = currentSurfaceBuffer(); @@ -394,14 +391,6 @@ bool Surface::postBuffer() { return false; } -void Surface::commit() -{ - if (!m_bufferQueue.isEmpty() && !m_backBuffer) - advanceBufferQueue(); - - doUpdate(); -} - void Surface::attach(struct wl_buffer *buffer) { SurfaceBuffer *last = m_bufferQueue.size()?m_bufferQueue.last():0; @@ -428,72 +417,59 @@ void Surface::attach(struct wl_buffer *buffer) void Surface::damage(const QRect &rect) { SurfaceBuffer *surfaceBuffer = m_bufferQueue.isEmpty() ? currentSurfaceBuffer() : m_bufferQueue.last(); + if (surfaceBuffer) surfaceBuffer->setDamage(rect); else qWarning() << "Surface::damage() null buffer"; } -const struct wl_surface_interface Surface::surface_interface = { - Surface::surface_destroy, - Surface::surface_attach, - Surface::surface_damage, - Surface::surface_frame, - Surface::surface_set_opaque_region, - Surface::surface_set_input_region, - Surface::surface_commit -}; +void Surface::surface_destroy_resource(Resource *) +{ + compositor()->surfaceDestroyed(this); + delete this; +} -void Surface::surface_destroy(struct wl_client *, struct wl_resource *surface_resource) +void Surface::surface_destroy(Resource *resource) { - wl_resource_destroy(surface_resource); + wl_resource_destroy(resource->handle); } -void Surface::surface_attach(struct wl_client *client, struct wl_resource *surface, - struct wl_resource *buffer, int x, int y) +void Surface::surface_attach(Resource *, struct wl_resource *buffer, int x, int y) { - Q_UNUSED(client); Q_UNUSED(x); Q_UNUSED(y); - resolve<Surface>(surface)->attach(buffer ? reinterpret_cast<wl_buffer *>(buffer->data) : 0); + + attach(buffer ? reinterpret_cast<wl_buffer *>(buffer->data) : 0); } -void Surface::surface_damage(struct wl_client *client, struct wl_resource *surface, - int32_t x, int32_t y, int32_t width, int32_t height) +void Surface::surface_damage(Resource *, int32_t x, int32_t y, int32_t width, int32_t height) { - Q_UNUSED(client); - resolve<Surface>(surface)->damage(QRect(x, y, width, height)); + damage(QRect(x, y, width, height)); } -void Surface::surface_frame(struct wl_client *client, - struct wl_resource *resource, - uint32_t callback) +void Surface::surface_frame(Resource *resource, uint32_t callback) { - Surface *surface = resolve<Surface>(resource); - struct wl_resource *frame_callback = wl_client_add_object(client,&wl_callback_interface,0,callback,surface); - wl_list_insert(&surface->m_frame_callback_list,&frame_callback->link); + struct wl_resource *frame_callback = wl_client_add_object(resource->client(), &wl_callback_interface, 0, callback, this); + wl_list_insert(&m_frame_callback_list, &frame_callback->link); } -void Surface::surface_set_opaque_region(struct wl_client *client, struct wl_resource *surfaceResource, - struct wl_resource *region) +void Surface::surface_set_opaque_region(Resource *, struct wl_resource *region) { - Q_UNUSED(client); - Surface *surface = resolve<Surface>(surfaceResource); - surface->m_opaqueRegion = region ? resolve<Region>(region)->region() : QRegion(); + m_opaqueRegion = region ? Region::fromResource(region)->region() : QRegion(); } -void Surface::surface_set_input_region(struct wl_client *client, struct wl_resource *surfaceResource, - struct wl_resource *region) +void Surface::surface_set_input_region(Resource *, struct wl_resource *region) { - Q_UNUSED(client); - Surface *surface = resolve<Surface>(surfaceResource); - surface->m_inputRegion = region ? resolve<Region>(region)->region() : QRegion(QRect(QPoint(), surface->size())); + m_inputRegion = region ? Region::fromResource(region)->region() : QRegion(QRect(QPoint(), size())); } -void Surface::surface_commit(wl_client *client, wl_resource *resource) +void Surface::surface_commit(Resource *) { - Q_UNUSED(client); - resolve<Surface>(resource)->commit(); + if (!m_bufferQueue.isEmpty() && !m_backBuffer) + advanceBufferQueue(); + + doUpdate(); } void Surface::setClassName(const QString &className) diff --git a/src/compositor/wayland_wrapper/qwlsurface_p.h b/src/compositor/wayland_wrapper/qwlsurface_p.h index 21b1ae742..264b42e17 100644 --- a/src/compositor/wayland_wrapper/qwlsurface_p.h +++ b/src/compositor/wayland_wrapper/qwlsurface_p.h @@ -42,12 +42,11 @@ #define WL_SURFACE_H #include <QtCompositor/qwaylandexport.h> +#include <QtCompositor/qwaylandobject.h> #include <private/qwlsurfacebuffer_p.h> #include <QtCompositor/qwaylandsurface.h> -#include <QtCompositor/qwaylandobject.h> - #include <QtCore/QRect> #include <QtGui/QImage> @@ -61,6 +60,8 @@ #include <wayland-util.h> +#include "qwayland-server-wayland.h" + QT_BEGIN_NAMESPACE class QTouchEvent; @@ -73,18 +74,22 @@ class ExtendedSurface; class SubSurface; class ShellSurface; -class Q_COMPOSITOR_EXPORT Surface : public Object<struct wl_surface> +class Q_COMPOSITOR_EXPORT Surface : public Object<struct ::wl_surface>, public QtWaylandServer::wl_surface { public: Surface(struct wl_client *client, uint32_t id, Compositor *compositor); ~Surface(); + static Surface *fromResource(struct ::wl_resource *resource); + QWaylandSurface::Type type() const; bool isYInverted() const; bool visible() const; - uint id() const { return base()->resource.object.id; } + uint id() const { return ::wl_surface::resource.object.id; } + + using QtWaylandServer::wl_surface::resource; QPointF pos() const; QPointF nonAdjustedPos() const; @@ -123,8 +128,6 @@ public: void damage(const QRect &rect); - static const struct wl_surface_interface surface_interface; - QString className() const { return m_className; } void setClassName(const QString &className); @@ -176,22 +179,23 @@ private: SurfaceBuffer *createSurfaceBuffer(struct wl_buffer *buffer); void frameFinishedInternal(); bool postBuffer(); - void commit(); void attach(struct wl_buffer *buffer); - static void surface_destroy(struct wl_client *client, struct wl_resource *_surface); - static void surface_attach(struct wl_client *client, struct wl_resource *surface, - struct wl_resource *buffer, int x, int y); - static void surface_damage(struct wl_client *client, struct wl_resource *_surface, - int32_t x, int32_t y, int32_t width, int32_t height); - static void surface_frame(struct wl_client *client, struct wl_resource *resource, - uint32_t callback); - static void surface_set_opaque_region(struct wl_client *client, struct wl_resource *resource, - struct wl_resource *region); - static void surface_set_input_region(struct wl_client *client, struct wl_resource *resource, - struct wl_resource *region); - static void surface_commit(struct wl_client *client, struct wl_resource *resource); + void surface_destroy_resource(Resource *resource) Q_DECL_OVERRIDE; + + void surface_destroy(Resource *resource) Q_DECL_OVERRIDE; + void surface_attach(Resource *resource, + struct wl_resource *buffer, int x, int y) Q_DECL_OVERRIDE; + void surface_damage(Resource *resource, + int32_t x, int32_t y, int32_t width, int32_t height) Q_DECL_OVERRIDE; + void surface_frame(Resource *resource, + uint32_t callback) Q_DECL_OVERRIDE; + void surface_set_opaque_region(Resource *resource, + struct wl_resource *region) Q_DECL_OVERRIDE; + void surface_set_input_region(Resource *resource, + struct wl_resource *region) Q_DECL_OVERRIDE; + void surface_commit(Resource *resource) Q_DECL_OVERRIDE; }; diff --git a/src/compositor/wayland_wrapper/qwltouch.cpp b/src/compositor/wayland_wrapper/qwltouch.cpp index 458c74bf9..47886890f 100644 --- a/src/compositor/wayland_wrapper/qwltouch.cpp +++ b/src/compositor/wayland_wrapper/qwltouch.cpp @@ -105,7 +105,7 @@ bool TouchExtensionGlobal::postTouchEvent(QTouchEvent *event, Surface *surface) return false; QPointF surfacePos = surface->pos(); - wl_client *surfaceClient = surface->base()->resource.client; + wl_client *surfaceClient = surface->resource()->client(); uint32_t time = m_compositor->currentTimeMsecs(); const int rescount = m_resources.count(); diff --git a/src/plugins/waylandcompositors/brcm-egl/brcm-egl.pro b/src/plugins/waylandcompositors/brcm-egl/brcm-egl.pro index 401d6d461..4dcfbaf96 100644 --- a/src/plugins/waylandcompositors/brcm-egl/brcm-egl.pro +++ b/src/plugins/waylandcompositors/brcm-egl/brcm-egl.pro @@ -19,4 +19,4 @@ HEADERS += \ OTHER_FILES += brcm-egl.json -WAYLANDSERVERSOURCES += $$PWD/../../../extensions/brcm.xml +WAYLANDSERVERSOURCES += $$PWD/../../../extensions/brcm.xml $$PWD/../../../3rdparty/protocol/wayland.xml diff --git a/src/plugins/waylandcompositors/wayland-egl/wayland-egl.pro b/src/plugins/waylandcompositors/wayland-egl/wayland-egl.pro index cc980be36..730956398 100644 --- a/src/plugins/waylandcompositors/wayland-egl/wayland-egl.pro +++ b/src/plugins/waylandcompositors/wayland-egl/wayland-egl.pro @@ -5,6 +5,8 @@ QT = compositor compositor-private core-private gui-private OTHER_FILES += wayland-egl.json +WAYLANDSERVERSOURCES += $$PWD/../../../3rdparty/protocol/wayland.xml + !contains(QT_CONFIG, no-pkg-config) { CONFIG += link_pkgconfig PKGCONFIG += wayland-egl egl diff --git a/src/plugins/waylandcompositors/xcomposite_share/xcomposite_share.pri b/src/plugins/waylandcompositors/xcomposite_share/xcomposite_share.pri index 823925d1e..7e0bc4579 100644 --- a/src/plugins/waylandcompositors/xcomposite_share/xcomposite_share.pri +++ b/src/plugins/waylandcompositors/xcomposite_share/xcomposite_share.pri @@ -1,6 +1,6 @@ INCLUDEPATH += $$PWD -WAYLANDSERVERSOURCES += $$PWD/../../../extensions/xcomposite.xml +WAYLANDSERVERSOURCES += $$PWD/../../../extensions/xcomposite.xml $$PWD/../../../3rdparty/protocol/wayland.xml HEADERS += \ $$PWD/xcompositebuffer.h \ diff --git a/src/qtwaylandscanner/qtwaylandscanner.cpp b/src/qtwaylandscanner/qtwaylandscanner.cpp index fe91b796b..6f1516f4b 100644 --- a/src/qtwaylandscanner/qtwaylandscanner.cpp +++ b/src/qtwaylandscanner/qtwaylandscanner.cpp @@ -386,6 +386,7 @@ void process(QXmlStreamReader &xml) printf(" class %s\n {\n", interfaceName); printf(" public:\n"); + printf(" %s(struct ::wl_client *client, struct ::wl_resource *resource, int id);\n", interfaceName); printf(" %s(struct ::wl_client *client, int id);\n", interfaceName); printf(" %s(struct ::wl_display *display);\n", interfaceName); printf(" %s();\n", interfaceName); @@ -406,6 +407,7 @@ void process(QXmlStreamReader &xml) printf(" static Resource *fromResource(struct ::wl_resource *resource) { return static_cast<Resource *>(resource->data); }\n"); printf(" };\n"); printf("\n"); + printf(" void init(struct ::wl_client *client, struct ::wl_resource *resource, int id);\n"); printf(" void init(struct ::wl_client *client, int id);\n"); printf(" void init(struct ::wl_display *display);\n"); printf("\n"); @@ -460,7 +462,7 @@ void process(QXmlStreamReader &xml) printf(" static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id);\n"); printf(" static void destroy_func(struct ::wl_resource *client_resource);\n"); printf("\n"); - printf(" Resource *bind(struct ::wl_client *client, uint32_t id);\n"); + printf(" Resource *bind(struct ::wl_client *client, struct ::wl_resource *resource, uint32_t id);\n"); if (hasRequests) { printf("\n"); @@ -478,6 +480,7 @@ void process(QXmlStreamReader &xml) printf("\n"); printf(" Resource *m_resource;\n"); + printf(" bool m_ownResource;\n"); printf(" struct ::wl_list m_resource_list;\n"); printf(" struct ::wl_global *m_global;\n"); printf(" };\n"); @@ -517,8 +520,19 @@ void process(QXmlStreamReader &xml) QByteArray stripped = stripInterfaceName(interface.name); const char *interfaceNameStripped = stripped.constData(); + printf(" %s::%s(struct ::wl_client *client, struct ::wl_resource *resource, int id)\n", interfaceName, interfaceName); + printf(" : m_resource(0)\n"); + printf(" , m_ownResource(false)\n"); + printf(" , m_global(0)\n"); + printf(" {\n"); + printf(" wl_list_init(&m_resource_list);\n"); + printf(" init(client, resource, id);\n"); + printf(" }\n"); + printf("\n"); + printf(" %s::%s(struct ::wl_client *client, int id)\n", interfaceName, interfaceName); printf(" : m_resource(0)\n"); + printf(" , m_ownResource(true)\n"); printf(" , m_global(0)\n"); printf(" {\n"); printf(" wl_list_init(&m_resource_list);\n"); @@ -528,6 +542,7 @@ void process(QXmlStreamReader &xml) printf(" %s::%s(struct ::wl_display *display)\n", interfaceName, interfaceName); printf(" : m_resource(0)\n"); + printf(" , m_ownResource(true)\n"); printf(" , m_global(0)\n"); printf(" {\n"); printf(" wl_list_init(&m_resource_list);\n"); @@ -548,9 +563,15 @@ void process(QXmlStreamReader &xml) printf(" }\n"); printf("\n"); + printf(" void %s::init(struct ::wl_client *client, struct ::wl_resource *resource, int id)\n", interfaceName); + printf(" {\n"); + printf(" m_resource = bind(client, resource, id);\n"); + printf(" }\n"); + printf("\n"); + printf(" void %s::init(struct ::wl_client *client, int id)\n", interfaceName); printf(" {\n"); - printf(" m_resource = bind(client, id);\n"); + printf(" m_resource = bind(client, 0, id);\n"); printf(" }\n"); printf("\n"); @@ -562,7 +583,7 @@ void process(QXmlStreamReader &xml) printf(" %s::Resource *%s::add(struct wl_list *resource_list, struct ::wl_client *client, int id)\n", interfaceName, interfaceName); printf(" {\n"); - printf(" Resource *resource = bind(client, id);\n"); + printf(" Resource *resource = bind(client, 0, id);\n"); printf(" wl_list_insert(resource_list, &resource->handle->link);\n"); printf(" return resource;\n"); printf(" }\n"); @@ -593,7 +614,7 @@ void process(QXmlStreamReader &xml) printf(" void %s::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id)\n", interfaceName); printf(" {\n"); printf(" Q_UNUSED(version);\n"); - printf(" static_cast<%s *>(data)->bind(client, id);\n", interfaceName); + printf(" static_cast<%s *>(data)->bind(client, 0, id);\n", interfaceName); printf(" }\n"); printf("\n"); @@ -601,25 +622,37 @@ void process(QXmlStreamReader &xml) printf(" {\n"); printf(" Resource *resource = Resource::fromResource(client_resource);\n"); printf(" %s *that = resource->%s;\n", interfaceName, interfaceNameStripped); + printf(" bool ownResource = that->m_ownResource;\n"); printf(" that->%s_destroy_resource(resource);\n", interfaceNameStripped); printf(" if (client_resource->link.next)\n"); printf(" wl_list_remove(&client_resource->link);\n"); printf(" delete resource;\n"); - printf(" free(client_resource);\n"); + printf(" if (ownResource)\n"); + printf(" free(client_resource);\n"); printf(" }\n"); printf("\n"); bool hasRequests = !interface.requests.isEmpty(); - printf(" %s::Resource *%s::bind(struct ::wl_client *client, uint32_t id)\n", interfaceName, interfaceName); + QByteArray interfaceMember = hasRequests ? "&m_" + interface.name + "_interface" : QByteArray("0"); + + printf(" %s::Resource *%s::bind(struct ::wl_client *client, struct ::wl_resource *handle, uint32_t id)\n", interfaceName, interfaceName); printf(" {\n"); printf(" Resource *resource = %s_allocate();\n", interfaceNameStripped); printf(" resource->%s = this;\n", interfaceNameStripped); - if (hasRequests) - printf(" resource->handle = wl_client_add_object(client, &::%s_interface, &m_%s_interface, id, resource);\n", interfaceName, interfaceName); - else - printf(" resource->handle = wl_client_add_object(client, &::%s_interface, 0, id, resource);\n", interfaceName); - printf(" resource->handle->destroy = destroy_func;\n"); + printf("\n"); + printf(" if (handle) {\n"); + printf(" handle->object.id = id;\n"); + printf(" handle->object.interface = &::%s_interface;\n", interfaceName); + printf(" handle->object.implementation = (void (**)(void))%s;\n", interfaceMember.constData()); + printf(" handle->data = resource;\n"); + printf(" wl_client_add_resource(client, handle);\n"); + printf(" } else {\n"); + printf(" handle = wl_client_add_object(client, &::%s_interface, %s, id, resource);\n", interfaceName, interfaceMember.constData()); + printf(" }\n"); + printf("\n"); + printf(" handle->destroy = destroy_func;\n"); + printf(" resource->handle = handle;\n"); printf(" %s_bind_resource(resource);\n", interfaceNameStripped); printf(" wl_list_init(&resource->handle->link);\n"); printf(" return resource;\n"); diff --git a/src/qtwaylandscanner/qtwaylandscanner.pro b/src/qtwaylandscanner/qtwaylandscanner.pro index 34d25b922..ac2d07b76 100644 --- a/src/qtwaylandscanner/qtwaylandscanner.pro +++ b/src/qtwaylandscanner/qtwaylandscanner.pro @@ -1,7 +1,5 @@ option(host_build) -HEADERS += qtwaylandscanner.h - SOURCES += qtwaylandscanner.cpp load(qt_tool) |