Pass argc, argv to the platform plugins.
Allow for parsing of X11-specific arguments like -display, -geometry. Introduce overload of QPlatformIntegration::create() with argc and argv and provide default implementation that calls the old version (for platforms that do not have argc, argv). Provide default implementation for the old version returning 0 so that platforms using the new API compile. Prototypically implement -display in XCB. Task-number: QTBUG-29396 Change-Id: I6a0e9271fad6e2d10f11b80393025ae3a3e36623 Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>bb10
parent
066d32d743
commit
c96a6ab627
|
|
@ -773,14 +773,14 @@ QString QGuiApplication::platformName()
|
|||
*QGuiApplicationPrivate::platform_name : QString();
|
||||
}
|
||||
|
||||
static void init_platform(const QString &pluginArgument, const QString &platformPluginPath)
|
||||
static void init_platform(const QString &pluginArgument, const QString &platformPluginPath, int &argc, char **argv)
|
||||
{
|
||||
// Split into platform name and arguments
|
||||
QStringList arguments = pluginArgument.split(QLatin1Char(':'));
|
||||
const QString name = arguments.takeFirst().toLower();
|
||||
|
||||
// Create the platform integration.
|
||||
QGuiApplicationPrivate::platform_integration = QPlatformIntegrationFactory::create(name, arguments, platformPluginPath);
|
||||
QGuiApplicationPrivate::platform_integration = QPlatformIntegrationFactory::create(name, arguments, argc, argv, platformPluginPath);
|
||||
if (QGuiApplicationPrivate::platform_integration) {
|
||||
QGuiApplicationPrivate::platform_name = new QString(name);
|
||||
} else {
|
||||
|
|
@ -908,7 +908,7 @@ void QGuiApplicationPrivate::createPlatformIntegration()
|
|||
argc = j;
|
||||
}
|
||||
|
||||
init_platform(QLatin1String(platformName), platformPluginPath);
|
||||
init_platform(QLatin1String(platformName), platformPluginPath, argc, argv);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -55,18 +55,30 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
|
|||
(QPlatformIntegrationFactoryInterface_iid, QLatin1String("/platforms"), Qt::CaseInsensitive))
|
||||
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader,
|
||||
(QPlatformIntegrationFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive))
|
||||
#endif
|
||||
|
||||
QPlatformIntegration *QPlatformIntegrationFactory::create(const QString &platform, const QStringList ¶mList, const QString &platformPluginPath)
|
||||
static inline QPlatformIntegration *loadIntegration(QFactoryLoader *loader, const QString &key, const QStringList ¶meters, int &argc, char ** argv)
|
||||
{
|
||||
const int index = loader->indexOf(key);
|
||||
if (index != -1) {
|
||||
if (QPlatformIntegrationPlugin *factory = qobject_cast<QPlatformIntegrationPlugin *>(loader->instance(index)))
|
||||
if (QPlatformIntegration *result = factory->create(key, parameters, argc, argv))
|
||||
return result;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif // !QT_NO_LIBRARY
|
||||
|
||||
QPlatformIntegration *QPlatformIntegrationFactory::create(const QString &platform, const QStringList ¶mList, int &argc, char **argv, const QString &platformPluginPath)
|
||||
{
|
||||
#ifndef QT_NO_LIBRARY
|
||||
// Try loading the plugin from platformPluginPath first:
|
||||
if (!platformPluginPath.isEmpty()) {
|
||||
QCoreApplication::addLibraryPath(platformPluginPath);
|
||||
if (QPlatformIntegration *ret = qLoadPlugin1<QPlatformIntegration, QPlatformIntegrationPlugin>(directLoader(), platform, paramList))
|
||||
if (QPlatformIntegration *ret = loadIntegration(directLoader(), platform, paramList, argc, argv))
|
||||
return ret;
|
||||
}
|
||||
if (QPlatformIntegration *ret = qLoadPlugin1<QPlatformIntegration, QPlatformIntegrationPlugin>(loader(), platform, paramList))
|
||||
if (QPlatformIntegration *ret = loadIntegration(loader(), platform, paramList, argc, argv))
|
||||
return ret;
|
||||
#endif
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ class Q_GUI_EXPORT QPlatformIntegrationFactory
|
|||
{
|
||||
public:
|
||||
static QStringList keys(const QString &platformPluginPath = QString());
|
||||
static QPlatformIntegration *create(const QString &name, const QStringList &args, const QString &platformPluginPath = QString());
|
||||
static QPlatformIntegration *create(const QString &name, const QStringList &args, int &argc, char **argv, const QString &platformPluginPath = QString());
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -52,4 +52,18 @@ QPlatformIntegrationPlugin::~QPlatformIntegrationPlugin()
|
|||
{
|
||||
}
|
||||
|
||||
QPlatformIntegration *QPlatformIntegrationPlugin::create(const QString &key, const QStringList ¶mList)
|
||||
{
|
||||
Q_UNUSED(key)
|
||||
Q_UNUSED(paramList);
|
||||
return 0;
|
||||
}
|
||||
|
||||
QPlatformIntegration *QPlatformIntegrationPlugin::create(const QString &key, const QStringList ¶mList, int &argc, char **argv)
|
||||
{
|
||||
Q_UNUSED(argc)
|
||||
Q_UNUSED(argv)
|
||||
return create(key, paramList); // Fallback for platform plugins that do not implement the argc/argv version.
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -68,7 +68,8 @@ public:
|
|||
explicit QPlatformIntegrationPlugin(QObject *parent = 0);
|
||||
~QPlatformIntegrationPlugin();
|
||||
|
||||
virtual QPlatformIntegration *create(const QString &key, const QStringList ¶mList) = 0;
|
||||
virtual QPlatformIntegration *create(const QString &key, const QStringList ¶mList);
|
||||
virtual QPlatformIntegration *create(const QString &key, const QStringList ¶mList, int &argc, char **argv);
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -107,10 +107,10 @@ class QWindowsIntegrationPlugin : public QPlatformIntegrationPlugin
|
|||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.1" FILE "windows.json")
|
||||
public:
|
||||
QPlatformIntegration *create(const QString&, const QStringList&);
|
||||
QPlatformIntegration *create(const QString&, const QStringList&, int &, char **);
|
||||
};
|
||||
|
||||
QPlatformIntegration *QWindowsIntegrationPlugin::create(const QString& system, const QStringList& paramList)
|
||||
QPlatformIntegration *QWindowsIntegrationPlugin::create(const QString& system, const QStringList& paramList, int &, char **)
|
||||
{
|
||||
if (system.compare(system, QStringLiteral("windows"), Qt::CaseInsensitive) == 0)
|
||||
return new QWindowsIntegration(paramList);
|
||||
|
|
|
|||
|
|
@ -49,13 +49,13 @@ class QXcbIntegrationPlugin : public QPlatformIntegrationPlugin
|
|||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.1" FILE "xcb.json")
|
||||
public:
|
||||
QPlatformIntegration *create(const QString&, const QStringList&);
|
||||
QPlatformIntegration *create(const QString&, const QStringList&, int &, char **);
|
||||
};
|
||||
|
||||
QPlatformIntegration* QXcbIntegrationPlugin::create(const QString& system, const QStringList& parameters)
|
||||
QPlatformIntegration* QXcbIntegrationPlugin::create(const QString& system, const QStringList& parameters, int &argc, char **argv)
|
||||
{
|
||||
if (system.toLower() == "xcb")
|
||||
return new QXcbIntegration(parameters);
|
||||
return new QXcbIntegration(parameters, argc, argv);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ static bool runningUnderDebugger()
|
|||
}
|
||||
#endif
|
||||
|
||||
QXcbIntegration::QXcbIntegration(const QStringList ¶meters)
|
||||
QXcbIntegration::QXcbIntegration(const QStringList ¶meters, int &argc, char **argv)
|
||||
: m_eventDispatcher(createUnixEventDispatcher())
|
||||
, m_services(new QGenericUnixServices)
|
||||
{
|
||||
|
|
@ -138,7 +138,25 @@ QXcbIntegration::QXcbIntegration(const QStringList ¶meters)
|
|||
if (canNotGrabEnv)
|
||||
canGrab = false;
|
||||
|
||||
m_connections << new QXcbConnection(m_nativeInterface.data(), canGrab);
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
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
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class QXcbScreen;
|
|||
class QXcbIntegration : public QPlatformIntegration
|
||||
{
|
||||
public:
|
||||
QXcbIntegration(const QStringList ¶meters);
|
||||
QXcbIntegration(const QStringList ¶meters, int &argc, char **argv);
|
||||
~QXcbIntegration();
|
||||
|
||||
QPlatformWindow *createPlatformWindow(QWindow *window) const;
|
||||
|
|
|
|||
Loading…
Reference in New Issue