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 #pragma once
21 
22 #include "display.h"
23 #include "idle_inhibit_v1.h"
24 #include "surface_p.h"
25 
26 #include "wayland/global.h"
27 #include "wayland/resource.h"
28 
29 #include <wayland-idle-inhibit-unstable-v1-server-protocol.h>
30 
31 namespace Wrapland::Server
32 {
33 
34 constexpr uint32_t IdleInhibitManagerV1Version = 1;
35 using IdleInhibitManagerV1Global
36     = Wayland::Global<IdleInhibitManagerV1, IdleInhibitManagerV1Version>;
37 using IdleInhibitManagerV1Bind = Wayland::Bind<IdleInhibitManagerV1Global>;
38 
39 class IdleInhibitManagerV1::Private : public IdleInhibitManagerV1Global
40 {
41 public:
42     Private(Display* display, IdleInhibitManagerV1* q);
43     ~Private() override;
44 
45 private:
46     static void
47     createInhibitorCallback(IdleInhibitManagerV1Bind* bind, uint32_t id, wl_resource* surface);
48 
49     static const struct zwp_idle_inhibit_manager_v1_interface s_interface;
50 };
51 
52 class WRAPLANDSERVER_EXPORT IdleInhibitor : public QObject
53 {
54     Q_OBJECT
55 public:
56     explicit IdleInhibitor(Client* client, uint32_t version, uint32_t id);
57     friend class IdleInhibitManagerV1;
58     ~IdleInhibitor() override;
59     class Private;
60     Private* d_ptr;
61 Q_SIGNALS:
62     void resourceDestroyed();
63 };
64 
65 class IdleInhibitor::Private : public Wayland::Resource<IdleInhibitor>
66 {
67 public:
68     Private(Client* client, uint32_t version, uint32_t id, IdleInhibitor* q);
69     ~Private() override;
70 
71 private:
72     static const struct zwp_idle_inhibitor_v1_interface s_interface;
73 };
74 
75 }
76