1 | // Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com> |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | #include "qwaylanddestroylistener.h" |
5 | #include "qwaylanddestroylistener_p.h" |
6 | |
7 | QT_BEGIN_NAMESPACE |
8 | |
9 | QWaylandDestroyListenerPrivate::QWaylandDestroyListenerPrivate() |
10 | { |
11 | listener.parent = this; |
12 | listener.listener.notify = handler; |
13 | wl_list_init(list: &listener.listener.link); |
14 | } |
15 | |
16 | QWaylandDestroyListener::QWaylandDestroyListener(QObject *parent) |
17 | : QObject(* new QWaylandDestroyListenerPrivate(), parent) |
18 | { |
19 | } |
20 | void QWaylandDestroyListener::listenForDestruction(::wl_resource *resource) |
21 | { |
22 | Q_D(QWaylandDestroyListener); |
23 | wl_resource_add_destroy_listener(resource, listener: &d->listener.listener); |
24 | } |
25 | |
26 | void QWaylandDestroyListener::reset() |
27 | { |
28 | Q_D(QWaylandDestroyListener); |
29 | wl_list_remove(elm: &d->listener.listener.link); |
30 | wl_list_init(list: &d->listener.listener.link); |
31 | } |
32 | |
33 | void QWaylandDestroyListenerPrivate::handler(wl_listener *listener, void *data) |
34 | { |
35 | QWaylandDestroyListenerPrivate *that = reinterpret_cast<Listener *>(listener)->parent; |
36 | emit that->q_func()->fired(data); |
37 | } |
38 | |
39 | QT_END_NAMESPACE |
40 | |
41 | #include "moc_qwaylanddestroylistener.cpp" |
42 |