| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||
| 4 | - | |||||||||||||||||||||||||
| 5 | - | |||||||||||||||||||||||||
| 6 | - | |||||||||||||||||||||||||
| 7 | - | |||||||||||||||||||||||||
| 8 | - | |||||||||||||||||||||||||
| 9 | - | |||||||||||||||||||||||||
| 10 | - | |||||||||||||||||||||||||
| 11 | - | |||||||||||||||||||||||||
| 12 | - | |||||||||||||||||||||||||
| 13 | - | |||||||||||||||||||||||||
| 14 | - | |||||||||||||||||||||||||
| 15 | - | |||||||||||||||||||||||||
| 16 | - | |||||||||||||||||||||||||
| 17 | - | |||||||||||||||||||||||||
| 18 | - | |||||||||||||||||||||||||
| 19 | - | |||||||||||||||||||||||||
| 20 | - | |||||||||||||||||||||||||
| 21 | - | |||||||||||||||||||||||||
| 22 | - | |||||||||||||||||||||||||
| 23 | - | |||||||||||||||||||||||||
| 24 | - | |||||||||||||||||||||||||
| 25 | - | |||||||||||||||||||||||||
| 26 | - | |||||||||||||||||||||||||
| 27 | - | |||||||||||||||||||||||||
| 28 | - | |||||||||||||||||||||||||
| 29 | - | |||||||||||||||||||||||||
| 30 | static bool runningUnderDebugger() | - | ||||||||||||||||||||||||
| 31 | { | - | ||||||||||||||||||||||||
| 32 | - | |||||||||||||||||||||||||
| 33 | const QString parentProc = QLatin1String("/proc/") + QString::number(getppid()); | - | ||||||||||||||||||||||||
| 34 | const QFileInfo parentProcExe(parentProc + QLatin1String("/exe")); | - | ||||||||||||||||||||||||
| 35 | if (parentProcExe.isSymLink()) | - | ||||||||||||||||||||||||
| 36 | return parentProcExe.symLinkTarget().endsWith(QLatin1String("/gdb")); | - | ||||||||||||||||||||||||
| 37 | QFile f(parentProc + QLatin1String("/cmdline")); | - | ||||||||||||||||||||||||
| 38 | if (!f.open(QIODevice::ReadOnly)) | - | ||||||||||||||||||||||||
| 39 | return false; | - | ||||||||||||||||||||||||
| 40 | QByteArray s; | - | ||||||||||||||||||||||||
| 41 | char c; | - | ||||||||||||||||||||||||
| 42 | while (f.getChar(&c) && c) { | - | ||||||||||||||||||||||||
| 43 | if (c == '/') | - | ||||||||||||||||||||||||
| 44 | s.clear(); | - | ||||||||||||||||||||||||
| 45 | else | - | ||||||||||||||||||||||||
| 46 | s += c; | - | ||||||||||||||||||||||||
| 47 | } | - | ||||||||||||||||||||||||
| 48 | return s == "gdb"; | - | ||||||||||||||||||||||||
| 49 | - | |||||||||||||||||||||||||
| 50 | - | |||||||||||||||||||||||||
| 51 | - | |||||||||||||||||||||||||
| 52 | } | - | ||||||||||||||||||||||||
| 53 | - | |||||||||||||||||||||||||
| 54 | QXcbIntegration *QXcbIntegration::m_instance = nullptr; | - | ||||||||||||||||||||||||
| 55 | - | |||||||||||||||||||||||||
| 56 | QXcbIntegration::QXcbIntegration(const QStringList ¶meters, int &argc, char **argv) | - | ||||||||||||||||||||||||
| 57 | : m_services(new QGenericUnixServices) | - | ||||||||||||||||||||||||
| 58 | , m_instanceName(0) | - | ||||||||||||||||||||||||
| 59 | , m_canGrab(true) | - | ||||||||||||||||||||||||
| 60 | , m_defaultVisualId((2147483647 * 2U + 1U)) | - | ||||||||||||||||||||||||
| 61 | { | - | ||||||||||||||||||||||||
| 62 | m_instance = this; | - | ||||||||||||||||||||||||
| 63 | (static_cast<QGuiApplication *>(QCoreApplication::instance()))->setAttribute(Qt::AA_CompressHighFrequencyEvents, true); | - | ||||||||||||||||||||||||
| 64 | - | |||||||||||||||||||||||||
| 65 | qRegisterMetaType<QXcbWindow*>(); | - | ||||||||||||||||||||||||
| 66 | - | |||||||||||||||||||||||||
| 67 | XInitThreads(); | - | ||||||||||||||||||||||||
| 68 | - | |||||||||||||||||||||||||
| 69 | m_nativeInterface.reset(new QXcbNativeInterface); | - | ||||||||||||||||||||||||
| 70 | - | |||||||||||||||||||||||||
| 71 | - | |||||||||||||||||||||||||
| 72 | const char *displayName = 0; | - | ||||||||||||||||||||||||
| 73 | bool noGrabArg = false; | - | ||||||||||||||||||||||||
| 74 | bool doGrabArg = false; | - | ||||||||||||||||||||||||
| 75 | if (argc
| 63-72 | ||||||||||||||||||||||||
| 76 | int j = 1; | - | ||||||||||||||||||||||||
| 77 | for (int i = 1; i < argc
| 63-74 | ||||||||||||||||||||||||
| 78 | QByteArray arg(argv[i]); | - | ||||||||||||||||||||||||
| 79 | if (arg.startsWith("--")
| 0-74 | ||||||||||||||||||||||||
| 80 | arg.remove(0, 1); never executed: arg.remove(0, 1); | 0 | ||||||||||||||||||||||||
| 81 | if (arg == "-display"
| 0-74 | ||||||||||||||||||||||||
| 82 | displayName = argv[++i]; never executed: displayName = argv[++i]; | 0 | ||||||||||||||||||||||||
| 83 | else if (arg == "-name"
| 0-74 | ||||||||||||||||||||||||
| 84 | m_instanceName = argv[++i]; never executed: m_instanceName = argv[++i]; | 0 | ||||||||||||||||||||||||
| 85 | else if (arg == "-nograb"
| 0-74 | ||||||||||||||||||||||||
| 86 | noGrabArg = true; never executed: noGrabArg = true; | 0 | ||||||||||||||||||||||||
| 87 | else if (arg == "-dograb"
| 0-74 | ||||||||||||||||||||||||
| 88 | doGrabArg = true; never executed: doGrabArg = true; | 0 | ||||||||||||||||||||||||
| 89 | else if (arg == "-visual"
| 0-74 | ||||||||||||||||||||||||
| 90 | bool ok = false; | - | ||||||||||||||||||||||||
| 91 | m_defaultVisualId = QByteArray(argv[++i]).toUInt(&ok, 0); | - | ||||||||||||||||||||||||
| 92 | if (!ok
| 0 | ||||||||||||||||||||||||
| 93 | m_defaultVisualId = (2147483647 * 2U + 1U); never executed: m_defaultVisualId = (2147483647 * 2U + 1U); | 0 | ||||||||||||||||||||||||
| 94 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 95 | else | - | ||||||||||||||||||||||||
| 96 | argv[j++] = argv[i]; executed 74 times by 3 tests: argv[j++] = argv[i];Executed by:
| 74 | ||||||||||||||||||||||||
| 97 | } | - | ||||||||||||||||||||||||
| 98 | argc = j; | - | ||||||||||||||||||||||||
| 99 | } executed 63 times by 5 tests: end of blockExecuted by:
| 63 | ||||||||||||||||||||||||
| 100 | - | |||||||||||||||||||||||||
| 101 | bool underDebugger = runningUnderDebugger(); | - | ||||||||||||||||||||||||
| 102 | if (noGrabArg
| 0-135 | ||||||||||||||||||||||||
| 103 | QMessageLogger(__FILE__, 161168, __PRETTY_FUNCTION__).warning() << ("Both -nograb and -dograb command line arguments specified. Please pick one. -nograb takes prcedence";); | - | ||||||||||||||||||||||||
| 104 | doGrabArg = false; | - | ||||||||||||||||||||||||
| 105 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 106 | - | |||||||||||||||||||||||||
| 107 | - | |||||||||||||||||||||||||
| 108 | if (!noGrabArg
| 0-135 | ||||||||||||||||||||||||
| 109 | QMessageLogger(__FILE__, 167174, __PRETTY_FUNCTION__).debug("Qt: gdb: -nograb added to command-line options.\n" | - | ||||||||||||||||||||||||
| 110 | "\t Use the -dograb option to enforce grabbing."); | - | ||||||||||||||||||||||||
| 111 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 112 | - | |||||||||||||||||||||||||
| 113 | m_canGrab = (!underDebugger
| 0-135 | ||||||||||||||||||||||||
| 114 | - | |||||||||||||||||||||||||
| 115 | static bool canNotGrabEnv = qEnvironmentVariableIsSet("QT_XCB_NO_GRAB_SERVER"); | - | ||||||||||||||||||||||||
| 116 | if (canNotGrabEnv
| 0-135 | ||||||||||||||||||||||||
| 117 | m_canGrab = false; never executed: m_canGrab = false; | 0 | ||||||||||||||||||||||||
| 118 | - | |||||||||||||||||||||||||
| 119 | const int numParameters = parameters.size(); | - | ||||||||||||||||||||||||
| 120 | m_connections.reserve(1 + numParameters / 2); | - | ||||||||||||||||||||||||
| 121 | m_connections << new QXcbConnection(m_nativeInterface.data(), m_canGrab, m_defaultVisualId, displayName); | - | ||||||||||||||||||||||||
| 122 | - | |||||||||||||||||||||||||
| 123 | for (int i = 0; i < numParameters - 1
| 0-135 | ||||||||||||||||||||||||
| 124 | for (bool qt_category_enabled = lcQpaScreen().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 189, __PRETTY_FUNCTION__, lcQpaScreen().categoryName()).debug() << "connecting to additional display: " << parameters.at(i) << parameters.at(i+1); | 0 | ||||||||||||||||||||||||
| 125 | QString display = parameters.at(i) + QLatin1Char(':') + parameters.at(i+1); | - | ||||||||||||||||||||||||
| 126 | m_connections << new QXcbConnection(m_nativeInterface.data(), m_canGrab, m_defaultVisualId, display.toLatin1().constData()); | - | ||||||||||||||||||||||||
| 127 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 128 | - | |||||||||||||||||||||||||
| 129 | m_fontDatabase.reset(new QGenericUnixFontDatabase()); | - | ||||||||||||||||||||||||
| 130 | } executed 135 times by 5 tests: end of blockExecuted by:
| 135 | ||||||||||||||||||||||||
| 131 | - | |||||||||||||||||||||||||
| 132 | QXcbIntegration::~QXcbIntegration() | - | ||||||||||||||||||||||||
| 133 | { | - | ||||||||||||||||||||||||
| 134 | qDeleteAll(m_connections); | - | ||||||||||||||||||||||||
| 135 | m_instance = nullptr; | - | ||||||||||||||||||||||||
| 136 | } | - | ||||||||||||||||||||||||
| 137 | - | |||||||||||||||||||||||||
| 138 | QPlatformWindow *QXcbIntegration::createPlatformWindow(QWindow *window) const | - | ||||||||||||||||||||||||
| 139 | { | - | ||||||||||||||||||||||||
| 140 | QXcbScreen *screen = static_cast<QXcbScreen *>(window->screen()->handle()); | - | ||||||||||||||||||||||||
| 141 | QXcbGlIntegration *glIntegration = screen->connection()->glIntegration(); | - | ||||||||||||||||||||||||
| 142 | if (window->type() != Qt::Desktop
| 133-4107 | ||||||||||||||||||||||||
| 143 | if (glIntegration
| 0-3974 | ||||||||||||||||||||||||
| 144 | QXcbWindow *xcbWindow = glIntegration->createWindow(window); | - | ||||||||||||||||||||||||
| 145 | xcbWindow->create(); | - | ||||||||||||||||||||||||
| 146 | return executed 3974 times by 118 tests: xcbWindow;return xcbWindow;Executed by:
executed 3974 times by 118 tests: return xcbWindow;Executed by:
| 3974 | ||||||||||||||||||||||||
| 147 | } | - | ||||||||||||||||||||||||
| 148 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 149 | - | |||||||||||||||||||||||||
| 150 | ((!(window->type() == Qt::Desktop || !window->supportsOpenGL() || (!glIntegration && window->surfaceType() == QSurface::RasterGLSurface))) ? qt_assert("window->type() == Qt::Desktop || !window->supportsOpenGL() || (!glIntegration && window->surfaceType() == QSurface::RasterGLSurface)", | - | ||||||||||||||||||||||||
| 151 | __FILE__ | - | ||||||||||||||||||||||||
| 152 | , | - | ||||||||||||||||||||||||
| 153 | 209216 | - | ||||||||||||||||||||||||
| 154 | ) : qt_noop()) | - | ||||||||||||||||||||||||
| 155 | ; | - | ||||||||||||||||||||||||
| 156 | QXcbWindow *xcbWindow = new QXcbWindow(window); | - | ||||||||||||||||||||||||
| 157 | xcbWindow->create(); | - | ||||||||||||||||||||||||
| 158 | return executed 431 times by 124 tests: xcbWindow;return xcbWindow;Executed by:
executed 431 times by 124 tests: return xcbWindow;Executed by:
| 431 | ||||||||||||||||||||||||
| 159 | } | - | ||||||||||||||||||||||||
| 160 | - | |||||||||||||||||||||||||
| 161 | - | |||||||||||||||||||||||||
| 162 | QPlatformOpenGLContext *QXcbIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const | - | ||||||||||||||||||||||||
| 163 | { | - | ||||||||||||||||||||||||
| 164 | QXcbScreen *screen = static_cast<QXcbScreen *>(context->screen()->handle()); | - | ||||||||||||||||||||||||
| 165 | QXcbGlIntegration *glIntegration = screen->connection()->glIntegration(); | - | ||||||||||||||||||||||||
| 166 | if (!glIntegration) { | - | ||||||||||||||||||||||||
| 167 | QMessageLogger(__FILE__, 221228, __PRETTY_FUNCTION__).warning("QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled"); | - | ||||||||||||||||||||||||
| 168 | return nullptr; | - | ||||||||||||||||||||||||
| 169 | } | - | ||||||||||||||||||||||||
| 170 | return glIntegration->createPlatformOpenGLContext(context); | - | ||||||||||||||||||||||||
| 171 | } | - | ||||||||||||||||||||||||
| 172 | - | |||||||||||||||||||||||||
| 173 | - | |||||||||||||||||||||||||
| 174 | QPlatformBackingStore *QXcbIntegration::createPlatformBackingStore(QWindow *window) const | - | ||||||||||||||||||||||||
| 175 | { | - | ||||||||||||||||||||||||
| 176 | return new QXcbBackingStore(window); | - | ||||||||||||||||||||||||
| 177 | } | - | ||||||||||||||||||||||||
| 178 | - | |||||||||||||||||||||||||
| 179 | QPlatformOffscreenSurface *QXcbIntegration::createPlatformOffscreenSurface(QOffscreenSurface *surface) const | - | ||||||||||||||||||||||||
| 180 | { | - | ||||||||||||||||||||||||
| 181 | QXcbScreen *screen = static_cast<QXcbScreen *>(surface->screen()->handle()); | - | ||||||||||||||||||||||||
| 182 | QXcbGlIntegration *glIntegration = screen->connection()->glIntegration(); | - | ||||||||||||||||||||||||
| 183 | if (!glIntegration) { | - | ||||||||||||||||||||||||
| 184 | QMessageLogger(__FILE__, 238245, __PRETTY_FUNCTION__).warning("QXcbIntegration: Cannot create platform offscreen surface, neither GLX nor EGL are enabled"); | - | ||||||||||||||||||||||||
| 185 | return nullptr; | - | ||||||||||||||||||||||||
| 186 | } | - | ||||||||||||||||||||||||
| 187 | return glIntegration->createPlatformOffscreenSurface(surface); | - | ||||||||||||||||||||||||
| 188 | } | - | ||||||||||||||||||||||||
| 189 | - | |||||||||||||||||||||||||
| 190 | bool QXcbIntegration::hasCapability(QPlatformIntegration::Capability cap) const | - | ||||||||||||||||||||||||
| 191 | { | - | ||||||||||||||||||||||||
| 192 | switch (cap) { | - | ||||||||||||||||||||||||
| 193 | case ThreadedPixmaps: return true;case executed 131 times by 125 tests: OpenGL:case OpenGL:Executed by:
executed 131 times by 125 tests: case OpenGL:Executed by:
| 131 | ||||||||||||||||||||||||
| 194 | return m_connections.first()->glIntegration();case executed 8 times by 2 tests: ThreadedOpenGL:case ThreadedOpenGL:Executed by:
executed 8 times by 2 tests: case ThreadedOpenGL:Executed by:
| 8 | ||||||||||||||||||||||||
| 195 | return m_connections.at{ | - | ||||||||||||||||||||||||
| 196 | const auto *connection = qAsConst(0)->threadedEventHandling() | - | ||||||||||||||||||||||||
| &&m_connections.at).first(); | ||||||||||||||||||||||||||
| 197 | if (0)->const
| 0-139 | ||||||||||||||||||||||||
| 198 | return executed 139 times by 126 tests: cap != ThreadedOpenGLreturn cap != ThreadedOpenGL || (connection->threadedEventHandling() && integration->supportsThreadedOpenGL());Executed by:
executed 139 times by 126 tests: return cap != ThreadedOpenGL || (connection->threadedEventHandling() && integration->supportsThreadedOpenGL());Executed by:
| 139 | ||||||||||||||||||||||||
| 199 | || (connection->threadedEventHandling executed 139 times by 126 tests: return cap != ThreadedOpenGL || (connection->threadedEventHandling() && integration->supportsThreadedOpenGL());Executed by:
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 | ||||||||||||||||||||||||
| 200 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 201 | } | - | ||||||||||||||||||||||||
| 202 | - | |||||||||||||||||||||||||
| 203 | case executed 2 times by 2 tests: ThreadedPixmaps:case ThreadedPixmaps:Executed by:
executed 2 times by 2 tests: case ThreadedPixmaps:Executed by:
| 2 | ||||||||||||||||||||||||
| 204 | case executed 2 times by 2 tests: WindowMasks:case WindowMasks:Executed by:
executed 2 times by 2 tests: case WindowMasks:Executed by:
| 2 | ||||||||||||||||||||||||
| 205 | return true;case executed 2 times by 1 test: MultipleWindows:case MultipleWindows:Executed by:
executed 2 times by 1 test: case MultipleWindows:Executed by:
| 2 | ||||||||||||||||||||||||
| 206 | return true;case never executed: ForeignWindows:case ForeignWindows:never executed: case ForeignWindows: | 0 | ||||||||||||||||||||||||
| 207 | return true;case executed 9 times by 3 tests: SyncState:case SyncState:Executed by:
executed 9 times by 3 tests: case SyncState:Executed by:
| 9 | ||||||||||||||||||||||||
| 208 | return true;case executed 4277 times by 120 tests: RasterGLSurface:case RasterGLSurface:Executed by:
executed 4277 times by 120 tests: case RasterGLSurface:Executed by:
| 4277 | ||||||||||||||||||||||||
| 209 | return executed 4292 times by 121 tests: true;return true;Executed by:
executed 4292 times by 121 tests: return true;Executed by:
| 4292 | ||||||||||||||||||||||||
| 210 | - | |||||||||||||||||||||||||
| 211 | case executed 1 time by 1 test: SwitchableWidgetComposition:case SwitchableWidgetComposition:Executed by:
executed 1 time by 1 test: case SwitchableWidgetComposition:Executed by:
| 1 | ||||||||||||||||||||||||
| 212 | { | - | ||||||||||||||||||||||||
| 213 | return executed 1 time by 1 test: m_connections.at(0)->glIntegration()return m_connections.at(0)->glIntegration() && m_connections.at(0)->glIntegration()->supportsSwitchableWidgetComposition();Executed by:
executed 1 time by 1 test: return m_connections.at(0)->glIntegration() && m_connections.at(0)->glIntegration()->supportsSwitchableWidgetComposition();Executed by:
| 1 | ||||||||||||||||||||||||
| 214 | && 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 | ||||||||||||||||||||||||
| 215 | } | - | ||||||||||||||||||||||||
| 216 | - | |||||||||||||||||||||||||
| 217 | default executed 11991 times by 125 tests: :default:Executed by:
executed 11991 times by 125 tests: returndefault:Executed by:
executed 11991 times by 125 tests: QPlatformIntegration::hasCapability(cap);return QPlatformIntegration::hasCapability(cap);Executed by:
executed 11991 times by 125 tests: return QPlatformIntegration::hasCapability(cap);Executed by:
| 11991 | ||||||||||||||||||||||||
| 218 | } | - | ||||||||||||||||||||||||
| 219 | } | - | ||||||||||||||||||||||||
| 220 | - | |||||||||||||||||||||||||
| 221 | QAbstractEventDispatcher *QXcbIntegration::createEventDispatcher() const | - | ||||||||||||||||||||||||
| 222 | { | - | ||||||||||||||||||||||||
| 223 | QAbstractEventDispatcher *dispatcher = createUnixEventDispatcher(); | - | ||||||||||||||||||||||||
| 224 | for (int i = 0; i < m_connections.size(); i++) | - | ||||||||||||||||||||||||
| 225 | m_connections[i]->eventReader()->registerEventDispatcher(dispatcher); | - | ||||||||||||||||||||||||
| 226 | return dispatcher; | - | ||||||||||||||||||||||||
| 227 | } | - | ||||||||||||||||||||||||
| 228 | - | |||||||||||||||||||||||||
| 229 | void QXcbIntegration::initialize() | - | ||||||||||||||||||||||||
| 230 | { | - | ||||||||||||||||||||||||
| 231 | - | |||||||||||||||||||||||||
| 232 | - | |||||||||||||||||||||||||
| 233 | QString icStr = QPlatformInputContextFactory::requested(); | - | ||||||||||||||||||||||||
| 234 | if (icStr.isNull()) | - | ||||||||||||||||||||||||
| 235 | icStr = QLatin1String("compose"); | - | ||||||||||||||||||||||||
| 236 | m_inputContext.reset(QPlatformInputContextFactory::create(icStr)); | - | ||||||||||||||||||||||||
| 237 | } | - | ||||||||||||||||||||||||
| 238 | - | |||||||||||||||||||||||||
| 239 | void QXcbIntegration::moveToScreen(QWindow *window, int screen) | - | ||||||||||||||||||||||||
| 240 | { | - | ||||||||||||||||||||||||
| 241 | (void)window;; | - | ||||||||||||||||||||||||
| 242 | (void)screen;; | - | ||||||||||||||||||||||||
| 243 | } | - | ||||||||||||||||||||||||
| 244 | - | |||||||||||||||||||||||||
| 245 | QPlatformFontDatabase *QXcbIntegration::fontDatabase() const | - | ||||||||||||||||||||||||
| 246 | { | - | ||||||||||||||||||||||||
| 247 | return m_fontDatabase.data(); | - | ||||||||||||||||||||||||
| 248 | } | - | ||||||||||||||||||||||||
| 249 | - | |||||||||||||||||||||||||
| 250 | QPlatformNativeInterface * QXcbIntegration::nativeInterface() const | - | ||||||||||||||||||||||||
| 251 | { | - | ||||||||||||||||||||||||
| 252 | return m_nativeInterface.data(); | - | ||||||||||||||||||||||||
| 253 | } | - | ||||||||||||||||||||||||
| 254 | - | |||||||||||||||||||||||||
| 255 | - | |||||||||||||||||||||||||
| 256 | QPlatformClipboard *QXcbIntegration::clipboard() const | - | ||||||||||||||||||||||||
| 257 | { | - | ||||||||||||||||||||||||
| 258 | return m_connections.at(0)->clipboard(); | - | ||||||||||||||||||||||||
| 259 | } | - | ||||||||||||||||||||||||
| 260 | - | |||||||||||||||||||||||||
| 261 | - | |||||||||||||||||||||||||
| 262 | - | |||||||||||||||||||||||||
| 263 | QPlatformDrag *QXcbIntegration::drag() const | - | ||||||||||||||||||||||||
| 264 | { | - | ||||||||||||||||||||||||
| 265 | return m_connections.at(0)->drag(); | - | ||||||||||||||||||||||||
| 266 | } | - | ||||||||||||||||||||||||
| 267 | - | |||||||||||||||||||||||||
| 268 | - | |||||||||||||||||||||||||
| 269 | QPlatformInputContext *QXcbIntegration::inputContext() const | - | ||||||||||||||||||||||||
| 270 | { | - | ||||||||||||||||||||||||
| 271 | return m_inputContext.data(); | - | ||||||||||||||||||||||||
| 272 | } | - | ||||||||||||||||||||||||
| 273 | - | |||||||||||||||||||||||||
| 274 | - | |||||||||||||||||||||||||
| 275 | QPlatformAccessibility *QXcbIntegration::accessibility() const | - | ||||||||||||||||||||||||
| 276 | { | - | ||||||||||||||||||||||||
| 277 | - | |||||||||||||||||||||||||
| 278 | if (!m_accessibility) { | - | ||||||||||||||||||||||||
| 279 | ((!(QCoreApplication::eventDispatcher())) ? qt_assert_x("QXcbIntegration", "Initializing accessibility without event-dispatcher!", | - | ||||||||||||||||||||||||
| 280 | __FILE__ | - | ||||||||||||||||||||||||
| 281 | , | - | ||||||||||||||||||||||||
| 282 | 322341 | - | ||||||||||||||||||||||||
| 283 | ) : qt_noop()) | - | ||||||||||||||||||||||||
| 284 | ; | - | ||||||||||||||||||||||||
| 285 | m_accessibility.reset(new QSpiAccessibleBridge()); | - | ||||||||||||||||||||||||
| 286 | } | - | ||||||||||||||||||||||||
| 287 | - | |||||||||||||||||||||||||
| 288 | - | |||||||||||||||||||||||||
| 289 | return m_accessibility.data(); | - | ||||||||||||||||||||||||
| 290 | } | - | ||||||||||||||||||||||||
| 291 | - | |||||||||||||||||||||||||
| 292 | - | |||||||||||||||||||||||||
| 293 | QPlatformServices *QXcbIntegration::services() const | - | ||||||||||||||||||||||||
| 294 | { | - | ||||||||||||||||||||||||
| 295 | return m_services.data(); | - | ||||||||||||||||||||||||
| 296 | } | - | ||||||||||||||||||||||||
| 297 | - | |||||||||||||||||||||||||
| 298 | Qt::KeyboardModifiers QXcbIntegration::queryKeyboardModifiers() const | - | ||||||||||||||||||||||||
| 299 | { | - | ||||||||||||||||||||||||
| 300 | int keybMask = 0; | - | ||||||||||||||||||||||||
| 301 | QXcbConnection *conn = m_connections.at(0); | - | ||||||||||||||||||||||||
| 302 | QXcbCursor::queryPointer(conn, 0, 0, &keybMask); | - | ||||||||||||||||||||||||
| 303 | return conn->keyboard()->translateModifiers(keybMask); | - | ||||||||||||||||||||||||
| 304 | } | - | ||||||||||||||||||||||||
| 305 | - | |||||||||||||||||||||||||
| 306 | QList<int> QXcbIntegration::possibleKeys(const QKeyEvent *e) const | - | ||||||||||||||||||||||||
| 307 | { | - | ||||||||||||||||||||||||
| 308 | return m_connections.at(0)->keyboard()->possibleKeys(e); | - | ||||||||||||||||||||||||
| 309 | } | - | ||||||||||||||||||||||||
| 310 | - | |||||||||||||||||||||||||
| 311 | QStringList QXcbIntegration::themeNames() const | - | ||||||||||||||||||||||||
| 312 | { | - | ||||||||||||||||||||||||
| 313 | return QGenericUnixTheme::themeNames(); | - | ||||||||||||||||||||||||
| 314 | } | - | ||||||||||||||||||||||||
| 315 | - | |||||||||||||||||||||||||
| 316 | QPlatformTheme *QXcbIntegration::createPlatformTheme(const QString &name) const | - | ||||||||||||||||||||||||
| 317 | { | - | ||||||||||||||||||||||||
| 318 | return QGenericUnixTheme::createUnixTheme(name); | - | ||||||||||||||||||||||||
| 319 | } | - | ||||||||||||||||||||||||
| 320 | - | |||||||||||||||||||||||||
| 321 | QVariant QXcbIntegration::styleHint(QPlatformIntegration::StyleHint hint) const | - | ||||||||||||||||||||||||
| 322 | { | - | ||||||||||||||||||||||||
| 323 | switch (hint) { | - | ||||||||||||||||||||||||
| 324 | case QPlatformIntegration::CursorFlashTime: | - | ||||||||||||||||||||||||
| 325 | case QPlatformIntegration::KeyboardInputInterval: | - | ||||||||||||||||||||||||
| 326 | case QPlatformIntegration::MouseDoubleClickInterval: | - | ||||||||||||||||||||||||
| 327 | case QPlatformIntegration::StartDragTime: | - | ||||||||||||||||||||||||
| 328 | case QPlatformIntegration::KeyboardAutoRepeatRate: | - | ||||||||||||||||||||||||
| 329 | case QPlatformIntegration::PasswordMaskDelay: | - | ||||||||||||||||||||||||
| 330 | case QPlatformIntegration::StartDragVelocity: | - | ||||||||||||||||||||||||
| 331 | case QPlatformIntegration::UseRtlExtensions: | - | ||||||||||||||||||||||||
| 332 | case QPlatformIntegration::PasswordMaskCharacter: | - | ||||||||||||||||||||||||
| 333 | - | |||||||||||||||||||||||||
| 334 | break; | - | ||||||||||||||||||||||||
| 335 | case QPlatformIntegration::FontSmoothingGamma: | - | ||||||||||||||||||||||||
| 336 | - | |||||||||||||||||||||||||
| 337 | return qreal(1.0); | - | ||||||||||||||||||||||||
| 338 | case QPlatformIntegration::StartDragDistance: { | - | ||||||||||||||||||||||||
| 339 | - | |||||||||||||||||||||||||
| 340 | - | |||||||||||||||||||||||||
| 341 | qreal dpi = 100.0; | - | ||||||||||||||||||||||||
| 342 | if (const QXcbScreen *screen = defaultConnection()->primaryScreen()) { | - | ||||||||||||||||||||||||
| 343 | if (screen->logicalDpi().first > dpi) | - | ||||||||||||||||||||||||
| 344 | dpi = screen->logicalDpi().first; | - | ||||||||||||||||||||||||
| 345 | if (screen->logicalDpi().second > dpi) | - | ||||||||||||||||||||||||
| 346 | dpi = screen->logicalDpi().second; | - | ||||||||||||||||||||||||
| 347 | } | - | ||||||||||||||||||||||||
| 348 | return 10.0 * dpi / 100.0; | - | ||||||||||||||||||||||||
| 349 | } | - | ||||||||||||||||||||||||
| 350 | case QPlatformIntegration::ShowIsFullScreen: | - | ||||||||||||||||||||||||
| 351 | - | |||||||||||||||||||||||||
| 352 | - | |||||||||||||||||||||||||
| 353 | return false; | - | ||||||||||||||||||||||||
| 354 | case QPlatformIntegration::ReplayMousePressOutsidePopup: | - | ||||||||||||||||||||||||
| 355 | return false; | - | ||||||||||||||||||||||||
| 356 | default: | - | ||||||||||||||||||||||||
| 357 | break; | - | ||||||||||||||||||||||||
| 358 | } | - | ||||||||||||||||||||||||
| 359 | return QPlatformIntegration::styleHint(hint); | - | ||||||||||||||||||||||||
| 360 | } | - | ||||||||||||||||||||||||
| 361 | - | |||||||||||||||||||||||||
| 362 | static QString argv0BaseName() | - | ||||||||||||||||||||||||
| 363 | { | - | ||||||||||||||||||||||||
| 364 | QString result; | - | ||||||||||||||||||||||||
| 365 | const QStringList arguments = QCoreApplication::arguments(); | - | ||||||||||||||||||||||||
| 366 | if (!arguments.isEmpty() && !arguments.front().isEmpty()) { | - | ||||||||||||||||||||||||
| 367 | result = arguments.front(); | - | ||||||||||||||||||||||||
| 368 | const int lastSlashPos = result.lastIndexOf(QLatin1Char('/')); | - | ||||||||||||||||||||||||
| 369 | if (lastSlashPos != -1) | - | ||||||||||||||||||||||||
| 370 | result.remove(0, lastSlashPos + 1); | - | ||||||||||||||||||||||||
| 371 | } | - | ||||||||||||||||||||||||
| 372 | return result; | - | ||||||||||||||||||||||||
| 373 | } | - | ||||||||||||||||||||||||
| 374 | - | |||||||||||||||||||||||||
| 375 | static const char resourceNameVar[] = "RESOURCE_NAME"; | - | ||||||||||||||||||||||||
| 376 | - | |||||||||||||||||||||||||
| 377 | QByteArray QXcbIntegration::wmClass() const | - | ||||||||||||||||||||||||
| 378 | { | - | ||||||||||||||||||||||||
| 379 | if (m_wmClass.isEmpty()) { | - | ||||||||||||||||||||||||
| 380 | - | |||||||||||||||||||||||||
| 381 | QString name; | - | ||||||||||||||||||||||||
| 382 | if (m_instanceName) | - | ||||||||||||||||||||||||
| 383 | name = QString::fromLocal8Bit(m_instanceName); | - | ||||||||||||||||||||||||
| 384 | if (name.isEmpty() && qEnvironmentVariableIsSet(resourceNameVar)) | - | ||||||||||||||||||||||||
| 385 | name = QString::fromLocal8Bit(qgetenv(resourceNameVar)); | - | ||||||||||||||||||||||||
| 386 | if (name.isEmpty()) | - | ||||||||||||||||||||||||
| 387 | name = argv0BaseName(); | - | ||||||||||||||||||||||||
| 388 | - | |||||||||||||||||||||||||
| 389 | - | |||||||||||||||||||||||||
| 390 | - | |||||||||||||||||||||||||
| 391 | QString className = QCoreApplication::applicationName(); | - | ||||||||||||||||||||||||
| 392 | if (className.isEmpty()) { | - | ||||||||||||||||||||||||
| 393 | className = argv0BaseName(); | - | ||||||||||||||||||||||||
| 394 | if (!className.isEmpty() && className.at(0).isLower()) | - | ||||||||||||||||||||||||
| 395 | className[0] = className.at(0).toUpper(); | - | ||||||||||||||||||||||||
| 396 | } | - | ||||||||||||||||||||||||
| 397 | - | |||||||||||||||||||||||||
| 398 | if (!name.isEmpty() && !className.isEmpty()) { | - | ||||||||||||||||||||||||
| 399 | m_wmClass = name.toLocal8Bit(); | - | ||||||||||||||||||||||||
| 400 | m_wmClass.append('\0'); | - | ||||||||||||||||||||||||
| 401 | m_wmClass.append(className.toLocal8Bit()); | - | ||||||||||||||||||||||||
| 402 | m_wmClass.append('\0'); | - | ||||||||||||||||||||||||
| 403 | } | - | ||||||||||||||||||||||||
| 404 | } | - | ||||||||||||||||||||||||
| 405 | return m_wmClass; | - | ||||||||||||||||||||||||
| 406 | } | - | ||||||||||||||||||||||||
| 407 | - | |||||||||||||||||||||||||
| 408 | - | |||||||||||||||||||||||||
| 409 | QPlatformSessionManager *QXcbIntegration::createPlatformSessionManager(const QString &id, const QString &key) const | - | ||||||||||||||||||||||||
| 410 | { | - | ||||||||||||||||||||||||
| 411 | return new QXcbSessionManager(id, key); | - | ||||||||||||||||||||||||
| 412 | } | - | ||||||||||||||||||||||||
| 413 | - | |||||||||||||||||||||||||
| 414 | - | |||||||||||||||||||||||||
| 415 | void QXcbIntegration::sync() | - | ||||||||||||||||||||||||
| 416 | { | - | ||||||||||||||||||||||||
| 417 | for (int i = 0; i < m_connections.size(); i++) { | - | ||||||||||||||||||||||||
| 418 | m_connections.at(i)->sync(); | - | ||||||||||||||||||||||||
| 419 | } | - | ||||||||||||||||||||||||
| 420 | } | - | ||||||||||||||||||||||||
| 421 | - | |||||||||||||||||||||||||
| 422 | - | |||||||||||||||||||||||||
| 423 | void QXcbIntegration::beep() const | - | ||||||||||||||||||||||||
| 424 | { | - | ||||||||||||||||||||||||
| 425 | QScreen *priScreen = QGuiApplication::primaryScreen(); | - | ||||||||||||||||||||||||
| 426 | if (!priScreen
| 0 | ||||||||||||||||||||||||
| 427 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 428 | QPlatformScreen *screen = priScreen->handle(); | - | ||||||||||||||||||||||||
| 429 | if (!screen
| 0 | ||||||||||||||||||||||||
| 430 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 431 | xcb_connection_t *connection = static_cast<QXcbScreen *>(screen)->xcb_connection(); | - | ||||||||||||||||||||||||
| 432 | xcb_bell(connection, 0); | - | ||||||||||||||||||||||||
| 433 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 434 | - | |||||||||||||||||||||||||
| 435 | - | |||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |