1 /****************************************************************************
2 Copyright © 2020 Roman Gilg <subdiff@gmail.com>
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 <QObject>
23 #include <QRegion>
24 
25 #include <Wrapland/Server/wraplandserver_export.h>
26 #include <memory>
27 
28 namespace Wrapland::Server
29 {
30 class Client;
31 class Display;
32 class Pointer;
33 
34 class WRAPLANDSERVER_EXPORT PointerConstraintsV1 : public QObject
35 {
36     Q_OBJECT
37 public:
38     ~PointerConstraintsV1() override;
39 
40 private:
41     friend class Display;
42     explicit PointerConstraintsV1(Display* display, QObject* parent = nullptr);
43 
44     class Private;
45     std::unique_ptr<Private> d_ptr;
46 };
47 
48 class WRAPLANDSERVER_EXPORT LockedPointerV1 : public QObject
49 {
50     Q_OBJECT
51 public:
52     enum class LifeTime {
53         OneShot,
54         Persistent,
55     };
56 
57     LifeTime lifeTime() const;
58     QRegion region() const;
59     QPointF cursorPositionHint() const;
60     bool isLocked() const;
61     void setLocked(bool locked);
62 
63 Q_SIGNALS:
64     void resourceDestroyed();
65     void regionChanged();
66     void cursorPositionHintChanged();
67     void lockedChanged();
68 
69 private:
70     friend class PointerConstraintsV1;
71     friend class Surface;
72     LockedPointerV1(Client* client,
73                     uint32_t version,
74                     uint32_t id,
75                     PointerConstraintsV1* constraints);
76 
77     class Private;
78     Private* d_ptr;
79 };
80 
81 class WRAPLANDSERVER_EXPORT ConfinedPointerV1 : public QObject
82 {
83     Q_OBJECT
84 public:
85     enum class LifeTime {
86         OneShot,
87         Persistent,
88     };
89 
90     LifeTime lifeTime() const;
91     QRegion region() const;
92     bool isConfined() const;
93     void setConfined(bool confined);
94 
95 Q_SIGNALS:
96     void resourceDestroyed();
97     void regionChanged();
98     void confinedChanged();
99 
100 private:
101     friend class PointerConstraintsV1;
102     friend class Surface;
103     ConfinedPointerV1(Client* client,
104                       uint32_t version,
105                       uint32_t id,
106                       PointerConstraintsV1* constraints);
107 
108     class Private;
109     Private* d_ptr;
110 };
111 
112 }
113