effects: Modularize builtin effects build

Currently, cpp source files are included partially in effect sub-folders
and src/effects/CMakeLists.txt, which is really confusing and hard to
follow.

With this change, effect targets will be defined in their own subfolders.
This makes build files more straightforward.

Effect sub-targets are eventually merged into a monolithic
kwin4_effect_builtins target.

Another reason for modularizing builtin effects is that no two effects
can generate moc files with the same name atm even though they are in
different sub-folders. This can be potentially useful in the future, e.g.
making effects static plugins in order to decouple builtin effects from
libkwin (every effect subfolder would need a main.cpp or plugin.cpp file,
which will include the associated moc file).
This commit is contained in:
Vlad Zahorodnii 2021-10-09 16:43:07 +03:00
parent ec6e6fa63c
commit 10b56bd43d
37 changed files with 399 additions and 118 deletions

View file

@ -45,8 +45,8 @@ set(kwin_effect_XCB_LIBS
set(kwin_effect_OWN_LIBS ${kwin_effect_OWN_LIBS} kwinglutils)
macro(KWIN4_ADD_EFFECT_BACKEND name)
add_library(${name} SHARED ${ARGN})
macro(KWIN4_ADD_EFFECT_BACKEND name type)
add_library(${name} ${type} ${ARGN})
target_link_libraries(${name} PRIVATE
${kwin_effect_KDE_LIBS}
${kwin_effect_OWN_LIBS}
@ -58,85 +58,20 @@ endmacro()
# Adds effect plugin with given name. Sources are given after the name
macro(KWIN4_ADD_EFFECT name)
kwin4_add_effect_backend(kwin4_effect_${name} ${ARGN})
kwin4_add_effect_backend(kwin4_effect_${name} SHARED ${ARGN})
set_target_properties(kwin4_effect_${name} PROPERTIES VERSION 1.0.0 SOVERSION 1)
set_target_properties(kwin4_effect_${name} PROPERTIES OUTPUT_NAME ${KWIN_NAME}4_effect_${name})
install(TARGETS kwin4_effect_${name} ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
endmacro()
macro(KWIN4_ADD_EFFECT_MODULE name)
kwin4_add_effect_backend(${name} OBJECT ${ARGN})
endmacro()
# Install the KWin/Effect service type
install(FILES kwineffect.desktop DESTINATION ${KDE_INSTALL_KSERVICETYPES5DIR})
# Create initial variables
set(kwin4_effect_include_directories)
set(kwin4_effect_builtins_sources
blur/blur.cpp
blur/blurshader.cpp
colorpicker/colorpicker.cpp
desktopgrid/desktopgrid.cpp
diminactive/diminactive.cpp
effect_builtins.cpp
glide/glide.cpp
invert/invert.cpp
logging.cpp
lookingglass/lookingglass.cpp
magiclamp/magiclamp.cpp
magnifier/magnifier.cpp
mouseclick/mouseclick.cpp
mousemark/mousemark.cpp
overview/expoarea.cpp
overview/expolayout.cpp
overview/overvieweffect.cpp
presentwindows/presentwindows.cpp
presentwindows/presentwindows_proxy.cpp
resize/resize.cpp
showfps/showfps.cpp
showpaint/showpaint.cpp
slide/slide.cpp
thumbnailaside/thumbnailaside.cpp
touchpoints/touchpoints.cpp
trackmouse/trackmouse.cpp
windowgeometry/windowgeometry.cpp
wobblywindows/wobblywindows.cpp
zoom/zoom.cpp
../service_utils.cpp
)
if (HAVE_ACCESSIBILITY)
set(kwin4_effect_builtins_sources
zoom/accessibilityintegration.cpp
${kwin4_effect_builtins_sources}
)
endif()
qt5_add_resources(kwin4_effect_builtins_sources shaders.qrc)
kconfig_add_kcfg_files(kwin4_effect_builtins_sources
blur/blurconfig.kcfgc
desktopgrid/desktopgridconfig.kcfgc
diminactive/diminactiveconfig.kcfgc
fallapart/fallapartconfig.kcfgc
glide/glideconfig.kcfgc
lookingglass/lookingglassconfig.kcfgc
magiclamp/magiclampconfig.kcfgc
magnifier/magnifierconfig.kcfgc
mouseclick/mouseclickconfig.kcfgc
mousemark/mousemarkconfig.kcfgc
overview/overviewconfig.kcfgc
presentwindows/presentwindowsconfig.kcfgc
resize/resizeconfig.kcfgc
showfps/showfpsconfig.kcfgc
slide/slideconfig.kcfgc
slidingpopups/slidingpopupsconfig.kcfgc
thumbnailaside/thumbnailasideconfig.kcfgc
trackmouse/trackmouseconfig.kcfgc
windowgeometry/windowgeometryconfig.kcfgc
wobblywindows/wobblywindowsconfig.kcfgc
zoom/zoomconfig.kcfgc
)
# scripted effects
function(install_scripted_effect name)
kpackage_install_package(${name}/package kwin4_effect_${name} effects kwin)
@ -166,43 +101,90 @@ install_scripted_effect(sessionquit)
# Built-in effects go here
# Common effects
add_subdirectory(colorpicker)
add_subdirectory(desktopgrid)
add_subdirectory(diminactive)
include(fallapart/CMakeLists.txt)
include(highlightwindow/CMakeLists.txt)
include(kscreen/CMakeLists.txt)
include(screentransform/CMakeLists.txt)
add_subdirectory(fallapart)
add_subdirectory(highlightwindow)
add_subdirectory(kscreen)
add_subdirectory(screentransform)
add_subdirectory(magiclamp)
add_subdirectory(overview)
add_subdirectory(presentwindows)
add_subdirectory(resize)
include(screenedge/CMakeLists.txt)
add_subdirectory(screenedge)
add_subdirectory(showfps)
add_subdirectory(showpaint)
add_subdirectory(slide)
include(slideback/CMakeLists.txt)
include(slidingpopups/CMakeLists.txt)
add_subdirectory(slideback)
add_subdirectory(slidingpopups)
add_subdirectory(thumbnailaside)
add_subdirectory(touchpoints)
add_subdirectory(windowgeometry)
add_subdirectory(zoom)
# OpenGL-specific effects
add_subdirectory(blur)
include(backgroundcontrast/CMakeLists.txt)
add_subdirectory(backgroundcontrast)
add_subdirectory(glide)
add_subdirectory(invert)
add_subdirectory(lookingglass)
add_subdirectory(magnifier)
add_subdirectory(mouseclick)
add_subdirectory(mousemark)
include(screenshot/CMakeLists.txt)
include(sheet/CMakeLists.txt)
include(snaphelper/CMakeLists.txt)
include(startupfeedback/CMakeLists.txt)
add_subdirectory(screenshot)
add_subdirectory(sheet)
add_subdirectory(snaphelper)
add_subdirectory(startupfeedback)
add_subdirectory(trackmouse)
add_subdirectory(wobblywindows)
###############################################################################
# Add the builtins plugin
set(kwin4_effect_builtins_sources
effect_builtins.cpp
logging.cpp
../service_utils.cpp
)
qt5_add_resources(kwin4_effect_builtins_sources shaders.qrc)
kwin4_add_effect(builtins ${kwin4_effect_builtins_sources})
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
)

View file

@ -2,7 +2,8 @@
# Effect
# Source files
set(kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources}
backgroundcontrast/contrast.cpp
backgroundcontrast/contrastshader.cpp
set(contrast_SOURCES
contrast.cpp
contrastshader.cpp
)
kwin4_add_effect_module(kwin4_effect_contrast ${contrast_SOURCES})

View file

@ -1,3 +1,17 @@
#######################################
# Effect
set(blur_SOURCES
blur.cpp
blurshader.cpp
)
kconfig_add_kcfg_files(blur_SOURCES
blurconfig.kcfgc
)
kwin4_add_effect_module(kwin4_effect_blur ${blur_SOURCES})
#######################################
# Config
set(kwin_blur_config_SRCS blur_config.cpp)

View file

@ -0,0 +1,8 @@
#######################################
# Effect
set(colorpicker_SOURCES
colorpicker.cpp
)
kwin4_add_effect_module(kwin4_effect_colorpicker ${colorpicker_SOURCES})

View file

@ -2,6 +2,16 @@
# Effect
install(FILES main.qml DESTINATION ${KDE_INSTALL_DATADIR}/kwin/effects/desktopgrid/)
set(desktopgrid_SOURCES
desktopgrid.cpp
)
kconfig_add_kcfg_files(desktopgrid_SOURCES
desktopgridconfig.kcfgc
)
kwin4_add_effect_module(kwin4_effect_desktopgrid ${desktopgrid_SOURCES})
#######################################
# Config
set(kwin_desktopgrid_config_SRCS desktopgrid_config.cpp)

View file

@ -1,3 +1,16 @@
#######################################
# Effect
set(diminactive_SOURCES
diminactive.cpp
)
kconfig_add_kcfg_files(diminactive_SOURCES
diminactiveconfig.kcfgc
)
kwin4_add_effect_module(kwin4_effect_diminactive ${diminactive_SOURCES})
#######################################
# Config
set(kwin_diminactive_config_SRCS diminactive_config.cpp)

View file

@ -2,6 +2,12 @@
# Effect
# Source files
set(kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources}
fallapart/fallapart.cpp
set(fallapart_SOURCES
fallapart.cpp
)
kconfig_add_kcfg_files(fallapart_SOURCES
fallapartconfig.kcfgc
)
kwin4_add_effect_module(kwin4_effect_fallapart ${fallapart_SOURCES})

View file

@ -1,3 +1,16 @@
#######################################
# Effect
set(glide_SOURCES
glide.cpp
)
kconfig_add_kcfg_files(glide_SOURCES
glideconfig.kcfgc
)
kwin4_add_effect_module(kwin4_effect_glide ${glide_SOURCES})
#######################################
# Config
set(kwin_glide_config_SRCS glide_config.cpp)

View file

@ -2,6 +2,8 @@
# Effect
# Source files
set(kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources}
highlightwindow/highlightwindow.cpp
set(highlightwindow_SOURCES
highlightwindow.cpp
)
kwin4_add_effect_module(kwin4_effect_highlightwindow ${highlightwindow_SOURCES})

View file

@ -1,6 +1,12 @@
#######################################
# Effect
set(invert_SOURCES
invert.cpp
)
kwin4_add_effect_module(kwin4_effect_invert ${invert_SOURCES})
#######################################
# Config
set(kwin_invert_config_SRCS invert_config.cpp)

View file

@ -2,9 +2,9 @@
# Effect
# Source files
set(kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources}
kscreen/kscreen.cpp
set(kscreen_SOURCES
kscreen.cpp
)
kconfig_add_kcfg_files(kwin4_effect_builtins_sources kscreen/kscreenconfig.kcfgc)
kconfig_add_kcfg_files(kscreen_SOURCES kscreenconfig.kcfgc)
kwin4_add_effect_module(kwin4_effect_kscreen ${kscreen_SOURCES})

View file

@ -1,6 +1,16 @@
#######################################
# Effect
set(lookingglass_SOURCES
lookingglass.cpp
)
kconfig_add_kcfg_files(lookingglass_SOURCES
lookingglassconfig.kcfgc
)
kwin4_add_effect_module(kwin4_effect_lookingglass ${lookingglass_SOURCES})
#######################################
# Config
set(kwin_lookingglass_config_SRCS lookingglass_config.cpp)

View file

@ -1,3 +1,16 @@
#######################################
# Effect
set(magiclamp_SOURCES
magiclamp.cpp
)
kconfig_add_kcfg_files(magiclamp_SOURCES
magiclampconfig.kcfgc
)
kwin4_add_effect_module(kwin4_effect_magiclamp ${magiclamp_SOURCES})
#######################################
# Config
set(kwin_magiclamp_config_SRCS magiclamp_config.cpp)

View file

@ -1,3 +1,16 @@
#######################################
# Effect
set(magnifier_SOURCES
magnifier.cpp
)
kconfig_add_kcfg_files(magnifier_SOURCES
magnifierconfig.kcfgc
)
kwin4_add_effect_module(kwin4_effect_magnifier ${magnifier_SOURCES})
#######################################
# Config
set(kwin_magnifier_config_SRCS magnifier_config.cpp)

View file

@ -1,5 +1,18 @@
#######################################
# Effect
set(mouseclick_SOURCES
mouseclick.cpp
)
kconfig_add_kcfg_files(mouseclick_SOURCES
mouseclickconfig.kcfgc
)
kwin4_add_effect_module(kwin4_effect_mouseclick ${mouseclick_SOURCES})
##########################
## configurtion dialog
## configurtion dialog
##########################
set(kwin_mouseclick_config_SRCS mouseclick_config.cpp)
ki18n_wrap_ui(kwin_mouseclick_config_SRCS mouseclick_config.ui)

View file

@ -1,3 +1,16 @@
#######################################
# Effect
set(mousemark_SOURCES
mousemark.cpp
)
kconfig_add_kcfg_files(mousemark_SOURCES
mousemarkconfig.kcfgc
)
kwin4_add_effect_module(kwin4_effect_mousemark ${mousemark_SOURCES})
#######################################
# Config
set(kwin_mousemark_config_SRCS mousemark_config.cpp)

View file

@ -4,4 +4,16 @@
add_subdirectory(kcm)
set(overview_SOURCES
expoarea.cpp
expolayout.cpp
overvieweffect.cpp
)
kconfig_add_kcfg_files(overview_SOURCES
overviewconfig.kcfgc
)
kwin4_add_effect_module(kwin4_effect_overview ${overview_SOURCES})
install(DIRECTORY qml DESTINATION ${KDE_INSTALL_DATADIR}/kwin/effects/overview)

View file

@ -2,6 +2,17 @@
# Effect
install(FILES main.qml DESTINATION ${KDE_INSTALL_DATADIR}/kwin/effects/presentwindows/)
set(presentwindows_SOURCES
presentwindows.cpp
presentwindows_proxy.cpp
)
kconfig_add_kcfg_files(presentwindows_SOURCES
presentwindowsconfig.kcfgc
)
kwin4_add_effect_module(kwin4_effect_presentwindows ${presentwindows_SOURCES})
#######################################
# Config
set(kwin_presentwindows_config_SRCS presentwindows_config.cpp)

View file

@ -1,3 +1,16 @@
#######################################
# Effect
set(resize_SOURCES
resize.cpp
)
kconfig_add_kcfg_files(resize_SOURCES
resizeconfig.kcfgc
)
kwin4_add_effect_module(kwin4_effect_resize ${resize_SOURCES})
#######################################
# Config
set(kwin_resize_config_SRCS resize_config.cpp)

View file

@ -2,6 +2,8 @@
# Effect
# Source files
set(kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources}
screenedge/screenedgeeffect.cpp
set(screenedge_SOURCES
screenedgeeffect.cpp
)
kwin4_add_effect_module(kwin4_effect_screenedge ${screenedge_SOURCES})

View file

@ -2,11 +2,12 @@
# Effect
# Source files
set(kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources}
../service_utils.cpp
screenshot/screenshot.cpp
screenshot/screenshotdbusinterface1.cpp
screenshot/screenshotdbusinterface2.cpp
set(screenshot_SOURCES
screenshot.cpp
screenshotdbusinterface1.cpp
screenshotdbusinterface2.cpp
)
qt_add_dbus_adaptor(kwin4_effect_builtins_sources screenshot/org.kde.KWin.ScreenShot2.xml screenshot/screenshotdbusinterface2.h KWin::ScreenShotDBusInterface2)
qt_add_dbus_adaptor(screenshot_SOURCES org.kde.KWin.ScreenShot2.xml screenshotdbusinterface2.h KWin::ScreenShotDBusInterface2)
kwin4_add_effect_module(kwin4_effect_screenshot ${screenshot_SOURCES})

View file

@ -1,7 +1,8 @@
#######################################
# Effect
set(kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources}
screentransform/screentransform.cpp
set(screentransform_SOURCES
screentransform.cpp
)
kwin4_add_effect_module(kwin4_effect_screentransform ${screentransform_SOURCES})

View file

@ -8,7 +8,7 @@
*/
// own
#include "screentransform.h"
#include "kscreenconfig.h"
#include "../kscreen/kscreenconfig.h"
#include "kwinglutils.h"
#include <QDebug>

View file

@ -2,7 +2,9 @@
# Effect
# Source files
set(kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources}
sheet/sheet.cpp
set(sheet_SOURCES
sheet.cpp
)
kconfig_add_kcfg_files(kwin4_effect_builtins_sources sheet/sheetconfig.kcfgc)
kconfig_add_kcfg_files(sheet_SOURCES sheetconfig.kcfgc)
kwin4_add_effect_module(kwin4_effect_sheet ${sheet_SOURCES})

View file

@ -1,3 +1,16 @@
#######################################
# Effect
set(showfps_SOURCES
showfps.cpp
)
kconfig_add_kcfg_files(showfps_SOURCES
showfpsconfig.kcfgc
)
kwin4_add_effect_module(kwin4_effect_showfps ${showfps_SOURCES})
#######################################
# Config
set(kwin_showfps_config_SRCS showfps_config.cpp)

View file

@ -1,5 +1,13 @@
#######################################
# Effect
set(showpaint_SOURCES
showpaint.cpp
)
kwin4_add_effect_module(kwin4_effect_showpaint ${showpaint_SOURCES})
#######################################
# Config
set(kwin_showpaint_config_SRCS showpaint_config.cpp)
ki18n_wrap_ui(kwin_showpaint_config_SRCS showpaint_config.ui)

View file

@ -1,3 +1,16 @@
#######################################
# Effect
set(slide_SOURCES
slide.cpp
)
kconfig_add_kcfg_files(slide_SOURCES
slideconfig.kcfgc
)
kwin4_add_effect_module(kwin4_effect_slide ${slide_SOURCES})
#######################################
# Config
set(kwin_slide_config_SRCS slide_config.cpp)

View file

@ -2,6 +2,8 @@
# Effect
# Source files
set(kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources}
slideback/slideback.cpp
set(slideback_SOURCES
slideback.cpp
)
kwin4_add_effect_module(kwin4_effect_slideback ${slideback_SOURCES})

View file

@ -2,6 +2,12 @@
# Effect
# Source files
set(kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources}
slidingpopups/slidingpopups.cpp
set(slidingpopups_SOURCES
slidingpopups.cpp
)
kconfig_add_kcfg_files(slidingpopups_SOURCES
slidingpopupsconfig.kcfgc
)
kwin4_add_effect_module(kwin4_effect_slidingpopups ${slidingpopups_SOURCES})

View file

@ -2,6 +2,8 @@
# Effect
# Source files
set(kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources}
snaphelper/snaphelper.cpp
set(snaphelper_SOURCES
snaphelper.cpp
)
kwin4_add_effect_module(kwin4_effect_snaphelper ${snaphelper_SOURCES})

View file

@ -2,6 +2,8 @@
# Effect
# Source files
set(kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources}
startupfeedback/startupfeedback.cpp
set(startupfeedback_SOURCES
startupfeedback.cpp
)
kwin4_add_effect_module(kwin4_effect_startupfeedback ${startupfeedback_SOURCES})

View file

@ -1,3 +1,16 @@
#######################################
# Effect
set(thumbnailaside_SOURCES
thumbnailaside.cpp
)
kconfig_add_kcfg_files(thumbnailaside_SOURCES
thumbnailasideconfig.kcfgc
)
kwin4_add_effect_module(kwin4_effect_thumbnailaside ${thumbnailaside_SOURCES})
#######################################
# Config
set(kwin_thumbnailaside_config_SRCS thumbnailaside_config.cpp)

View file

@ -0,0 +1,8 @@
#######################################
# Effect
set(touchpoints_SOURCES
touchpoints.cpp
)
kwin4_add_effect_module(kwin4_effect_touchpoints ${touchpoints_SOURCES})

View file

@ -3,6 +3,16 @@
# Data files
install(FILES data/tm_inner.png data/tm_outer.png DESTINATION ${KDE_INSTALL_DATADIR}/kwin)
set(trackmouse_SOURCES
trackmouse.cpp
)
kconfig_add_kcfg_files(trackmouse_SOURCES
trackmouseconfig.kcfgc
)
kwin4_add_effect_module(kwin4_effect_trackmouse ${trackmouse_SOURCES})
#######################################
# Config
set(kwin_trackmouse_config_SRCS trackmouse_config.cpp)

View file

@ -1,3 +1,16 @@
#######################################
# Effect
set(windowgeometry_SOURCES
windowgeometry.cpp
)
kconfig_add_kcfg_files(windowgeometry_SOURCES
windowgeometryconfig.kcfgc
)
kwin4_add_effect_module(kwin4_effect_windowgeometry ${windowgeometry_SOURCES})
#######################################
# Config
set(kwin_windowgeometry_config_SRCS windowgeometry_config.cpp)

View file

@ -1,3 +1,16 @@
#######################################
# Effect
set(wobblywindows_SOURCES
wobblywindows.cpp
)
kconfig_add_kcfg_files(wobblywindows_SOURCES
wobblywindowsconfig.kcfgc
)
kwin4_add_effect_module(kwin4_effect_wobblywindows ${wobblywindows_SOURCES})
#######################################
# Config
set(kwin_wobblywindows_config_SRCS wobblywindows_config.cpp)

View file

@ -1,3 +1,22 @@
#######################################
# Effect
set(zoom_SOURCES
zoom.cpp
)
if (HAVE_ACCESSIBILITY)
set(zoom_SOURCES ${zoom_SOURCES}
zoom/accessibilityintegration.cpp
)
endif()
kconfig_add_kcfg_files(zoom_SOURCES
zoomconfig.kcfgc
)
kwin4_add_effect_module(kwin4_effect_zoom ${zoom_SOURCES})
#######################################
# Config
set(kwin_zoom_config_SRCS zoom_config.cpp)