6#include "kwindoweffects_dummy_p.h"
7#include "kwindowshadow_dummy_p.h"
8#include "kwindowsystem_debug.h"
9#include "kwindowsystem_dummy_p.h"
10#include "kwindowsystemplugininterface_p.h"
11#include "pluginwrapper_p.h"
14#include <QGuiApplication>
17#include <QPluginLoader>
19Q_GLOBAL_STATIC(KWindowSystemPluginWrapper, s_pluginWrapper)
25 for (
const QString &path : paths) {
27 QStringLiteral(
"/kf6/org.kde.kwindowsystem.platforms"),
28 QStringLiteral(
"/kf6/kwindowsystem"),
30 for (
const QString &searchFolder : searchFolders) {
31 QDir pluginDir(path + searchFolder);
32 if (!pluginDir.exists()) {
36 for (
const QString &entry : entries) {
37 ret << pluginDir.absoluteFilePath(entry);
47 return std::any_of(platforms.
begin(), platforms.
end(), [&platformName](
const QJsonValue &value) {
48 return QString::compare(platformName, value.toString(), Qt::CaseInsensitive) == 0;
52static KWindowSystemPluginInterface *loadPlugin()
55 qCWarning(LOG_KWINDOWSYSTEM) <<
"Cannot use KWindowSystem without a QGuiApplication";
63 if (!flatpakPlatform.isEmpty()) {
64 platformName = flatpakPlatform;
70 const QJsonObject metadata = staticPlugin.metaData();
74 if (checkPlatform(metadata, platformName)) {
75 KWindowSystemPluginInterface *
interface = qobject_cast<KWindowSystemPluginInterface *>(staticPlugin.instance());
77 qCDebug(LOG_KWINDOWSYSTEM) <<
"Loaded a static plugin for platform" << platformName;
83 const auto candidates = pluginCandidates();
84 for (
const QString &candidate : candidates) {
89 if (checkPlatform(loader.metaData(), platformName)) {
90 KWindowSystemPluginInterface *
interface = qobject_cast<KWindowSystemPluginInterface *>(loader.instance());
92 qCDebug(LOG_KWINDOWSYSTEM) <<
"Loaded plugin" << candidate <<
"for platform" << platformName;
98 qCWarning(LOG_KWINDOWSYSTEM) <<
"Could not find any platform plugin";
102KWindowSystemPluginWrapper::KWindowSystemPluginWrapper()
103 : m_plugin(loadPlugin())
107 m_effects.reset(m_plugin->createEffects());
110 m_effects.reset(
new KWindowEffectsPrivateDummy());
114KWindowSystemPluginWrapper::~KWindowSystemPluginWrapper()
118KWindowEffectsPrivate *KWindowSystemPluginWrapper::effects()
const
120 return m_effects.get();
123KWindowSystemPrivate *KWindowSystemPluginWrapper::createWindowSystem()
const
125 KWindowSystemPrivate *p =
nullptr;
127 p = m_plugin->createWindowSystem();
130 p =
new KWindowSystemPrivateDummy();
135KWindowShadowPrivate *KWindowSystemPluginWrapper::createWindowShadow()
const
137 KWindowShadowPrivate *p =
nullptr;
139 p = m_plugin->createWindowShadow();
142 p =
new KWindowShadowPrivateDummy();
147KWindowShadowTilePrivate *KWindowSystemPluginWrapper::createWindowShadowTile()
const
149 KWindowShadowTilePrivate *p =
nullptr;
151 p = m_plugin->createWindowShadowTile();
154 p =
new KWindowShadowTilePrivateDummy();
159const KWindowSystemPluginWrapper &KWindowSystemPluginWrapper::self()
161 return *s_pluginWrapper;
QCoreApplication * instance()
QStringList libraryPaths()
QJsonValue value(QLatin1StringView key) const const
QJsonArray toArray() const const
QJsonObject toObject() const const
bool isLibrary(const QString &fileName)
QList< QStaticPlugin > staticPlugins()
QString fromLocal8Bit(QByteArrayView str)