1 /*
2     SPDX-FileCopyrightText: 2020 Benjamin Port <benjamin.port@enioka.com>
3 
4     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5 */
6 
7 #pragma once
8 
9 #include "seat_interface.h"
10 #include "surface_interface.h"
11 #include <KWaylandServer/kwaylandserver_export.h>
12 #include <QObject>
13 
14 namespace KWaylandServer
15 {
16 /**
17  * This is an implementation of wayland-protocols/unstable/keyboard-shortcuts-inhibit/keyboard-shortcuts-inhibit-unstable-v1.xml
18  *
19  * This class is just the means to get a @class KeyboardShortcutsInhibitorV1Interface, which is
20  * the class that will have all of the information we need.
21  */
22 
23 class KeyboardShortcutsInhibitManagerV1Interface;
24 class KeyboardShortcutsInhibitorV1InterfacePrivate;
25 class KeyboardShortcutsInhibitManagerV1InterfacePrivate;
26 
27 class KWAYLANDSERVER_EXPORT KeyboardShortcutsInhibitorV1Interface : public QObject
28 {
29     Q_OBJECT
30 
31 public:
32     ~KeyboardShortcutsInhibitorV1Interface() override;
33 
34     SurfaceInterface *surface() const;
35     SeatInterface *seat() const;
36     void setActive(bool active);
37     bool isActive() const;
38 
39 private:
40     friend class KeyboardShortcutsInhibitManagerV1InterfacePrivate;
41     explicit KeyboardShortcutsInhibitorV1Interface(SurfaceInterface *surface,
42                                                    SeatInterface *seat,
43                                                    KeyboardShortcutsInhibitManagerV1Interface *manager,
44                                                    wl_resource *resource);
45     QScopedPointer<KeyboardShortcutsInhibitorV1InterfacePrivate> d;
46 };
47 
48 /**
49  * The KeyboardShortcutsInhibitManagerV1Interface allows clients to inhibit global shortcuts.
50  *
51  * KeyboardShortcutsInhibitManagerV1Interface correponds to the wayland interface zwp_keyboard_shortcuts_inhibit_manager_v1.
52  */
53 class KWAYLANDSERVER_EXPORT KeyboardShortcutsInhibitManagerV1Interface : public QObject
54 {
55     Q_OBJECT
56 
57 public:
58     explicit KeyboardShortcutsInhibitManagerV1Interface(Display *d, QObject *parent = nullptr);
59     ~KeyboardShortcutsInhibitManagerV1Interface() override;
60 
61     /**
62      * return shortucts inhibitor associated with surface and seat, if no shortcut are associated, return nullptr
63      */
64     KeyboardShortcutsInhibitorV1Interface *findInhibitor(SurfaceInterface *surface, SeatInterface *seat) const;
65 
66 Q_SIGNALS:
67     /**
68      * This signal is emitted when a keyboard shortcuts inhibitor @a inhibitor is created.
69      */
70     void inhibitorCreated(KeyboardShortcutsInhibitorV1Interface *inhibitor);
71 
72 private:
73     friend class KeyboardShortcutsInhibitorV1InterfacePrivate;
74     void removeInhibitor(SurfaceInterface *const surface, SeatInterface *const seat);
75     QScopedPointer<KeyboardShortcutsInhibitManagerV1InterfacePrivate> d;
76 };
77 
78 }
79