QXcbIntegration::QXcbIntegration(const QStringList ¶meters, int &argc, char **argv) : m_services(new QGenericUnixServices) , m_instanceName(0) { #ifdef XCB_USE_XLIB XInitThreads(); #endif m_nativeInterface.reset(new QXcbNativeInterface); bool canGrab = true; #if defined(QT_DEBUG) && defined(Q_OS_LINUX) canGrab = !runningUnderDebugger(); #endif static bool canNotGrabEnv = qgetenv("QT_XCB_NO_GRAB_SERVER").length(); if (canNotGrabEnv) canGrab = false; // Parse arguments const char *displayName = 0; if (argc) { int j = 1; for (int i = 1; i < argc; i++) { char *arg = argv[i]; if (arg) { if (!strcmp(arg, "-display") && i < argc - 1) { displayName = argv[++i]; arg = 0; } else if (!strcmp(arg, "-name") && i < argc - 1) { m_instanceName = argv[++i]; arg = 0; } } if (arg) argv[j++] = arg; } argc = j; } // argc m_connections << new QXcbConnection(m_nativeInterface.data(), canGrab, displayName); for (int i = 0; i < parameters.size() - 1; i += 2) { #ifdef Q_XCB_DEBUG qDebug() << "QXcbIntegration: Connecting to additional display: " << parameters.at(i) << parameters.at(i+1); #endif QString display = parameters.at(i) + ':' + parameters.at(i+1); m_connections << new QXcbConnection(m_nativeInterface.data(), display.toLatin1().constData()); } m_fontDatabase.reset(new QGenericUnixFontDatabase()); }
QXcbIntegration::QXcbIntegration(const QStringList ¶meters, int &argc, char **argv) : m_services(new QGenericUnixServices) , m_instanceName(0) , m_canGrab(true) , m_defaultVisualId(UINT_MAX) { m_instance = this; qRegisterMetaType<QXcbWindow*>(); #ifdef XCB_USE_XLIB XInitThreads(); #endif m_nativeInterface.reset(new QXcbNativeInterface); // Parse arguments const char *displayName = 0; bool noGrabArg = false; bool doGrabArg = false; if (argc) { int j = 1; for (int i = 1; i < argc; i++) { QByteArray arg(argv[i]); if (arg.startsWith("--")) arg.remove(0, 1); if (arg == "-display" && i < argc - 1) displayName = argv[++i]; else if (arg == "-name" && i < argc - 1) m_instanceName = argv[++i]; else if (arg == "-nograb") noGrabArg = true; else if (arg == "-dograb") doGrabArg = true; else if (arg == "-visual" && i < argc - 1) { bool ok = false; m_defaultVisualId = QByteArray(argv[++i]).toUInt(&ok, 0); if (!ok) m_defaultVisualId = UINT_MAX; } else argv[j++] = argv[i]; } argc = j; } // argc bool underDebugger = runningUnderDebugger(); if (noGrabArg && doGrabArg && underDebugger) { qWarning() << "Both -nograb and -dograb command line arguments specified. Please pick one. -nograb takes prcedence"; doGrabArg = false; } #if defined(QT_DEBUG) if (!noGrabArg && !doGrabArg && underDebugger) { qDebug("Qt: gdb: -nograb added to command-line options.\n" "\t Use the -dograb option to enforce grabbing."); } #endif m_canGrab = (!underDebugger && !noGrabArg) || (underDebugger && doGrabArg); static bool canNotGrabEnv = qEnvironmentVariableIsSet("QT_XCB_NO_GRAB_SERVER"); if (canNotGrabEnv) m_canGrab = false; const int numParameters = parameters.size(); m_connections.reserve(1 + numParameters / 2); m_connections << new QXcbConnection(m_nativeInterface.data(), m_canGrab, m_defaultVisualId, displayName); for (int i = 0; i < numParameters - 1; i += 2) { qCDebug(lcQpaScreen) << "connecting to additional display: " << parameters.at(i) << parameters.at(i+1); QString display = parameters.at(i) + QLatin1Char(':') + parameters.at(i+1); m_connections << new QXcbConnection(m_nativeInterface.data(), m_canGrab, m_defaultVisualId, display.toLatin1().constData()); } m_fontDatabase.reset(new QGenericUnixFontDatabase()); }