qxcbscreen.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/plugins/platforms/xcb/qxcbscreen.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
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#include "qxcbscreen.h"-
41#include "qxcbwindow.h"-
42#include "qxcbcursor.h"-
43#include "qxcbimage.h"-
44#include "qnamespace.h"-
45#include "qxcbxsettings.h"-
46-
47#include <stdio.h>-
48-
49#include <QDebug>-
50#include <QtAlgorithms>-
51-
52#include <qpa/qwindowsysteminterface.h>-
53#include <private/qmath_p.h>-
54#include <QtGui/private/qhighdpiscaling_p.h>-
55-
56QT_BEGIN_NAMESPACE-
57-
58QXcbVirtualDesktop::QXcbVirtualDesktop(QXcbConnection *connection, xcb_screen_t *screen, int number)-
59 : QXcbObject(connection)-
60 , m_screen(screen)-
61 , m_number(number)-
62 , m_xSettings(Q_NULLPTR)-
63{-
64 QByteArray cmAtomName("_NET_WM_CM_S");-
65 cmAtomName += QByteArray::number(m_number);-
66 m_net_wm_cm_atom = connection->internAtom(cmAtomName.constData());-
67 m_compositingActive = connection->getSelectionOwner(m_net_wm_cm_atom);-
68-
69 m_workArea = getWorkArea();-
70}-
71-
72QXcbVirtualDesktop::~QXcbVirtualDesktop()-
73{-
74 delete m_xSettings;-
75}-
76-
77QXcbScreen *QXcbVirtualDesktop::screenAt(const QPoint &pos) const-
78{-
79 foreachconst auto screens = connection()->screens();-
80 for (QXcbScreen *screen , connection()->: screens())) {-
81 if (screen->virtualDesktop() == this && screen->geometry().contains(pos))
screen->virtua...ktop() == thisDescription
TRUEnever evaluated
FALSEnever evaluated
screen->geomet....contains(pos)Description
TRUEnever evaluated
FALSEnever evaluated
0
82 return screen;
never executed: return screen;
0
83 }
never executed: end of block
0
84 return Q_NULLPTR;
never executed: return nullptr;
0
85}-
86-
87void QXcbVirtualDesktop::addScreen(QPlatformScreen *s)-
88{-
89 ((QXcbScreen *) s)->isPrimary() ? m_screens.prepend(s) : m_screens.append(s);-
90}-
91-
92void QXcbVirtualDesktop::setPrimaryScreen(QPlatformScreen *s)-
93{-
94 const int idx = m_screens.indexOf(s);-
95 Q_ASSERT(idx > -1);-
96 m_screens.swap(0, idx);-
97}-
98-
99QXcbXSettings *QXcbVirtualDesktop::xSettings() const-
100{-
101 if (!m_xSettings) {-
102 QXcbVirtualDesktop *self = const_cast<QXcbVirtualDesktop *>(this);-
103 self->m_xSettings = new QXcbXSettings(self);-
104 }-
105 return m_xSettings;-
106}-
107-
108bool QXcbVirtualDesktop::compositingActive() const-
109{-
110 if (connection()->hasXFixes())-
111 return m_compositingActive;-
112 else-
113 return connection()->getSelectionOwner(m_net_wm_cm_atom);-
114}-
115-
116void QXcbVirtualDesktop::handleXFixesSelectionNotify(xcb_xfixes_selection_notify_event_t *notify_event)-
117{-
118 if (notify_event->selection == m_net_wm_cm_atom)-
119 m_compositingActive = notify_event->owner;-
120}-
121-
122void QXcbVirtualDesktop::subscribeToXFixesSelectionNotify()-
123{-
124 if (connection()->hasXFixes()) {-
125 const uint32_t mask = XCB_XFIXES_SELECTION_EVENT_MASK_SET_SELECTION_OWNER |-
126 XCB_XFIXES_SELECTION_EVENT_MASK_SELECTION_WINDOW_DESTROY |-
127 XCB_XFIXES_SELECTION_EVENT_MASK_SELECTION_CLIENT_CLOSE;-
128 Q_XCB_CALL(xcb_xfixes_select_selection_input_checked(xcb_connection(), connection()->getQtSelectionOwner(), m_net_wm_cm_atom, mask));-
129 }-
130}-
131-
132QRect QXcbVirtualDesktop::getWorkArea() const-
133{-
134 QRect r;-
135 xcb_get_property_reply_t * workArea =-
136 xcb_get_property_reply(xcb_connection(),-
137 xcb_get_property_unchecked(xcb_connection(), false, screen()->root,-
138 atom(QXcbAtom::_NET_WORKAREA),-
139 XCB_ATOM_CARDINAL, 0, 1024), NULL);-
140 if (workArea && workArea->type == XCB_ATOM_CARDINAL && workArea->format == 32 && workArea->value_len >= 4) {-
141 // If workArea->value_len > 4, the remaining ones seem to be for WM's virtual desktops-
142 // (don't mess with QXcbVirtualDesktop which represents an X screen).-
143 // But QScreen doesn't know about that concept. In reality there could be a-
144 // "docked" panel (with _NET_WM_STRUT_PARTIAL atom set) on just one desktop.-
145 // But for now just assume the first 4 values give us the geometry of the-
146 // "work area", AKA "available geometry"-
147 uint32_t *geom = (uint32_t*)xcb_get_property_value(workArea);-
148 r = QRect(geom[0], geom[1], geom[2], geom[3]);-
149 } else {-
150 r = QRect(QPoint(), size());-
151 }-
152 free(workArea);-
153 return r;-
154}-
155-
156void QXcbVirtualDesktop::updateWorkArea()-
157{-
158 QRect workArea = getWorkArea();-
159 if (m_workArea != workArea) {
m_workArea != workAreaDescription
TRUEnever evaluated
FALSEnever evaluated
0
160 m_workArea = workArea;-
161 foreachfor (QPlatformScreen *screen ,: qAsConst(m_screens)))-
162 ((QXcbScreen *)screen)->updateAvailableGeometry();
never executed: ((QXcbScreen *)screen)->updateAvailableGeometry();
0
163 }
never executed: end of block
0
164}
never executed: end of block
0
165-
166static inline QSizeF sizeInMillimeters(const QSize &size, const QDpi &dpi)-
167{-
168 return QSizeF(Q_MM_PER_INCH * size.width() / dpi.first,-
169 Q_MM_PER_INCH * size.height() / dpi.second);-
170}-
171-
172QXcbScreen::QXcbScreen(QXcbConnection *connection, QXcbVirtualDesktop *virtualDesktop,-
173 xcb_randr_output_t outputId, xcb_randr_get_output_info_reply_t *output,-
174 const xcb_xinerama_screen_info_t *xineramaScreenInfo, int xineramaScreenIdx)-
175 : QXcbObject(connection)-
176 , m_virtualDesktop(virtualDesktop)-
177 , m_output(outputId)-
178 , m_crtc(output ? output->crtc : XCB_NONE)-
179 , m_mode(XCB_NONE)-
180 , m_primary(false)-
181 , m_rotation(XCB_RANDR_ROTATION_ROTATE_0)-
182 , m_outputName(getOutputName(output))-
183 , m_outputSizeMillimeters(output ? QSize(output->mm_width, output->mm_height) : QSize())-
184 , m_virtualSize(virtualDesktop->size())-
185 , m_virtualSizeMillimeters(virtualDesktop->physicalSize())-
186 , m_orientation(Qt::PrimaryOrientation)-
187 , m_refreshRate(60)-
188 , m_forcedDpi(-1)-
189 , m_pixelDensity(1)-
190 , m_hintStyle(QFontEngine::HintStyle(-1))-
191 , m_noFontHinting(false)-
192 , m_subpixelType(QFontEngine::SubpixelAntialiasingType(-1))-
193 , m_antialiasingEnabled(-1)-
194{-
195 if (connection->hasXRandr()) {-
196 xcb_randr_select_input(xcb_connection(), screen()->root, true);-
197 xcb_randr_get_crtc_info_cookie_t crtcCookie =-
198 xcb_randr_get_crtc_info_unchecked(xcb_connection(), m_crtc, output ? output->timestamp : 0);-
199 xcb_randr_get_crtc_info_reply_t *crtc =-
200 xcb_randr_get_crtc_info_reply(xcb_connection(), crtcCookie, NULL);-
201 if (crtc) {-
202 updateGeometry(QRect(crtc->x, crtc->y, crtc->width, crtc->height), crtc->rotation);-
203 updateRefreshRate(crtc->mode);-
204 free(crtc);-
205 }-
206 } else if (xineramaScreenInfo) {-
207 m_geometry = QRect(xineramaScreenInfo->x_org, xineramaScreenInfo->y_org,-
208 xineramaScreenInfo->width, xineramaScreenInfo->height);-
209 m_availableGeometry = m_geometry & m_virtualDesktop->workArea();-
210 m_sizeMillimeters = sizeInMillimeters(m_geometry.size(), virtualDpi());-
211 if (xineramaScreenIdx > -1)-
212 m_outputName += QLatin1Char('-') + QString::number(xineramaScreenIdx);-
213 }-
214-
215 if (m_geometry.isEmpty())-
216 m_geometry = QRect(QPoint(), m_virtualSize);-
217-
218 if (m_availableGeometry.isEmpty())-
219 m_availableGeometry = m_geometry & m_virtualDesktop->workArea();-
220-
221 if (m_sizeMillimeters.isEmpty())-
222 m_sizeMillimeters = m_virtualSizeMillimeters;-
223-
224 readXResources();-
225-
226 QScopedPointer<xcb_get_window_attributes_reply_t, QScopedPointerPodDeleter> rootAttribs(-
227 xcb_get_window_attributes_reply(xcb_connection(),-
228 xcb_get_window_attributes_unchecked(xcb_connection(), screen()->root), NULL));-
229 const quint32 existingEventMask = rootAttribs.isNull() ? 0 : rootAttribs->your_event_mask;-
230-
231 const quint32 mask = XCB_CW_EVENT_MASK;-
232 const quint32 values[] = {-
233 // XCB_CW_EVENT_MASK-
234 XCB_EVENT_MASK_ENTER_WINDOW-
235 | XCB_EVENT_MASK_LEAVE_WINDOW-
236 | XCB_EVENT_MASK_PROPERTY_CHANGE-
237 | XCB_EVENT_MASK_STRUCTURE_NOTIFY // for the "MANAGER" atom (system tray notification).-
238 | existingEventMask // don't overwrite the event mask on the root window-
239 };-
240-
241 xcb_change_window_attributes(xcb_connection(), screen()->root, mask, values);-
242-
243 xcb_get_property_reply_t *reply =-
244 xcb_get_property_reply(xcb_connection(),-
245 xcb_get_property_unchecked(xcb_connection(), false, screen()->root,-
246 atom(QXcbAtom::_NET_SUPPORTING_WM_CHECK),-
247 XCB_ATOM_WINDOW, 0, 1024), NULL);-
248-
249 if (reply && reply->format == 32 && reply->type == XCB_ATOM_WINDOW) {-
250 xcb_window_t windowManager = *((xcb_window_t *)xcb_get_property_value(reply));-
251-
252 if (windowManager != XCB_WINDOW_NONE) {-
253 xcb_get_property_reply_t *windowManagerReply =-
254 xcb_get_property_reply(xcb_connection(),-
255 xcb_get_property_unchecked(xcb_connection(), false, windowManager,-
256 atom(QXcbAtom::_NET_WM_NAME),-
257 atom(QXcbAtom::UTF8_STRING), 0, 1024), NULL);-
258 if (windowManagerReply && windowManagerReply->format == 8 && windowManagerReply->type == atom(QXcbAtom::UTF8_STRING)) {-
259 m_windowManagerName = QString::fromUtf8((const char *)xcb_get_property_value(windowManagerReply), xcb_get_property_value_length(windowManagerReply));-
260 }-
261-
262 free(windowManagerReply);-
263 }-
264 }-
265 free(reply);-
266-
267 const xcb_query_extension_reply_t *sync_reply = xcb_get_extension_data(xcb_connection(), &xcb_sync_id);-
268 if (!sync_reply || !sync_reply->present)-
269 m_syncRequestSupported = false;-
270 else-
271 m_syncRequestSupported = true;-
272-
273 xcb_depth_iterator_t depth_iterator =-
274 xcb_screen_allowed_depths_iterator(screen());-
275-
276 while (depth_iterator.rem) {-
277 xcb_depth_t *depth = depth_iterator.data;-
278 xcb_visualtype_iterator_t visualtype_iterator =-
279 xcb_depth_visuals_iterator(depth);-
280-
281 while (visualtype_iterator.rem) {-
282 xcb_visualtype_t *visualtype = visualtype_iterator.data;-
283 m_visuals.insert(visualtype->visual_id, *visualtype);-
284 m_visualDepths.insert(visualtype->visual_id, depth->depth);-
285 xcb_visualtype_next(&visualtype_iterator);-
286 }-
287-
288 xcb_depth_next(&depth_iterator);-
289 }-
290-
291 m_cursor = new QXcbCursor(connection, this);-
292}-
293-
294QXcbScreen::~QXcbScreen()-
295{-
296 delete m_cursor;-
297}-
298-
299QString QXcbScreen::getOutputName(xcb_randr_get_output_info_reply_t *outputInfo)-
300{-
301 QString name;-
302 if (outputInfo) {-
303 name = QString::fromUtf8((const char*)xcb_randr_get_output_info_name(outputInfo),-
304 xcb_randr_get_output_info_name_length(outputInfo));-
305 } else {-
306 QByteArray displayName = connection()->displayName();-
307 int dotPos = displayName.lastIndexOf('.');-
308 if (dotPos != -1)-
309 displayName.truncate(dotPos);-
310 name = QString::fromLocal8Bit(displayName) + QLatin1Char('.')-
311 + QString::number(m_virtualDesktop->number());-
312 }-
313 return name;-
314}-
315-
316QWindow *QXcbScreen::topLevelAt(const QPoint &p) const-
317{-
318 xcb_window_t root = screen()->root;-
319-
320 int x = p.x();-
321 int y = p.y();-
322-
323 xcb_window_t parent = root;-
324 xcb_window_t child = root;-
325-
326 do {-
327 xcb_translate_coordinates_cookie_t translate_cookie =-
328 xcb_translate_coordinates_unchecked(xcb_connection(), parent, child, x, y);-
329-
330 xcb_translate_coordinates_reply_t *translate_reply =-
331 xcb_translate_coordinates_reply(xcb_connection(), translate_cookie, NULL);-
332-
333 if (!translate_reply) {-
334 return 0;-
335 }-
336-
337 parent = child;-
338 child = translate_reply->child;-
339 x = translate_reply->dst_x;-
340 y = translate_reply->dst_y;-
341-
342 free(translate_reply);-
343-
344 if (!child || child == root)-
345 return 0;-
346-
347 QPlatformWindow *platformWindow = connection()->platformWindowFromId(child);-
348 if (platformWindow)-
349 return platformWindow->window();-
350 } while (parent != child);-
351-
352 return 0;-
353}-
354-
355void QXcbScreen::windowShown(QXcbWindow *window)-
356{-
357 // Freedesktop.org Startup Notification-
358 if (!connection()->startupId().isEmpty() && window->window()->isTopLevel()) {-
359 sendStartupMessage(QByteArrayLiteral("remove: ID=") + connection()->startupId());-
360 connection()->clearStartupId();-
361 }-
362}-
363-
364QSurfaceFormat QXcbScreen::surfaceFormatFor(const QSurfaceFormat &format) const-
365{-
366 const xcb_visualid_t xcb_visualid = connection()->hasDefaultVisualId() ? connection()->defaultVisualId()
connection()->...aultVisualId()Description
TRUEnever evaluated
FALSEevaluated 4190 times by 126 tests
Evaluated by:
  • tst_Gestures
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataWidgetMapper
  • tst_QDateTimeEdit
  • tst_QDesktopWidget
  • tst_QDial
  • tst_QDialog
  • ...
0-4190
367 : screen()->root_visual;-
368 const xcb_visualtype_t *xcb_visualtype = visualForId(xcb_visualid);-
369-
370 const int redSize = qPopulationCount(xcb_visualtype->red_mask);-
371 const int greenSize = qPopulationCount(xcb_visualtype->green_mask);-
372 const int blueSize = qPopulationCount(xcb_visualtype->blue_mask);-
373-
374 QSurfaceFormat result = format;-
375-
376 if (result.redBufferSize() < 0)
result.redBufferSize() < 0Description
TRUEevaluated 4150 times by 126 tests
Evaluated by:
  • tst_Gestures
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataWidgetMapper
  • tst_QDateTimeEdit
  • tst_QDesktopWidget
  • tst_QDial
  • tst_QDialog
  • ...
FALSEevaluated 40 times by 4 tests
Evaluated by:
  • tst_QGraphicsView
  • tst_QOpenGLWidget
  • tst_QOpenGLWindow
  • tst_QOpenGlConfig
40-4150
377 result.setRedBufferSize(redSize);
executed 4150 times by 126 tests: result.setRedBufferSize(redSize);
Executed by:
  • tst_Gestures
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataWidgetMapper
  • tst_QDateTimeEdit
  • tst_QDesktopWidget
  • tst_QDial
  • tst_QDialog
  • ...
4150
378-
379 if (result.greenBufferSize() < 0)
result.greenBufferSize() < 0Description
TRUEevaluated 4150 times by 126 tests
Evaluated by:
  • tst_Gestures
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataWidgetMapper
  • tst_QDateTimeEdit
  • tst_QDesktopWidget
  • tst_QDial
  • tst_QDialog
  • ...
FALSEevaluated 40 times by 4 tests
Evaluated by:
  • tst_QGraphicsView
  • tst_QOpenGLWidget
  • tst_QOpenGLWindow
  • tst_QOpenGlConfig
40-4150
380 result.setGreenBufferSize(greenSize);
executed 4150 times by 126 tests: result.setGreenBufferSize(greenSize);
Executed by:
  • tst_Gestures
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataWidgetMapper
  • tst_QDateTimeEdit
  • tst_QDesktopWidget
  • tst_QDial
  • tst_QDialog
  • ...
4150
381-
382 if (result.blueBufferSize() < 0)
result.blueBufferSize() < 0Description
TRUEevaluated 4150 times by 126 tests
Evaluated by:
  • tst_Gestures
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataWidgetMapper
  • tst_QDateTimeEdit
  • tst_QDesktopWidget
  • tst_QDial
  • tst_QDialog
  • ...
FALSEevaluated 40 times by 4 tests
Evaluated by:
  • tst_QGraphicsView
  • tst_QOpenGLWidget
  • tst_QOpenGLWindow
  • tst_QOpenGlConfig
40-4150
383 result.setBlueBufferSize(blueSize);
executed 4150 times by 126 tests: result.setBlueBufferSize(blueSize);
Executed by:
  • tst_Gestures
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataWidgetMapper
  • tst_QDateTimeEdit
  • tst_QDesktopWidget
  • tst_QDial
  • tst_QDialog
  • ...
4150
384-
385 return result;
executed 4190 times by 126 tests: return result;
Executed by:
  • tst_Gestures
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataWidgetMapper
  • tst_QDateTimeEdit
  • tst_QDesktopWidget
  • tst_QDial
  • tst_QDialog
  • ...
4190
386}-
387-
388const xcb_visualtype_t *QXcbScreen::visualForFormat(const QSurfaceFormat &format) const-
389{-
390 const xcb_visualtype_t *candidate = nullptr;-
391-
392 for (const xcb_visualtype_t &xcb_visualtype : m_visuals) {-
393-
394 const int redSize = qPopulationCount(xcb_visualtype.red_mask);-
395 const int greenSize = qPopulationCount(xcb_visualtype.green_mask);-
396 const int blueSize = qPopulationCount(xcb_visualtype.blue_mask);-
397 const int alphaSize = depthOfVisual(xcb_visualtype.visual_id) - redSize - greenSize - blueSize;-
398-
399 if (format.redBufferSize() != -1 && redSize != format.redBufferSize())
format.redBufferSize() != -1Description
TRUEevaluated 133 times by 12 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBackingStore
  • tst_QGuiApplication
  • tst_QKeyEvent
  • tst_QLineEdit
  • tst_QMouseEvent
  • tst_QRasterWindow
  • tst_QTouchEvent
  • tst_QWindow
  • tst_QWindowContainer
  • tst_qinputmethod
FALSEnever evaluated
redSize != for...edBufferSize()Description
TRUEnever evaluated
FALSEevaluated 133 times by 12 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBackingStore
  • tst_QGuiApplication
  • tst_QKeyEvent
  • tst_QLineEdit
  • tst_QMouseEvent
  • tst_QRasterWindow
  • tst_QTouchEvent
  • tst_QWindow
  • tst_QWindowContainer
  • tst_qinputmethod
0-133
400 continue;
never executed: continue;
0
401-
402 if (format.greenBufferSize() != -1 && greenSize != format.greenBufferSize())
format.greenBufferSize() != -1Description
TRUEevaluated 133 times by 12 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBackingStore
  • tst_QGuiApplication
  • tst_QKeyEvent
  • tst_QLineEdit
  • tst_QMouseEvent
  • tst_QRasterWindow
  • tst_QTouchEvent
  • tst_QWindow
  • tst_QWindowContainer
  • tst_qinputmethod
FALSEnever evaluated
greenSize != f...enBufferSize()Description
TRUEnever evaluated
FALSEevaluated 133 times by 12 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBackingStore
  • tst_QGuiApplication
  • tst_QKeyEvent
  • tst_QLineEdit
  • tst_QMouseEvent
  • tst_QRasterWindow
  • tst_QTouchEvent
  • tst_QWindow
  • tst_QWindowContainer
  • tst_qinputmethod
0-133
403 continue;
never executed: continue;
0
404-
405 if (format.blueBufferSize() != -1 && blueSize != format.blueBufferSize())
format.blueBufferSize() != -1Description
TRUEevaluated 133 times by 12 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBackingStore
  • tst_QGuiApplication
  • tst_QKeyEvent
  • tst_QLineEdit
  • tst_QMouseEvent
  • tst_QRasterWindow
  • tst_QTouchEvent
  • tst_QWindow
  • tst_QWindowContainer
  • tst_qinputmethod
FALSEnever evaluated
blueSize != fo...ueBufferSize()Description
TRUEnever evaluated
FALSEevaluated 133 times by 12 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBackingStore
  • tst_QGuiApplication
  • tst_QKeyEvent
  • tst_QLineEdit
  • tst_QMouseEvent
  • tst_QRasterWindow
  • tst_QTouchEvent
  • tst_QWindow
  • tst_QWindowContainer
  • tst_qinputmethod
0-133
406 continue;
never executed: continue;
0
407-
408 if (format.alphaBufferSize() != -1 && alphaSize != format.alphaBufferSize())
format.alphaBufferSize() != -1Description
TRUEnever evaluated
FALSEevaluated 133 times by 12 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBackingStore
  • tst_QGuiApplication
  • tst_QKeyEvent
  • tst_QLineEdit
  • tst_QMouseEvent
  • tst_QRasterWindow
  • tst_QTouchEvent
  • tst_QWindow
  • tst_QWindowContainer
  • tst_qinputmethod
alphaSize != f...haBufferSize()Description
TRUEnever evaluated
FALSEnever evaluated
0-133
409 continue;
never executed: continue;
0
410-
411 // Try to find a RGB visual rather than e.g. BGR or GBR-
412
qCountTrailing...lue_mask) == 0Description
TRUEevaluated 133 times by 12 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBackingStore
  • tst_QGuiApplication
  • tst_QKeyEvent
  • tst_QLineEdit
  • tst_QMouseEvent
  • tst_QRasterWindow
  • tst_QTouchEvent
  • tst_QWindow
  • tst_QWindowContainer
  • tst_qinputmethod
FALSEnever evaluated
if (qCountTrailingZeroBits(xcb_visualtype.blue_mask) == 0)
qCountTrailing...lue_mask) == 0Description
TRUEevaluated 133 times by 12 tests
Evaluated by:
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBackingStore
  • tst_QGuiApplication
  • tst_QKeyEvent
  • tst_QLineEdit
  • tst_QMouseEvent
  • tst_QRasterWindow
  • tst_QTouchEvent
  • tst_QWindow
  • tst_QWindowContainer
  • tst_qinputmethod
FALSEnever evaluated
0-133
413 return &xcb_visualtype;
executed 133 times by 12 tests: return &xcb_visualtype;
Executed by:
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBackingStore
  • tst_QGuiApplication
  • tst_QKeyEvent
  • tst_QLineEdit
  • tst_QMouseEvent
  • tst_QRasterWindow
  • tst_QTouchEvent
  • tst_QWindow
  • tst_QWindowContainer
  • tst_qinputmethod
133
414-
415 // In case we do not find anything we like, just remember the first one-
416 // and hope for the best:-
417
!candidateDescription
TRUEnever evaluated
FALSEnever evaluated
if (!candidate)
!candidateDescription
TRUEnever evaluated
FALSEnever evaluated
0
418 candidate = &xcb_visualtype;
never executed: candidate = &xcb_visualtype;
0
419 }
never executed: end of block
0
420-
421 return candidate;
never executed: return candidate;
0
422}-
423-
424void QXcbScreen::sendStartupMessage(const QByteArray &message) const-
425{-
426 xcb_window_t rootWindow = root();-
427-
428 xcb_client_message_event_t ev;-
429 ev.response_type = XCB_CLIENT_MESSAGE;-
430 ev.format = 8;-
431 ev.type = connection()->atom(QXcbAtom::_NET_STARTUP_INFO_BEGIN);-
432 ev.sequence = 0;-
433 ev.window = rootWindow;-
434 int sent = 0;-
435 int length = message.length() + 1; // include NUL byte-
436 const char *data = message.constData();-
437 do {-
438 if (sent == 20)-
439 ev.type = connection()->atom(QXcbAtom::_NET_STARTUP_INFO);-
440-
441 const int start = sent;-
442 const int numBytes = qMin(length - start, 20);-
443 memcpy(ev.data.data8, data + start, numBytes);-
444 xcb_send_event(connection()->xcb_connection(), false, rootWindow, XCB_EVENT_MASK_PROPERTY_CHANGE, (const char *) &ev);-
445-
446 sent += numBytes;-
447 } while (sent < length);-
448}-
449-
450const xcb_visualtype_t *QXcbScreen::visualForId(xcb_visualid_t visualid) const-
451{-
452 QMap<xcb_visualid_t, xcb_visualtype_t>::const_iterator it = m_visuals.find(visualid);-
453 if (it == m_visuals.constEnd())-
454 return 0;-
455 return &*it;-
456}-
457-
458quint8 QXcbScreen::depthOfVisual(xcb_visualid_t visualid) const-
459{-
460 QMap<xcb_visualid_t, quint8>::const_iterator it = m_visualDepths.find(visualid);-
461 if (it == m_visualDepths.constEnd())-
462 return 0;-
463 return *it;-
464}-
465-
466QImage::Format QXcbScreen::format() const-
467{-
468 return QImage::Format_RGB32;qt_xcb_imageFormatForVisual(connection(), screen()->root_depth, visualForId(screen()->root_visual));
executed 72809 times by 105 tests: return qt_xcb_imageFormatForVisual(connection(), screen()->root_depth, visualForId(screen()->root_visual));
Executed by:
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDialogButtonBox
  • tst_QDockWidget
  • tst_QDoubleSpinBox
  • tst_QErrorMessage
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • ...
72809
469}-
470-
471QDpi QXcbScreen::virtualDpi() const-
472{-
473 return QDpi(Q_MM_PER_INCH * m_virtualSize.width() / m_virtualSizeMillimeters.width(),-
474 Q_MM_PER_INCH * m_virtualSize.height() / m_virtualSizeMillimeters.height());-
475}-
476-
477-
478QDpi QXcbScreen::logicalDpi() const-
479{-
480 static const int overrideDpi = qEnvironmentVariableIntValue("QT_FONT_DPI");-
481 if (overrideDpi)-
482 return QDpi(overrideDpi, overrideDpi);-
483-
484 if (m_forcedDpi > 0) {-
485 return QDpi(m_forcedDpi, m_forcedDpi);-
486 }-
487 return virtualDpi();-
488}-
489-
490qreal QXcbScreen::pixelDensity() const-
491{-
492 return m_pixelDensity;-
493}-
494-
495QPlatformCursor *QXcbScreen::cursor() const-
496{-
497 return m_cursor;-
498}-
499-
500void QXcbScreen::setOutput(xcb_randr_output_t outputId,-
501 xcb_randr_get_output_info_reply_t *outputInfo)-
502{-
503 m_output = outputId;-
504 m_crtc = outputInfo ? outputInfo->crtc : XCB_NONE;-
505 m_mode = XCB_NONE;-
506 m_outputName = getOutputName(outputInfo);-
507 // TODO: Send an event to the QScreen instance that the screen changed its name-
508}-
509-
510int QXcbScreen::virtualDesktopNumberStatic(const QScreen *screen)-
511{-
512 if (screen && screen->handle())-
513 return static_cast<const QXcbScreen *>(screen->handle())->screenNumber();-
514-
515 return 0;-
516}-
517-
518/*!-
519 \brief handle the XCB screen change event and update properties-
520-
521 On a mobile device, the ideal use case is that the accelerometer would-
522 drive the orientation. This could be achieved by using QSensors to read the-
523 accelerometer and adjusting the rotation in QML, or by reading the-
524 orientation from the QScreen object and doing the same, or in many other-
525 ways. However, on X we have the XRandR extension, which makes it possible-
526 to have the whole screen rotated, so that individual apps DO NOT have to-
527 rotate themselves. Apps could optionally use the-
528 QScreen::primaryOrientation property to optimize layout though.-
529 Furthermore, there is no support in X for accelerometer events anyway. So-
530 it makes more sense on a Linux system running X to just run a daemon which-
531 monitors the accelerometer and runs xrandr automatically to do the rotation,-
532 then apps do not have to be aware of it (but probably the window manager-
533 would resize them accordingly). updateGeometry() is written with this-
534 design in mind. Therefore the physical geometry, available geometry,-
535 virtual geometry, orientation and primaryOrientation should all change at-
536 the same time. On a system which cannot rotate the whole screen, it would-
537 be correct for only the orientation (not the primary orientation) to-
538 change.-
539*/-
540void QXcbScreen::handleScreenChange(xcb_randr_screen_change_notify_event_t *change_event)-
541{-
542 // No need to do anything when screen rotation did not change - if any-
543 // xcb output geometry has changed, we will get RRCrtcChangeNotify and-
544 // RROutputChangeNotify events next-
545 if (change_event->rotation == m_rotation)-
546 return;-
547-
548 m_rotation = change_event->rotation;-
549 switch (m_rotation) {-
550 case XCB_RANDR_ROTATION_ROTATE_0: // xrandr --rotate normal-
551 m_orientation = Qt::LandscapeOrientation;-
552 m_virtualSize.setWidth(change_event->width);-
553 m_virtualSize.setHeight(change_event->height);-
554 m_virtualSizeMillimeters.setWidth(change_event->mwidth);-
555 m_virtualSizeMillimeters.setHeight(change_event->mheight);-
556 break;-
557 case XCB_RANDR_ROTATION_ROTATE_90: // xrandr --rotate left-
558 m_orientation = Qt::PortraitOrientation;-
559 m_virtualSize.setWidth(change_event->height);-
560 m_virtualSize.setHeight(change_event->width);-
561 m_virtualSizeMillimeters.setWidth(change_event->mheight);-
562 m_virtualSizeMillimeters.setHeight(change_event->mwidth);-
563 break;-
564 case XCB_RANDR_ROTATION_ROTATE_180: // xrandr --rotate inverted-
565 m_orientation = Qt::InvertedLandscapeOrientation;-
566 m_virtualSize.setWidth(change_event->width);-
567 m_virtualSize.setHeight(change_event->height);-
568 m_virtualSizeMillimeters.setWidth(change_event->mwidth);-
569 m_virtualSizeMillimeters.setHeight(change_event->mheight);-
570 break;-
571 case XCB_RANDR_ROTATION_ROTATE_270: // xrandr --rotate right-
572 m_orientation = Qt::InvertedPortraitOrientation;-
573 m_virtualSize.setWidth(change_event->height);-
574 m_virtualSize.setHeight(change_event->width);-
575 m_virtualSizeMillimeters.setWidth(change_event->mheight);-
576 m_virtualSizeMillimeters.setHeight(change_event->mwidth);-
577 break;-
578 // We don't need to do anything with these, since QScreen doesn't store reflection state,-
579 // and Qt-based applications probably don't need to care about it anyway.-
580 case XCB_RANDR_ROTATION_REFLECT_X: break;-
581 case XCB_RANDR_ROTATION_REFLECT_Y: break;-
582 }-
583-
584 updateGeometry(change_event->timestamp);-
585-
586 QWindowSystemInterface::handleScreenOrientationChange(QPlatformScreen::screen(), m_orientation);-
587-
588 QDpi ldpi = logicalDpi();-
589 QWindowSystemInterface::handleScreenLogicalDotsPerInchChange(QPlatformScreen::screen(), ldpi.first, ldpi.second);-
590}-
591-
592void QXcbScreen::updateGeometry(xcb_timestamp_t timestamp)-
593{-
594 if (!connection()->hasXRandr())-
595 return;-
596-
597 xcb_randr_get_crtc_info_cookie_t crtcCookie =-
598 xcb_randr_get_crtc_info_unchecked(xcb_connection(), m_crtc, timestamp);-
599 xcb_randr_get_crtc_info_reply_t *crtc =-
600 xcb_randr_get_crtc_info_reply(xcb_connection(), crtcCookie, NULL);-
601 if (crtc) {-
602 updateGeometry(QRect(crtc->x, crtc->y, crtc->width, crtc->height), crtc->rotation);-
603 free(crtc);-
604 }-
605}-
606-
607void QXcbScreen::updateGeometry(const QRect &geom, uint8_t rotation)-
608{-
609 QRect xGeometry = geom;-
610 switch (rotation) {-
611 case XCB_RANDR_ROTATION_ROTATE_0: // xrandr --rotate normal-
612 m_orientation = Qt::LandscapeOrientation;-
613 m_sizeMillimeters = m_outputSizeMillimeters;-
614 break;-
615 case XCB_RANDR_ROTATION_ROTATE_90: // xrandr --rotate left-
616 m_orientation = Qt::PortraitOrientation;-
617 m_sizeMillimeters = m_outputSizeMillimeters.transposed();-
618 break;-
619 case XCB_RANDR_ROTATION_ROTATE_180: // xrandr --rotate inverted-
620 m_orientation = Qt::InvertedLandscapeOrientation;-
621 m_sizeMillimeters = m_outputSizeMillimeters;-
622 break;-
623 case XCB_RANDR_ROTATION_ROTATE_270: // xrandr --rotate right-
624 m_orientation = Qt::InvertedPortraitOrientation;-
625 m_sizeMillimeters = m_outputSizeMillimeters.transposed();-
626 break;-
627 }-
628-
629 // It can be that physical size is unknown while virtual size-
630 // is known (probably back-calculated from DPI and resolution),-
631 // e.g. on VNC or with some hardware.-
632 if (m_sizeMillimeters.isEmpty())-
633 m_sizeMillimeters = sizeInMillimeters(xGeometry.size(), virtualDpi());-
634-
635 qreal dpi = xGeometry.width() / physicalSize().width() * qreal(25.4);-
636 m_pixelDensity = qRound(dpi/96);-
637 m_geometry = QRect(xGeometry.topLeft(), xGeometry.size());-
638 m_availableGeometry = xGeometry & m_virtualDesktop->workArea();-
639 QWindowSystemInterface::handleScreenGeometryChange(QPlatformScreen::screen(), m_geometry, m_availableGeometry);-
640}-
641-
642void QXcbScreen::updateAvailableGeometry()-
643{-
644 QRect availableGeometry = m_geometry & m_virtualDesktop->workArea();-
645 if (m_availableGeometry != availableGeometry) {-
646 m_availableGeometry = availableGeometry;-
647 QWindowSystemInterface::handleScreenGeometryChange(QPlatformScreen::screen(), m_geometry, m_availableGeometry);-
648 }-
649}-
650-
651void QXcbScreen::updateRefreshRate(xcb_randr_mode_t mode)-
652{-
653 if (!connection()->hasXRandr())-
654 return;-
655-
656 if (m_mode == mode)-
657 return;-
658-
659 // we can safely use get_screen_resources_current here, because in order to-
660 // get here, we must have called get_screen_resources before-
661 xcb_randr_get_screen_resources_current_cookie_t resourcesCookie =-
662 xcb_randr_get_screen_resources_current_unchecked(xcb_connection(), screen()->root);-
663 xcb_randr_get_screen_resources_current_reply_t *resources =-
664 xcb_randr_get_screen_resources_current_reply(xcb_connection(), resourcesCookie, NULL);-
665 if (resources) {-
666 xcb_randr_mode_info_iterator_t modesIter =-
667 xcb_randr_get_screen_resources_current_modes_iterator(resources);-
668 for (; modesIter.rem; xcb_randr_mode_info_next(&modesIter)) {-
669 xcb_randr_mode_info_t *modeInfo = modesIter.data;-
670 if (modeInfo->id == mode) {-
671 const uint32_t dotCount = modeInfo->htotal * modeInfo->vtotal;-
672 m_refreshRate = (dotCount != 0) ? modeInfo->dot_clock / dotCount : 0;-
673 m_mode = mode;-
674 break;-
675 }-
676 }-
677-
678 free(resources);-
679 QWindowSystemInterface::handleScreenRefreshRateChange(QPlatformScreen::screen(), m_refreshRate);-
680 }-
681}-
682-
683QPixmap QXcbScreen::grabWindow(WId window, int x, int y, int width, int height) const-
684{-
685 if (width == 0 || height == 0)-
686 return QPixmap();-
687-
688 // TODO: handle multiple screens-
689 QXcbScreen *screen = const_cast<QXcbScreen *>(this);-
690 xcb_window_t root = screen->root();-
691-
692 if (window == 0)-
693 window = root;-
694-
695 xcb_get_geometry_cookie_t geometry_cookie = xcb_get_geometry_unchecked(xcb_connection(), window);-
696-
697 xcb_get_geometry_reply_t *reply =-
698 xcb_get_geometry_reply(xcb_connection(), geometry_cookie, NULL);-
699-
700 if (!reply) {-
701 return QPixmap();-
702 }-
703-
704 if (width < 0)-
705 width = reply->width - x;-
706 if (height < 0)-
707 height = reply->height - y;-
708-
709 geometry_cookie = xcb_get_geometry_unchecked(xcb_connection(), root);-
710 xcb_get_geometry_reply_t *root_reply =-
711 xcb_get_geometry_reply(xcb_connection(), geometry_cookie, NULL);-
712-
713 if (!root_reply) {-
714 free(reply);-
715 return QPixmap();-
716 }-
717-
718 if (reply->depth == root_reply->depth) {-
719 // if the depth of the specified window and the root window are the-
720 // same, grab pixels from the root window (so that we get the any-
721 // overlapping windows and window manager frames)-
722-
723 // map x and y to the root window-
724 xcb_translate_coordinates_cookie_t translate_cookie =-
725 xcb_translate_coordinates_unchecked(xcb_connection(), window, root, x, y);-
726-
727 xcb_translate_coordinates_reply_t *translate_reply =-
728 xcb_translate_coordinates_reply(xcb_connection(), translate_cookie, NULL);-
729-
730 if (!translate_reply) {-
731 free(reply);-
732 free(root_reply);-
733 return QPixmap();-
734 }-
735-
736 x = translate_reply->dst_x;-
737 y = translate_reply->dst_y;-
738-
739 window = root;-
740-
741 free(translate_reply);-
742 free(reply);-
743 reply = root_reply;-
744 } else {-
745 free(root_reply);-
746 root_reply = 0;-
747 }-
748-
749 xcb_get_window_attributes_reply_t *attributes_reply =-
750 xcb_get_window_attributes_reply(xcb_connection(), xcb_get_window_attributes_unchecked(xcb_connection(), window), NULL);-
751-
752 if (!attributes_reply) {-
753 free(reply);-
754 return QPixmap();-
755 }-
756-
757 const xcb_visualtype_t *visual = screen->visualForId(attributes_reply->visual);-
758 free(attributes_reply);-
759-
760 xcb_pixmap_t pixmap = xcb_generate_id(xcb_connection());-
761 xcb_create_pixmap(xcb_connection(), reply->depth, pixmap, window, width, height);-
762-
763 uint32_t gc_value_mask = XCB_GC_SUBWINDOW_MODE;-
764 uint32_t gc_value_list[] = { XCB_SUBWINDOW_MODE_INCLUDE_INFERIORS };-
765-
766 xcb_gcontext_t gc = xcb_generate_id(xcb_connection());-
767 xcb_create_gc(xcb_connection(), gc, pixmap, gc_value_mask, gc_value_list);-
768-
769 xcb_copy_area(xcb_connection(), window, pixmap, gc, x, y, 0, 0, width, height);-
770-
771 QPixmap result = qt_xcb_pixmapFromXPixmap(connection(), pixmap, width, height, reply->depth, visual);-
772-
773 free(reply);-
774 xcb_free_gc(xcb_connection(), gc);-
775 xcb_free_pixmap(xcb_connection(), pixmap);-
776-
777 return result;-
778}-
779-
780static bool parseXftInt(const QByteArray& stringValue, int *value)-
781{-
782 Q_ASSERT(value != 0);-
783 bool ok;-
784 *value = stringValue.toInt(&ok);-
785 return ok;-
786}-
787-
788static QFontEngine::HintStyle parseXftHintStyle(const QByteArray& stringValue)-
789{-
790 if (stringValue == "hintfull")-
791 return QFontEngine::HintFull;-
792 else if (stringValue == "hintnone")-
793 return QFontEngine::HintNone;-
794 else if (stringValue == "hintmedium")-
795 return QFontEngine::HintMedium;-
796 else if (stringValue == "hintslight")-
797 return QFontEngine::HintLight;-
798-
799 return QFontEngine::HintStyle(-1);-
800}-
801-
802static QFontEngine::SubpixelAntialiasingType parseXftRgba(const QByteArray& stringValue)-
803{-
804 if (stringValue == "none")-
805 return QFontEngine::Subpixel_None;-
806 else if (stringValue == "rgb")-
807 return QFontEngine::Subpixel_RGB;-
808 else if (stringValue == "bgr")-
809 return QFontEngine::Subpixel_BGR;-
810 else if (stringValue == "vrgb")-
811 return QFontEngine::Subpixel_VRGB;-
812 else if (stringValue == "vbgr")-
813 return QFontEngine::Subpixel_VBGR;-
814-
815 return QFontEngine::SubpixelAntialiasingType(-1);-
816}-
817-
818bool QXcbScreen::xResource(const QByteArray &identifier,-
819 const QByteArray &expectedIdentifier,-
820 QByteArray& stringValue)-
821{-
822 if (identifier.startsWith(expectedIdentifier)) {-
823 stringValue = identifier.mid(expectedIdentifier.size());-
824 return true;-
825 }-
826 return false;-
827}-
828-
829void QXcbScreen::readXResources()-
830{-
831 int offset = 0;-
832 QByteArray resources;-
833 while(1) {-
834 xcb_get_property_reply_t *reply =-
835 xcb_get_property_reply(xcb_connection(),-
836 xcb_get_property_unchecked(xcb_connection(), false, screen()->root,-
837 XCB_ATOM_RESOURCE_MANAGER,-
838 XCB_ATOM_STRING, offset/4, 8192), NULL);-
839 bool more = false;-
840 if (reply && reply->format == 8 && reply->type == XCB_ATOM_STRING) {-
841 resources += QByteArray((const char *)xcb_get_property_value(reply), xcb_get_property_value_length(reply));-
842 offset += xcb_get_property_value_length(reply);-
843 more = reply->bytes_after != 0;-
844 }-
845-
846 if (reply)-
847 free(reply);-
848-
849 if (!more)-
850 break;-
851 }-
852-
853 QList<QByteArray> split = resources.split('\n');-
854 for (int i = 0; i < split.size(); ++i) {-
855 const QByteArray &r = split.at(i);-
856 int value;-
857 QByteArray stringValue;-
858 if (xResource(r, "Xft.dpi:\t", stringValue)) {-
859 if (parseXftInt(stringValue, &value))-
860 m_forcedDpi = value;-
861 } else if (xResource(r, "Xft.hintstyle:\t", stringValue)) {-
862 m_hintStyle = parseXftHintStyle(stringValue);-
863 } else if (xResource(r, "Xft.antialias:\t", stringValue)) {-
864 if (parseXftInt(stringValue, &value))-
865 m_antialiasingEnabled = value;-
866 } else if (xResource(r, "Xft.rgba:\t", stringValue)) {-
867 m_subpixelType = parseXftRgba(stringValue);-
868 }-
869 }-
870}-
871-
872QXcbXSettings *QXcbScreen::xSettings() const-
873{-
874 return m_virtualDesktop->xSettings();-
875}-
876-
877static inline void formatRect(QDebug &debug, const QRect r)-
878{-
879 debug << r.width() << 'x' << r.height()-
880 << forcesign << r.x() << r.y() << noforcesign;-
881}-
882-
883static inline void formatSizeF(QDebug &debug, const QSizeF s)-
884{-
885 debug << s.width() << 'x' << s.height() << "mm";-
886}-
887-
888QDebug operator<<(QDebug debug, const QXcbScreen *screen)-
889{-
890 const QDebugStateSaver saver(debug);-
891 debug.nospace();-
892 debug << "QXcbScreen(" << (const void *)screen;-
893 if (screen) {-
894 debug << fixed << qSetRealNumberPrecision(1);-
895 debug << ", name=" << screen->name();-
896 debug << ", geometry=";-
897 formatRect(debug, screen->geometry());-
898 debug << ", availableGeometry=";-
899 formatRect(debug, screen->availableGeometry());-
900 debug << ", devicePixelRatio=" << screen->devicePixelRatio();-
901 debug << ", logicalDpi=" << screen->logicalDpi();-
902 debug << ", physicalSize=";-
903 formatSizeF(debug, screen->physicalSize());-
904 // TODO 5.6 if (debug.verbosity() > 2) {-
905 debug << ", screenNumber=" << screen->screenNumber();-
906 debug << ", virtualSize=" << screen->virtualSize().width() << 'x' << screen->virtualSize().height() << " (";-
907 formatSizeF(debug, screen->virtualSize());-
908 debug << "), orientation=" << screen->orientation();-
909 debug << ", depth=" << screen->depth();-
910 debug << ", refreshRate=" << screen->refreshRate();-
911 debug << ", root=" << hex << screen->root();-
912 debug << ", windowManagerName=" << screen->windowManagerName();-
913 }-
914 debug << ')';-
915 return debug;-
916}-
917-
918QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9