Utilize KCoreAddons infrastructure for static plugins

This commit is contained in:
Alexander Lohnau 2021-10-23 13:56:00 +02:00 committed by Vlad Zahorodnii
parent f1e96676ef
commit 66352bfc87
45 changed files with 59 additions and 184 deletions

View file

@ -6,7 +6,7 @@ project(KWin VERSION ${PROJECT_VERSION})
set(CMAKE_C_STANDARD 99)
set(QT_MIN_VERSION "5.15.0")
set(KF5_MIN_VERSION "5.86")
set(KF5_MIN_VERSION "5.88")
set(KDE_COMPILERSETTINGS_LEVEL "5.82")
find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE)

View file

@ -29,8 +29,7 @@ public:
} // namespace
KWIN_EFFECT_FACTORY_SUPPORTED_ENABLED( FakeEffectPluginFactory,
KWin::FakeEffect,
KWIN_EFFECT_FACTORY_SUPPORTED_ENABLED(KWin::FakeEffect,
"fakeeffectplugin.json",
return KWin::FakeEffect::supported();,
return KWin::FakeEffect::enabledByDefault();)

View file

@ -9,7 +9,6 @@
#include "kwin_wayland_test.h"
#include "composite.h"
#include "effect_builtins.h"
#include "effects.h"
#include "inputmethod.h"
#include "platform.h"
@ -38,8 +37,6 @@ Q_IMPORT_PLUGIN(KGlobalAccelImpl)
Q_IMPORT_PLUGIN(KWindowSystemKWinPlugin)
Q_IMPORT_PLUGIN(KWinIdleTimePoller)
KWIN_IMPORT_BUILTIN_EFFECTS
namespace KWin
{

View file

@ -202,6 +202,7 @@ StaticPluginEffectLoader::StaticPluginEffectLoader(QObject *parent)
, m_queue(new EffectLoadQueue<StaticPluginEffectLoader, QString>(this))
{
const QVector<QStaticPlugin> staticPlugins = QPluginLoader::staticPlugins();
qWarning()<<Q_FUNC_INFO<<staticPlugins.count();
for (const QStaticPlugin &staticPlugin : staticPlugins) {
const QJsonObject rootMetaData = staticPlugin.metaData();
if (rootMetaData.value(QLatin1String("IID")) != QLatin1String(EffectPluginFactory_iid)) {

View file

@ -76,8 +76,8 @@ set(kwin_effect_XCB_LIBS
set(kwin_effect_OWN_LIBS ${kwin_effect_OWN_LIBS} kwinglutils)
macro(KWIN4_ADD_EFFECT_BACKEND name type)
add_library(${name} ${type} ${ARGN})
macro(KWIN4_ADD_EFFECT_MODULE name)
kcoreaddons_add_plugin(${name} STATIC SOURCES ${ARGN} INSTALL_NAMESPACE "kwin/effects/static")
target_link_libraries(${name} PRIVATE
${kwin_effect_KDE_LIBS}
${kwin_effect_OWN_LIBS}
@ -85,11 +85,6 @@ macro(KWIN4_ADD_EFFECT_BACKEND name type)
${kwin_effect_XCB_LIBS}
${kwin_effect_XLIB_LIBS}
)
endmacro()
macro(KWIN4_ADD_EFFECT_MODULE name)
kwin4_add_effect_backend(${name} OBJECT ${ARGN})
target_compile_definitions(${name} PRIVATE QT_STATICPLUGIN)
kwin_strip_builtin_effect_metadata(${name} metadata.json)
install(FILES metadata.json DESTINATION ${KDE_INSTALL_DATADIR}/${KWIN_NAME}/builtin-effects/${name}/)
endmacro()
@ -174,41 +169,12 @@ set(kwin4_effect_builtins_sources
qt5_add_resources(kwin4_effect_builtins_sources shaders.qrc)
kwin4_add_effect_backend(kwin4_effect_builtins STATIC ${kwin4_effect_builtins_sources})
add_library(kwin4_effect_builtins STATIC ${kwin4_effect_builtins_sources})
kcoreaddons_target_static_plugins(kwin4_effect_builtins "kwin/effects/static" LINK_OPTION "PRIVATE")
target_link_libraries(kwin4_effect_builtins PRIVATE
kwin4_effect_blur
kwin4_effect_colorpicker
kwin4_effect_contrast
kwin4_effect_desktopgrid
kwin4_effect_diminactive
kwin4_effect_fallapart
kwin4_effect_glide
kwin4_effect_highlightwindow
kwin4_effect_invert
kwin4_effect_kscreen
kwin4_effect_lookingglass
kwin4_effect_magiclamp
kwin4_effect_magnifier
kwin4_effect_mouseclick
kwin4_effect_mousemark
kwin4_effect_overview
kwin4_effect_presentwindows
kwin4_effect_resize
kwin4_effect_screenedge
kwin4_effect_screenshot
kwin4_effect_screentransform
kwin4_effect_sheet
kwin4_effect_showfps
kwin4_effect_showpaint
kwin4_effect_slide
kwin4_effect_slideback
kwin4_effect_slidingpopups
kwin4_effect_snaphelper
kwin4_effect_startupfeedback
kwin4_effect_thumbnailaside
kwin4_effect_touchpoints
kwin4_effect_trackmouse
kwin4_effect_windowgeometry
kwin4_effect_wobblywindows
kwin4_effect_zoom
${kwin_effect_KDE_LIBS}
${kwin_effect_OWN_LIBS}
${kwin_effect_QT_LIBS}
${kwin_effect_XCB_LIBS}
${kwin_effect_XLIB_LIBS}
)

View file

@ -9,8 +9,7 @@
namespace KWin
{
KWIN_EFFECT_FACTORY_SUPPORTED_ENABLED(ContrastEffectFactory,
ContrastEffect,
KWIN_EFFECT_FACTORY_SUPPORTED_ENABLED(ContrastEffect,
"metadata.json.stripped",
return ContrastEffect::supported();,
return ContrastEffect::enabledByDefault();)

View file

@ -9,8 +9,7 @@
namespace KWin
{
KWIN_EFFECT_FACTORY_SUPPORTED_ENABLED(BlurEffectFactory,
BlurEffect,
KWIN_EFFECT_FACTORY_SUPPORTED_ENABLED(BlurEffect,
"metadata.json.stripped",
return BlurEffect::supported();,
return BlurEffect::enabledByDefault();)

View file

@ -9,8 +9,7 @@
namespace KWin
{
KWIN_EFFECT_FACTORY_SUPPORTED(ColorPickerEffectFactory,
ColorPickerEffect,
KWIN_EFFECT_FACTORY_SUPPORTED(ColorPickerEffect,
"metadata.json.stripped",
return ColorPickerEffect::supported();)

View file

@ -9,8 +9,7 @@
namespace KWin
{
KWIN_EFFECT_FACTORY(DesktopGridEffectFactory,
DesktopGridEffect,
KWIN_EFFECT_FACTORY(DesktopGridEffect,
"metadata.json.stripped")
} // namespace KWin

View file

@ -9,8 +9,7 @@
namespace KWin
{
KWIN_EFFECT_FACTORY(DimInactiveEffectFactory,
DimInactiveEffect,
KWIN_EFFECT_FACTORY(DimInactiveEffect,
"metadata.json.stripped")
} // namespace KWin

View file

@ -1,49 +0,0 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef KWIN_EFFECT_BUILTINS_H
#define KWIN_EFFECT_BUILTINS_H
#define KWIN_IMPORT_BUILTIN_EFFECTS \
Q_IMPORT_PLUGIN(BlurEffectFactory) \
Q_IMPORT_PLUGIN(ColorPickerEffectFactory) \
Q_IMPORT_PLUGIN(ContrastEffectFactory) \
Q_IMPORT_PLUGIN(DesktopGridEffectFactory) \
Q_IMPORT_PLUGIN(DimInactiveEffectFactory) \
Q_IMPORT_PLUGIN(FallApartEffectFactory) \
Q_IMPORT_PLUGIN(GlideEffectFactory) \
Q_IMPORT_PLUGIN(HighlightWindowEffectFactory) \
Q_IMPORT_PLUGIN(InvertEffectFactory) \
Q_IMPORT_PLUGIN(KscreenEffectFactory) \
Q_IMPORT_PLUGIN(LookingGlassEffectFactory) \
Q_IMPORT_PLUGIN(MagicLampEffectFactory) \
Q_IMPORT_PLUGIN(MagnifierEffectFactory) \
Q_IMPORT_PLUGIN(MouseClickEffectFactory) \
Q_IMPORT_PLUGIN(MouseMarkEffectFactory) \
Q_IMPORT_PLUGIN(OverviewEffectFactory) \
Q_IMPORT_PLUGIN(PresentWindowsEffectFactory) \
Q_IMPORT_PLUGIN(ResizeEffectFactory) \
Q_IMPORT_PLUGIN(ScreenEdgeEffectFactory) \
Q_IMPORT_PLUGIN(ScreenShotEffectFactory) \
Q_IMPORT_PLUGIN(ScreenTransformEffectFactory) \
Q_IMPORT_PLUGIN(SheetEffectFactory) \
Q_IMPORT_PLUGIN(ShowFpsEffectFactory) \
Q_IMPORT_PLUGIN(ShowPaintEffectFactory) \
Q_IMPORT_PLUGIN(SlideEffectFactory) \
Q_IMPORT_PLUGIN(SlideBackEffectFactory) \
Q_IMPORT_PLUGIN(SlidingPopupsEffectFactory) \
Q_IMPORT_PLUGIN(SnapHelperEffectFactory) \
Q_IMPORT_PLUGIN(StartupFeedbackEffectFactory) \
Q_IMPORT_PLUGIN(ThumbnailAsideEffectFactory) \
Q_IMPORT_PLUGIN(TouchPointsEffectFactory) \
Q_IMPORT_PLUGIN(TrackMouseEffectFactory) \
Q_IMPORT_PLUGIN(WindowGeometryFactory) \
Q_IMPORT_PLUGIN(WobblyWindowsEffectFactory) \
Q_IMPORT_PLUGIN(ZoomEffectFactory)
#endif

View file

@ -9,8 +9,7 @@
namespace KWin
{
KWIN_EFFECT_FACTORY_SUPPORTED(FallApartEffectFactory,
FallApartEffect,
KWIN_EFFECT_FACTORY_SUPPORTED(FallApartEffect,
"metadata.json.stripped",
return FallApartEffect::supported();)

View file

@ -9,8 +9,7 @@
namespace KWin
{
KWIN_EFFECT_FACTORY_SUPPORTED(GlideEffectFactory,
GlideEffect,
KWIN_EFFECT_FACTORY_SUPPORTED(GlideEffect,
"metadata.json.stripped",
return GlideEffect::supported();)

View file

@ -9,8 +9,7 @@
namespace KWin
{
KWIN_EFFECT_FACTORY(HighlightWindowEffectFactory,
HighlightWindowEffect,
KWIN_EFFECT_FACTORY(HighlightWindowEffect,
"metadata.json.stripped")
} // namespace KWin

View file

@ -9,8 +9,7 @@
namespace KWin
{
KWIN_EFFECT_FACTORY_SUPPORTED(InvertEffectFactory,
InvertEffect,
KWIN_EFFECT_FACTORY_SUPPORTED(InvertEffect,
"metadata.json.stripped",
return InvertEffect::supported();)

View file

@ -9,8 +9,7 @@
namespace KWin
{
KWIN_EFFECT_FACTORY(KscreenEffectFactory,
KscreenEffect,
KWIN_EFFECT_FACTORY(KscreenEffect,
"metadata.json.stripped")
} // namespace KWin

View file

@ -9,8 +9,7 @@
namespace KWin
{
KWIN_EFFECT_FACTORY_SUPPORTED(LookingGlassEffectFactory,
LookingGlassEffect,
KWIN_EFFECT_FACTORY_SUPPORTED(LookingGlassEffect,
"metadata.json.stripped",
return LookingGlassEffect::supported();)

View file

@ -9,8 +9,7 @@
namespace KWin
{
KWIN_EFFECT_FACTORY_SUPPORTED(MagicLampEffectFactory,
MagicLampEffect,
KWIN_EFFECT_FACTORY_SUPPORTED(MagicLampEffect,
"metadata.json.stripped",
return MagicLampEffect::supported();)

View file

@ -9,8 +9,7 @@
namespace KWin
{
KWIN_EFFECT_FACTORY_SUPPORTED(MagnifierEffectFactory,
MagnifierEffect,
KWIN_EFFECT_FACTORY_SUPPORTED(MagnifierEffect,
"metadata.json.stripped",
return MagnifierEffect::supported();)

View file

@ -9,8 +9,7 @@
namespace KWin
{
KWIN_EFFECT_FACTORY(MouseClickEffectFactory,
MouseClickEffect,
KWIN_EFFECT_FACTORY(MouseClickEffect,
"metadata.json.stripped")
} // namespace KWin

View file

@ -9,8 +9,7 @@
namespace KWin
{
KWIN_EFFECT_FACTORY(MouseMarkEffectFactory,
MouseMarkEffect,
KWIN_EFFECT_FACTORY(MouseMarkEffect,
"metadata.json.stripped")
} // namespace KWin

View file

@ -9,8 +9,7 @@
namespace KWin
{
KWIN_EFFECT_FACTORY_SUPPORTED(OverviewEffectFactory,
OverviewEffect,
KWIN_EFFECT_FACTORY_SUPPORTED(OverviewEffect,
"metadata.json.stripped",
return OverviewEffect::supported();)

View file

@ -9,8 +9,7 @@
namespace KWin
{
KWIN_EFFECT_FACTORY(PresentWindowsEffectFactory,
PresentWindowsEffect,
KWIN_EFFECT_FACTORY(PresentWindowsEffect,
"metadata.json.stripped")
} // namespace KWin

View file

@ -9,8 +9,7 @@
namespace KWin
{
KWIN_EFFECT_FACTORY(ResizeEffectFactory,
ResizeEffect,
KWIN_EFFECT_FACTORY(ResizeEffect,
"metadata.json.stripped")
} // namespace KWin

View file

@ -9,8 +9,7 @@
namespace KWin
{
KWIN_EFFECT_FACTORY(ScreenEdgeEffectFactory,
ScreenEdgeEffect,
KWIN_EFFECT_FACTORY(ScreenEdgeEffect,
"metadata.json.stripped")
} // namespace KWin

View file

@ -9,8 +9,7 @@
namespace KWin
{
KWIN_EFFECT_FACTORY_SUPPORTED(ScreenShotEffectFactory,
ScreenShotEffect,
KWIN_EFFECT_FACTORY_SUPPORTED(ScreenShotEffect,
"metadata.json.stripped",
return ScreenShotEffect::supported();)

View file

@ -19,6 +19,7 @@
#include <QtConcurrent>
#include <unistd.h>
Q_LOGGING_CATEGORY(KWINEFFECTS, "kwineffects", QtWarningMsg)
namespace KWin
{

View file

@ -9,8 +9,7 @@
namespace KWin
{
KWIN_EFFECT_FACTORY_SUPPORTED(ScreenTransformEffectFactory,
ScreenTransformEffect,
KWIN_EFFECT_FACTORY_SUPPORTED(ScreenTransformEffect,
"metadata.json.stripped",
return ScreenTransformEffect::supported();)

View file

@ -9,8 +9,7 @@
namespace KWin
{
KWIN_EFFECT_FACTORY_SUPPORTED(SheetEffectFactory,
SheetEffect,
KWIN_EFFECT_FACTORY_SUPPORTED(SheetEffect,
"metadata.json.stripped",
return SheetEffect::supported();)

View file

@ -9,8 +9,7 @@
namespace KWin
{
KWIN_EFFECT_FACTORY(ShowFpsEffectFactory,
ShowFpsEffect,
KWIN_EFFECT_FACTORY(ShowFpsEffect,
"metadata.json.stripped")
} // namespace KWin

View file

@ -9,8 +9,7 @@
namespace KWin
{
KWIN_EFFECT_FACTORY(ShowPaintEffectFactory,
ShowPaintEffect,
KWIN_EFFECT_FACTORY(ShowPaintEffect,
"metadata.json.stripped")
} // namespace KWin

View file

@ -9,8 +9,7 @@
namespace KWin
{
KWIN_EFFECT_FACTORY_SUPPORTED(SlideEffectFactory,
SlideEffect,
KWIN_EFFECT_FACTORY_SUPPORTED(SlideEffect,
"metadata.json.stripped",
return SlideEffect::supported();)

View file

@ -9,8 +9,7 @@
namespace KWin
{
KWIN_EFFECT_FACTORY(SlideBackEffectFactory,
SlideBackEffect,
KWIN_EFFECT_FACTORY(SlideBackEffect,
"metadata.json.stripped")
} // namespace KWin

View file

@ -9,8 +9,7 @@
namespace KWin
{
KWIN_EFFECT_FACTORY_SUPPORTED(SlidingPopupsEffectFactory,
SlidingPopupsEffect,
KWIN_EFFECT_FACTORY_SUPPORTED(SlidingPopupsEffect,
"metadata.json.stripped",
return SlidingPopupsEffect::supported();)

View file

@ -9,8 +9,7 @@
namespace KWin
{
KWIN_EFFECT_FACTORY(SnapHelperEffectFactory,
SnapHelperEffect,
KWIN_EFFECT_FACTORY(SnapHelperEffect,
"metadata.json.stripped")
} // namespace KWin

View file

@ -9,8 +9,7 @@
namespace KWin
{
KWIN_EFFECT_FACTORY_SUPPORTED(StartupFeedbackEffectFactory,
StartupFeedbackEffect,
KWIN_EFFECT_FACTORY_SUPPORTED(StartupFeedbackEffect,
"metadata.json.stripped",
return StartupFeedbackEffect::supported();)

View file

@ -9,8 +9,7 @@
namespace KWin
{
KWIN_EFFECT_FACTORY(ThumbnailAsideEffectFactory,
ThumbnailAsideEffect,
KWIN_EFFECT_FACTORY(ThumbnailAsideEffect,
"metadata.json.stripped")
} // namespace KWin

View file

@ -9,8 +9,7 @@
namespace KWin
{
KWIN_EFFECT_FACTORY(TouchPointsEffectFactory,
TouchPointsEffect,
KWIN_EFFECT_FACTORY(TouchPointsEffect,
"metadata.json.stripped")
} // namespace KWin

View file

@ -9,8 +9,7 @@
namespace KWin
{
KWIN_EFFECT_FACTORY(TrackMouseEffectFactory,
TrackMouseEffect,
KWIN_EFFECT_FACTORY(TrackMouseEffect,
"metadata.json.stripped")
} // namespace KWin

View file

@ -9,8 +9,7 @@
namespace KWin
{
KWIN_EFFECT_FACTORY(WindowGeometryFactory,
WindowGeometry,
KWIN_EFFECT_FACTORY(WindowGeometry,
"metadata.json.stripped")
} // namespace KWin

View file

@ -9,8 +9,7 @@
namespace KWin
{
KWIN_EFFECT_FACTORY_SUPPORTED(WobblyWindowsEffectFactory,
WobblyWindowsEffect,
KWIN_EFFECT_FACTORY_SUPPORTED(WobblyWindowsEffect,
"metadata.json.stripped",
return WobblyWindowsEffect::supported();)

View file

@ -9,8 +9,7 @@
namespace KWin
{
KWIN_EFFECT_FACTORY(ZoomEffectFactory,
ZoomEffect,
KWIN_EFFECT_FACTORY(ZoomEffect,
"metadata.json.stripped")
} // namespace KWin

View file

@ -703,6 +703,7 @@ public:
};
#define EffectPluginFactory_iid "org.kde.kwin.EffectPluginFactory" KWIN_PLUGIN_VERSION_STRING
#define KWIN_PLUGIN_FACTORY_NAME KPLUGINFACTORY_PLUGIN_CLASS_INTERNAL_NAME
/**
* Defines an EffectPluginFactory sub class with customized isSupported and enabledByDefault methods.
@ -720,15 +721,15 @@ public:
* @param supported Source code to go into the isSupported() method, must return a boolean
* @param enabled Source code to go into the enabledByDefault() method, must return a boolean
*/
#define KWIN_EFFECT_FACTORY_SUPPORTED_ENABLED( factoryName, className, jsonFile, supported, enabled ) \
class factoryName : public KWin::EffectPluginFactory \
#define KWIN_EFFECT_FACTORY_SUPPORTED_ENABLED(className, jsonFile, supported, enabled ) \
class KWIN_PLUGIN_FACTORY_NAME : public KWin::EffectPluginFactory \
{ \
Q_OBJECT \
Q_PLUGIN_METADATA(IID EffectPluginFactory_iid FILE jsonFile) \
Q_INTERFACES(KPluginFactory) \
public: \
explicit factoryName() {} \
~factoryName() {} \
explicit KWIN_PLUGIN_FACTORY_NAME() {} \
~KWIN_PLUGIN_FACTORY_NAME() {} \
bool isSupported() const override { \
supported \
} \
@ -740,14 +741,14 @@ public:
} \
};
#define KWIN_EFFECT_FACTORY_ENABLED( factoryName, className, jsonFile, enabled ) \
KWIN_EFFECT_FACTORY_SUPPORTED_ENABLED( factoryName, className, jsonFile, return true;, enabled )
#define KWIN_EFFECT_FACTORY_ENABLED(className, jsonFile, enabled ) \
KWIN_EFFECT_FACTORY_SUPPORTED_ENABLED(className, jsonFile, return true;, enabled )
#define KWIN_EFFECT_FACTORY_SUPPORTED( factoryName, className, jsonFile, supported ) \
KWIN_EFFECT_FACTORY_SUPPORTED_ENABLED( factoryName, className, jsonFile, supported, return true; )
#define KWIN_EFFECT_FACTORY_SUPPORTED(className, jsonFile, supported ) \
KWIN_EFFECT_FACTORY_SUPPORTED_ENABLED(className, jsonFile, supported, return true; )
#define KWIN_EFFECT_FACTORY( factoryName, className, jsonFile ) \
KWIN_EFFECT_FACTORY_SUPPORTED_ENABLED( factoryName, className, jsonFile, return true;, return true; )
#define KWIN_EFFECT_FACTORY(className, jsonFile ) \
KWIN_EFFECT_FACTORY_SUPPORTED_ENABLED(className, jsonFile, return true;, return true; )

View file

@ -8,7 +8,6 @@
*/
#include "main_wayland.h"
#include "composite.h"
#include "effect_builtins.h"
#include "inputmethod.h"
#include "workspace.h"
#include <config-kwin.h>
@ -59,8 +58,6 @@
#include <iostream>
#include <iomanip>
KWIN_IMPORT_BUILTIN_EFFECTS
Q_IMPORT_PLUGIN(KWinIntegrationPlugin)
Q_IMPORT_PLUGIN(KGlobalAccelImpl)
Q_IMPORT_PLUGIN(KWindowSystemKWinPlugin)

View file

@ -12,7 +12,6 @@
#include <config-kwin.h>
#include "effect_builtins.h"
#include "platform.h"
#include "sm.h"
#include "workspace.h"
@ -46,8 +45,6 @@
Q_LOGGING_CATEGORY(KWIN_CORE, "kwin_core", QtWarningMsg)
KWIN_IMPORT_BUILTIN_EFFECTS
namespace KWin
{