From e179d9cea100984719c4db00a2e8bbd78b5780dd Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Thu, 21 Jul 2022 19:13:07 +0300 Subject: [PATCH] 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. --- autotests/integration/kwin_wayland_test.cpp | 2 +- src/main.cpp | 1 - src/main_wayland.cpp | 4 +++- src/main_x11.cpp | 2 ++ .../windowsrunnerinterface.cpp | 14 +++--------- .../windowsrunnerinterface.h | 1 - src/plugins/nightcolor/nightcolormanager.cpp | 22 +++++-------------- src/plugins/nightcolor/nightcolormanager.h | 2 -- 8 files changed, 15 insertions(+), 33 deletions(-) diff --git a/autotests/integration/kwin_wayland_test.cpp b/autotests/integration/kwin_wayland_test.cpp index dbc0900675..f315bf0872 100644 --- a/autotests/integration/kwin_wayland_test.cpp +++ b/autotests/integration/kwin_wayland_test.cpp @@ -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"); diff --git a/src/main.cpp b/src/main.cpp index 17ca4104bb..c26580259c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -123,7 +123,6 @@ void Application::start() Application::~Application() { delete options; - destroyPlugins(); destroyColorManager(); destroyAtoms(); destroyPlatform(); diff --git a/src/main_wayland.cpp b/src/main_wayland.cpp index f10c212485..351f6171a7 100644 --- a/src/main_wayland.cpp +++ b/src/main_wayland.cpp @@ -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(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"); diff --git a/src/main_x11.cpp b/src/main_x11.cpp index e784bc9e68..02bd33f40a 100644 --- a/src/main_x11.cpp +++ b/src/main_x11.cpp @@ -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 diff --git a/src/plugins/krunner-integration/windowsrunnerinterface.cpp b/src/plugins/krunner-integration/windowsrunnerinterface.cpp index 46b879bc76..68697df5a3 100644 --- a/src/plugins/krunner-integration/windowsrunnerinterface.cpp +++ b/src/plugins/krunner-integration/windowsrunnerinterface.cpp @@ -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(); @@ -42,6 +32,8 @@ void WindowsRunner::initialize() QDBusConnection::sessionBus().registerService(QStringLiteral("org.kde.KWin")); } +WindowsRunner::~WindowsRunner() = default; + RemoteActions WindowsRunner::Actions() { RemoteActions actions; diff --git a/src/plugins/krunner-integration/windowsrunnerinterface.h b/src/plugins/krunner-integration/windowsrunnerinterface.h index 5f38239d4f..4bbafb8a1a 100644 --- a/src/plugins/krunner-integration/windowsrunnerinterface.h +++ b/src/plugins/krunner-integration/windowsrunnerinterface.h @@ -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; diff --git a/src/plugins/nightcolor/nightcolormanager.cpp b/src/plugins/nightcolor/nightcolormanager.cpp index 3c5d3f4262..a192ae76fa 100644 --- a/src/plugins/nightcolor/nightcolormanager.cpp +++ b/src/plugins/nightcolor/nightcolormanager.cpp @@ -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(); diff --git a/src/plugins/nightcolor/nightcolormanager.h b/src/plugins/nightcolor/nightcolormanager.h index ed1927a471..1fa6a1a5c0 100644 --- a/src/plugins/nightcolor/nightcolormanager.h +++ b/src/plugins/nightcolor/nightcolormanager.h @@ -81,8 +81,6 @@ public: explicit NightColorManager(); ~NightColorManager() override; - void init(); - void autoLocationUpdate(double latitude, double longitude); /**