Don't use members of wl_resource

When we switch to only including core wayland headers, wl_resource will be an
opaque type. Use the getters and setter functions instead.

Task-number: QTBUG-70553
Change-Id: I7d84d48a4ee3586f231a331cd15716686dcee775
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
This commit is contained in:
Johan Klokkhammer Helsing 2018-09-12 14:17:43 +02:00 committed by Johan Helsing
parent 6513ac8582
commit 2f9379552c
2 changed files with 6 additions and 6 deletions

View File

@ -506,7 +506,7 @@ bool Scanner::process()
printf(" %s *%s_object;\n", interfaceName, interfaceNameStripped);
printf(" struct ::wl_resource *handle;\n");
printf("\n");
printf(" struct ::wl_client *client() const { return handle->client; }\n");
printf(" struct ::wl_client *client() const { return wl_resource_get_client(handle); }\n");
printf(" int version() const { return wl_resource_get_version(handle); }\n");
printf("\n");
printf(" static Resource *fromResource(struct ::wl_resource *resource);\n");
@ -806,7 +806,7 @@ bool Scanner::process()
printf(" if (Q_UNLIKELY(!resource))\n");
printf(" return nullptr;\n");
printf(" if (wl_resource_instance_of(resource, &::%s_interface, %s))\n", interfaceName, interfaceMember.constData());
printf(" return static_cast<Resource *>(resource->data);\n");
printf(" return static_cast<Resource *>(wl_resource_get_user_data(resource));\n");
printf(" return nullptr;\n");
printf(" }\n");

View File

@ -400,7 +400,7 @@ void Compositor::dispatchEvents(int timeout)
static void compositor_create_surface(wl_client *client, wl_resource *compositorResource, uint32_t id)
{
Compositor *compositor = static_cast<Compositor *>(compositorResource->data);
Compositor *compositor = static_cast<Compositor *>(wl_resource_get_user_data(compositorResource));
compositor->addSurface(new Surface(client, id, wl_resource_get_version(compositorResource), compositor));
}
@ -425,18 +425,18 @@ void Compositor::bindCompositor(wl_client *client, void *compositorData, uint32_
static void unregisterResourceCallback(wl_listener *listener, void *data)
{
struct wl_resource *resource = reinterpret_cast<struct wl_resource *>(data);
wl_list_remove(&resource->link);
wl_list_remove(wl_resource_get_link(resource));
delete listener;
}
void registerResource(wl_list *list, wl_resource *resource)
{
wl_list_insert(list, &resource->link);
wl_list_insert(list, wl_resource_get_link(resource));
wl_listener *listener = new wl_listener;
listener->notify = unregisterResourceCallback;
wl_signal_add(&resource->destroy_signal, listener);
wl_resource_add_destroy_listener(resource, listener);
}
QVector<Surface *> Compositor::surfaces() const