Debian Codegraph @

xcb/libqt6xcbqpa-dev/6.2.4/qxcbscreen.h

raw
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 QXCBSCREEN_H
41 #define QXCBSCREEN_H
42
43 #include <qpa/qplatformscreen.h>
44 #include <qpa/qplatformscreen_p.h>
45 #include <QtCore/QString>
46
47 #include <xcb/xcb.h>
48 #include <xcb/randr.h>
49 #include <xcb/xfixes.h>
50
51 #include "qxcbobject.h"
52
53 #include <private/qfontengine_p.h>
54
55 #include <QtGui/private/qedidparser_p.h>
56
57 QT_BEGIN_NAMESPACE
58
59 class QXcbConnection;
60 class QXcbCursor;
61 class QXcbXSettings;
62 #ifndef QT_NO_DEBUG_STREAM
63 class QDebug;
64 #endif
65
66 class QXcbVirtualDesktop : public QXcbObject
67 {
68 public:
69 QXcbVirtualDesktop(QXcbConnection *connection, xcb_screen_t *screen, int number);
70 ~QXcbVirtualDesktop();
71
72 xcb_screen_t *screen() const { return m_screen; }
73 int number() const { return m_number; }
74 QSize size() const { return QSize(m_screen->width_in_pixels, m_screen->height_in_pixels); }
75 QSize physicalSize() const { return QSize(m_screen->width_in_millimeters, m_screen->height_in_millimeters); }
76 QDpi dpi() const;
77 xcb_window_t root() const { return m_screen->root; }
78 QXcbScreen *screenAt(const QPoint &pos) const;
79
80 QList<QPlatformScreen *> screens() const { return m_screens; }
81 void setScreens(QList<QPlatformScreen *> &&sl) { m_screens = std::move(sl); }
82 void removeScreen(QPlatformScreen *s) { m_screens.removeOne(s); }
83 void addScreen(QPlatformScreen *s);
84 void setPrimaryScreen(QPlatformScreen *s);
85
86 QXcbXSettings *xSettings() const;
87
88 bool compositingActive() const;
89
90 void updateWorkArea();
91 QRect availableGeometry(const QRect &screenGeometry) const;
92
93 void handleXFixesSelectionNotify(xcb_xfixes_selection_notify_event_t *notify_event);
94 void subscribeToXFixesSelectionNotify();
95
96 void handleScreenChange(xcb_randr_screen_change_notify_event_t *change_event);
97
98 int forcedDpi() const { return m_forcedDpi; }
99 QFontEngine::HintStyle hintStyle() const { return m_hintStyle; }
100 QFontEngine::SubpixelAntialiasingType subpixelType() const { return m_subpixelType; }
101 int antialiasingEnabled() const { return m_antialiasingEnabled; }
102
103 QString windowManagerName() const { return m_windowManagerName; }
104
105 QSurfaceFormat surfaceFormatFor(const QSurfaceFormat &format) const;
106
107 const xcb_visualtype_t *visualForFormat(const QSurfaceFormat &format) const;
108 const xcb_visualtype_t *visualForId(xcb_visualid_t) const;
109 quint8 depthOfVisual(xcb_visualid_t) const;
110 xcb_colormap_t colormapForVisual(xcb_visualid_t) const;
111
112 private:
113 QRect getWorkArea() const;
114
115 static bool xResource(const QByteArray &identifier,
116 const QByteArray &expectedIdentifier,
117 QByteArray &stringValue);
118 void readXResources();
119
120 bool setDpiFromXSettings(const QVariant &property);
121
122 xcb_screen_t *m_screen;
123 const int m_number;
124 QList<QPlatformScreen *> m_screens;
125
126 QXcbXSettings *m_xSettings = nullptr;
127 xcb_atom_t m_net_wm_cm_atom = 0;
128 bool m_compositingActive = false;
129
130 QRect m_workArea;
131
132 int m_forcedDpi = -1;
133 QFontEngine::HintStyle m_hintStyle = QFontEngine::HintStyle(-1);
134 QFontEngine::SubpixelAntialiasingType m_subpixelType = QFontEngine::SubpixelAntialiasingType(-1);
135 int m_antialiasingEnabled = -1;
136 QString m_windowManagerName;
137 QMap<xcb_visualid_t, xcb_visualtype_t> m_visuals;
138 QMap<xcb_visualid_t, quint8> m_visualDepths;
139 mutable QMap<xcb_visualid_t, xcb_colormap_t> m_visualColormaps;
140 uint16_t m_rotation = 0;
141 };
142
143 class Q_XCB_EXPORT QXcbScreen : public QXcbObject, public QPlatformScreen
144 , public QNativeInterface::Private::QXcbScreen
145 {
146 public:
147 QXcbScreen(QXcbConnection *connection, QXcbVirtualDesktop *virtualDesktop,
148 xcb_randr_output_t outputId, xcb_randr_get_output_info_reply_t *outputInfo);
149 ~QXcbScreen();
150
151 QString getOutputName(xcb_randr_get_output_info_reply_t *outputInfo);
152
153 QPixmap grabWindow(WId window, int x, int y, int width, int height) const override;
154
155 QWindow *topLevelAt(const QPoint &point) const override;
156
157 QString manufacturer() const override;
158 QString model() const override;
159 QString serialNumber() const override;
160
161 QRect geometry() const override { return m_geometry; }
162 QRect availableGeometry() const override;
163 int depth() const override { return screen()->root_depth; }
164 QImage::Format format() const override;
165 QColorSpace colorSpace() const override { return m_colorSpace; }
166 QSizeF physicalSize() const override { return m_sizeMillimeters; }
167 QDpi logicalDpi() const override;
168 QDpi logicalBaseDpi() const override { return QDpi(96, 96); }
169 QPlatformCursor *cursor() const override;
170 qreal refreshRate() const override { return m_refreshRate; }
171 Qt::ScreenOrientation orientation() const override { return m_orientation; }
172 QList<QPlatformScreen *> virtualSiblings() const override { return m_virtualDesktop->screens(); }
173 QXcbVirtualDesktop *virtualDesktop() const { return m_virtualDesktop; }
174
175 void setPrimary(bool primary) { m_primary = primary; }
176 bool isPrimary() const { return m_primary; }
177
178 int screenNumber() const { return m_virtualDesktop->number(); }
179 int virtualDesktopNumber() const override { return screenNumber(); }
180
181 xcb_screen_t *screen() const { return m_virtualDesktop->screen(); }
182 xcb_window_t root() const { return screen()->root; }
183 xcb_randr_output_t output() const { return m_output; }
184 xcb_randr_crtc_t crtc() const { return m_crtc; }
185 xcb_randr_mode_t mode() const { return m_mode; }
186
187 void setOutput(xcb_randr_output_t outputId,
188 xcb_randr_get_output_info_reply_t *outputInfo);
189 void setCrtc(xcb_randr_crtc_t crtc) { m_crtc = crtc; }
190
191 void windowShown(QXcbWindow *window);
192 QString windowManagerName() const { return m_virtualDesktop->windowManagerName(); }
193
194 QSurfaceFormat surfaceFormatFor(const QSurfaceFormat &format) const;
195
196 const xcb_visualtype_t *visualForFormat(const QSurfaceFormat &format) const { return m_virtualDesktop->visualForFormat(format); }
197 const xcb_visualtype_t *visualForId(xcb_visualid_t visualid) const;
198 xcb_colormap_t colormapForVisual(xcb_visualid_t visualid) const { return m_virtualDesktop->colormapForVisual(visualid); }
199 quint8 depthOfVisual(xcb_visualid_t visualid) const { return m_virtualDesktop->depthOfVisual(visualid); }
200
201 QString name() const override { return m_outputName; }
202
203 void updateGeometry(const QRect &geometry, uint8_t rotation);
204 void updateGeometry(xcb_timestamp_t timestamp = XCB_TIME_CURRENT_TIME);
205 void updateAvailableGeometry();
206 void updateRefreshRate(xcb_randr_mode_t mode);
207
208 QFontEngine::HintStyle hintStyle() const { return m_virtualDesktop->hintStyle(); }
209 QFontEngine::SubpixelAntialiasingType subpixelType() const { return m_virtualDesktop->subpixelType(); }
210 int antialiasingEnabled() const { return m_virtualDesktop->antialiasingEnabled(); }
211
212 QXcbXSettings *xSettings() const;
213
214 private:
215 void sendStartupMessage(const QByteArray &message) const;
216 int forcedDpi() const;
217
218 QByteArray getOutputProperty(xcb_atom_t atom) const;
219 QByteArray getEdid() const;
220
221 QXcbVirtualDesktop *m_virtualDesktop;
222 xcb_randr_output_t m_output;
223 xcb_randr_crtc_t m_crtc;
224 xcb_randr_mode_t m_mode = XCB_NONE;
225 bool m_primary = false;
226
227 QString m_outputName;
228 QSizeF m_outputSizeMillimeters;
229 QSizeF m_sizeMillimeters;
230 QRect m_geometry;
231 QRect m_availableGeometry;
232 QColorSpace m_colorSpace;
233 Qt::ScreenOrientation m_orientation = Qt::PrimaryOrientation;
234 QXcbCursor *m_cursor;
235 qreal m_refreshRate = 60.0;
236 QEdidParser m_edid;
237 };
238
239 #ifndef QT_NO_DEBUG_STREAM
240 Q_GUI_EXPORT QDebug operator<<(QDebug, const QXcbScreen *);
241 #endif
242
243 QT_END_NAMESPACE
244
245 #endif