Try all supported Compositor Types of the current Platform
Summary: The Compositor now tries to create a Scene not just once but every type supported by the Platform till it finds one which works. The user's configuration is only used as a preferred hint and tried first if the platform supports it. This brings as an advantage that on platforms such as framebuffer the user does not need to specify which compositor to use: KWin uses QPainter automatically. Also we don't need to do the "translation" from XRender to QPainter any more. XRender is not supported by any platform using QPainter, so the user configuration is ignored anyway. BUG: 350159 FIXED-IN: 5.12.0 Test Plan: Run on framebuffer, verified debug output. Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D8363icc-effect-5.14.5
parent
abedb464d5
commit
729bfd04a0
|
@ -198,25 +198,42 @@ void Compositor::slotCompositingOptionsInitialized()
|
|||
}
|
||||
}
|
||||
|
||||
auto supportedCompositors = kwinApp()->platform()->supportedCompositors();
|
||||
const auto userConfigIt = std::find(supportedCompositors.begin(), supportedCompositors.end(), options->compositingMode());
|
||||
if (userConfigIt != supportedCompositors.end()) {
|
||||
supportedCompositors.erase(userConfigIt);
|
||||
supportedCompositors.prepend(options->compositingMode());
|
||||
} else {
|
||||
qCWarning(KWIN_CORE) << "Configured compositor not supported by Platform. Falling back to defaults";
|
||||
}
|
||||
|
||||
const auto availablePlugins = KPluginLoader::findPlugins(QStringLiteral("org.kde.kwin.scenes"));
|
||||
|
||||
const auto pluginIt = std::find_if(availablePlugins.begin(), availablePlugins.end(),
|
||||
[] (const auto &plugin) {
|
||||
const auto &metaData = plugin.rawData();
|
||||
auto it = metaData.find(QStringLiteral("CompositingType"));
|
||||
if (it != metaData.end()) {
|
||||
if ((*it).toInt() == int{options->compositingMode()}) {
|
||||
return true;
|
||||
for (auto type : qAsConst(supportedCompositors)) {
|
||||
const auto pluginIt = std::find_if(availablePlugins.begin(), availablePlugins.end(),
|
||||
[type] (const auto &plugin) {
|
||||
const auto &metaData = plugin.rawData();
|
||||
auto it = metaData.find(QStringLiteral("CompositingType"));
|
||||
if (it != metaData.end()) {
|
||||
if ((*it).toInt() == int{type}) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
if (pluginIt != availablePlugins.end()) {
|
||||
std::unique_ptr<SceneFactory> factory{qobject_cast<SceneFactory*>(pluginIt->instantiate())};
|
||||
if (factory) {
|
||||
m_scene = factory->create(this);
|
||||
if (m_scene) {
|
||||
if (!m_scene->initFailed()) {
|
||||
qCDebug(KWIN_CORE) << "Instantiated compositing plugin:" << pluginIt->name();
|
||||
break;
|
||||
} else {
|
||||
delete m_scene;
|
||||
m_scene = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
if (pluginIt != availablePlugins.end()) {
|
||||
std::unique_ptr<SceneFactory> factory{qobject_cast<SceneFactory*>(pluginIt->instantiate())};
|
||||
if (factory) {
|
||||
m_scene = factory->create(this);
|
||||
if (m_scene) {
|
||||
qCDebug(KWIN_CORE) << "Instantiated compositing plugin:" << pluginIt->name();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -230,7 +247,7 @@ void Compositor::slotCompositingOptionsInitialized()
|
|||
cm_selection->owning = false;
|
||||
cm_selection->release();
|
||||
}
|
||||
if (kwinApp()->platform()->requiresCompositing()) {
|
||||
if (!supportedCompositors.contains(NoCompositing)) {
|
||||
qCCritical(KWIN_CORE) << "The used windowing system requires compositing";
|
||||
qCCritical(KWIN_CORE) << "We are going to quit KWin now as it is broken";
|
||||
qApp->quit();
|
||||
|
|
|
@ -933,19 +933,16 @@ bool Options::loadCompositingConfig (bool force)
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (kwinApp()->shouldUseWaylandForCompositing() && (compositingMode == XRenderCompositing || compositingMode == NoCompositing)) {
|
||||
qCDebug(KWIN_CORE) << "Compositing forced to QPainter mode by invalid compositor selection";
|
||||
compositingMode = QPainterCompositing;
|
||||
}
|
||||
setCompositingMode(compositingMode);
|
||||
|
||||
if (m_compositingMode == NoCompositing) {
|
||||
const bool platformSupportsNoCompositing = kwinApp()->platform()->supportedCompositors().contains(NoCompositing);
|
||||
if (m_compositingMode == NoCompositing && platformSupportsNoCompositing) {
|
||||
setUseCompositing(false);
|
||||
return false; // do not even detect compositing preferences if explicitly disabled
|
||||
}
|
||||
|
||||
// it's either enforced by env or by initial resume from "suspend" or we check the settings
|
||||
setUseCompositing(useCompositing || force || config.readEntry("Enabled", Options::defaultUseCompositing()));
|
||||
setUseCompositing(useCompositing || force || config.readEntry("Enabled", Options::defaultUseCompositing() || !platformSupportsNoCompositing));
|
||||
|
||||
if (!m_useCompositing)
|
||||
return false; // not enforced or necessary and not "enabled" by settings
|
||||
|
|
Loading…
Reference in New Issue