Consolidate the platform plugins
Instead of having multiple platform plugins, have one that switches behavior depending on the requested platform. From the outside there is no behavior difference. Requesting wayland-egl or wayland-brcm fails if the feature was not enabled and initializes the client integration early. Task-number: QTBUG-133223 Change-Id: I6fbaec7309b78cfcc470ad18dd6b63008119760e Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
This commit is contained in:
parent
5e9c9eba0f
commit
ab73b6c286
@ -10,6 +10,7 @@
|
|||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
using RegistryGlobal = QtWaylandClient::QWaylandDisplay::RegistryGlobal;
|
using RegistryGlobal = QtWaylandClient::QWaylandDisplay::RegistryGlobal;
|
||||||
|
using namespace Qt::StringLiterals;
|
||||||
|
|
||||||
QWaylandClientExtensionPrivate::QWaylandClientExtensionPrivate()
|
QWaylandClientExtensionPrivate::QWaylandClientExtensionPrivate()
|
||||||
{
|
{
|
||||||
@ -17,7 +18,7 @@ QWaylandClientExtensionPrivate::QWaylandClientExtensionPrivate()
|
|||||||
// but also add the possibility to run it as a QML component.
|
// but also add the possibility to run it as a QML component.
|
||||||
waylandIntegration = QtWaylandClient::QWaylandIntegration::instance();
|
waylandIntegration = QtWaylandClient::QWaylandIntegration::instance();
|
||||||
if (!waylandIntegration)
|
if (!waylandIntegration)
|
||||||
waylandIntegration = new QtWaylandClient::QWaylandIntegration();
|
waylandIntegration = new QtWaylandClient::QWaylandIntegration("wayland"_L1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWaylandClientExtensionPrivate::globalAdded(const RegistryGlobal &global)
|
void QWaylandClientExtensionPrivate::globalAdded(const RegistryGlobal &global)
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
add_subdirectory(hardwareintegration)
|
add_subdirectory(hardwareintegration)
|
||||||
if(TARGET Qt::WaylandClient)
|
if(TARGET Qt::WaylandClient)
|
||||||
add_subdirectory(platforms)
|
add_subdirectory(platform)
|
||||||
add_subdirectory(decorations)
|
add_subdirectory(decorations)
|
||||||
add_subdirectory(shellintegration)
|
add_subdirectory(shellintegration)
|
||||||
endif()
|
endif()
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
# Copyright (C) 2022 The Qt Company Ltd.
|
||||||
|
# SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
|
# Generated from qwayland-generic.pro.
|
||||||
|
|
||||||
|
#####################################################################
|
||||||
|
## QWaylandIntegrationPlugin Plugin:
|
||||||
|
#####################################################################
|
||||||
|
|
||||||
|
qt_internal_add_plugin(QWaylandIntegrationPlugin
|
||||||
|
OUTPUT_NAME qwayland
|
||||||
|
PLUGIN_TYPE platforms
|
||||||
|
DEFAULT_IF "wayland" IN_LIST QT_QPA_PLATFORMS
|
||||||
|
SOURCES
|
||||||
|
main.cpp
|
||||||
|
LIBRARIES
|
||||||
|
Qt::Core
|
||||||
|
Qt::Gui
|
||||||
|
Qt::WaylandClientPrivate
|
||||||
|
QT_LICENSE_ID QT_COMMERCIAL_OR_LGPL3
|
||||||
|
)
|
||||||
|
|
||||||
|
#### Keys ignored in scope 1:.:.:qwayland-generic.pro:<TRUE>:
|
||||||
|
# OTHER_FILES = "qwayland-generic.json"
|
45
src/plugins/platforms/wayland/plugins/platform/main.cpp
Normal file
45
src/plugins/platforms/wayland/plugins/platform/main.cpp
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
// Copyright (C) 2016 The Qt Company Ltd.
|
||||||
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||||
|
|
||||||
|
#include <qpa/qplatformintegrationplugin.h>
|
||||||
|
#include <QtWaylandClient/private/qwaylandintegration_p.h>
|
||||||
|
#include <QtWaylandClient/private/qtwaylandclientglobal_p.h>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
namespace QtWaylandClient {
|
||||||
|
|
||||||
|
class QWaylandIntegrationPlugin : public QPlatformIntegrationPlugin
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PLUGIN_METADATA(IID QPlatformIntegrationFactoryInterface_iid FILE "qwayland-generic.json")
|
||||||
|
public:
|
||||||
|
QPlatformIntegration *create(const QString&, const QStringList&) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
QPlatformIntegration *QWaylandIntegrationPlugin::create(const QString& system, const QStringList& paramList)
|
||||||
|
{
|
||||||
|
Q_UNUSED(paramList)
|
||||||
|
#if !QT_CONFIG(wayland_egl)
|
||||||
|
if (system == "wayland-egl")
|
||||||
|
return nullptr;
|
||||||
|
#endif
|
||||||
|
#if !QT_CONFIG(wayland_brcm)
|
||||||
|
if (system == "wayland-brcm")
|
||||||
|
return nullptr;
|
||||||
|
#endif
|
||||||
|
auto *integration = new QWaylandIntegration(system);
|
||||||
|
|
||||||
|
if (!integration->init()) {
|
||||||
|
delete integration;
|
||||||
|
integration = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return integration;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace QtWaylandClient
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
#include "main.moc"
|
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"Keys": [
|
||||||
|
"wayland",
|
||||||
|
"wayland-egl",
|
||||||
|
"wayland-brcm"
|
||||||
|
]
|
||||||
|
}
|
@ -74,15 +74,17 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
using namespace Qt::StringLiterals;
|
||||||
|
|
||||||
namespace QtWaylandClient {
|
namespace QtWaylandClient {
|
||||||
|
|
||||||
QWaylandIntegration *QWaylandIntegration::sInstance = nullptr;
|
QWaylandIntegration *QWaylandIntegration::sInstance = nullptr;
|
||||||
|
|
||||||
QWaylandIntegration::QWaylandIntegration()
|
QWaylandIntegration::QWaylandIntegration(const QString &platformName)
|
||||||
#if defined(Q_OS_MACOS)
|
#if defined(Q_OS_MACOS)
|
||||||
: mFontDb(new QCoreTextFontDatabaseEngineFactory<QCoreTextFontEngine>)
|
: mFontDb(new QCoreTextFontDatabaseEngineFactory<QCoreTextFontEngine>)
|
||||||
#else
|
#else
|
||||||
: mFontDb(new QGenericUnixFontDatabase())
|
: mPlatformName(platformName), mFontDb(new QGenericUnixFontDatabase())
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
mDisplay.reset(new QWaylandDisplay(this));
|
mDisplay.reset(new QWaylandDisplay(this));
|
||||||
@ -92,6 +94,8 @@ QWaylandIntegration::QWaylandIntegration()
|
|||||||
!qEnvironmentVariableIsSet("QT_WAYLAND_DISABLE_FIXED_POSITIONS");
|
!qEnvironmentVariableIsSet("QT_WAYLAND_DISABLE_FIXED_POSITIONS");
|
||||||
|
|
||||||
sInstance = this;
|
sInstance = this;
|
||||||
|
if (platformName != "wayland"_L1)
|
||||||
|
initializeClientBufferIntegration();
|
||||||
}
|
}
|
||||||
|
|
||||||
QWaylandIntegration::~QWaylandIntegration()
|
QWaylandIntegration::~QWaylandIntegration()
|
||||||
@ -335,6 +339,10 @@ void QWaylandIntegration::initializeClientBufferIntegration()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
QString targetKey = QString::fromLocal8Bit(qgetenv("QT_WAYLAND_CLIENT_BUFFER_INTEGRATION"));
|
QString targetKey = QString::fromLocal8Bit(qgetenv("QT_WAYLAND_CLIENT_BUFFER_INTEGRATION"));
|
||||||
|
if (mPlatformName == "wayland-egl"_L1)
|
||||||
|
targetKey = "wayland-egl"_L1;
|
||||||
|
else if (mPlatformName == "wayland-brcm"_L1)
|
||||||
|
targetKey = "brcm"_L1;
|
||||||
|
|
||||||
if (targetKey.isEmpty()) {
|
if (targetKey.isEmpty()) {
|
||||||
if (mDisplay->hardwareIntegration()
|
if (mDisplay->hardwareIntegration()
|
||||||
|
@ -39,7 +39,7 @@ class QWaylandPlatformServices;
|
|||||||
class Q_WAYLANDCLIENT_EXPORT QWaylandIntegration : public QPlatformIntegration
|
class Q_WAYLANDCLIENT_EXPORT QWaylandIntegration : public QPlatformIntegration
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QWaylandIntegration();
|
QWaylandIntegration(const QString &platformName);
|
||||||
~QWaylandIntegration() override;
|
~QWaylandIntegration() override;
|
||||||
|
|
||||||
static QWaylandIntegration *instance() { return sInstance; }
|
static QWaylandIntegration *instance() { return sInstance; }
|
||||||
@ -127,6 +127,7 @@ private:
|
|||||||
void initializeInputDeviceIntegration();
|
void initializeInputDeviceIntegration();
|
||||||
QWaylandShellIntegration *createShellIntegration(const QString& interfaceName);
|
QWaylandShellIntegration *createShellIntegration(const QString& interfaceName);
|
||||||
|
|
||||||
|
const QString mPlatformName;
|
||||||
QScopedPointer<QPlatformFontDatabase> mFontDb;
|
QScopedPointer<QPlatformFontDatabase> mFontDb;
|
||||||
#if QT_CONFIG(clipboard)
|
#if QT_CONFIG(clipboard)
|
||||||
QScopedPointer<QPlatformClipboard> mClipboard;
|
QScopedPointer<QPlatformClipboard> mClipboard;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user