diff --git a/composite.cpp b/composite.cpp index 63b0735277..1eab396afa 100644 --- a/composite.cpp +++ b/composite.cpp @@ -63,6 +63,16 @@ namespace KWin extern int currentRefreshRate(); +CompositorSelectionOwner::CompositorSelectionOwner(const char *selection) : KSelectionOwner(selection), owning(false) +{ + connect (this, SIGNAL(lostOwnership()), SLOT(looseOwnership())); +} + +void CompositorSelectionOwner::looseOwnership() +{ + owning = false; +} + KWIN_SINGLETON_FACTORY_VARIABLE(Compositor, s_compositor) Compositor::Compositor(QObject* workspace) @@ -148,11 +158,13 @@ void Compositor::slotCompositingOptionsInitialized() char selection_name[ 100 ]; sprintf(selection_name, "_NET_WM_CM_S%d", DefaultScreen(display())); if (!cm_selection) { - cm_selection = new KSelectionOwner(selection_name); + cm_selection = new CompositorSelectionOwner(selection_name); connect(cm_selection, SIGNAL(lostOwnership()), SLOT(finish())); } - cm_selection->claim(true); // force claiming - + if (!cm_selection->owning) { + cm_selection->claim(true); // force claiming + cm_selection->owning = true; + } switch(options->compositingMode()) { case OpenGLCompositing: { kDebug(1212) << "Initializing OpenGL compositing"; @@ -199,6 +211,7 @@ void Compositor::slotCompositingOptionsInitialized() default: kDebug(1212) << "No compositing enabled"; m_starting = false; + cm_selection->owning = false; cm_selection->release(); return; } @@ -208,6 +221,7 @@ void Compositor::slotCompositingOptionsInitialized() delete m_scene; m_scene = NULL; m_starting = false; + cm_selection->owning = false; cm_selection->release(); return; } @@ -316,6 +330,7 @@ void Compositor::releaseCompositorSelection() return; } kDebug(1212) << "Releasing compositor selection"; + cm_selection->owning = false; cm_selection->release(); } diff --git a/composite.h b/composite.h index 2479eaa493..c920e88d57 100644 --- a/composite.h +++ b/composite.h @@ -23,6 +23,8 @@ along with this program. If not, see . #define KWIN_COMPOSITE_H // KWin #include +// KDE +#include // Qt #include #include @@ -30,13 +32,23 @@ along with this program. If not, see . #include #include -class KSelectionOwner; - namespace KWin { class Client; class Scene; +class CompositorSelectionOwner : public KSelectionOwner +{ + Q_OBJECT +public: + CompositorSelectionOwner(const char *selection); +private: + friend class Compositor; + bool owning; +private slots: + void looseOwnership(); +}; + class Compositor : public QObject { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.kde.kwin.Compositing") @@ -275,7 +287,7 @@ private: SuspendReasons m_suspended; QBasicTimer compositeTimer; - KSelectionOwner* cm_selection; + CompositorSelectionOwner* cm_selection; QTimer m_releaseSelectionTimer; uint vBlankInterval, fpsInterval; int m_xrrRefreshRate;