1 /*
2     SPDX-FileCopyrightText: 2021 Roman Gilg <subdiff@gmail.com>
3 
4     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only
5 */
6 #pragma once
7 
8 #include <Wrapland/Server/wraplandserver_export.h>
9 
10 #include <QMargins>
11 #include <QObject>
12 #include <QSize>
13 #include <memory>
14 
15 namespace Wrapland::Server
16 {
17 
18 class Client;
19 class Display;
20 class LayerSurfaceV1;
21 class Output;
22 class Surface;
23 class XdgShellPopup;
24 
25 class WRAPLANDSERVER_EXPORT LayerShellV1 : public QObject
26 {
27     Q_OBJECT
28 public:
29     ~LayerShellV1() override;
30 
31 Q_SIGNALS:
32     void surface_created(LayerSurfaceV1* surface);
33 
34 private:
35     explicit LayerShellV1(Display* display, QObject* parent = nullptr);
36     friend class Display;
37 
38     class Private;
39     std::unique_ptr<Private> d_ptr;
40 };
41 
42 class WRAPLANDSERVER_EXPORT LayerSurfaceV1 : public QObject
43 {
44     Q_OBJECT
45 public:
46     enum class Layer {
47         Background,
48         Bottom,
49         Top,
50         Overlay,
51     };
52     enum class KeyboardInteractivity {
53         None,
54         Exclusive,
55         OnDemand,
56     };
57 
58     Surface* surface() const;
59     Output* output() const;
60 
61     /**
62      * Compositor should set a fixed output on first commit if client did not specify one.
63      */
64     void set_output(Output* output);
65     std::string domain() const;
66 
67     QSize size() const;
68     Qt::Edges anchor() const;
69     QMargins margins() const;
70 
71     Layer layer() const;
72     KeyboardInteractivity keyboard_interactivity() const;
73 
74     int exclusive_zone() const;
75     Qt::Edge exclusive_edge() const;
76 
77     uint32_t configure(QSize const& size);
78     void close();
79 
80     bool change_pending() const;
81 
82 Q_SIGNALS:
83     void configure_acknowledged(quint32 serial);
84     void got_popup(Wrapland::Server::XdgShellPopup* popup);
85     void resourceDestroyed();
86 
87 private:
88     LayerSurfaceV1(Client* client,
89                    uint32_t version,
90                    uint32_t id,
91                    Surface* surface,
92                    Output* output,
93                    Layer layer,
94                    std::string domain);
95     friend class LayerShellV1;
96     friend class Surface;
97 
98     class Private;
99     Private* d_ptr;
100 };
101 
102 }
103