diff --git a/COMPOSITE_TODO b/COMPOSITE_TODO
index 811f7398e6..45ca357909 100644
--- a/COMPOSITE_TODO
+++ b/COMPOSITE_TODO
@@ -71,8 +71,6 @@ KDE 4.0 TODO
- disable application effects when kwin can provide them, e.g. shadow/transparency
-- since API won't be stable, a version check for modules is needed
-
- Plasma taskbar doesn't set icon geometry
- Plasma pager doesn't set desktop layout
diff --git a/effects.cpp b/effects.cpp
index 53c9327613..1231a14d60 100644
--- a/effects.cpp
+++ b/effects.cpp
@@ -723,6 +723,22 @@ bool EffectsHandlerImpl::loadEffect( const QString& name )
return false;
}
+ QString version_symbol = "effect_version_" + name;
+ KLibrary::void_function_ptr version_func = library->resolveFunction(version_symbol.toAscii());
+ if( version_func == NULL )
+ {
+ kWarning( 1212 ) << "Effect " << name << " does not provide required API version, ignoring.";
+ return false;
+ }
+ typedef int (*t_versionfunc)();
+ int version = reinterpret_cast< t_versionfunc >( version_func )(); // call it
+ // version must be the same or less, but major must be the same
+ if( version > KWIN_EFFECT_API_VERSION
+ || ( version >> 8 ) != KWIN_EFFECT_API_VERSION_MAJOR )
+ {
+ kWarning( 1212 ) << "Effect " << name << " requires unsupported API version " << version;
+ return false;
+ }
QString supported_symbol = "effect_supported_" + name;
KLibrary::void_function_ptr supported_func = library->resolveFunction(supported_symbol.toAscii().data());
QString create_symbol = "effect_create_" + name;
diff --git a/lib/kwineffects.h b/lib/kwineffects.h
index 165c166cfe..a8a718164c 100644
--- a/lib/kwineffects.h
+++ b/lib/kwineffects.h
@@ -39,7 +39,11 @@ along with this program. If not, see .
#include
-#define KWIN_EFFECT_API_VERSION 0x000100
+#define KWIN_EFFECT_API_MAKE_VERSION( major, minor ) (( major ) << 8 | ( minor ))
+#define KWIN_EFFECT_API_VERSION_MAJOR 0
+#define KWIN_EFFECT_API_VERSION_MINOR 1
+#define KWIN_EFFECT_API_VERSION KWIN_EFFECT_API_MAKE_VERSION( \
+ KWIN_EFFECT_API_VERSION_MAJOR, KWIN_EFFECT_API_VERSION_MINOR )
class KLibrary;
class KConfigGroup;
@@ -283,6 +287,7 @@ class KWIN_EXPORT Effect
#define KWIN_EFFECT( name, classname ) \
extern "C" { \
KWIN_EXPORT Effect* effect_create_kwin4_effect_##name() { return new classname; } \
+ KWIN_EXPORT int effect_version_kwin4_effect_##name() { return KWIN_EFFECT_API_VERSION; } \
}
/**
* Defines the function used to check whether an effect is supported