summaryrefslogtreecommitdiff
path: root/src/imports/compositor-extensions/qtshell/qwaylandqtshell.h
blob: c1e6ed4143e2f023bbf9bd943a9c4ad0c8107f43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/****************************************************************************
**
** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:GPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 or (at your option) any later version
** approved by the KDE Free Qt Foundation. The licenses are as published by
** the Free Software Foundation and appearing in the file LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/

#ifndef QWAYLANDQTSHELL_H
#define QWAYLANDQTSHELL_H

#include <QtWaylandCompositor/QWaylandCompositorExtension>
#include <QtWaylandCompositor/QWaylandSurface>
#include <QtWaylandCompositor/QWaylandResource>
#include <QtCore/QSize>

#include <QtWaylandCompositor/QWaylandShellSurface>
#include <QtWaylandCompositor/qwaylandquickchildren.h>

struct wl_resource;
struct wl_interface;

QT_BEGIN_NAMESPACE

class QWaylandQtShellPrivate;
class QWaylandQtShellSurface;
class QWaylandQtShellChrome;

class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQtShell : public QWaylandCompositorExtensionTemplate<QWaylandQtShell>
{
    Q_OBJECT
    Q_DECLARE_PRIVATE(QWaylandQtShell)

public:
    QWaylandQtShell();
    QWaylandQtShell(QWaylandCompositor *compositor);

    void initialize() override;

    static const struct wl_interface *interface();
    static QByteArray interfaceName();

    void registerChrome(QWaylandQtShellChrome *chrome);
    void unregisterChrome(QWaylandQtShellChrome *chrome);

private Q_SLOTS:
    void chromeActivated();
    void chromeDeactivated();

Q_SIGNALS:
    void qtShellSurfaceRequested(QWaylandSurface *surface, const QWaylandResource &resource);
    void qtShellSurfaceCreated(QWaylandQtShellSurface *qtShellSurface);

private:
    bool moveChromeToFront(QWaylandQtShellChrome *chrome);
};


class QWaylandQtShellSurfacePrivate;
class QWaylandSurfaceRole;
class QWaylandResource;

class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQtShellSurface : public QWaylandShellSurfaceTemplate<QWaylandQtShellSurface>
{
    Q_OBJECT
    Q_DECLARE_PRIVATE(QWaylandQtShellSurface)
    Q_WAYLAND_COMPOSITOR_DECLARE_QUICK_CHILDREN(QWaylandQtShellSurface)
    Q_PROPERTY(QWaylandSurface *surface READ surface NOTIFY surfaceChanged)
    Q_PROPERTY(uint windowFlags READ windowFlags NOTIFY windowFlagsChanged)
    Q_PROPERTY(uint windowState READ windowState NOTIFY windowStateChanged)
    Q_PROPERTY(QString windowTitle READ windowTitle READ windowTitle NOTIFY windowTitleChanged)
    Q_PROPERTY(QRect windowGeometry READ windowGeometry NOTIFY windowGeometryChanged)
    Q_PROPERTY(QPoint windowPosition READ windowPosition WRITE setWindowPosition NOTIFY windowGeometryChanged)
    Q_PROPERTY(bool positionAutomatic READ positionAutomatic NOTIFY positionAutomaticChanged)
    Q_PROPERTY(QSize minimumSize READ minimumSize NOTIFY minimumSizeChanged)
    Q_PROPERTY(QSize maximumSize READ maximumSize NOTIFY maximumSizeChanged)
    Q_PROPERTY(int frameMarginLeft READ frameMarginLeft WRITE setFrameMarginLeft NOTIFY frameMarginChanged)
    Q_PROPERTY(int frameMarginRight READ frameMarginRight WRITE setFrameMarginRight NOTIFY frameMarginChanged)
    Q_PROPERTY(int frameMarginTop READ frameMarginTop WRITE setFrameMarginTop NOTIFY frameMarginChanged)
    Q_PROPERTY(int frameMarginBottom READ frameMarginBottom WRITE setFrameMarginBottom NOTIFY frameMarginChanged)
    Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged)
    Q_PROPERTY(CapabilityFlags capabilities READ capabilities WRITE setCapabilities NOTIFY capabilitiesChanged)
    Q_MOC_INCLUDE("qwaylandsurface.h")

public:
    // Matches the "capabilities" enum in the protocol xml
    enum CapabilityFlag {
        InteractiveMove = 1,
        InteractiveResize = 2
    };
    Q_DECLARE_FLAGS(CapabilityFlags, CapabilityFlag)
    Q_ENUM(CapabilityFlag)

    QWaylandQtShellSurface();
    QWaylandQtShellSurface(QWaylandQtShell *application, QWaylandSurface *surface, const QWaylandResource &resource);

    void initialize(QWaylandQtShell *qtShell, QWaylandSurface *surface,
                    const QWaylandResource &resource);

    QWaylandSurface *surface() const;

    static const wl_interface *interface();
    static QByteArray interfaceName();
    static QWaylandSurfaceRole *role();
    static QWaylandQtShellSurface *fromResource(::wl_resource *resource);

    QRect windowGeometry() const;

    void setWindowPosition(const QPoint &position);
    QPoint windowPosition() const;

    Q_INVOKABLE void requestWindowGeometry(uint windowState, const QRect &windowGeometry);

    QSize minimumSize() const;
    QSize maximumSize() const;

    void setFrameMargins(const QMargins &margins);

    int frameMarginLeft() const;
    void setFrameMarginLeft(int left);

    int frameMarginRight() const;
    void setFrameMarginRight(int right);

    int frameMarginTop() const;
    void setFrameMarginTop(int top);

    int frameMarginBottom() const;
    void setFrameMarginBottom(int bottom);

    bool positionAutomatic() const;

    bool active() const;
    void setActive(bool active);

    QString windowTitle() const;

    uint windowFlags() const;

    Q_INVOKABLE void sendClose();

    uint windowState() const;
    void setWindowState(uint windowState);
#if QT_CONFIG(wayland_compositor_quick)
    QWaylandQuickShellIntegration *createIntegration(QWaylandQuickShellSurfaceItem *item) override;
#endif

    CapabilityFlags capabilities() const;
    void setCapabilities(CapabilityFlags capabilities);

Q_SIGNALS:
    void surfaceChanged();
    void windowFlagsChanged();
    void windowStateChanged();
    void windowGeometryChanged();
    void minimumSizeChanged();
    void maximumSizeChanged();
    void positionAutomaticChanged();
    void startMove();
    void startResize(Qt::Edges edges);
    void windowTitleChanged();
    void frameMarginChanged();
    void raiseRequested();
    void lowerRequested();
    void activeChanged();
    void capabilitiesChanged();

private Q_SLOTS:
    void surfaceCommitted();

private:
    friend class QWaylandQtShellChrome;

    void initialize() override;

    QWaylandQtShell *shell() const;
};

QT_END_NAMESPACE

#endif // QWAYLANDQTSHELL_H