1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the plugins of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QWAYLANDSCREEN_H
41#define QWAYLANDSCREEN_H
42
43//
44// W A R N I N G
45// -------------
46//
47// This file is not part of the Qt API. It exists purely as an
48// implementation detail. This header file may change from version to
49// version without notice, or even be removed.
50//
51// We mean it.
52//
53
54#include <qpa/qplatformscreen.h>
55#include <QtWaylandClient/qtwaylandclientglobal.h>
56
57#include <QtWaylandClient/private/qwayland-wayland.h>
58#include <QtWaylandClient/private/qwayland-xdg-output-unstable-v1.h>
59
60QT_BEGIN_NAMESPACE
61
62namespace QtWaylandClient {
63
64class QWaylandDisplay;
65class QWaylandCursor;
66
67class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgOutputManagerV1 : public QtWayland::zxdg_output_manager_v1 {
68public:
69 QWaylandXdgOutputManagerV1(QWaylandDisplay *display, uint id, uint version);
70 uint version() const { return m_version; }
71private:
72 uint m_version = 1; // TODO: remove when we upgrade minimum libwayland requriement to 1.10
73};
74
75class Q_WAYLAND_CLIENT_EXPORT QWaylandScreen : public QPlatformScreen, QtWayland::wl_output, QtWayland::zxdg_output_v1
76{
77public:
78 QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uint32_t id);
79 ~QWaylandScreen() override;
80
81 void maybeInitialize();
82
83 void initXdgOutput(QWaylandXdgOutputManagerV1 *xdgOutputManager);
84
85 QWaylandDisplay *display() const;
86
87 QString manufacturer() const override;
88 QString model() const override;
89
90 QRect geometry() const override;
91 int depth() const override;
92 QImage::Format format() const override;
93
94 QSizeF physicalSize() const override;
95
96 QDpi logicalDpi() const override;
97 QList<QPlatformScreen *> virtualSiblings() const override;
98
99 void setOrientationUpdateMask(Qt::ScreenOrientations mask) override;
100
101 Qt::ScreenOrientation orientation() const override;
102 int scale() const;
103 qreal devicePixelRatio() const override;
104 qreal refreshRate() const override;
105
106 QString name() const override { return mOutputName; }
107
108#if QT_CONFIG(cursor)
109 QPlatformCursor *cursor() const override;
110#endif
111
112 uint32_t outputId() const { return m_outputId; }
113 ::wl_output *output() { return QtWayland::wl_output::object(); }
114
115 static QWaylandScreen *waylandScreenFromWindow(QWindow *window);
116 static QWaylandScreen *fromWlOutput(::wl_output *output);
117
118private:
119 void output_mode(uint32_t flags, int width, int height, int refresh) override;
120 void output_geometry(int32_t x, int32_t y,
121 int32_t width, int32_t height,
122 int subpixel,
123 const QString &make,
124 const QString &model,
125 int32_t transform) override;
126 void output_scale(int32_t factor) override;
127 void output_done() override;
128 void updateOutputProperties();
129
130 // XdgOutput
131 void zxdg_output_v1_logical_position(int32_t x, int32_t y) override;
132 void zxdg_output_v1_logical_size(int32_t width, int32_t height) override;
133 void zxdg_output_v1_done() override;
134 void zxdg_output_v1_name(const QString &name) override;
135 void updateXdgOutputProperties();
136
137 int m_outputId;
138 QWaylandDisplay *mWaylandDisplay = nullptr;
139 QString mManufacturer;
140 QString mModel;
141 QRect mGeometry;
142 QRect mXdgGeometry;
143 int mScale = 1;
144 int mDepth = 32;
145 int mRefreshRate = 60000;
146 int mTransform = -1;
147 QImage::Format mFormat = QImage::Format_ARGB32_Premultiplied;
148 QSize mPhysicalSize;
149 QString mOutputName;
150 Qt::ScreenOrientation m_orientation = Qt::PrimaryOrientation;
151 bool mOutputDone = false;
152 bool mXdgOutputDone = false;
153 bool mInitialized = false;
154
155#if QT_CONFIG(cursor)
156 QScopedPointer<QWaylandCursor> mWaylandCursor;
157#endif
158};
159
160}
161
162QT_END_NAMESPACE
163
164#endif // QWAYLANDSCREEN_H
165

source code of qtwayland/src/client/qwaylandscreen_p.h