From 2ace94d3c887cbf79767acc68ffe370f766f86bf Mon Sep 17 00:00:00 2001 From: Rivo Laks Date: Mon, 28 May 2007 11:12:20 +0000 Subject: [PATCH] Move all .desktop files of effects to $SERVICES_DIR/kwin and use ksycoca to e.g. get list of available effects. As effect's full internal name is used when looking up the effect, you now need to provide the full name (e.g. kwin4_effect_blur instead of just blur) when loading effects via dcop. svn path=/trunk/KDE/kdebase/workspace/; revision=669032 --- effects.cpp | 26 +++++++++++++++----------- effects/CMakeLists.txt | 16 +++++++++------- kcmkwin/kwineffects/main.cpp | 6 +++--- 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/effects.cpp b/effects.cpp index c4089112ef..a7b6f7025a 100644 --- a/effects.cpp +++ b/effects.cpp @@ -25,6 +25,9 @@ License. See the file "COPYING" for the exact licensing terms. #include "kdesktopfile.h" #include "kconfiggroup.h" #include "kstandarddirs.h" +#include +#include +#include #include @@ -37,8 +40,6 @@ EffectsHandlerImpl::EffectsHandlerImpl(CompositingType type) : EffectsHandler(type) , keyboard_grab_effect( NULL ) { - foreach( const QString& effect, options->defaultEffects ) - loadEffect( effect ); } EffectsHandlerImpl::~EffectsHandlerImpl() @@ -571,17 +572,17 @@ unsigned long EffectsHandlerImpl::xrenderBufferPicture() KLibrary* EffectsHandlerImpl::findEffectLibrary( const QString& effectname ) { - QString libname = "kwin4_effect_" + effectname.toLower(); + QString internalname = effectname.toLower(); - QString desktopfile = KStandardDirs::locate("appdata", - "effects/" + effectname.toLower() + ".desktop"); - if( !desktopfile.isEmpty() ) - { - KDesktopFile desktopconf( desktopfile ); - KConfigGroup conf = desktopconf.desktopGroup(); - libname = conf.readEntry( "X-KDE-Library", libname ); - } + QString constraint = QString("[X-KDE-PluginInfo-Name] == '%1'").arg(internalname); + KService::List offers = KServiceTypeTrader::self()->query("KWin/Effect", constraint); + if(offers.isEmpty()) + { + kError( 1212 ) << k_funcinfo << "Couldn't find effect " << effectname << endl; + return 0; + } + QString libname = offers.first()->library(); KLibrary* library = KLibLoader::self()->library(libname); if( !library ) { @@ -620,6 +621,9 @@ void EffectsHandlerImpl::loadEffect( const QString& name ) assert( current_draw_window == 0 ); assert( current_transform == 0 ); + if( !name.startsWith("kwin4_effect_") ) + kWarning( 1212 ) << k_funcinfo << "Effect names usually have kwin4_effect_ prefix" << endl; + // Make sure a single effect won't be loaded multiple times for(QVector< EffectPair >::const_iterator it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); it++) { diff --git a/effects/CMakeLists.txt b/effects/CMakeLists.txt index a8dc94eef5..74cf672c47 100644 --- a/effects/CMakeLists.txt +++ b/effects/CMakeLists.txt @@ -1,6 +1,6 @@ # Adds effect plugin with given name. Sources are given after the name macro(KWIN4_ADD_EFFECT name) - kde4_automoc(kwin4_effect_${name} ${ARGN}) + kde4_automoc(${ARGN}) kde4_add_plugin(kwin4_effect_${name} ${ARGN}) target_link_libraries(kwin4_effect_${name} kwineffects ${KDE4_KDEUI_LIBS}) install(TARGETS kwin4_effect_${name} DESTINATION ${PLUGIN_INSTALL_DIR}) @@ -10,6 +10,8 @@ include_directories( ${CMAKE_SOURCE_DIR}/workspace/kwin/lib ) +install( FILES kwineffect.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR}) + ### builtins - most important, ready-to-use effects @@ -44,7 +46,7 @@ install( FILES scalein.desktop thumbnailaside.desktop zoom.desktop - DESTINATION ${DATA_INSTALL_DIR}/kwin/effects ) + DESTINATION ${SERVICES_INSTALL_DIR}/kwin ) if(OPENGL_FOUND) # opengl-based effects @@ -63,7 +65,7 @@ if(OPENGL_FOUND) mousemark.desktop shadow.desktop trackmouse.desktop - DESTINATION ${DATA_INSTALL_DIR}/kwin/effects ) + DESTINATION ${SERVICES_INSTALL_DIR}/kwin ) install( FILES data/trackmouse.png data/explosion.frag @@ -84,7 +86,7 @@ if( OPENGL_FOUND AND X11_Xrender_FOUND ) ) install( FILES showfps.desktop - DESTINATION ${DATA_INSTALL_DIR}/kwin/effects ) + DESTINATION ${SERVICES_INSTALL_DIR}/kwin ) endif( OPENGL_FOUND AND X11_Xrender_FOUND ) # add the plugin @@ -115,7 +117,7 @@ install( FILES shakymove.desktop test_input.desktop test_thumbnail.desktop - DESTINATION ${DATA_INSTALL_DIR}/kwin/effects ) + DESTINATION ${SERVICES_INSTALL_DIR}/kwin ) if(OPENGL_FOUND) # opengl test/demo stuff @@ -131,7 +133,7 @@ if(OPENGL_FOUND) demo_showpicture.desktop test_fbo.desktop wavywindows.desktop - DESTINATION ${DATA_INSTALL_DIR}/kwin/effects ) + DESTINATION ${SERVICES_INSTALL_DIR}/kwin ) install( FILES data/liquid.frag @@ -154,6 +156,6 @@ macro_bool_to_01( CAPTURY_FOUND HAVE_CAPTURY ) if( HAVE_CAPTURY ) KWIN4_ADD_EFFECT(videorecord videorecord.cpp) target_link_libraries(kwin4_effect_videorecord ${CAPTURY_LDFLAGS}) - install( FILES videorecord.desktop DESTINATION ${DATA_INSTALL_DIR}/kwin/effects ) + install( FILES videorecord.desktop DESTINATION ${SERVICES_INSTALL_DIR}/kwin ) endif( HAVE_CAPTURY ) diff --git a/kcmkwin/kwineffects/main.cpp b/kcmkwin/kwineffects/main.cpp index de43917e9a..1517d9eb6d 100644 --- a/kcmkwin/kwineffects/main.cpp +++ b/kcmkwin/kwineffects/main.cpp @@ -12,12 +12,12 @@ License. See the file "COPYING" for the exact licensing terms. #include #include -#include #include #include #include #include #include +#include #include #include @@ -46,8 +46,8 @@ KWinEffectsConfig::KWinEffectsConfig(QWidget *parent, const QStringList &) connect(mPluginSelector, SIGNAL(changed(bool)), this, SLOT(changed())); // Find all .desktop files of the effects - QStringList desktopFiles = KGlobal::dirs()->findAllResources("data", "kwin/effects/*.desktop"); - QList effectinfos = KPluginInfo::fromFiles(desktopFiles); + KService::List offers = KServiceTypeTrader::self()->query("KWin/Effect"); + QList effectinfos = KPluginInfo::fromServices(offers); // Add them to the plugin selector mPluginSelector->addPlugins(effectinfos, i18n("Appearance"), "Appearance", mKWinConfig);