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 
21 #pragma once
22 #include "keyboard_shortcuts_inhibit.h"
23 #include "seat.h"
24 #include "surface.h"
25 
26 #include "wayland/global.h"
27 #include "wayland/resource.h"
28 
29 #include "wayland-keyboard-shortcuts-inhibit-server-protocol.h"
30 
31 namespace Wrapland::Server
32 {
33 
34 constexpr uint32_t KeyboardShortcutsInhibitManagerV1Version = 1;
35 using KeyboardShortcutsInhibitManagerV1Global
36     = Wayland::Global<KeyboardShortcutsInhibitManagerV1, KeyboardShortcutsInhibitManagerV1Version>;
37 using KeyboardShortcutsInhibitManagerV1Bind
38     = Wayland::Bind<KeyboardShortcutsInhibitManagerV1Global>;
39 
40 class KeyboardShortcutsInhibitManagerV1::Private : public KeyboardShortcutsInhibitManagerV1Global
41 {
42 public:
43     Private(Display* display, KeyboardShortcutsInhibitManagerV1* q);
44 
45     static void inhibitShortcutsCallback(KeyboardShortcutsInhibitManagerV1Bind* bind,
46                                          uint32_t id,
47                                          wl_resource* wlSurface,
48                                          wl_resource* wlSeat);
49 
50     KeyboardShortcutsInhibitorV1* findInhibitor(Surface* surface, Seat* seat) const;
51     void removeInhibitor(Surface* surface, Seat* seat);
52 
53     QHash<QPair<Surface*, Seat*>, KeyboardShortcutsInhibitorV1*> m_inhibitors;
54 
55 private:
56     static const struct zwp_keyboard_shortcuts_inhibit_manager_v1_interface s_interface;
57 };
58 
59 class KeyboardShortcutsInhibitorV1::Private : public Wayland::Resource<KeyboardShortcutsInhibitorV1>
60 {
61 public:
62     Private(Client* client,
63             uint32_t version,
64             uint32_t id,
65             Surface* surface,
66             Seat* seat,
67             KeyboardShortcutsInhibitorV1* q);
68 
69     Surface* m_surface;
70     Seat* m_seat;
71     bool m_active;
72 
73 private:
74     static const struct zwp_keyboard_shortcuts_inhibitor_v1_interface s_interface;
75 };
76 
77 }
78