diff --git a/main_x11.cpp b/main_x11.cpp
index 140acc49a9..194ee54f9a 100644
--- a/main_x11.cpp
+++ b/main_x11.cpp
@@ -22,12 +22,15 @@ along with this program. If not, see .
#include "main_x11.h"
#include
// kwin
+#include "platform.h"
#include "sm.h"
#include "workspace.h"
#include "xcbutils.h"
// KDE
#include
+#include
+#include
// Qt
#include
#include
@@ -36,6 +39,7 @@ along with this program. If not, see .
#ifdef HAVE_UNISTD_H
#include
#endif // HAVE_UNISTD_H
+#include
namespace KWin
{
@@ -179,11 +183,23 @@ void ApplicationX11::performStartup()
}
createInput();
- createWorkspace();
- Xcb::sync(); // Trigger possible errors, there's still a chance to abort
+ connect(platform(), &Platform::screensQueried, this,
+ [this] {
+ createWorkspace();
- notifyKSplash();
+ Xcb::sync(); // Trigger possible errors, there's still a chance to abort
+
+ notifyKSplash();
+ }
+ );
+ connect(platform(), &Platform::initFailed, this,
+ [] () {
+ std::cerr << "FATAL ERROR: backend failed to initialize, exiting now" << std::endl;
+ ::exit(1);
+ }
+ );
+ platform()->init();
});
// we need to do an XSync here, otherwise the QPA might crash us later on
Xcb::sync();
@@ -319,6 +335,19 @@ KWIN_EXPORT int kdemain(int argc, char * argv[])
exit(1);
}
+ // find and load the X11 platform plugin
+ const auto plugins = KPluginLoader::findPluginsById(QStringLiteral("org.kde.kwin.platforms"),
+ QStringLiteral("KWinX11Platform"));
+ if (plugins.isEmpty()) {
+ std::cerr << "FATAL ERROR: KWin could not find the KWinX11Platform plugin" << std::endl;
+ return 1;
+ }
+ a.initPlatform(plugins.first());
+ if (!a.platform()) {
+ std::cerr << "FATAL ERROR: could not instantiate the platform plugin" << std::endl;
+ return 1;
+ }
+
a.start();
KWin::SessionSaveDoneHelper helper;