| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/plugins/platforms/xcb/qxcbnativeinterface.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 "qxcbnativeinterface.h" | - | ||||||
| 41 | - | |||||||
| 42 | #include "qxcbcursor.h" | - | ||||||
| 43 | #include "qxcbscreen.h" | - | ||||||
| 44 | #include "qxcbwindow.h" | - | ||||||
| 45 | #include "qxcbintegration.h" | - | ||||||
| 46 | #include "qxcbsystemtraytracker.h" | - | ||||||
| 47 | - | |||||||
| 48 | #include <private/qguiapplication_p.h> | - | ||||||
| 49 | #include <QtCore/QMap> | - | ||||||
| 50 | - | |||||||
| 51 | #include <QtCore/QDebug> | - | ||||||
| 52 | - | |||||||
| 53 | #include <QtGui/qopenglcontext.h> | - | ||||||
| 54 | #include <QtGui/qscreen.h> | - | ||||||
| 55 | - | |||||||
| 56 | #include <QtPlatformHeaders/qxcbwindowfunctions.h> | - | ||||||
| 57 | #include <QtPlatformHeaders/qxcbintegrationfunctions.h> | - | ||||||
| 58 | #include <QtPlatformHeaders/qxcbscreenfunctions.h> | - | ||||||
| 59 | - | |||||||
| 60 | #ifndef QT_NO_DBUS | - | ||||||
| 61 | #include "QtPlatformSupport/private/qdbusmenuconnection_p.h" | - | ||||||
| 62 | #endif | - | ||||||
| 63 | - | |||||||
| 64 | #ifdef XCB_USE_XLIB | - | ||||||
| 65 | # include <X11/Xlib.h> | - | ||||||
| 66 | #else | - | ||||||
| 67 | # include <stdio.h> | - | ||||||
| 68 | #endif | - | ||||||
| 69 | - | |||||||
| 70 | #include <algorithm> | - | ||||||
| 71 | - | |||||||
| 72 | #include "qxcbnativeinterfacehandler.h" | - | ||||||
| 73 | - | |||||||
| 74 | QT_BEGIN_NAMESPACE | - | ||||||
| 75 | - | |||||||
| 76 | // return QXcbNativeInterface::ResourceType for the key. | - | ||||||
| 77 | static int resourceType(const QByteArray &key) | - | ||||||
| 78 | { | - | ||||||
| 79 | static const QByteArray names[] = { // match QXcbNativeInterface::ResourceType | - | ||||||
| 80 | QByteArrayLiteral("display"), | - | ||||||
| 81 | QByteArrayLiteral("connection"), QByteArrayLiteral("screen"), | - | ||||||
| 82 | QByteArrayLiteral("apptime"), | - | ||||||
| 83 | QByteArrayLiteral("appusertime"), QByteArrayLiteral("hintstyle"), | - | ||||||
| 84 | QByteArrayLiteral("startupid"), QByteArrayLiteral("traywindow"), | - | ||||||
| 85 | QByteArrayLiteral("gettimestamp"), QByteArrayLiteral("x11screen"), | - | ||||||
| 86 | QByteArrayLiteral("rootwindow"), | - | ||||||
| 87 | QByteArrayLiteral("subpixeltype"), QByteArrayLiteral("antialiasingenabled"), | - | ||||||
| 88 | QByteArrayLiteral("nofonthinting"), | - | ||||||
| 89 | QByteArrayLiteral("atspibus"), | - | ||||||
| 90 | QByteArrayLiteral("compositingenabled") | - | ||||||
| 91 | }; | - | ||||||
| 92 | const QByteArray *end = names + sizeof(names) / sizeof(names[0]); | - | ||||||
| 93 | const QByteArray *result = std::find(names, end, key); | - | ||||||
| 94 | return int(result - names); executed 186 times by 128 tests: return int(result - names);Executed by:
| 186 | ||||||
| 95 | } | - | ||||||
| 96 | - | |||||||
| 97 | QXcbNativeInterface::QXcbNativeInterface() : | - | ||||||
| 98 | m_genericEventFilterType(QByteArrayLiteral("xcb_generic_event_t")), | - | ||||||
| 99 | m_sysTraySelectionAtom(XCB_ATOM_NONE) | - | ||||||
| { | ||||||||
| } | ||||||||
| void QXcbNativeInterface::beep() { | ||||||||
| QScreen *priScreen = QGuiApplication::primaryScreen(); | ||||||||
| if (!priScreen) | ||||||||
| return; | ||||||||
| QPlatformScreen *screen = priScreen->handle(); | ||||||||
| if (!screen) | ||||||||
| return; | ||||||||
| xcb_connection_t *connection = static_cast<QXcbScreen *>(screen)->xcb_connection(); | ||||||||
| xcb_bell(connection, 0);} | ||||||||
| 102 | - | |||||||
| 103 | static inline QXcbSystemTrayTracker *systemTrayTracker(const QScreen *s) | - | ||||||
| 104 | { | - | ||||||
| 105 | if (!s) | - | ||||||
| 106 | return Q_NULLPTR; | - | ||||||
| 107 | - | |||||||
| 108 | return static_cast<const QXcbScreen *>(s->handle())->connection()->systemTrayTracker(); | - | ||||||
| 109 | } | - | ||||||
| 110 | - | |||||||
| 111 | bool QXcbNativeInterface::systemTrayAvailable(const QScreen *screen) const | - | ||||||
| 112 | { | - | ||||||
| 113 | return systemTrayTracker(screen); | - | ||||||
| 114 | } | - | ||||||
| 115 | - | |||||||
| 116 | bool QXcbNativeInterface::requestSystemTrayWindowDock(const QWindow *window) | - | ||||||
| 117 | { | - | ||||||
| 118 | return QXcbWindow::requestSystemTrayWindowDockStatic(window); | - | ||||||
| 119 | } | - | ||||||
| 120 | - | |||||||
| 121 | QRect QXcbNativeInterface::systemTrayWindowGlobalGeometry(const QWindow *window) | - | ||||||
| 122 | { | - | ||||||
| 123 | return QXcbWindow::systemTrayWindowGlobalGeometryStatic(window); | - | ||||||
| 124 | } | - | ||||||
| 125 | - | |||||||
| 126 | xcb_window_t QXcbNativeInterface::locateSystemTray(xcb_connection_t *conn, const QXcbScreen *screen) | - | ||||||
| 127 | { | - | ||||||
| 128 | if (m_sysTraySelectionAtom == XCB_ATOM_NONE) { | - | ||||||
| 129 | const QByteArray net_sys_tray = QString::fromLatin1("_NET_SYSTEM_TRAY_S%1").arg(screen->screenNumber()).toLatin1(); | - | ||||||
| 130 | xcb_intern_atom_cookie_t intern_c = | - | ||||||
| 131 | xcb_intern_atom_unchecked(conn, true, net_sys_tray.length(), net_sys_tray); | - | ||||||
| 132 | - | |||||||
| 133 | xcb_intern_atom_reply_t *intern_r = xcb_intern_atom_reply(conn, intern_c, 0); | - | ||||||
| 134 | - | |||||||
| 135 | if (!intern_r) | - | ||||||
| 136 | return XCB_WINDOW_NONE; | - | ||||||
| 137 | - | |||||||
| 138 | m_sysTraySelectionAtom = intern_r->atom; | - | ||||||
| 139 | free(intern_r); | - | ||||||
| 140 | } | - | ||||||
| 141 | - | |||||||
| 142 | xcb_get_selection_owner_cookie_t sel_owner_c = xcb_get_selection_owner_unchecked(conn, m_sysTraySelectionAtom); | - | ||||||
| 143 | xcb_get_selection_owner_reply_t *sel_owner_r = xcb_get_selection_owner_reply(conn, sel_owner_c, 0); | - | ||||||
| 144 | - | |||||||
| 145 | if (!sel_owner_r) | - | ||||||
| 146 | return XCB_WINDOW_NONE; | - | ||||||
| 147 | - | |||||||
| 148 | xcb_window_t selection_window = sel_owner_r->owner; | - | ||||||
| 149 | free(sel_owner_r); | - | ||||||
| 150 | - | |||||||
| 151 | return selection_window; | - | ||||||
| 152 | } | - | ||||||
| 153 | - | |||||||
| 154 | bool QXcbNativeInterface::systrayVisualHasAlphaChannel() | - | ||||||
| 155 | { | - | ||||||
| 156 | return QXcbConnection::xEmbedSystemTrayVisualHasAlphaChannel(); | - | ||||||
| 157 | } | - | ||||||
| 158 | - | |||||||
| 159 | void QXcbNativeInterface::setParentRelativeBackPixmap(QWindow *window) | - | ||||||
| 160 | { | - | ||||||
| 161 | QXcbWindow::setParentRelativeBackPixmapStatic(window); | - | ||||||
| 162 | } | - | ||||||
| 163 | - | |||||||
| 164 | void *QXcbNativeInterface::nativeResourceForIntegration(const QByteArray &resourceString) | - | ||||||
| 165 | { | - | ||||||
| 166 | QByteArray lowerCaseResource = resourceString.toLower(); | - | ||||||
| 167 | void *result = handlerNativeResourceForIntegration(lowerCaseResource); | - | ||||||
| 168 | if (result) | - | ||||||
| 169 | return result; | - | ||||||
| 170 | - | |||||||
| 171 | switch (resourceType(lowerCaseResource)) { | - | ||||||
| 172 | case StartupId: | - | ||||||
| 173 | result = startupId(); | - | ||||||
| 174 | break; | - | ||||||
| 175 | case X11Screen: | - | ||||||
| 176 | result = x11Screen(); | - | ||||||
| 177 | break; | - | ||||||
| 178 | case RootWindow: | - | ||||||
| 179 | result = rootWindow(); | - | ||||||
| 180 | break; | - | ||||||
| 181 | case Display: | - | ||||||
| 182 | result = display(); | - | ||||||
| 183 | break; | - | ||||||
| 184 | case AtspiBus: | - | ||||||
| 185 | result = atspiBus(); | - | ||||||
| 186 | break; | - | ||||||
| 187 | case Connection: | - | ||||||
| 188 | result = connection(); | - | ||||||
| 189 | break; | - | ||||||
| 190 | default: | - | ||||||
| 191 | break; | - | ||||||
| 192 | } | - | ||||||
| 193 | - | |||||||
| 194 | return result; | - | ||||||
| 195 | } | - | ||||||
| 196 | - | |||||||
| 197 | void *QXcbNativeInterface::nativeResourceForContext(const QByteArray &resourceString, QOpenGLContext *context) | - | ||||||
| 198 | { | - | ||||||
| 199 | QByteArray lowerCaseResource = resourceString.toLower(); | - | ||||||
| 200 | void *result = handlerNativeResourceForContext(lowerCaseResource, context); | - | ||||||
| 201 | return result; | - | ||||||
| 202 | } | - | ||||||
| 203 | - | |||||||
| 204 | void *QXcbNativeInterface::nativeResourceForScreen(const QByteArray &resourceString, QScreen *screen) | - | ||||||
| 205 | { | - | ||||||
| 206 | if (!screen) {
| 0-6 | ||||||
| 207 | qWarning() << ("nativeResourceForScreen: null screen";); | - | ||||||
| 208 | return Q_NULLPTR; never executed: return nullptr; | 0 | ||||||
| 209 | } | - | ||||||
| 210 | - | |||||||
| 211 | QByteArray lowerCaseResource = resourceString.toLower(); | - | ||||||
| 212 | void *result = handlerNativeResourceForScreen(lowerCaseResource, screen); | - | ||||||
| 213 | if (result)
| 0-6 | ||||||
| 214 | return result; never executed: return result; | 0 | ||||||
| 215 | - | |||||||
| 216 | const QXcbScreen *xcbScreen = static_cast<QXcbScreen *>(screen->handle()); | - | ||||||
| 217 | switch (resourceType(lowerCaseResource)) { | - | ||||||
| 218 | case Display: never executed: case Display: | 0 | ||||||
| 219 | #ifdef XCB_USE_XLIB | - | ||||||
| 220 | result = xcbScreen->connection()->xlib_display(); | - | ||||||
| 221 | #endif | - | ||||||
| 222 | break; never executed: break; | 0 | ||||||
| 223 | case AppTime: never executed: case AppTime: | 0 | ||||||
| 224 | result = appTime(xcbScreen); | - | ||||||
| 225 | break; never executed: break; | 0 | ||||||
| 226 | case AppUserTime: never executed: case AppUserTime: | 0 | ||||||
| 227 | result = appUserTime(xcbScreen); | - | ||||||
| 228 | break; never executed: break; | 0 | ||||||
| 229 | case ScreenHintStyle: never executed: case ScreenHintStyle: | 0 | ||||||
| 230 | result = reinterpret_cast<void *>(xcbScreen->hintStyle() + 1); | - | ||||||
| 231 | break; never executed: break; | 0 | ||||||
| 232 | case ScreenSubpixelType: never executed: case ScreenSubpixelType: | 0 | ||||||
| 233 | result = reinterpret_cast<void *>(xcbScreen->subpixelType() + 1); | - | ||||||
| 234 | break; never executed: break; | 0 | ||||||
| 235 | case ScreenAntialiasingEnabled: never executed: case ScreenAntialiasingEnabled: | 0 | ||||||
| 236 | result = reinterpret_cast<void *>(xcbScreen->antialiasingEnabled() + 1); | - | ||||||
| 237 | break; never executed: break; | 0 | ||||||
| 238 | case TrayWindow: executed 6 times by 1 test: case TrayWindow:Executed by:
| 6 | ||||||
| 239 | if (QXcbSystemTrayTracker *s = systemTrayTracker(screen))
| 0-6 | ||||||
| 240 | result = (void *)quintptr(s->trayWindow()); executed 6 times by 1 test: result = (void *)quintptr(s->trayWindow());Executed by:
| 6 | ||||||
| 241 | break; executed 6 times by 1 test: break;Executed by:
| 6 | ||||||
| 242 | case GetTimestamp: never executed: case GetTimestamp: | 0 | ||||||
| 243 | result = getTimestamp(xcbScreen); | - | ||||||
| 244 | break; never executed: break; | 0 | ||||||
| 245 | case NoFontHinting: never executed: case NoFontHinting: | 0 | ||||||
| 246 | result = xcbScreen->noFontHinting() ? this : 0; //qboolptr...
| 0 | ||||||
| 247 | break; never executed: break; | 0 | ||||||
| 248 | case RootWindow: never executed: case RootWindow: | 0 | ||||||
| 249 | result = reinterpret_cast<void *>(xcbScreen->root()); | - | ||||||
| 250 | break; never executed: break; | 0 | ||||||
| 251 | case CompositingEnabled: never executed: case CompositingEnabled: | 0 | ||||||
| 252 | if (QXcbVirtualDesktop *vd = xcbScreen->virtualDesktop())
| 0 | ||||||
| 253 | result = vd->compositingActive() ? this : Q_NULLPTR; never executed: result = vd->compositingActive() ? this : nullptr;
| 0 | ||||||
| 254 | break; never executed: break; | 0 | ||||||
| 255 | default: never executed: default: | 0 | ||||||
| 256 | break; never executed: break; | 0 | ||||||
| 257 | } | - | ||||||
| 258 | return result; executed 6 times by 1 test: return result;Executed by:
| 6 | ||||||
| 259 | } | - | ||||||
| 260 | - | |||||||
| 261 | void *QXcbNativeInterface::nativeResourceForWindow(const QByteArray &resourceString, QWindow *window) | - | ||||||
| 262 | { | - | ||||||
| 263 | QByteArray lowerCaseResource = resourceString.toLower(); | - | ||||||
| 264 | void *result = handlerNativeResourceForWindow(lowerCaseResource, window); | - | ||||||
| 265 | if (result) | - | ||||||
| 266 | return result; | - | ||||||
| 267 | - | |||||||
| 268 | switch (resourceType(lowerCaseResource)) { | - | ||||||
| 269 | case Display: | - | ||||||
| 270 | result = displayForWindow(window); | - | ||||||
| 271 | break; | - | ||||||
| 272 | case Connection: | - | ||||||
| 273 | result = connectionForWindow(window); | - | ||||||
| 274 | break; | - | ||||||
| 275 | case Screen: | - | ||||||
| 276 | result = screenForWindow(window); | - | ||||||
| 277 | break; | - | ||||||
| 278 | default: | - | ||||||
| 279 | break; | - | ||||||
| 280 | } | - | ||||||
| 281 | - | |||||||
| 282 | return result; | - | ||||||
| 283 | } | - | ||||||
| 284 | - | |||||||
| 285 | void *QXcbNativeInterface::nativeResourceForBackingStore(const QByteArray &resourceString, QBackingStore *backingStore) | - | ||||||
| 286 | { | - | ||||||
| 287 | const QByteArray lowerCaseResource = resourceString.toLower(); | - | ||||||
| 288 | void *result = handlerNativeResourceForBackingStore(lowerCaseResource,backingStore); | - | ||||||
| 289 | return result; | - | ||||||
| 290 | } | - | ||||||
| 291 | - | |||||||
| 292 | #ifndef QT_NO_CURSOR | - | ||||||
| 293 | void *QXcbNativeInterface::nativeResourceForCursor(const QByteArray &resource, const QCursor &cursor) | - | ||||||
| 294 | { | - | ||||||
| 295 | if (resource == QByteArrayLiteral("xcbcursor")) { never executed: return ba;
| 0 | ||||||
| 296 | if (const QScreen *primaryScreen = QGuiApplication::primaryScreen()) {
| 0 | ||||||
| 297 | if (const QPlatformCursor *pCursor= primaryScreen->handle()->cursor()) {
| 0 | ||||||
| 298 | xcb_cursor_t xcbCursor = static_cast<const QXcbCursor *>(pCursor)->xcbCursor(cursor); | - | ||||||
| 299 | return reinterpret_cast<void *>(quintptr(xcbCursor)); never executed: return reinterpret_cast<void *>(quintptr(xcbCursor)); | 0 | ||||||
| 300 | } | - | ||||||
| 301 | } never executed: end of block | 0 | ||||||
| 302 | } never executed: end of block | 0 | ||||||
| 303 | return Q_NULLPTR never executed: ;return nullptr;never executed: return nullptr; | 0 | ||||||
| 304 | } | - | ||||||
| 305 | #endif // !QT_NO_CURSOR | - | ||||||
| 306 | - | |||||||
| 307 | QPlatformNativeInterface::NativeResourceForIntegrationFunction QXcbNativeInterface::nativeResourceFunctionForIntegration(const QByteArray &resource) | - | ||||||
| 308 | { | - | ||||||
| 309 | const QByteArray lowerCaseResource = resource.toLower(); | - | ||||||
| 310 | QPlatformNativeInterface::NativeResourceForIntegrationFunction func = handlerNativeResourceFunctionForIntegration(lowerCaseResource); | - | ||||||
| 311 | if (func) | - | ||||||
| 312 | return func; | - | ||||||
| 313 | - | |||||||
| 314 | if (lowerCaseResource == "setstartupid") | - | ||||||
| 315 | return NativeResourceForIntegrationFunction(setStartupId); | - | ||||||
| 316 | return 0; | - | ||||||
| 317 | } | - | ||||||
| 318 | - | |||||||
| 319 | QPlatformNativeInterface::NativeResourceForContextFunction QXcbNativeInterface::nativeResourceFunctionForContext(const QByteArray &resource) | - | ||||||
| 320 | { | - | ||||||
| 321 | const QByteArray lowerCaseResource = resource.toLower(); | - | ||||||
| 322 | QPlatformNativeInterface::NativeResourceForContextFunction func = handlerNativeResourceFunctionForContext(lowerCaseResource); | - | ||||||
| 323 | if (func) | - | ||||||
| 324 | return func; | - | ||||||
| 325 | return Q_NULLPTR; | - | ||||||
| 326 | } | - | ||||||
| 327 | - | |||||||
| 328 | QPlatformNativeInterface::NativeResourceForScreenFunction QXcbNativeInterface::nativeResourceFunctionForScreen(const QByteArray &resource) | - | ||||||
| 329 | { | - | ||||||
| 330 | const QByteArray lowerCaseResource = resource.toLower(); | - | ||||||
| 331 | NativeResourceForScreenFunction func = handlerNativeResourceFunctionForScreen(lowerCaseResource); | - | ||||||
| 332 | if (func) | - | ||||||
| 333 | return func; | - | ||||||
| 334 | - | |||||||
| 335 | if (lowerCaseResource == "setapptime") | - | ||||||
| 336 | return NativeResourceForScreenFunction(setAppTime); | - | ||||||
| 337 | else if (lowerCaseResource == "setappusertime") | - | ||||||
| 338 | return NativeResourceForScreenFunction(setAppUserTime); | - | ||||||
| 339 | return 0; | - | ||||||
| 340 | } | - | ||||||
| 341 | - | |||||||
| 342 | QPlatformNativeInterface::NativeResourceForWindowFunction QXcbNativeInterface::nativeResourceFunctionForWindow(const QByteArray &resource) | - | ||||||
| 343 | { | - | ||||||
| 344 | const QByteArray lowerCaseResource = resource.toLower(); | - | ||||||
| 345 | NativeResourceForWindowFunction func = handlerNativeResourceFunctionForWindow(lowerCaseResource); | - | ||||||
| 346 | return func; | - | ||||||
| 347 | } | - | ||||||
| 348 | - | |||||||
| 349 | QPlatformNativeInterface::NativeResourceForBackingStoreFunction QXcbNativeInterface::nativeResourceFunctionForBackingStore(const QByteArray &resource) | - | ||||||
| 350 | { | - | ||||||
| 351 | const QByteArray lowerCaseResource = resource.toLower(); | - | ||||||
| 352 | NativeResourceForBackingStoreFunction func = handlerNativeResourceFunctionForBackingStore(resource); | - | ||||||
| 353 | return func; | - | ||||||
| 354 | } | - | ||||||
| 355 | - | |||||||
| 356 | QFunctionPointer QXcbNativeInterface::platformFunction(const QByteArray &function) const | - | ||||||
| 357 | { | - | ||||||
| 358 | const QByteArray lowerCaseFunction = function.toLower(); | - | ||||||
| 359 | QFunctionPointer func = handlerPlatformFunction(lowerCaseFunction); | - | ||||||
| 360 | if (func) | - | ||||||
| 361 | return func; | - | ||||||
| 362 | - | |||||||
| 363 | //case sensitive | - | ||||||
| 364 | if (function == QXcbWindowFunctions::setWmWindowTypeIdentifier()) | - | ||||||
| 365 | return QFunctionPointer(QXcbWindowFunctions::SetWmWindowType(QXcbWindow::setWmWindowTypeStatic)); | - | ||||||
| 366 | - | |||||||
| 367 | if (function == QXcbWindowFunctions::setWmWindowRoleIdentifier()) | - | ||||||
| 368 | return QFunctionPointer(QXcbWindowFunctions::SetWmWindowRole(QXcbWindow::setWmWindowRoleStatic)); | - | ||||||
| 369 | - | |||||||
| 370 | if (function == QXcbWindowFunctions::setWmWindowIconTextIdentifier()) | - | ||||||
| 371 | return QFunctionPointer(QXcbWindowFunctions::SetWmWindowIconText(QXcbWindow::setWindowIconTextStatic)); | - | ||||||
| 372 | - | |||||||
| 373 | if (function == QXcbWindowFunctions::setParentRelativeBackPixmapIdentifier()) | - | ||||||
| 374 | return QFunctionPointer(QXcbWindowFunctions::SetParentRelativeBackPixmap(QXcbWindow::setParentRelativeBackPixmapStatic)); | - | ||||||
| 375 | - | |||||||
| 376 | if (function == QXcbWindowFunctions::requestSystemTrayWindowDockIdentifier()) | - | ||||||
| 377 | return QFunctionPointer(QXcbWindowFunctions::RequestSystemTrayWindowDock(QXcbWindow::requestSystemTrayWindowDockStatic)); | - | ||||||
| 378 | - | |||||||
| 379 | if (function == QXcbWindowFunctions::systemTrayWindowGlobalGeometryIdentifier()) | - | ||||||
| 380 | return QFunctionPointer(QXcbWindowFunctions::SystemTrayWindowGlobalGeometry(QXcbWindow::systemTrayWindowGlobalGeometryStatic)); | - | ||||||
| 381 | - | |||||||
| 382 | if (function == QXcbIntegrationFunctions::xEmbedSystemTrayVisualHasAlphaChannelIdentifier()) | - | ||||||
| 383 | return QFunctionPointer(QXcbIntegrationFunctions::XEmbedSystemTrayVisualHasAlphaChannel(QXcbConnection::xEmbedSystemTrayVisualHasAlphaChannel)); | - | ||||||
| 384 | - | |||||||
| 385 | if (function == QXcbWindowFunctions::visualIdIdentifier()) { | - | ||||||
| 386 | return QFunctionPointer(QXcbWindowFunctions::VisualId(QXcbWindow::visualIdStatic)); | - | ||||||
| 387 | } | - | ||||||
| 388 | - | |||||||
| 389 | if (function == QXcbScreenFunctions::virtualDesktopNumberIdentifier()) | - | ||||||
| 390 | return QFunctionPointer(QXcbScreenFunctions::VirtualDesktopNumber(QXcbScreen::virtualDesktopNumberStatic)); | - | ||||||
| 391 | - | |||||||
| 392 | return Q_NULLPTR; | - | ||||||
| 393 | } | - | ||||||
| 394 | - | |||||||
| 395 | void *QXcbNativeInterface::appTime(const QXcbScreen *screen) | - | ||||||
| 396 | { | - | ||||||
| 397 | if (!screen) | - | ||||||
| 398 | return Q_NULLPTR; | - | ||||||
| 399 | - | |||||||
| 400 | return reinterpret_cast<void *>(quintptr(screen->connection()->time())); | - | ||||||
| 401 | } | - | ||||||
| 402 | - | |||||||
| 403 | void *QXcbNativeInterface::appUserTime(const QXcbScreen *screen) | - | ||||||
| 404 | { | - | ||||||
| 405 | if (!screen) | - | ||||||
| 406 | return Q_NULLPTR; | - | ||||||
| 407 | - | |||||||
| 408 | return reinterpret_cast<void *>(quintptr(screen->connection()->netWmUserTime())); | - | ||||||
| 409 | } | - | ||||||
| 410 | - | |||||||
| 411 | void *QXcbNativeInterface::getTimestamp(const QXcbScreen *screen) | - | ||||||
| 412 | { | - | ||||||
| 413 | if (!screen) | - | ||||||
| 414 | return Q_NULLPTR; | - | ||||||
| 415 | - | |||||||
| 416 | return reinterpret_cast<void *>(quintptr(screen->connection()->getTimestamp())); | - | ||||||
| 417 | } | - | ||||||
| 418 | - | |||||||
| 419 | void *QXcbNativeInterface::startupId() | - | ||||||
| 420 | { | - | ||||||
| 421 | QXcbIntegration* integration = QXcbIntegration::instance(); | - | ||||||
| 422 | QXcbConnection *defaultConnection = integration->defaultConnection(); | - | ||||||
| 423 | if (defaultConnection) | - | ||||||
| 424 | return reinterpret_cast<void *>(const_cast<char *>(defaultConnection->startupId().constData())); | - | ||||||
| 425 | return 0; | - | ||||||
| 426 | } | - | ||||||
| 427 | - | |||||||
| 428 | void *QXcbNativeInterface::x11Screen() | - | ||||||
| 429 | { | - | ||||||
| 430 | QXcbIntegration *integration = QXcbIntegration::instance(); | - | ||||||
| 431 | QXcbConnection *defaultConnection = integration->defaultConnection(); | - | ||||||
| 432 | if (defaultConnection) | - | ||||||
| 433 | return reinterpret_cast<void *>(defaultConnection->primaryScreenNumber()); | - | ||||||
| 434 | return 0; | - | ||||||
| 435 | } | - | ||||||
| 436 | - | |||||||
| 437 | void *QXcbNativeInterface::rootWindow() | - | ||||||
| 438 | { | - | ||||||
| 439 | QXcbIntegration *integration = QXcbIntegration::instance(); | - | ||||||
| 440 | QXcbConnection *defaultConnection = integration->defaultConnection(); | - | ||||||
| 441 | if (defaultConnection) | - | ||||||
| 442 | return reinterpret_cast<void *>(defaultConnection->rootWindow()); | - | ||||||
| 443 | return 0; | - | ||||||
| 444 | } | - | ||||||
| 445 | - | |||||||
| 446 | void *QXcbNativeInterface::display() | - | ||||||
| 447 | { | - | ||||||
| 448 | #ifdef XCB_USE_XLIB | - | ||||||
| 449 | QXcbIntegration *integration = QXcbIntegration::instance(); | - | ||||||
| 450 | QXcbConnection *defaultConnection = integration->defaultConnection(); | - | ||||||
| 451 | if (defaultConnection) | - | ||||||
| 452 | return defaultConnection->xlib_display(); | - | ||||||
| 453 | #endif | - | ||||||
| 454 | return Q_NULLPTR; | - | ||||||
| 455 | } | - | ||||||
| 456 | - | |||||||
| 457 | void *QXcbNativeInterface::connection() | - | ||||||
| 458 | { | - | ||||||
| 459 | QXcbIntegration *integration = QXcbIntegration::instance(); | - | ||||||
| 460 | return integration->defaultConnection()->xcb_connection(); | - | ||||||
| 461 | } | - | ||||||
| 462 | - | |||||||
| 463 | void *QXcbNativeInterface::atspiBus() | - | ||||||
| 464 | { | - | ||||||
| 465 | QXcbIntegration *integration = static_cast<QXcbIntegration *>(QGuiApplicationPrivate::platformIntegration()); | - | ||||||
| 466 | QXcbConnection *defaultConnection = integration->defaultConnection(); | - | ||||||
| 467 | if (defaultConnection) {
| 0-180 | ||||||
| 468 | xcb_atom_t atspiBusAtom = defaultConnection->internAtom("AT_SPI_BUS"); | - | ||||||
| 469 | xcb_get_property_cookie_t cookie = Q_XCB_CALLQ_XCB_CALL2(xcb_get_property( | - | ||||||
| 470 | defaultConnection->xcb_connection(), | - | ||||||
| 471 | false, defaultConnection->rootWindow(), | - | ||||||
| 472 | atspiBusAtom, XCB_ATOM_STRING, 0, 128));), | - | ||||||
| 473 | defaultConnection); | - | ||||||
| 474 | xcb_get_property_reply_t *reply = Q_XCB_CALLQ_XCB_CALL2(xcb_get_property_reply( | - | ||||||
| 475 | defaultConnection->xcb_connection(), | - | ||||||
| 476 | cookie, 0));), | - | ||||||
| 477 | defaultConnection); | - | ||||||
| 478 | Q_ASSERT(!reply->bytes_after); | - | ||||||
| 479 | char *data = (char *)xcb_get_property_value(reply); | - | ||||||
| 480 | int length = xcb_get_property_value_length(reply); | - | ||||||
| 481 | QByteArray *busAddress = new QByteArray(data, length); | - | ||||||
| 482 | free(reply); | - | ||||||
| 483 | return busAddress; executed 180 times by 128 tests: return busAddress;Executed by:
| 180 | ||||||
| 484 | } | - | ||||||
| 485 | return 0; never executed: return 0; | 0 | ||||||
| 486 | } | - | ||||||
| 487 | - | |||||||
| 488 | void QXcbNativeInterface::setAppTime(QScreen* screen, xcb_timestamp_t time) | - | ||||||
| 489 | { | - | ||||||
| 490 | if (screen) { | - | ||||||
| 491 | static_cast<QXcbScreen *>(screen->handle())->connection()->setTime(time); | - | ||||||
| 492 | } | - | ||||||
| 493 | } | - | ||||||
| 494 | - | |||||||
| 495 | void QXcbNativeInterface::setAppUserTime(QScreen* screen, xcb_timestamp_t time) | - | ||||||
| 496 | { | - | ||||||
| 497 | if (screen) { | - | ||||||
| 498 | static_cast<QXcbScreen *>(screen->handle())->connection()->setNetWmUserTime(time); | - | ||||||
| 499 | } | - | ||||||
| 500 | } | - | ||||||
| 501 | - | |||||||
| 502 | void QXcbNativeInterface::setStartupId(const char *data) | - | ||||||
| 503 | { | - | ||||||
| 504 | QByteArray startupId(data); | - | ||||||
| 505 | QXcbIntegration *integration = QXcbIntegration::instance(); | - | ||||||
| 506 | QXcbConnection *defaultConnection = integration->defaultConnection(); | - | ||||||
| 507 | if (defaultConnection) | - | ||||||
| 508 | defaultConnection->setStartupId(startupId); | - | ||||||
| 509 | } | - | ||||||
| 510 | - | |||||||
| 511 | QXcbScreen *QXcbNativeInterface::qPlatformScreenForWindow(QWindow *window) | - | ||||||
| 512 | { | - | ||||||
| 513 | QXcbScreen *screen; | - | ||||||
| 514 | if (window) { | - | ||||||
| 515 | QScreen *qs = window->screen(); | - | ||||||
| 516 | screen = static_cast<QXcbScreen *>(qs ? qs->handle() : Q_NULLPTR); | - | ||||||
| 517 | } else { | - | ||||||
| 518 | QScreen *qs = QGuiApplication::primaryScreen(); | - | ||||||
| 519 | screen = static_cast<QXcbScreen *>(qs ? qs->handle() : Q_NULLPTR); | - | ||||||
| 520 | } | - | ||||||
| 521 | return screen; | - | ||||||
| 522 | } | - | ||||||
| 523 | - | |||||||
| 524 | void *QXcbNativeInterface::displayForWindow(QWindow *window) | - | ||||||
| 525 | { | - | ||||||
| 526 | #if defined(XCB_USE_XLIB) | - | ||||||
| 527 | QXcbScreen *screen = qPlatformScreenForWindow(window); | - | ||||||
| 528 | return screen ? screen->connection()->xlib_display() : Q_NULLPTR; | - | ||||||
| 529 | #else | - | ||||||
| 530 | Q_UNUSED(window); | - | ||||||
| 531 | return Q_NULLPTR; | - | ||||||
| 532 | #endif | - | ||||||
| 533 | } | - | ||||||
| 534 | - | |||||||
| 535 | void *QXcbNativeInterface::connectionForWindow(QWindow *window) | - | ||||||
| 536 | { | - | ||||||
| 537 | QXcbScreen *screen = qPlatformScreenForWindow(window); | - | ||||||
| 538 | return screen ? screen->xcb_connection() : Q_NULLPTR; | - | ||||||
| 539 | } | - | ||||||
| 540 | - | |||||||
| 541 | void *QXcbNativeInterface::screenForWindow(QWindow *window) | - | ||||||
| 542 | { | - | ||||||
| 543 | QXcbScreen *screen = qPlatformScreenForWindow(window); | - | ||||||
| 544 | return screen ? screen->screen() : Q_NULLPTR; | - | ||||||
| 545 | } | - | ||||||
| 546 | - | |||||||
| 547 | void QXcbNativeInterface::addHandler(QXcbNativeInterfaceHandler *handler) | - | ||||||
| 548 | { | - | ||||||
| 549 | m_handlers.removeAll(handler); | - | ||||||
| 550 | m_handlers.prepend(handler); | - | ||||||
| 551 | } | - | ||||||
| 552 | - | |||||||
| 553 | void QXcbNativeInterface::removeHandler(QXcbNativeInterfaceHandler *handler) | - | ||||||
| 554 | { | - | ||||||
| 555 | m_handlers.removeAll(handler); | - | ||||||
| 556 | } | - | ||||||
| 557 | - | |||||||
| 558 | QPlatformNativeInterface::NativeResourceForIntegrationFunction QXcbNativeInterface::handlerNativeResourceFunctionForIntegration(const QByteArray &resource) const | - | ||||||
| 559 | { | - | ||||||
| 560 | for (int i = 0; i < m_handlers.size(); i++) { | - | ||||||
| 561 | QXcbNativeInterfaceHandler *handler = m_handlers.at(i); | - | ||||||
| 562 | NativeResourceForIntegrationFunction result = handler->nativeResourceFunctionForIntegration(resource); | - | ||||||
| 563 | if (result) | - | ||||||
| 564 | return result; | - | ||||||
| 565 | } | - | ||||||
| 566 | return Q_NULLPTR; | - | ||||||
| 567 | } | - | ||||||
| 568 | - | |||||||
| 569 | QPlatformNativeInterface::NativeResourceForContextFunction QXcbNativeInterface::handlerNativeResourceFunctionForContext(const QByteArray &resource) const | - | ||||||
| 570 | { | - | ||||||
| 571 | for (int i = 0; i < m_handlers.size(); i++) { | - | ||||||
| 572 | QXcbNativeInterfaceHandler *handler = m_handlers.at(i); | - | ||||||
| 573 | NativeResourceForContextFunction result = handler->nativeResourceFunctionForContext(resource); | - | ||||||
| 574 | if (result) | - | ||||||
| 575 | return result; | - | ||||||
| 576 | } | - | ||||||
| 577 | return Q_NULLPTR; | - | ||||||
| 578 | } | - | ||||||
| 579 | - | |||||||
| 580 | QPlatformNativeInterface::NativeResourceForScreenFunction QXcbNativeInterface::handlerNativeResourceFunctionForScreen(const QByteArray &resource) const | - | ||||||
| 581 | { | - | ||||||
| 582 | for (int i = 0; i < m_handlers.size(); i++) { | - | ||||||
| 583 | QXcbNativeInterfaceHandler *handler = m_handlers.at(i); | - | ||||||
| 584 | NativeResourceForScreenFunction result = handler->nativeResourceFunctionForScreen(resource); | - | ||||||
| 585 | if (result) | - | ||||||
| 586 | return result; | - | ||||||
| 587 | } | - | ||||||
| 588 | return Q_NULLPTR; | - | ||||||
| 589 | } | - | ||||||
| 590 | - | |||||||
| 591 | QPlatformNativeInterface::NativeResourceForWindowFunction QXcbNativeInterface::handlerNativeResourceFunctionForWindow(const QByteArray &resource) const | - | ||||||
| 592 | { | - | ||||||
| 593 | for (int i = 0; i < m_handlers.size(); i++) { | - | ||||||
| 594 | QXcbNativeInterfaceHandler *handler = m_handlers.at(i); | - | ||||||
| 595 | NativeResourceForWindowFunction result = handler->nativeResourceFunctionForWindow(resource); | - | ||||||
| 596 | if (result) | - | ||||||
| 597 | return result; | - | ||||||
| 598 | } | - | ||||||
| 599 | return Q_NULLPTR; | - | ||||||
| 600 | } | - | ||||||
| 601 | - | |||||||
| 602 | QPlatformNativeInterface::NativeResourceForBackingStoreFunction QXcbNativeInterface::handlerNativeResourceFunctionForBackingStore(const QByteArray &resource) const | - | ||||||
| 603 | { | - | ||||||
| 604 | for (int i = 0; i < m_handlers.size(); i++) { | - | ||||||
| 605 | QXcbNativeInterfaceHandler *handler = m_handlers.at(i); | - | ||||||
| 606 | NativeResourceForBackingStoreFunction result = handler->nativeResourceFunctionForBackingStore(resource); | - | ||||||
| 607 | if (result) | - | ||||||
| 608 | return result; | - | ||||||
| 609 | } | - | ||||||
| 610 | return Q_NULLPTR; | - | ||||||
| 611 | } | - | ||||||
| 612 | - | |||||||
| 613 | QFunctionPointer QXcbNativeInterface::handlerPlatformFunction(const QByteArray &function) const | - | ||||||
| 614 | { | - | ||||||
| 615 | for (int i = 0; i < m_handlers.size(); i++) { | - | ||||||
| 616 | QXcbNativeInterfaceHandler *handler = m_handlers.at(i); | - | ||||||
| 617 | QFunctionPointer func = handler->platformFunction(function); | - | ||||||
| 618 | if (func) | - | ||||||
| 619 | return func; | - | ||||||
| 620 | } | - | ||||||
| 621 | return Q_NULLPTR; | - | ||||||
| 622 | } | - | ||||||
| 623 | - | |||||||
| 624 | void *QXcbNativeInterface::handlerNativeResourceForIntegration(const QByteArray &resource) const | - | ||||||
| 625 | { | - | ||||||
| 626 | NativeResourceForIntegrationFunction func = handlerNativeResourceFunctionForIntegration(resource); | - | ||||||
| 627 | if (func) | - | ||||||
| 628 | return func(); | - | ||||||
| 629 | return Q_NULLPTR; | - | ||||||
| 630 | } | - | ||||||
| 631 | - | |||||||
| 632 | void *QXcbNativeInterface::handlerNativeResourceForContext(const QByteArray &resource, QOpenGLContext *context) const | - | ||||||
| 633 | { | - | ||||||
| 634 | NativeResourceForContextFunction func = handlerNativeResourceFunctionForContext(resource); | - | ||||||
| 635 | if (func) | - | ||||||
| 636 | return func(context); | - | ||||||
| 637 | return Q_NULLPTR; | - | ||||||
| 638 | } | - | ||||||
| 639 | - | |||||||
| 640 | void *QXcbNativeInterface::handlerNativeResourceForScreen(const QByteArray &resource, QScreen *screen) const | - | ||||||
| 641 | { | - | ||||||
| 642 | NativeResourceForScreenFunction func = handlerNativeResourceFunctionForScreen(resource); | - | ||||||
| 643 | if (func) | - | ||||||
| 644 | return func(screen); | - | ||||||
| 645 | return Q_NULLPTR; | - | ||||||
| 646 | } | - | ||||||
| 647 | - | |||||||
| 648 | void *QXcbNativeInterface::handlerNativeResourceForWindow(const QByteArray &resource, QWindow *window) const | - | ||||||
| 649 | { | - | ||||||
| 650 | NativeResourceForWindowFunction func = handlerNativeResourceFunctionForWindow(resource); | - | ||||||
| 651 | if (func) | - | ||||||
| 652 | return func(window); | - | ||||||
| 653 | return Q_NULLPTR; | - | ||||||
| 654 | } | - | ||||||
| 655 | - | |||||||
| 656 | void *QXcbNativeInterface::handlerNativeResourceForBackingStore(const QByteArray &resource, QBackingStore *backingStore) const | - | ||||||
| 657 | { | - | ||||||
| 658 | NativeResourceForBackingStoreFunction func = handlerNativeResourceFunctionForBackingStore(resource); | - | ||||||
| 659 | if (func) | - | ||||||
| 660 | return func(backingStore); | - | ||||||
| 661 | return Q_NULLPTR; | - | ||||||
| 662 | } | - | ||||||
| 663 | - | |||||||
| 664 | QT_END_NAMESPACE | - | ||||||
| Source code | Switch to Preprocessed file |