diff --git a/effects.cpp b/effects.cpp
index e0ebb6a755..b39d2a6661 100644
--- a/effects.cpp
+++ b/effects.cpp
@@ -355,6 +355,18 @@ void EffectsHandlerImpl::grabbedKeyboardEvent( QKeyEvent* e )
keyboard_grab_effect->grabbedKeyboardEvent( e );
}
+const void* EffectsHandlerImpl::getProxy( QString name )
+ {
+ // All effects start with "kwin4_effect_", prepend it to the name
+ name.prepend( "kwin4_effect_" );
+
+ for( QVector< EffectPair >::iterator it = loaded_effects.begin(); it != loaded_effects.end(); ++it)
+ if ( (*it).first == name )
+ return (*it).second->proxy();
+
+ return NULL;
+ }
+
void EffectsHandlerImpl::startMousePolling()
{
if( !mouse_poll_ref_count ) // Start timer if required
diff --git a/effects.h b/effects.h
index 4bd7412976..e78eb7057e 100644
--- a/effects.h
+++ b/effects.h
@@ -65,6 +65,7 @@ class EffectsHandlerImpl : public EffectsHandler
virtual QPoint cursorPos() const;
virtual bool grabKeyboard( Effect* effect );
virtual void ungrabKeyboard();
+ virtual const void* getProxy( QString name );
virtual void startMousePolling();
virtual void stopMousePolling();
virtual EffectWindow* findWindow( WId id ) const;
diff --git a/effects/desktopgrid/desktopgrid.cpp b/effects/desktopgrid/desktopgrid.cpp
index 25b6a57ba9..15ea3aaef0 100644
--- a/effects/desktopgrid/desktopgrid.cpp
+++ b/effects/desktopgrid/desktopgrid.cpp
@@ -21,6 +21,8 @@ along with this program. If not, see .
#include "desktopgrid.h"
+#include "../presentwindows/presentwindows_proxy.h"
+
#include
#include
@@ -712,6 +714,15 @@ void DesktopGridEffect::setActive( bool active )
if( activated == active )
return; // Already in that state
+ // Example proxy code, TODO: Use or remove
+ //const PresentWindowsEffectProxy* proxy =
+ // static_cast( effects->getProxy( "presentwindows" ));
+ //if( proxy )
+ // kDebug() << "Retrieved PresentWindowsEffectProxy, is present windows activate?"
+ // << proxy->isActive();
+ //else
+ // kDebug() << "Failed to retrieve PresentWindowsEffectProxy. Maybe present windows isn't enabled?";
+
activated = active;
if( activated && timeline.value() == 0 )
setup();
diff --git a/effects/presentwindows/CMakeLists.txt b/effects/presentwindows/CMakeLists.txt
index 9b015f44bb..964b0fe333 100644
--- a/effects/presentwindows/CMakeLists.txt
+++ b/effects/presentwindows/CMakeLists.txt
@@ -4,6 +4,7 @@
# Source files
set( kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources}
presentwindows/presentwindows.cpp
+ presentwindows/presentwindows_proxy.cpp
)
# .desktop files
diff --git a/effects/presentwindows/presentwindows.cpp b/effects/presentwindows/presentwindows.cpp
index c47c851150..cb653d6985 100644
--- a/effects/presentwindows/presentwindows.cpp
+++ b/effects/presentwindows/presentwindows.cpp
@@ -41,7 +41,8 @@ namespace KWin
KWIN_EFFECT( presentwindows, PresentWindowsEffect )
PresentWindowsEffect::PresentWindowsEffect()
- : m_borderActivate( ElectricNone )
+ : m_proxy( this )
+ , m_borderActivate( ElectricNone )
, m_borderActivateAll( ElectricNone )
, m_activated( false )
, m_allDesktops( false )
@@ -100,6 +101,11 @@ void PresentWindowsEffect::reconfigure( ReconfigureFlags )
m_showPanel = conf.readEntry( "ShowPanel", false );
}
+const void* PresentWindowsEffect::proxy() const
+ {
+ return &m_proxy;
+ }
+
//-----------------------------------------------------------------------------
// Screen painting
diff --git a/effects/presentwindows/presentwindows.h b/effects/presentwindows/presentwindows.h
index 34bd16ffdb..19a9db5eac 100644
--- a/effects/presentwindows/presentwindows.h
+++ b/effects/presentwindows/presentwindows.h
@@ -22,6 +22,8 @@ along with this program. If not, see .
#ifndef KWIN_PRESENTWINDOWS_H
#define KWIN_PRESENTWINDOWS_H
+#include "presentwindows_proxy.h"
+
// Include with base class for effects.
#include
#include
@@ -69,6 +71,8 @@ class PresentWindowsEffect
virtual ~PresentWindowsEffect();
virtual void reconfigure( ReconfigureFlags );
+ virtual const void* proxy() const;
+
// Screen painting
virtual void prePaintScreen( ScreenPrePaintData &data, int time );
virtual void paintScreen( int mask, QRegion region, ScreenPaintData &data );
@@ -129,6 +133,9 @@ class PresentWindowsEffect
void paintWindowIcon( EffectWindow *w, WindowPaintData &data ); // TODO: Do we need this?
private:
+ PresentWindowsEffectProxy m_proxy;
+ friend class PresentWindowsEffectProxy;
+
// User configuration settings
ElectricBorder m_borderActivate;
ElectricBorder m_borderActivateAll;
diff --git a/effects/presentwindows/presentwindows_proxy.cpp b/effects/presentwindows/presentwindows_proxy.cpp
new file mode 100644
index 0000000000..adbceda74b
--- /dev/null
+++ b/effects/presentwindows/presentwindows_proxy.cpp
@@ -0,0 +1,41 @@
+/********************************************************************
+ KWin - the KDE window manager
+ This file is part of the KDE project.
+
+Copyright (C) 2009 Lucas Murray
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see .
+*********************************************************************/
+
+#include "presentwindows_proxy.h"
+#include "presentwindows.h"
+
+namespace KWin
+{
+
+PresentWindowsEffectProxy::PresentWindowsEffectProxy( PresentWindowsEffect* effect )
+ : m_effect( effect )
+ {
+ }
+
+PresentWindowsEffectProxy::~PresentWindowsEffectProxy()
+ {
+ }
+
+bool PresentWindowsEffectProxy::isActive() const
+ {
+ return m_effect->m_activated;
+ }
+
+} // namespace
diff --git a/effects/presentwindows/presentwindows_proxy.h b/effects/presentwindows/presentwindows_proxy.h
new file mode 100644
index 0000000000..8ee56a764e
--- /dev/null
+++ b/effects/presentwindows/presentwindows_proxy.h
@@ -0,0 +1,44 @@
+/********************************************************************
+ KWin - the KDE window manager
+ This file is part of the KDE project.
+
+Copyright (C) 2009 Lucas Murray
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see .
+*********************************************************************/
+
+#ifndef KWIN_PRESENTWINDOWS_PROXY_H
+#define KWIN_PRESENTWINDOWS_PROXY_H
+
+namespace KWin
+{
+
+class PresentWindowsEffect;
+
+// Example proxy code, TODO: Use or remove
+class PresentWindowsEffectProxy
+ {
+ public:
+ PresentWindowsEffectProxy( PresentWindowsEffect* effect );
+ ~PresentWindowsEffectProxy();
+
+ bool isActive() const;
+
+ private:
+ PresentWindowsEffect* m_effect;
+ };
+
+} // namespace
+
+#endif
diff --git a/lib/kwineffects.cpp b/lib/kwineffects.cpp
index 342cdbf744..72300adade 100644
--- a/lib/kwineffects.cpp
+++ b/lib/kwineffects.cpp
@@ -112,6 +112,11 @@ void Effect::reconfigure( ReconfigureFlags )
{
}
+const void* Effect::proxy() const
+ {
+ return NULL;
+ }
+
void Effect::windowUserMovedResized( EffectWindow* , bool, bool )
{
}
diff --git a/lib/kwineffects.h b/lib/kwineffects.h
index b8ccf88cd5..206a618df4 100644
--- a/lib/kwineffects.h
+++ b/lib/kwineffects.h
@@ -296,6 +296,11 @@ class KWIN_EXPORT Effect
*/
virtual void reconfigure( ReconfigureFlags flags );
+ /**
+ * Called when another effect requests the proxy for this effect.
+ */
+ virtual const void* proxy() const;
+
/**
* Called before starting to paint the screen.
* In this method you can:
@@ -522,6 +527,12 @@ class KWIN_EXPORT EffectsHandler
virtual bool grabKeyboard( Effect* effect ) = 0;
virtual void ungrabKeyboard() = 0;
+ /**
+ * Retrieve the proxy class for an effect if it has one. Will return NULL if
+ * the effect isn't loaded or doesn't have a proxy class.
+ */
+ virtual const void* getProxy( QString name ) = 0;
+
// Mouse polling
virtual void startMousePolling() = 0;
virtual void stopMousePolling() = 0;