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 <QSize>
24 
25 #include <Wrapland/Server/wraplandserver_export.h>
26 
27 namespace Wrapland::Server
28 {
29 class Client;
30 class Seat;
31 class Surface;
32 class XdgShell;
33 
34 class WRAPLANDSERVER_EXPORT XdgShellSurface : public QObject
35 {
36     Q_OBJECT
37 public:
38     enum class State {
39         Maximized = 1 << 0,
40         Fullscreen = 1 << 1,
41         Resizing = 1 << 2,
42         Activated = 1 << 3,
43         TiledLeft = 1 << 4,
44         TiledRight = 1 << 5,
45         TiledTop = 1 << 6,
46         TiledBottom = 1 << 7,
47     };
48     Q_DECLARE_FLAGS(States, State)
49 
50     enum class ConstraintAdjustment {
51         SlideX = 1 << 0,
52         SlideY = 1 << 1,
53         FlipX = 1 << 2,
54         FlipY = 1 << 3,
55         ResizeX = 1 << 4,
56         ResizeY = 1 << 5,
57     };
58     Q_DECLARE_FLAGS(ConstraintAdjustments, ConstraintAdjustment)
59 
60     bool configurePending() const;
61 
62     Surface* surface() const;
63     void commit();
64 
65     QRect window_geometry() const;
66 
67     /**
68      * Relative to main surface even when no explicit window geometry is set. Then describes the
69      * margins between main surface and its expanse, i.e. it's union with all subsurfaces.
70      */
71     QMargins window_margins() const;
72 
73 Q_SIGNALS:
74     void window_geometry_changed(QRect const& windowGeometry);
75     void resourceDestroyed();
76 
77 private:
78     friend class Surface;
79     friend class XdgShell;
80     friend class XdgShellToplevel;
81     friend class XdgShellPopup;
82     XdgShellSurface(Client* client,
83                     uint32_t version,
84                     uint32_t id,
85                     XdgShell* shell,
86                     Surface* surface);
87 
88     class Private;
89     Private* d_ptr;
90 };
91 
92 }
93 
94 Q_DECLARE_METATYPE(Wrapland::Server::XdgShellSurface*)
95 Q_DECLARE_METATYPE(Wrapland::Server::XdgShellSurface::State)
96 Q_DECLARE_METATYPE(Wrapland::Server::XdgShellSurface::States)
97 Q_DECLARE_OPERATORS_FOR_FLAGS(Wrapland::Server::XdgShellSurface::ConstraintAdjustments)
98