1 | // Copyright (C) 2017-2016 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> |
---|---|
2 | // Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB). |
3 | // Copyright (C) 2017 The Qt Company Ltd. |
4 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
5 | |
6 | #ifndef QWAYLANDOUTPUT_P_H |
7 | #define QWAYLANDOUTPUT_P_H |
8 | |
9 | // |
10 | // W A R N I N G |
11 | // ------------- |
12 | // |
13 | // This file is not part of the Qt API. It exists purely as an |
14 | // implementation detail. This header file may change from version to |
15 | // version without notice, or even be removed. |
16 | // |
17 | // We mean it. |
18 | // |
19 | |
20 | #include <QtWaylandCompositor/qtwaylandcompositorglobal.h> |
21 | #include <QtWaylandCompositor/QWaylandOutput> |
22 | #include <QtWaylandCompositor/QWaylandClient> |
23 | #include <QtWaylandCompositor/QWaylandSurface> |
24 | #include <QtWaylandCompositor/QWaylandXdgOutputV1> |
25 | |
26 | #include <QtWaylandCompositor/private/qwayland-server-wayland.h> |
27 | |
28 | #include <QtCore/QList> |
29 | #include <QtCore/QRect> |
30 | |
31 | #include <QtCore/private/qobject_p.h> |
32 | |
33 | QT_BEGIN_NAMESPACE |
34 | |
35 | struct QWaylandSurfaceViewMapper |
36 | { |
37 | QWaylandSurfaceViewMapper() |
38 | {} |
39 | |
40 | QWaylandSurfaceViewMapper(QWaylandSurface *s, QWaylandView *v) |
41 | : surface(s) |
42 | , views(1, v) |
43 | {} |
44 | |
45 | QWaylandView *maybePrimaryView() const |
46 | { |
47 | for (int i = 0; i < views.size(); i++) { |
48 | if (surface && surface->primaryView() == views.at(i)) |
49 | return views.at(i); |
50 | } |
51 | return nullptr; |
52 | } |
53 | |
54 | QWaylandSurface *surface = nullptr; |
55 | QList<QWaylandView *> views; |
56 | bool has_entered = false; |
57 | }; |
58 | |
59 | class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandOutputPrivate : public QObjectPrivate, public QtWaylandServer::wl_output |
60 | { |
61 | public: |
62 | Q_DECLARE_PUBLIC(QWaylandOutput) |
63 | |
64 | QWaylandOutputPrivate(); |
65 | |
66 | ~QWaylandOutputPrivate() override; |
67 | static QWaylandOutputPrivate *get(QWaylandOutput *output) { return output->d_func(); } |
68 | |
69 | void addView(QWaylandView *view, QWaylandSurface *surface); |
70 | void removeView(QWaylandView *view, QWaylandSurface *surface); |
71 | |
72 | void sendGeometry(const Resource *resource); |
73 | void sendGeometryInfo(); |
74 | |
75 | void sendMode(const Resource *resource, const QWaylandOutputMode &mode); |
76 | void sendModesInfo(); |
77 | |
78 | void handleWindowPixelSizeChanged(); |
79 | |
80 | QPointer<QWaylandXdgOutputV1> xdgOutput; |
81 | |
82 | protected: |
83 | void output_bind_resource(Resource *resource) override; |
84 | |
85 | private: |
86 | void _q_handleMaybeWindowPixelSizeChanged(); |
87 | void _q_handleWindowDestroyed(); |
88 | |
89 | QWaylandCompositor *compositor = nullptr; |
90 | QWindow *window = nullptr; |
91 | QString manufacturer; |
92 | QString model; |
93 | QPoint position; |
94 | QList<QWaylandOutputMode> modes; |
95 | int currentMode = -1; |
96 | int preferredMode = -1; |
97 | QRect availableGeometry; |
98 | QList<QWaylandSurfaceViewMapper> surfaceViews; |
99 | QSize physicalSize; |
100 | QWaylandOutput::Subpixel subpixel = QWaylandOutput::SubpixelUnknown; |
101 | QWaylandOutput::Transform transform = QWaylandOutput::TransformNormal; |
102 | int scaleFactor = 1; |
103 | bool sizeFollowsWindow = false; |
104 | bool initialized = false; |
105 | QSize windowPixelSize; |
106 | |
107 | Q_DISABLE_COPY(QWaylandOutputPrivate) |
108 | |
109 | friend class QWaylandXdgOutputManagerV1Private; |
110 | }; |
111 | |
112 | |
113 | QT_END_NAMESPACE |
114 | |
115 | #endif /*QWAYLANDOUTPUT_P_H*/ |
116 |