add deco API versioning support

REVIEW: 104978
BUG: 299141
FIXED-IN: 4.9
This commit is contained in:
Thomas Lübking 2012-05-17 23:25:22 +02:00
parent 36932d3f2e
commit e2553bd842
8 changed files with 47 additions and 13 deletions

View file

@ -434,6 +434,9 @@ extern "C"
KDE_EXPORT KDecorationFactory *create_factory() {
return Aurorae::AuroraeFactory::instance();
}
KWIN_EXPORT int decoration_version() {
return KWIN_DECORATION_API_VERSION;
}
}

View file

@ -119,10 +119,7 @@ static bool drawSmallBorders = false;
// =====================================
extern "C" KDE_EXPORT KDecorationFactory* create_factory()
{
return new B2::B2ClientFactory();
}
KWIN_DECORATION(B2::B2ClientFactory)
// =====================================

View file

@ -78,10 +78,8 @@ static bool pixmaps_created = false;
// =====================================
extern "C" KDE_EXPORT KDecorationFactory* create_factory()
{
return new Laptop::LaptopClientFactory();
}
KWIN_DECORATION(Laptop::LaptopClientFactory)
// =====================================

View file

@ -35,11 +35,7 @@
#include <KWindowInfo>
#include <kdeversion.h>
extern "C"
{
KDE_EXPORT KDecorationFactory* create_factory()
{ return new Oxygen::Factory(); }
}
KWIN_DECORATION(Oxygen::Factory)
namespace Oxygen
{

View file

@ -552,6 +552,8 @@ PlastikHandler* Handler()
// Plugin Stuff //
//////////////////////////////////////////////////////////////////////////////
// KWIN_DECORATION(KWinPlastik::PlastikHandler)
extern "C"
{
KDE_EXPORT KDecorationFactory *create_factory()
@ -559,4 +561,8 @@ extern "C"
KWinPlastik::handler = new KWinPlastik::PlastikHandler();
return KWinPlastik::handler;
}
KWIN_EXPORT int decoration_version() {
return KWIN_DECORATION_API_VERSION;
}
}

View file

@ -34,6 +34,19 @@ DEALINGS IN THE SOFTWARE.
#define KWIN_EXPORT KDE_EXPORT
#define KWIN_DECORATION_API_VERSION 1
/**
* Defines the class to be used for decoration factory.
* The class must be namespace complete.
* E.g. KWIN_EFFECT( Oxygen::Factory )
**/
#define KWIN_DECORATION( classname ) \
extern "C" { \
KWIN_EXPORT KDecorationFactory* create_factory() { return new classname(); } \
KWIN_EXPORT int decoration_version() { return KWIN_DECORATION_API_VERSION; } \
}
class KConfig;
/** @defgroup kdecoration KWin decorations library */

View file

@ -157,6 +157,25 @@ trydefaultlib:
}
create_ptr = NULL;
version_ptr = 0;
KLibrary::void_function_ptr version_func = library->resolveFunction("decoration_version");
if (version_func) {
// TODO for the moment we let unversioned decos through
// later on this function shall become mandatory!
version_ptr = (int(*)())version_func;
const int deco_version = version_ptr();
if (deco_version != KWIN_DECORATION_API_VERSION) {
if (nameStr != defaultPlugin) {
kWarning(1212) << i18n("The library %1 has wrong API version %2", path, deco_version);
library->unload();
library = NULL;
goto trydefaultlib;
}
}
} else {
kWarning(1212) << i18n("******\n\nThe library %1 has no API version\nPlease use the KWIN_DECORATION or future versions of kwin will no longer load this decoration!\n*******", path);
}
KLibrary::void_function_ptr create_func = library->resolveFunction("create_factory");
if (create_func)
create_ptr = (KDecorationFactory * (*)())create_func;

View file

@ -59,6 +59,7 @@ protected:
QString defaultPlugin; // FRAME normalne protected?
private:
KDecorationFactory*(*create_ptr)();
int (*version_ptr)();
KLibrary *library;
KDecorationFactory* fact;
KLibrary *old_library;
@ -71,6 +72,7 @@ private:
Plugins API:
KDecorationFactory* create_factory(); - called once after loading
int decoration_version(); - called once after loading
*/