1 /****************************************************************************
2 Copyright 2020  Faveraux Adrien <ad1rie3@hotmail.fr>
3 
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) version 3, or any
8 later version accepted by the membership of KDE e.V. (or its
9 successor approved by the membership of KDE e.V.), which shall
10 act as a proxy defined in Section 6 of version 3 of the license.
11 
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 Lesser General Public License for more details.
16 
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library.  If not, see <http://www.gnu.org/licenses/>.
19 ****************************************************************************/
20 #include "idle_inhibit_v1_p.h"
21 
22 namespace Wrapland::Server
23 {
24 
25 const struct zwp_idle_inhibit_manager_v1_interface IdleInhibitManagerV1::Private::s_interface = {
26     resourceDestroyCallback,
27     cb<createInhibitorCallback>,
28 };
29 
Private(Display * display,IdleInhibitManagerV1 * q)30 IdleInhibitManagerV1::Private::Private(Display* display, IdleInhibitManagerV1* q)
31     : Wayland::Global<IdleInhibitManagerV1>(q,
32                                             display,
33                                             &zwp_idle_inhibit_manager_v1_interface,
34                                             &s_interface)
35 {
36     create();
37 }
38 IdleInhibitManagerV1::Private::~Private() = default;
39 
createInhibitorCallback(IdleInhibitManagerV1Bind * bind,uint32_t id,wl_resource * wlSurface)40 void IdleInhibitManagerV1::Private::createInhibitorCallback(IdleInhibitManagerV1Bind* bind,
41                                                             uint32_t id,
42                                                             wl_resource* wlSurface)
43 {
44     auto surface = Wayland::Resource<Surface>::handle(wlSurface);
45     auto inhibitor = new IdleInhibitor(bind->client()->handle(), bind->version(), id);
46 
47     surface->d_ptr->installIdleInhibitor(inhibitor);
48 }
49 
IdleInhibitManagerV1(Display * display,QObject * parent)50 IdleInhibitManagerV1::IdleInhibitManagerV1(Display* display, QObject* parent)
51     : QObject(parent)
52     , d_ptr(new Private(display, this))
53 
54 {
55 }
56 
57 IdleInhibitManagerV1::~IdleInhibitManagerV1() = default;
58 
59 const struct zwp_idle_inhibitor_v1_interface IdleInhibitor::Private::s_interface
60     = {destroyCallback};
61 
Private(Client * client,uint32_t version,uint32_t id,IdleInhibitor * q)62 IdleInhibitor::Private::Private(Client* client, uint32_t version, uint32_t id, IdleInhibitor* q)
63     : Wayland::Resource<IdleInhibitor>(client,
64                                        version,
65                                        id,
66                                        &zwp_idle_inhibitor_v1_interface,
67                                        &s_interface,
68                                        q)
69 {
70 }
71 
72 IdleInhibitor::Private::~Private() = default;
73 
IdleInhibitor(Client * client,uint32_t version,uint32_t id)74 IdleInhibitor::IdleInhibitor(Client* client, uint32_t version, uint32_t id)
75     : d_ptr(new Private(client, version, id, this))
76 {
77 }
78 IdleInhibitor::~IdleInhibitor() = default;
79 }
80