Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
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 "qxcbintegration.h" | - | ||||||||||||||||||||||||
41 | #include "qxcbconnection.h" | - | ||||||||||||||||||||||||
42 | #include "qxcbscreen.h" | - | ||||||||||||||||||||||||
43 | #include "qxcbwindow.h" | - | ||||||||||||||||||||||||
44 | #include "qxcbcursor.h" | - | ||||||||||||||||||||||||
45 | #include "qxcbkeyboard.h" | - | ||||||||||||||||||||||||
46 | #include "qxcbbackingstore.h" | - | ||||||||||||||||||||||||
47 | #include "qxcbnativeinterface.h" | - | ||||||||||||||||||||||||
48 | #include "qxcbclipboard.h" | - | ||||||||||||||||||||||||
49 | #include "qxcbdrag.h" | - | ||||||||||||||||||||||||
50 | #include "qxcbglintegration.h" | - | ||||||||||||||||||||||||
51 | - | |||||||||||||||||||||||||
52 | #ifndef QT_NO_SESSIONMANAGER | - | ||||||||||||||||||||||||
53 | #include "qxcbsessionmanager.h" | - | ||||||||||||||||||||||||
54 | #endif | - | ||||||||||||||||||||||||
55 | - | |||||||||||||||||||||||||
56 | #include <xcb/xcb.h> | - | ||||||||||||||||||||||||
57 | - | |||||||||||||||||||||||||
58 | #include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h> | - | ||||||||||||||||||||||||
59 | #include <QtPlatformSupport/private/qgenericunixfontdatabase_p.h> | - | ||||||||||||||||||||||||
60 | #include <QtPlatformSupport/private/qgenericunixservices_p.h> | - | ||||||||||||||||||||||||
61 | - | |||||||||||||||||||||||||
62 | #include <stdio.h> | - | ||||||||||||||||||||||||
63 | - | |||||||||||||||||||||||||
64 | //this has to be included before egl, since egl pulls in X headers | - | ||||||||||||||||||||||||
65 | #include <QtGui/private/qguiapplication_p.h> | - | ||||||||||||||||||||||||
66 | - | |||||||||||||||||||||||||
67 | #ifdef XCB_USE_EGL | - | ||||||||||||||||||||||||
#include# include <EGLQtPlatformSupport/eglprivate/qt_egl_p.h> | ||||||||||||||||||||||||||
69 | #endif | - | ||||||||||||||||||||||||
70 | - | |||||||||||||||||||||||||
71 | #ifdef XCB_USE_XLIB | - | ||||||||||||||||||||||||
72 | #include <X11/Xlib.h> | - | ||||||||||||||||||||||||
73 | #endif | - | ||||||||||||||||||||||||
74 | - | |||||||||||||||||||||||||
75 | #include <qpa/qplatforminputcontextfactory_p.h> | - | ||||||||||||||||||||||||
76 | #include <private/qgenericunixthemes_p.h> | - | ||||||||||||||||||||||||
77 | #include <qpa/qplatforminputcontext.h> | - | ||||||||||||||||||||||||
78 | - | |||||||||||||||||||||||||
79 | #include <QtGui/QOpenGLContext> | - | ||||||||||||||||||||||||
80 | #include <QtGui/QScreen> | - | ||||||||||||||||||||||||
81 | #include <QtGui/QOffscreenSurface> | - | ||||||||||||||||||||||||
82 | #ifndef QT_NO_ACCESSIBILITY | - | ||||||||||||||||||||||||
83 | #include <qpa/qplatformaccessibility.h> | - | ||||||||||||||||||||||||
84 | #ifndef QT_NO_ACCESSIBILITY_ATSPI_BRIDGE | - | ||||||||||||||||||||||||
85 | #include "../../../platformsupport/linuxaccessibility/bridge_p.h" | - | ||||||||||||||||||||||||
86 | #endif | - | ||||||||||||||||||||||||
87 | #endif | - | ||||||||||||||||||||||||
88 | - | |||||||||||||||||||||||||
89 | #include <QtCore/QFileInfo> | - | ||||||||||||||||||||||||
90 | - | |||||||||||||||||||||||||
91 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||||||||
92 | - | |||||||||||||||||||||||||
93 | // Find out if our parent process is gdb by looking at the 'exe' symlink under /proc,. | - | ||||||||||||||||||||||||
94 | // or, for older Linuxes, read out 'cmdline'. | - | ||||||||||||||||||||||||
95 | static bool runningUnderDebugger() | - | ||||||||||||||||||||||||
96 | { | - | ||||||||||||||||||||||||
97 | #if defined(QT_DEBUG) && defined(Q_OS_LINUX) | - | ||||||||||||||||||||||||
98 | const QString parentProc = QLatin1String("/proc/") + QString::number(getppid()); | - | ||||||||||||||||||||||||
99 | const QFileInfo parentProcExe(parentProc + QLatin1String("/exe")); | - | ||||||||||||||||||||||||
100 | if (parentProcExe.isSymLink()) | - | ||||||||||||||||||||||||
101 | return parentProcExe.symLinkTarget().endsWith(QLatin1String("/gdb")); | - | ||||||||||||||||||||||||
102 | QFile f(parentProc + QLatin1String("/cmdline")); | - | ||||||||||||||||||||||||
103 | if (!f.open(QIODevice::ReadOnly)) | - | ||||||||||||||||||||||||
104 | return false; | - | ||||||||||||||||||||||||
105 | QByteArray s; | - | ||||||||||||||||||||||||
106 | char c; | - | ||||||||||||||||||||||||
107 | while (f.getChar(&c) && c) { | - | ||||||||||||||||||||||||
108 | if (c == '/') | - | ||||||||||||||||||||||||
109 | s.clear(); | - | ||||||||||||||||||||||||
110 | else | - | ||||||||||||||||||||||||
111 | s += c; | - | ||||||||||||||||||||||||
112 | } | - | ||||||||||||||||||||||||
113 | return s == "gdb"; | - | ||||||||||||||||||||||||
114 | #else | - | ||||||||||||||||||||||||
115 | return false; | - | ||||||||||||||||||||||||
116 | #endif | - | ||||||||||||||||||||||||
117 | } | - | ||||||||||||||||||||||||
118 | - | |||||||||||||||||||||||||
119 | QXcbIntegration *QXcbIntegration::m_instance = Q_NULLPTR; | - | ||||||||||||||||||||||||
120 | - | |||||||||||||||||||||||||
121 | QXcbIntegration::QXcbIntegration(const QStringList ¶meters, int &argc, char **argv) | - | ||||||||||||||||||||||||
122 | : m_services(new QGenericUnixServices) | - | ||||||||||||||||||||||||
123 | , m_instanceName(0) | - | ||||||||||||||||||||||||
124 | , m_canGrab(true) | - | ||||||||||||||||||||||||
125 | , m_defaultVisualId(UINT_MAX) | - | ||||||||||||||||||||||||
126 | { | - | ||||||||||||||||||||||||
127 | m_instance = this; | - | ||||||||||||||||||||||||
128 | qApp->setAttribute(Qt::AA_CompressHighFrequencyEvents, true); | - | ||||||||||||||||||||||||
129 | - | |||||||||||||||||||||||||
130 | qRegisterMetaType<QXcbWindow*>(); | - | ||||||||||||||||||||||||
131 | #ifdef XCB_USE_XLIB | - | ||||||||||||||||||||||||
132 | XInitThreads(); | - | ||||||||||||||||||||||||
133 | #endif | - | ||||||||||||||||||||||||
134 | m_nativeInterface.reset(new QXcbNativeInterface); | - | ||||||||||||||||||||||||
135 | - | |||||||||||||||||||||||||
136 | // Parse arguments | - | ||||||||||||||||||||||||
137 | const char *displayName = 0; | - | ||||||||||||||||||||||||
138 | bool noGrabArg = false; | - | ||||||||||||||||||||||||
139 | bool doGrabArg = false; | - | ||||||||||||||||||||||||
140 | if (argc) {
| 63-72 | ||||||||||||||||||||||||
141 | int j = 1; | - | ||||||||||||||||||||||||
142 | for (int i = 1; i < argc; i++) {
| 63-74 | ||||||||||||||||||||||||
143 | QByteArray arg(argv[i]); | - | ||||||||||||||||||||||||
144 | if (arg.startsWith("--"))
| 0-74 | ||||||||||||||||||||||||
145 | arg.remove(0, 1); never executed: arg.remove(0, 1); | 0 | ||||||||||||||||||||||||
146 | if (arg == "-display" && i < argc - 1)
| 0-74 | ||||||||||||||||||||||||
147 | displayName = argv[++i]; never executed: displayName = argv[++i]; | 0 | ||||||||||||||||||||||||
148 | else if (arg == "-name" && i < argc - 1)
| 0-74 | ||||||||||||||||||||||||
149 | m_instanceName = argv[++i]; never executed: m_instanceName = argv[++i]; | 0 | ||||||||||||||||||||||||
150 | else if (arg == "-nograb")
| 0-74 | ||||||||||||||||||||||||
151 | noGrabArg = true; never executed: noGrabArg = true; | 0 | ||||||||||||||||||||||||
152 | else if (arg == "-dograb")
| 0-74 | ||||||||||||||||||||||||
153 | doGrabArg = true; never executed: doGrabArg = true; | 0 | ||||||||||||||||||||||||
154 | else if (arg == "-visual" && i < argc - 1) {
| 0-74 | ||||||||||||||||||||||||
155 | bool ok = false; | - | ||||||||||||||||||||||||
156 | m_defaultVisualId = QByteArray(argv[++i]).toUInt(&ok, 0); | - | ||||||||||||||||||||||||
157 | if (!ok)
| 0 | ||||||||||||||||||||||||
158 | m_defaultVisualId = UINT_MAX; never executed: m_defaultVisualId = (2147483647 * 2U + 1U); | 0 | ||||||||||||||||||||||||
159 | } never executed: end of block | 0 | ||||||||||||||||||||||||
160 | else | - | ||||||||||||||||||||||||
161 | argv[j++] = argv[i]; executed 74 times by 3 tests: argv[j++] = argv[i]; Executed by:
| 74 | ||||||||||||||||||||||||
162 | } | - | ||||||||||||||||||||||||
163 | argc = j; | - | ||||||||||||||||||||||||
164 | } // argc executed 63 times by 5 tests: end of block Executed by:
| 63 | ||||||||||||||||||||||||
165 | - | |||||||||||||||||||||||||
166 | bool underDebugger = runningUnderDebugger(); | - | ||||||||||||||||||||||||
167 | if (noGrabArg && doGrabArg && underDebugger) {
| 0-135 | ||||||||||||||||||||||||
168 | qWarning() << ("Both -nograb and -dograb command line arguments specified. Please pick one. -nograb takes prcedence";); | - | ||||||||||||||||||||||||
169 | doGrabArg = false; | - | ||||||||||||||||||||||||
170 | } never executed: end of block | 0 | ||||||||||||||||||||||||
171 | - | |||||||||||||||||||||||||
172 | #if defined(QT_DEBUG) | - | ||||||||||||||||||||||||
173 | if (!noGrabArg && !doGrabArg && underDebugger) {
| 0-135 | ||||||||||||||||||||||||
174 | qDebug("Qt: gdb: -nograb added to command-line options.\n" | - | ||||||||||||||||||||||||
175 | "\t Use the -dograb option to enforce grabbing."); | - | ||||||||||||||||||||||||
176 | } never executed: end of block | 0 | ||||||||||||||||||||||||
177 | #endif | - | ||||||||||||||||||||||||
178 | m_canGrab = (!underDebugger && !noGrabArg) || (underDebugger && doGrabArg);
| 0-135 | ||||||||||||||||||||||||
179 | - | |||||||||||||||||||||||||
180 | static bool canNotGrabEnv = qEnvironmentVariableIsSet("QT_XCB_NO_GRAB_SERVER"); | - | ||||||||||||||||||||||||
181 | if (canNotGrabEnv)
| 0-135 | ||||||||||||||||||||||||
182 | m_canGrab = false; never executed: m_canGrab = false; | 0 | ||||||||||||||||||||||||
183 | - | |||||||||||||||||||||||||
184 | const int numParameters = parameters.size(); | - | ||||||||||||||||||||||||
185 | m_connections.reserve(1 + numParameters / 2); | - | ||||||||||||||||||||||||
186 | m_connections << new QXcbConnection(m_nativeInterface.data(), m_canGrab, m_defaultVisualId, displayName); | - | ||||||||||||||||||||||||
187 | - | |||||||||||||||||||||||||
188 | for (int i = 0; i < numParameters - 1; i += 2) {
| 0-135 | ||||||||||||||||||||||||
189 | qCDebug(lcQpaScreen) << "connecting to additional display: " << parameters.at(i) << parameters.at(i+1); never executed: QMessageLogger(__FILE__, 189, __PRETTY_FUNCTION__, lcQpaScreen().categoryName()).debug() << "connecting to additional display: " << parameters.at(i) << parameters.at(i+1);
| 0 | ||||||||||||||||||||||||
190 | QString display = parameters.at(i) + QLatin1Char(':') + parameters.at(i+1); | - | ||||||||||||||||||||||||
191 | m_connections << new QXcbConnection(m_nativeInterface.data(), m_canGrab, m_defaultVisualId, display.toLatin1().constData()); | - | ||||||||||||||||||||||||
192 | } never executed: end of block | 0 | ||||||||||||||||||||||||
193 | - | |||||||||||||||||||||||||
194 | m_fontDatabase.reset(new QGenericUnixFontDatabase()); | - | ||||||||||||||||||||||||
195 | } executed 135 times by 5 tests: end of block Executed by:
| 135 | ||||||||||||||||||||||||
196 | - | |||||||||||||||||||||||||
197 | QXcbIntegration::~QXcbIntegration() | - | ||||||||||||||||||||||||
198 | { | - | ||||||||||||||||||||||||
199 | qDeleteAll(m_connections); | - | ||||||||||||||||||||||||
200 | m_instance = Q_NULLPTR; | - | ||||||||||||||||||||||||
201 | } | - | ||||||||||||||||||||||||
202 | - | |||||||||||||||||||||||||
203 | QPlatformWindow *QXcbIntegration::createPlatformWindow(QWindow *window) const | - | ||||||||||||||||||||||||
204 | { | - | ||||||||||||||||||||||||
205 | QXcbScreen *screen = static_cast<QXcbScreen *>(window->screen()->handle()); | - | ||||||||||||||||||||||||
206 | QXcbGlIntegration *glIntegration = screen->connection()->glIntegration(); | - | ||||||||||||||||||||||||
207 | if (window->type() != Qt::Desktop )&& window->supportsOpenGL()) {
| 133-4107 | ||||||||||||||||||||||||
208 | if (glIntegration) {
| 0-3974 | ||||||||||||||||||||||||
209 | QXcbWindow *xcbWindow = glIntegration->createWindow(window); | - | ||||||||||||||||||||||||
210 | xcbWindow->create(); | - | ||||||||||||||||||||||||
211 | return xcbWindow; executed 3974 times by 118 tests: return xcbWindow; Executed by:
| 3974 | ||||||||||||||||||||||||
212 | } | - | ||||||||||||||||||||||||
213 | } never executed: end of block | 0 | ||||||||||||||||||||||||
214 | - | |||||||||||||||||||||||||
215 | Q_ASSERT(window->type() == Qt::Desktop || !window->supportsOpenGL() | - | ||||||||||||||||||||||||
216 | || (!glIntegration && window->surfaceType() == QSurface::RasterGLSurface)); // for VNC | - | ||||||||||||||||||||||||
217 | QXcbWindow *xcbWindow = new QXcbWindow(window); | - | ||||||||||||||||||||||||
218 | xcbWindow->create(); | - | ||||||||||||||||||||||||
219 | return xcbWindow; executed 431 times by 124 tests: return xcbWindow; Executed by:
| 431 | ||||||||||||||||||||||||
220 | } | - | ||||||||||||||||||||||||
221 | - | |||||||||||||||||||||||||
222 | #ifndef QT_NO_OPENGL | - | ||||||||||||||||||||||||
223 | QPlatformOpenGLContext *QXcbIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const | - | ||||||||||||||||||||||||
224 | { | - | ||||||||||||||||||||||||
225 | QXcbScreen *screen = static_cast<QXcbScreen *>(context->screen()->handle()); | - | ||||||||||||||||||||||||
226 | QXcbGlIntegration *glIntegration = screen->connection()->glIntegration(); | - | ||||||||||||||||||||||||
227 | if (!glIntegration) { | - | ||||||||||||||||||||||||
228 | qWarning("QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled"); | - | ||||||||||||||||||||||||
229 | return Q_NULLPTR; | - | ||||||||||||||||||||||||
230 | } | - | ||||||||||||||||||||||||
231 | return glIntegration->createPlatformOpenGLContext(context); | - | ||||||||||||||||||||||||
232 | } | - | ||||||||||||||||||||||||
233 | #endif | - | ||||||||||||||||||||||||
234 | - | |||||||||||||||||||||||||
235 | QPlatformBackingStore *QXcbIntegration::createPlatformBackingStore(QWindow *window) const | - | ||||||||||||||||||||||||
236 | { | - | ||||||||||||||||||||||||
237 | return new QXcbBackingStore(window); | - | ||||||||||||||||||||||||
238 | } | - | ||||||||||||||||||||||||
239 | - | |||||||||||||||||||||||||
240 | QPlatformOffscreenSurface *QXcbIntegration::createPlatformOffscreenSurface(QOffscreenSurface *surface) const | - | ||||||||||||||||||||||||
241 | { | - | ||||||||||||||||||||||||
242 | QXcbScreen *screen = static_cast<QXcbScreen *>(surface->screen()->handle()); | - | ||||||||||||||||||||||||
243 | QXcbGlIntegration *glIntegration = screen->connection()->glIntegration(); | - | ||||||||||||||||||||||||
244 | if (!glIntegration) { | - | ||||||||||||||||||||||||
245 | qWarning("QXcbIntegration: Cannot create platform offscreen surface, neither GLX nor EGL are enabled"); | - | ||||||||||||||||||||||||
246 | return Q_NULLPTR; | - | ||||||||||||||||||||||||
247 | } | - | ||||||||||||||||||||||||
248 | return glIntegration->createPlatformOffscreenSurface(surface); | - | ||||||||||||||||||||||||
249 | } | - | ||||||||||||||||||||||||
250 | - | |||||||||||||||||||||||||
251 | bool QXcbIntegration::hasCapability(QPlatformIntegration::Capability cap) const | - | ||||||||||||||||||||||||
252 | { | - | ||||||||||||||||||||||||
253 | switch (cap) { | - | ||||||||||||||||||||||||
254 | case ThreadedPixmaps: return true;case OpenGL: executed 131 times by 125 tests: case OpenGL: Executed by:
| 131 | ||||||||||||||||||||||||
255 | return m_connections.first()->glIntegration();case ThreadedOpenGL: executed 8 times by 2 tests: case ThreadedOpenGL: Executed by:
| 8 | ||||||||||||||||||||||||
256 | return m_connections.at{ | - | ||||||||||||||||||||||||
257 | const auto *connection = qAsConst(0)->threadedEventHandling() | - | ||||||||||||||||||||||||
&&m_connections.at).first(); | ||||||||||||||||||||||||||
258 | if
| 0-139 | ||||||||||||||||||||||||
259 | return cap != ThreadedOpenGL executed 139 times by 126 tests: return cap != ThreadedOpenGL || (connection->threadedEventHandling() && integration->supportsThreadedOpenGL()); Executed by:
| 139 | ||||||||||||||||||||||||
260 | || (connection->threadedEventHandling executed 139 times by 126 tests: () && m_connections.at(0)->glIntegration()->integration->supportsThreadedOpenGL();());return cap != ThreadedOpenGL || (connection->threadedEventHandling() && integration->supportsThreadedOpenGL()); Executed by:
executed 139 times by 126 tests: return cap != ThreadedOpenGL || (connection->threadedEventHandling() && integration->supportsThreadedOpenGL()); Executed by:
| 139 | ||||||||||||||||||||||||
261 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
262 | } | - | ||||||||||||||||||||||||
263 | - | |||||||||||||||||||||||||
264 | case ThreadedPixmaps: executed 2 times by 2 tests: case ThreadedPixmaps: Executed by:
| 2 | ||||||||||||||||||||||||
265 | case WindowMasks: executed 2 times by 2 tests: case WindowMasks: Executed by:
| 2 | ||||||||||||||||||||||||
266 | return true;case MultipleWindows: executed 2 times by 1 test: case MultipleWindows: Executed by:
| 2 | ||||||||||||||||||||||||
267 | return true;case ForeignWindows: never executed: case ForeignWindows: | 0 | ||||||||||||||||||||||||
268 | return true;case SyncState: executed 9 times by 3 tests: case SyncState: Executed by:
| 9 | ||||||||||||||||||||||||
269 | return true;case RasterGLSurface: executed 4277 times by 120 tests: case RasterGLSurface: Executed by:
| 4277 | ||||||||||||||||||||||||
270 | return true; executed 4292 times by 121 tests: return true; Executed by:
| 4292 | ||||||||||||||||||||||||
271 | - | |||||||||||||||||||||||||
272 | case SwitchableWidgetComposition: executed 1 time by 1 test: case SwitchableWidgetComposition: Executed by:
| 1 | ||||||||||||||||||||||||
273 | { | - | ||||||||||||||||||||||||
274 | return m_connections.at(0)->glIntegration() executed 1 time by 1 test: return m_connections.at(0)->glIntegration() && m_connections.at(0)->glIntegration()->supportsSwitchableWidgetComposition(); Executed by:
| 1 | ||||||||||||||||||||||||
275 | && m_connections.at(0)->glIntegration()->supportsSwitchableWidgetComposition(); executed 1 time by 1 test: return m_connections.at(0)->glIntegration() && m_connections.at(0)->glIntegration()->supportsSwitchableWidgetComposition(); Executed by:
| 1 | ||||||||||||||||||||||||
276 | } | - | ||||||||||||||||||||||||
277 | - | |||||||||||||||||||||||||
278 | default: return QPlatformIntegration::hasCapability(cap); executed 11991 times by 125 tests: return QPlatformIntegration::hasCapability(cap); Executed by:
executed 11991 times by 125 tests: default: Executed by:
| 11991 | ||||||||||||||||||||||||
279 | } | - | ||||||||||||||||||||||||
280 | } | - | ||||||||||||||||||||||||
281 | - | |||||||||||||||||||||||||
282 | QAbstractEventDispatcher *QXcbIntegration::createEventDispatcher() const | - | ||||||||||||||||||||||||
283 | { | - | ||||||||||||||||||||||||
284 | QAbstractEventDispatcher *dispatcher = createUnixEventDispatcher(); | - | ||||||||||||||||||||||||
285 | for (int i = 0; i < m_connections.size(); i++) | - | ||||||||||||||||||||||||
286 | m_connections[i]->eventReader()->registerEventDispatcher(dispatcher); | - | ||||||||||||||||||||||||
287 | return dispatcher; | - | ||||||||||||||||||||||||
288 | } | - | ||||||||||||||||||||||||
289 | - | |||||||||||||||||||||||||
290 | void QXcbIntegration::initialize() | - | ||||||||||||||||||||||||
291 | { | - | ||||||||||||||||||||||||
292 | // Perform everything that may potentially need the event dispatcher (timers, socket | - | ||||||||||||||||||||||||
293 | // notifiers) here instead of the constructor. | - | ||||||||||||||||||||||||
294 | QString icStr = QPlatformInputContextFactory::requested(); | - | ||||||||||||||||||||||||
295 | if (icStr.isNull()) | - | ||||||||||||||||||||||||
296 | icStr = QLatin1String("compose"); | - | ||||||||||||||||||||||||
297 | m_inputContext.reset(QPlatformInputContextFactory::create(icStr)); | - | ||||||||||||||||||||||||
298 | } | - | ||||||||||||||||||||||||
299 | - | |||||||||||||||||||||||||
300 | void QXcbIntegration::moveToScreen(QWindow *window, int screen) | - | ||||||||||||||||||||||||
301 | { | - | ||||||||||||||||||||||||
302 | Q_UNUSED(window); | - | ||||||||||||||||||||||||
303 | Q_UNUSED(screen); | - | ||||||||||||||||||||||||
304 | } | - | ||||||||||||||||||||||||
305 | - | |||||||||||||||||||||||||
306 | QPlatformFontDatabase *QXcbIntegration::fontDatabase() const | - | ||||||||||||||||||||||||
307 | { | - | ||||||||||||||||||||||||
308 | return m_fontDatabase.data(); | - | ||||||||||||||||||||||||
309 | } | - | ||||||||||||||||||||||||
310 | - | |||||||||||||||||||||||||
311 | QPlatformNativeInterface * QXcbIntegration::nativeInterface() const | - | ||||||||||||||||||||||||
312 | { | - | ||||||||||||||||||||||||
313 | return m_nativeInterface.data(); | - | ||||||||||||||||||||||||
314 | } | - | ||||||||||||||||||||||||
315 | - | |||||||||||||||||||||||||
316 | #ifndef QT_NO_CLIPBOARD | - | ||||||||||||||||||||||||
317 | QPlatformClipboard *QXcbIntegration::clipboard() const | - | ||||||||||||||||||||||||
318 | { | - | ||||||||||||||||||||||||
319 | return m_connections.at(0)->clipboard(); | - | ||||||||||||||||||||||||
320 | } | - | ||||||||||||||||||||||||
321 | #endif | - | ||||||||||||||||||||||||
322 | - | |||||||||||||||||||||||||
323 | #ifndef QT_NO_DRAGANDDROP | - | ||||||||||||||||||||||||
324 | QPlatformDrag *QXcbIntegration::drag() const | - | ||||||||||||||||||||||||
325 | { | - | ||||||||||||||||||||||||
326 | return m_connections.at(0)->drag(); | - | ||||||||||||||||||||||||
327 | } | - | ||||||||||||||||||||||||
328 | #endif | - | ||||||||||||||||||||||||
329 | - | |||||||||||||||||||||||||
330 | QPlatformInputContext *QXcbIntegration::inputContext() const | - | ||||||||||||||||||||||||
331 | { | - | ||||||||||||||||||||||||
332 | return m_inputContext.data(); | - | ||||||||||||||||||||||||
333 | } | - | ||||||||||||||||||||||||
334 | - | |||||||||||||||||||||||||
335 | #ifndef QT_NO_ACCESSIBILITY | - | ||||||||||||||||||||||||
336 | QPlatformAccessibility *QXcbIntegration::accessibility() const | - | ||||||||||||||||||||||||
337 | { | - | ||||||||||||||||||||||||
338 | #if !defined(QT_NO_ACCESSIBILITY_ATSPI_BRIDGE) | - | ||||||||||||||||||||||||
339 | if (!m_accessibility) { | - | ||||||||||||||||||||||||
340 | Q_ASSERT_X(QCoreApplication::eventDispatcher(), "QXcbIntegration", | - | ||||||||||||||||||||||||
341 | "Initializing accessibility without event-dispatcher!"); | - | ||||||||||||||||||||||||
342 | m_accessibility.reset(new QSpiAccessibleBridge()); | - | ||||||||||||||||||||||||
343 | } | - | ||||||||||||||||||||||||
344 | #endif | - | ||||||||||||||||||||||||
345 | - | |||||||||||||||||||||||||
346 | return m_accessibility.data(); | - | ||||||||||||||||||||||||
347 | } | - | ||||||||||||||||||||||||
348 | #endif | - | ||||||||||||||||||||||||
349 | - | |||||||||||||||||||||||||
350 | QPlatformServices *QXcbIntegration::services() const | - | ||||||||||||||||||||||||
351 | { | - | ||||||||||||||||||||||||
352 | return m_services.data(); | - | ||||||||||||||||||||||||
353 | } | - | ||||||||||||||||||||||||
354 | - | |||||||||||||||||||||||||
355 | Qt::KeyboardModifiers QXcbIntegration::queryKeyboardModifiers() const | - | ||||||||||||||||||||||||
356 | { | - | ||||||||||||||||||||||||
357 | int keybMask = 0; | - | ||||||||||||||||||||||||
358 | QXcbConnection *conn = m_connections.at(0); | - | ||||||||||||||||||||||||
359 | QXcbCursor::queryPointer(conn, 0, 0, &keybMask); | - | ||||||||||||||||||||||||
360 | return conn->keyboard()->translateModifiers(keybMask); | - | ||||||||||||||||||||||||
361 | } | - | ||||||||||||||||||||||||
362 | - | |||||||||||||||||||||||||
363 | QList<int> QXcbIntegration::possibleKeys(const QKeyEvent *e) const | - | ||||||||||||||||||||||||
364 | { | - | ||||||||||||||||||||||||
365 | return m_connections.at(0)->keyboard()->possibleKeys(e); | - | ||||||||||||||||||||||||
366 | } | - | ||||||||||||||||||||||||
367 | - | |||||||||||||||||||||||||
368 | QStringList QXcbIntegration::themeNames() const | - | ||||||||||||||||||||||||
369 | { | - | ||||||||||||||||||||||||
370 | return QGenericUnixTheme::themeNames(); | - | ||||||||||||||||||||||||
371 | } | - | ||||||||||||||||||||||||
372 | - | |||||||||||||||||||||||||
373 | QPlatformTheme *QXcbIntegration::createPlatformTheme(const QString &name) const | - | ||||||||||||||||||||||||
374 | { | - | ||||||||||||||||||||||||
375 | return QGenericUnixTheme::createUnixTheme(name); | - | ||||||||||||||||||||||||
376 | } | - | ||||||||||||||||||||||||
377 | - | |||||||||||||||||||||||||
378 | QVariant QXcbIntegration::styleHint(QPlatformIntegration::StyleHint hint) const | - | ||||||||||||||||||||||||
379 | { | - | ||||||||||||||||||||||||
380 | switch (hint) { | - | ||||||||||||||||||||||||
381 | case QPlatformIntegration::CursorFlashTime: | - | ||||||||||||||||||||||||
382 | case QPlatformIntegration::KeyboardInputInterval: | - | ||||||||||||||||||||||||
383 | case QPlatformIntegration::MouseDoubleClickInterval: | - | ||||||||||||||||||||||||
384 | case QPlatformIntegration::StartDragTime: | - | ||||||||||||||||||||||||
385 | case QPlatformIntegration::KeyboardAutoRepeatRate: | - | ||||||||||||||||||||||||
386 | case QPlatformIntegration::PasswordMaskDelay: | - | ||||||||||||||||||||||||
387 | case QPlatformIntegration::StartDragVelocity: | - | ||||||||||||||||||||||||
388 | case QPlatformIntegration::UseRtlExtensions: | - | ||||||||||||||||||||||||
389 | case QPlatformIntegration::PasswordMaskCharacter: | - | ||||||||||||||||||||||||
390 | // TODO using various xcb, gnome or KDE settings | - | ||||||||||||||||||||||||
391 | break; // Not implemented, use defaults | - | ||||||||||||||||||||||||
392 | case QPlatformIntegration::FontSmoothingGamma: | - | ||||||||||||||||||||||||
393 | // Match Qt 4.8 text rendering, and rendering of other X11 toolkits. | - | ||||||||||||||||||||||||
394 | return qreal(1.0); | - | ||||||||||||||||||||||||
395 | case QPlatformIntegration::StartDragDistance: { | - | ||||||||||||||||||||||||
396 | // The default (in QPlatformTheme::defaultThemeHint) is 10 pixels, but | - | ||||||||||||||||||||||||
397 | // on a high-resolution screen it makes sense to increase it. | - | ||||||||||||||||||||||||
398 | qreal dpi = 100.0; | - | ||||||||||||||||||||||||
399 | if (const QXcbScreen *screen = defaultConnection()->primaryScreen()) { | - | ||||||||||||||||||||||||
400 | if (screen->logicalDpi().first > dpi) | - | ||||||||||||||||||||||||
401 | dpi = screen->logicalDpi().first; | - | ||||||||||||||||||||||||
402 | if (screen->logicalDpi().second > dpi) | - | ||||||||||||||||||||||||
403 | dpi = screen->logicalDpi().second; | - | ||||||||||||||||||||||||
404 | } | - | ||||||||||||||||||||||||
405 | return 10.0 * dpi / 100.0; | - | ||||||||||||||||||||||||
406 | } | - | ||||||||||||||||||||||||
407 | case QPlatformIntegration::ShowIsFullScreen: | - | ||||||||||||||||||||||||
408 | // X11 always has support for windows, but the | - | ||||||||||||||||||||||||
409 | // window manager could prevent it (e.g. matchbox) | - | ||||||||||||||||||||||||
410 | return false; | - | ||||||||||||||||||||||||
411 | case QPlatformIntegration::ReplayMousePressOutsidePopup: | - | ||||||||||||||||||||||||
412 | return false; | - | ||||||||||||||||||||||||
413 | default: | - | ||||||||||||||||||||||||
414 | break; | - | ||||||||||||||||||||||||
415 | } | - | ||||||||||||||||||||||||
416 | return QPlatformIntegration::styleHint(hint); | - | ||||||||||||||||||||||||
417 | } | - | ||||||||||||||||||||||||
418 | - | |||||||||||||||||||||||||
419 | static QString argv0BaseName() | - | ||||||||||||||||||||||||
420 | { | - | ||||||||||||||||||||||||
421 | QString result; | - | ||||||||||||||||||||||||
422 | const QStringList arguments = QCoreApplication::arguments(); | - | ||||||||||||||||||||||||
423 | if (!arguments.isEmpty() && !arguments.front().isEmpty()) { | - | ||||||||||||||||||||||||
424 | result = arguments.front(); | - | ||||||||||||||||||||||||
425 | const int lastSlashPos = result.lastIndexOf(QLatin1Char('/')); | - | ||||||||||||||||||||||||
426 | if (lastSlashPos != -1) | - | ||||||||||||||||||||||||
427 | result.remove(0, lastSlashPos + 1); | - | ||||||||||||||||||||||||
428 | } | - | ||||||||||||||||||||||||
429 | return result; | - | ||||||||||||||||||||||||
430 | } | - | ||||||||||||||||||||||||
431 | - | |||||||||||||||||||||||||
432 | static const char resourceNameVar[] = "RESOURCE_NAME"; | - | ||||||||||||||||||||||||
433 | - | |||||||||||||||||||||||||
434 | QByteArray QXcbIntegration::wmClass() const | - | ||||||||||||||||||||||||
435 | { | - | ||||||||||||||||||||||||
436 | if (m_wmClass.isEmpty()) { | - | ||||||||||||||||||||||||
437 | // Instance name according to ICCCM 4.1.2.5 | - | ||||||||||||||||||||||||
438 | QString name; | - | ||||||||||||||||||||||||
439 | if (m_instanceName) | - | ||||||||||||||||||||||||
440 | name = QString::fromLocal8Bit(m_instanceName); | - | ||||||||||||||||||||||||
441 | if (name.isEmpty() && qEnvironmentVariableIsSet(resourceNameVar)) | - | ||||||||||||||||||||||||
442 | name = QString::fromLocal8Bit(qgetenv(resourceNameVar)); | - | ||||||||||||||||||||||||
443 | if (name.isEmpty()) | - | ||||||||||||||||||||||||
444 | name = argv0BaseName(); | - | ||||||||||||||||||||||||
445 | - | |||||||||||||||||||||||||
446 | // Note: QCoreApplication::applicationName() cannot be called from the QGuiApplication constructor, | - | ||||||||||||||||||||||||
447 | // hence this delayed initialization. | - | ||||||||||||||||||||||||
448 | QString className = QCoreApplication::applicationName(); | - | ||||||||||||||||||||||||
449 | if (className.isEmpty()) { | - | ||||||||||||||||||||||||
450 | className = argv0BaseName(); | - | ||||||||||||||||||||||||
451 | if (!className.isEmpty() && className.at(0).isLower()) | - | ||||||||||||||||||||||||
452 | className[0] = className.at(0).toUpper(); | - | ||||||||||||||||||||||||
453 | } | - | ||||||||||||||||||||||||
454 | - | |||||||||||||||||||||||||
455 | if (!name.isEmpty() && !className.isEmpty()) { | - | ||||||||||||||||||||||||
456 | m_wmClass = name.toLocal8Bit(); | - | ||||||||||||||||||||||||
457 | m_wmClass.append('\0'); | - | ||||||||||||||||||||||||
458 | m_wmClass.append(className.toLocal8Bit()); | - | ||||||||||||||||||||||||
459 | m_wmClass.append('\0'); | - | ||||||||||||||||||||||||
460 | } | - | ||||||||||||||||||||||||
461 | } | - | ||||||||||||||||||||||||
462 | return m_wmClass; | - | ||||||||||||||||||||||||
463 | } | - | ||||||||||||||||||||||||
464 | - | |||||||||||||||||||||||||
465 | #if !defined(QT_NO_SESSIONMANAGER) && defined(XCB_USE_SM) | - | ||||||||||||||||||||||||
466 | QPlatformSessionManager *QXcbIntegration::createPlatformSessionManager(const QString &id, const QString &key) const | - | ||||||||||||||||||||||||
467 | { | - | ||||||||||||||||||||||||
468 | return new QXcbSessionManager(id, key); | - | ||||||||||||||||||||||||
469 | } | - | ||||||||||||||||||||||||
470 | #endif | - | ||||||||||||||||||||||||
471 | - | |||||||||||||||||||||||||
472 | void QXcbIntegration::sync() | - | ||||||||||||||||||||||||
473 | { | - | ||||||||||||||||||||||||
474 | for (int i = 0; i < m_connections.size(); i++) { | - | ||||||||||||||||||||||||
475 | m_connections.at(i)->sync(); | - | ||||||||||||||||||||||||
476 | } | - | ||||||||||||||||||||||||
477 | } | - | ||||||||||||||||||||||||
478 | - | |||||||||||||||||||||||||
479 | // For QApplication::beep() | - | ||||||||||||||||||||||||
480 | void QXcbIntegration::beep() const | - | ||||||||||||||||||||||||
481 | { | - | ||||||||||||||||||||||||
482 | QScreen *priScreen = QGuiApplication::primaryScreen(); | - | ||||||||||||||||||||||||
483 | if (!priScreen)
| 0 | ||||||||||||||||||||||||
484 | return; never executed: return; | 0 | ||||||||||||||||||||||||
485 | QPlatformScreen *screen = priScreen->handle(); | - | ||||||||||||||||||||||||
486 | if (!screen)
| 0 | ||||||||||||||||||||||||
487 | return; never executed: return; | 0 | ||||||||||||||||||||||||
488 | xcb_connection_t *connection = static_cast<QXcbScreen *>(screen)->xcb_connection(); | - | ||||||||||||||||||||||||
489 | xcb_bell(connection, 0); | - | ||||||||||||||||||||||||
490 | } never executed: end of block | 0 | ||||||||||||||||||||||||
491 | - | |||||||||||||||||||||||||
492 | QT_END_NAMESPACE | - | ||||||||||||||||||||||||
Source code | Switch to Preprocessed file |