From 8f6edea5213b0d4e7304bbf607ed778f4899522c Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Tue, 24 Nov 2020 18:58:52 +0200 Subject: [PATCH] Turn krunner integration into a plugin krunner stuff doesn't really belong in kwin, it has nothing to do with compositing or any other things that are the domain of compositors. Given that, being as a plugin suits the krunner integration stuff best. --- CMakeLists.txt | 18 --------- plugins/CMakeLists.txt | 3 ++ plugins/krunner-integration/CMakeLists.txt | 12 ++++++ .../krunner-integration}/dbusutils_p.h | 0 .../kwin-runner-windows.desktop | 0 plugins/krunner-integration/main.cpp | 38 +++++++++++++++++++ plugins/krunner-integration/metadata.json | 6 +++ .../krunner-integration}/org.kde.krunner1.xml | 0 .../windowsrunnerinterface.cpp | 19 +++++++--- .../windowsrunnerinterface.h | 11 ++++-- workspace.cpp | 7 ---- 11 files changed, 80 insertions(+), 34 deletions(-) create mode 100644 plugins/krunner-integration/CMakeLists.txt rename {runners => plugins/krunner-integration}/dbusutils_p.h (100%) rename {runners => plugins/krunner-integration}/kwin-runner-windows.desktop (100%) create mode 100644 plugins/krunner-integration/main.cpp create mode 100644 plugins/krunner-integration/metadata.json rename {runners => plugins/krunner-integration}/org.kde.krunner1.xml (100%) rename {runners => plugins/krunner-integration}/windowsrunnerinterface.cpp (98%) rename {runners => plugins/krunner-integration}/windowsrunnerinterface.h (94%) diff --git a/CMakeLists.txt b/CMakeLists.txt index d2f11dfa72..961ae76ab8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -607,12 +607,6 @@ if (KWIN_BUILD_ACTIVITIES) ) endif() -if (KWIN_BUILD_RUNNERS) - set(kwin_SRCS ${kwin_SRCS} - runners/windowsrunnerinterface.cpp - ) -endif() - if (HAVE_LINUX_VT_H) set(kwin_SRCS ${kwin_SRCS} virtual_terminal.cpp @@ -643,9 +637,6 @@ qt5_add_dbus_adaptor(kwin_SRCS ${kwin_effects_dbus_xml} effects.h KWin::EffectsH qt5_add_dbus_adaptor(kwin_SRCS org.kde.KWin.VirtualDesktopManager.xml dbusinterface.h KWin::VirtualDesktopManagerDBusInterface) qt5_add_dbus_adaptor(kwin_SRCS org.kde.KWin.Session.xml sm.h KWin::SessionManager) qt5_add_dbus_adaptor(kwin_SRCS org.kde.KWin.Plugins.xml dbusinterface.h KWin::PluginManagerDBusInterface) -if (KWIN_BUILD_RUNNERS) - qt5_add_dbus_adaptor(kwin_SRCS "runners/org.kde.krunner1.xml" runners/windowsrunnerinterface.h KWin::WindowsRunner) -endif() qt5_add_dbus_interface(kwin_SRCS ${KSCREENLOCKER_DBUS_INTERFACES_DIR}/kf5_org.freedesktop.ScreenSaver.xml screenlocker_interface) qt5_add_dbus_interface(kwin_SRCS ${KSCREENLOCKER_DBUS_INTERFACES_DIR}/org.kde.screensaver.xml kscreenlocker_interface) @@ -722,10 +713,6 @@ if (KWIN_BUILD_ACTIVITIES) set(kwin_KDE_LIBS ${kwin_KDE_LIBS} KF5::Activities) endif() -if (KWIN_BUILD_RUNNERS) - set(kwin_KDE_LIBS ${kwin_KDE_LIBS} KF5::Runner) -endif() - set(kwinLibs ${kwin_OWN_LIBS} ${kwin_QT_LIBS} @@ -847,11 +834,6 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kwin_export.h DESTINATION ${INCLUDE_IN # Install the KWin/Script service type install(FILES scripting/kwinscript.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR}) -# install KWin krunner runner -if (KWIN_BUILD_RUNNERS) - install(FILES runners/kwin-runner-windows.desktop DESTINATION ${KDE_INSTALL_DATAROOTDIR}/krunner/dbusplugins) -endif() - add_subdirectory(qml) if (BUILD_TESTING) diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index db379218d5..cb3c44b2c0 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -15,3 +15,6 @@ endif() if (lcms2_FOUND) add_subdirectory(colord-integration) endif() +if (KWIN_BUILD_RUNNERS) + add_subdirectory(krunner-integration) +endif() diff --git a/plugins/krunner-integration/CMakeLists.txt b/plugins/krunner-integration/CMakeLists.txt new file mode 100644 index 0000000000..5ec2182433 --- /dev/null +++ b/plugins/krunner-integration/CMakeLists.txt @@ -0,0 +1,12 @@ +set(krunnerintegration_SOURCES + main.cpp + windowsrunnerinterface.cpp +) + +qt5_add_dbus_adaptor(krunnerintegration_SOURCES org.kde.krunner1.xml windowsrunnerinterface.h KWin::WindowsRunner) + +add_library(krunnerintegration MODULE ${krunnerintegration_SOURCES}) +target_link_libraries(krunnerintegration kwin KF5::Runner) + +install(TARGETS krunnerintegration DESTINATION ${PLUGIN_INSTALL_DIR}/kwin/plugins/) +install(FILES kwin-runner-windows.desktop DESTINATION ${KDE_INSTALL_DATAROOTDIR}/krunner/dbusplugins) diff --git a/runners/dbusutils_p.h b/plugins/krunner-integration/dbusutils_p.h similarity index 100% rename from runners/dbusutils_p.h rename to plugins/krunner-integration/dbusutils_p.h diff --git a/runners/kwin-runner-windows.desktop b/plugins/krunner-integration/kwin-runner-windows.desktop similarity index 100% rename from runners/kwin-runner-windows.desktop rename to plugins/krunner-integration/kwin-runner-windows.desktop diff --git a/plugins/krunner-integration/main.cpp b/plugins/krunner-integration/main.cpp new file mode 100644 index 0000000000..a189b02c01 --- /dev/null +++ b/plugins/krunner-integration/main.cpp @@ -0,0 +1,38 @@ +/* + SPDX-FileCopyrightText: 2020 Vlad Zahorodnii + + SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#include "windowsrunnerinterface.h" +#include "main.h" + +#include + +using namespace KWin; + +class KWIN_EXPORT KRunnerIntegrationFactory : public PluginFactory +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID PluginFactory_iid FILE "metadata.json") + Q_INTERFACES(KWin::PluginFactory) + +public: + explicit KRunnerIntegrationFactory(QObject *parent = nullptr); + + Plugin *create() const override; +}; + +KRunnerIntegrationFactory::KRunnerIntegrationFactory(QObject *parent) + : PluginFactory(parent) +{ +} + +Plugin *KRunnerIntegrationFactory::create() const +{ + return new WindowsRunner(); +} + +K_EXPORT_PLUGIN_VERSION(KWIN_PLUGIN_API_VERSION) + +#include "main.moc" diff --git a/plugins/krunner-integration/metadata.json b/plugins/krunner-integration/metadata.json new file mode 100644 index 0000000000..e0fd675dd4 --- /dev/null +++ b/plugins/krunner-integration/metadata.json @@ -0,0 +1,6 @@ +{ + "KPlugin": { + "EnabledByDefault": true, + "Id": "kwin5_plugin_krunner" + } +} diff --git a/runners/org.kde.krunner1.xml b/plugins/krunner-integration/org.kde.krunner1.xml similarity index 100% rename from runners/org.kde.krunner1.xml rename to plugins/krunner-integration/org.kde.krunner1.xml diff --git a/runners/windowsrunnerinterface.cpp b/plugins/krunner-integration/windowsrunnerinterface.cpp similarity index 98% rename from runners/windowsrunnerinterface.cpp rename to plugins/krunner-integration/windowsrunnerinterface.cpp index cd758d05bc..92f39d13e5 100644 --- a/runners/windowsrunnerinterface.cpp +++ b/plugins/krunner-integration/windowsrunnerinterface.cpp @@ -20,7 +20,20 @@ namespace KWin { WindowsRunner::WindowsRunner(QObject *parent) - : QObject(parent) + : Plugin(parent) +{ + if (workspace()) { + initialize(); + } else { + connect(kwinApp(), &Application::workspaceCreated, this, &WindowsRunner::initialize); + } +} + +WindowsRunner::~WindowsRunner() +{ +} + +void WindowsRunner::initialize() { new Krunner1Adaptor(this); qDBusRegisterMetaType(); @@ -31,10 +44,6 @@ WindowsRunner::WindowsRunner(QObject *parent) QDBusConnection::sessionBus().registerService(QStringLiteral("org.kde.KWin")); } -WindowsRunner::~WindowsRunner() -{ -} - RemoteActions WindowsRunner::Actions() { RemoteActions actions; diff --git a/runners/windowsrunnerinterface.h b/plugins/krunner-integration/windowsrunnerinterface.h similarity index 94% rename from runners/windowsrunnerinterface.h rename to plugins/krunner-integration/windowsrunnerinterface.h index 3f6381e70f..2386c4dc60 100644 --- a/runners/windowsrunnerinterface.h +++ b/plugins/krunner-integration/windowsrunnerinterface.h @@ -13,21 +13,23 @@ #pragma once +#include "plugin.h" +#include "dbusutils_p.h" + +#include + #include #include #include #include #include -#include -#include "dbusutils_p.h" - namespace KWin { class VirtualDesktop; class AbstractClient; -class WindowsRunner : public QObject, protected QDBusContext +class WindowsRunner : public Plugin, protected QDBusContext { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.kde.KWin.WindowsRunner") @@ -54,6 +56,7 @@ private: ActivateDesktopAction }; + void initialize(); RemoteMatch desktopMatch(const VirtualDesktop *desktop, const WindowsRunnerAction action = ActivateDesktopAction, qreal relevance = 1.0) const; RemoteMatch windowsMatch(const AbstractClient *client, const WindowsRunnerAction action = ActivateAction, qreal relevance = 1.0, Plasma::QueryMatch::Type type = Plasma::QueryMatch::ExactMatch) const; bool actionSupported(const AbstractClient *client, const WindowsRunnerAction action) const; diff --git a/workspace.cpp b/workspace.cpp index 687288343f..f709889e49 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -60,10 +60,6 @@ // Qt #include -#ifdef KF5Runner_FOUND - #include -#endif - namespace KWin { @@ -201,9 +197,6 @@ Workspace::Workspace() }); new DBusInterface(this); -#ifdef KF5Runner_FOUND - new WindowsRunner(this); -#endif Outline::create(this); initShortcuts();