Load plugins after Workspace is created

The original intention behind creating plugins before the workspace was
to handle the case where kwin_wayland may need to wait until outputs are
available. However, since things have changed a lot in that regard,
plugins can be loaded after the workspace now.

The main benefit behind this is that plugins can be simpler, they won't
need to track when the workspace is created.

On X11, plugins are already loaded after the workspace is instantiated.
This commit is contained in:
Vlad Zahorodnii 2022-07-21 19:13:07 +03:00
parent 211d0c00fc
commit e179d9cea1
8 changed files with 15 additions and 33 deletions

View file

@ -140,7 +140,6 @@ void WaylandTestApplication::performStartup()
// try creating the Wayland Backend
createInput();
createPlugins();
createVirtualInputDevices();
if (!platform()->enabledOutputs().isEmpty()) {
@ -171,6 +170,7 @@ void WaylandTestApplication::continueStartupWithScene()
disconnect(Compositor::self(), &Compositor::sceneCreated, this, &WaylandTestApplication::continueStartupWithScene);
createWorkspace();
createPlugins();
if (!waylandServer()->start()) {
qFatal("Failed to initialize the Wayland server, exiting now");

View file

@ -123,7 +123,6 @@ void Application::start()
Application::~Application()
{
delete options;
destroyPlugins();
destroyColorManager();
destroyAtoms();
destroyPlatform();

View file

@ -115,6 +115,8 @@ ApplicationWayland::~ApplicationWayland()
return;
}
destroyPlugins();
// need to unload all effects prior to destroying X connection as they might do X calls
if (effects) {
static_cast<EffectsHandlerImpl *>(effects)->unloadAllEffects();
@ -146,7 +148,6 @@ void ApplicationWayland::performStartup()
createInput();
createInputMethod();
TabletModeManager::create(this);
createPlugins();
WaylandCompositor::create();
@ -160,6 +161,7 @@ void ApplicationWayland::continueStartupWithScene()
// Note that we start accepting client connections after creating the Workspace.
createWorkspace();
createPlugins();
if (!waylandServer()->start()) {
qFatal("Failed to initialze the Wayland server, exiting now");

View file

@ -182,6 +182,7 @@ ApplicationX11::ApplicationX11(int &argc, char **argv)
ApplicationX11::~ApplicationX11()
{
setTerminating();
destroyPlugins();
destroyCompositor();
destroyWorkspace();
if (!owner.isNull() && owner->ownerWindow() != XCB_WINDOW_NONE) { // If there was no --replace (no new WM)
@ -197,6 +198,7 @@ void ApplicationX11::setReplace(bool replace)
void ApplicationX11::lostSelection()
{
sendPostedEvents();
destroyPlugins();
destroyCompositor();
destroyWorkspace();
// Remove windowmanager privileges

View file

@ -19,18 +19,8 @@
namespace KWin
{
WindowsRunner::WindowsRunner()
{
if (workspace()) {
initialize();
} else {
connect(kwinApp(), &Application::workspaceCreated, this, &WindowsRunner::initialize);
}
}
WindowsRunner::~WindowsRunner() = default;
void WindowsRunner::initialize()
{
new Krunner1Adaptor(this);
qDBusRegisterMetaType<RemoteMatch>();
@ -42,6 +32,8 @@ void WindowsRunner::initialize()
QDBusConnection::sessionBus().registerService(QStringLiteral("org.kde.KWin"));
}
WindowsRunner::~WindowsRunner() = default;
RemoteActions WindowsRunner::Actions()
{
RemoteActions actions;

View file

@ -56,7 +56,6 @@ private:
ActivateDesktopAction
};
void initialize();
RemoteMatch desktopMatch(const VirtualDesktop *desktop, const WindowsRunnerAction action = ActivateDesktopAction, qreal relevance = 1.0) const;
RemoteMatch windowsMatch(const Window *window, const WindowsRunnerAction action = ActivateAction, qreal relevance = 1.0, Plasma::QueryMatch::Type type = Plasma::QueryMatch::ExactMatch) const;
bool actionSupported(const Window *window, const WindowsRunnerAction action) const;

View file

@ -47,6 +47,7 @@ NightColorManager *NightColorManager::self()
NightColorManager::NightColorManager()
{
NightColorSettings::instance(kwinApp()->config());
s_instance = this;
m_iface = new NightColorDBusInterface(this);
@ -73,22 +74,6 @@ NightColorManager::NightColorManager()
QDBusConnection::sessionBus().asyncCall(message);
});
if (workspace()) {
init();
} else {
connect(kwinApp(), &Application::workspaceCreated, this, &NightColorManager::init);
}
}
NightColorManager::~NightColorManager()
{
s_instance = nullptr;
}
void NightColorManager::init()
{
NightColorSettings::instance(kwinApp()->config());
m_configWatcher = KConfigWatcher::create(kwinApp()->config());
connect(m_configWatcher.data(), &KConfigWatcher::configChanged, this, &NightColorManager::reconfigure);
@ -153,6 +138,11 @@ void NightColorManager::init()
hardReset();
}
NightColorManager::~NightColorManager()
{
s_instance = nullptr;
}
void NightColorManager::hardReset()
{
cancelAllTimers();

View file

@ -81,8 +81,6 @@ public:
explicit NightColorManager();
~NightColorManager() override;
void init();
void autoLocationUpdate(double latitude, double longitude);
/**