From 88d50727ee0616308e1f645b5faad169423c00cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Sat, 12 Mar 2011 15:04:22 +0100 Subject: [PATCH] WindowDamaged becomes a signal --- composite.cpp | 4 ++-- effects.cpp | 9 ++++----- effects.h | 2 +- effects/boxswitch/boxswitch.cpp | 3 ++- effects/boxswitch/boxswitch.h | 2 +- effects/taskbarthumbnail/taskbarthumbnail.cpp | 3 ++- effects/taskbarthumbnail/taskbarthumbnail.h | 2 +- effects/thumbnailaside/thumbnailaside.cpp | 3 ++- effects/thumbnailaside/thumbnailaside.h | 2 +- libkwineffects/kwineffects.cpp | 4 ---- libkwineffects/kwineffects.h | 9 ++++++++- toplevel.h | 1 + 12 files changed, 25 insertions(+), 19 deletions(-) diff --git a/composite.cpp b/composite.cpp index 9d16f68bd3..e6fb408099 100644 --- a/composite.cpp +++ b/composite.cpp @@ -825,7 +825,7 @@ void Toplevel::addDamage(int x, int y, int w, int h) r &= rect(); damage_region += r; repaints_region += r; - static_cast(effects)->windowDamaged(effectWindow(), r); + emit damaged(this, r); // discard lanczos texture if (effect_window) { QVariant cachedTextureVariant = effect_window->data(LanczosCacheRole); @@ -845,7 +845,7 @@ void Toplevel::addDamageFull() return; damage_region = rect(); repaints_region = rect(); - static_cast(effects)->windowDamaged(effectWindow(), rect()); + emit damaged(this, rect()); // discard lanczos texture if (effect_window) { QVariant cachedTextureVariant = effect_window->data(LanczosCacheRole); diff --git a/effects.cpp b/effects.cpp index 8b2cd04c39..254a90d460 100644 --- a/effects.cpp +++ b/effects.cpp @@ -137,6 +137,7 @@ void EffectsHandlerImpl::setupClientConnections(Client* c) connect(c, SIGNAL(clientMinimized(KWin::Client*,bool)), this, SLOT(slotClientMinimized(KWin::Client*,bool))); connect(c, SIGNAL(clientUnminimized(KWin::Client*,bool)), this, SLOT(slotClientUnminimized(KWin::Client*,bool))); connect(c, SIGNAL(clientGeometryShapeChanged(KWin::Client*,QRect)), this, SLOT(slotClientGeometryShapeChanged(KWin::Client*,QRect))); + connect(c, SIGNAL(damaged(KWin::Toplevel*,QRect)), this, SLOT(slotWindowDamaged(KWin::Toplevel*,QRect))); } void EffectsHandlerImpl::setupUnmanagedConnections(Unmanaged* u) @@ -144,6 +145,7 @@ void EffectsHandlerImpl::setupUnmanagedConnections(Unmanaged* u) connect(u, SIGNAL(unmanagedClosed(KWin::Unmanaged*)), this, SLOT(slotUnmanagedClosed(KWin::Unmanaged*))); connect(u, SIGNAL(opacityChanged(KWin::Toplevel*,qreal)), this, SLOT(slotOpacityChanged(KWin::Toplevel*,qreal))); connect(u, SIGNAL(unmanagedGeometryShapeChanged(KWin::Unmanaged*,QRect)), this, SLOT(slotUnmanagedGeometryShapeChanged(KWin::Unmanaged*,QRect))); + connect(u, SIGNAL(damaged(KWin::Toplevel*,QRect)), this, SLOT(slotWindowDamaged(KWin::Toplevel*,QRect))); } void EffectsHandlerImpl::reconfigure() @@ -391,12 +393,9 @@ void EffectsHandlerImpl::slotDesktopChanged(int old) } } -void EffectsHandlerImpl::windowDamaged(EffectWindow* w, const QRect& r) +void EffectsHandlerImpl::slotWindowDamaged(Toplevel* t, const QRect& r) { - if (w == NULL) - return; - foreach (const EffectPair & ep, loaded_effects) - ep.second->windowDamaged(w, r); + emit windowDamaged(t->effectWindow(), r); } void EffectsHandlerImpl::slotClientGeometryShapeChanged(Client* c, const QRect& old) diff --git a/effects.h b/effects.h index e757ee171e..e87145f518 100644 --- a/effects.h +++ b/effects.h @@ -159,7 +159,6 @@ public: // internal (used by kwin core or compositing code) void startPaint(); void windowMoveResizeGeometryUpdate(EffectWindow* c, const QRect& geometry); - void windowDamaged(EffectWindow* w, const QRect& r); bool borderActivated(ElectricBorder border); void grabbedKeyboardEvent(QKeyEvent* e); bool hasKeyboardGrab() const; @@ -195,6 +194,7 @@ protected Q_SLOTS: void slotClientUnminimized(KWin::Client *c, bool animate); void slotClientGeometryShapeChanged(KWin::Client *c, const QRect &old); void slotUnmanagedGeometryShapeChanged(KWin::Unmanaged *u, const QRect &old); + void slotWindowDamaged(KWin::Toplevel *t, const QRect& r); protected: KLibrary* findEffectLibrary(KService* service); diff --git a/effects/boxswitch/boxswitch.cpp b/effects/boxswitch/boxswitch.cpp index 98edd4f09d..11097b3089 100644 --- a/effects/boxswitch/boxswitch.cpp +++ b/effects/boxswitch/boxswitch.cpp @@ -62,6 +62,7 @@ BoxSwitchEffect::BoxSwitchEffect() connect(effects, SIGNAL(tabBoxClosed()), this, SLOT(slotTabBoxClosed())); connect(effects, SIGNAL(tabBoxUpdated()), this, SLOT(slotTabBoxUpdated())); connect(effects, SIGNAL(windowGeometryShapeChanged(EffectWindow*,QRect)), this, SLOT(slotWindowGeometryShapeChanged(EffectWindow*,QRect))); + connect(effects, SIGNAL(windowDamaged(EffectWindow*,QRect)), this, SLOT(slotWindowDamaged(EffectWindow*,QRect))); } BoxSwitchEffect::~BoxSwitchEffect() @@ -255,7 +256,7 @@ void BoxSwitchEffect::windowInputMouseEvent(Window w, QEvent* e) } } -void BoxSwitchEffect::windowDamaged(EffectWindow* w, const QRect& damage) +void BoxSwitchEffect::slotWindowDamaged(EffectWindow* w, const QRect& damage) { Q_UNUSED(damage); if (mActivated) { diff --git a/effects/boxswitch/boxswitch.h b/effects/boxswitch/boxswitch.h index daa4f162fe..1ccef4d2dd 100644 --- a/effects/boxswitch/boxswitch.h +++ b/effects/boxswitch/boxswitch.h @@ -53,7 +53,6 @@ public: virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); virtual void windowInputMouseEvent(Window w, QEvent* e); - virtual void windowDamaged(EffectWindow* w, const QRect& damage); virtual void* proxy(); void activateFromProxy(int mode, bool animate, bool showText, float positioningFactor); void paintWindowsBox(const QRegion& region); @@ -64,6 +63,7 @@ public Q_SLOTS: void slotTabBoxClosed(); void slotTabBoxUpdated(); void slotWindowGeometryShapeChanged(EffectWindow *w, const QRect &old); + void slotWindowDamaged(EffectWindow* w, const QRect& damage); private: class ItemInfo; diff --git a/effects/taskbarthumbnail/taskbarthumbnail.cpp b/effects/taskbarthumbnail/taskbarthumbnail.cpp index 9c81fd5bf9..99f38d888f 100644 --- a/effects/taskbarthumbnail/taskbarthumbnail.cpp +++ b/effects/taskbarthumbnail/taskbarthumbnail.cpp @@ -45,6 +45,7 @@ TaskbarThumbnailEffect::TaskbarThumbnailEffect() XChangeProperty(display(), rootWindow(), atom, atom, 8, PropModeReplace, &dummy, 1); connect(effects, SIGNAL(windowAdded(EffectWindow*)), this, SLOT(slotWindowAdded(EffectWindow*))); connect(effects, SIGNAL(windowDeleted(EffectWindow*)), this, SLOT(slotWindowDeleted(EffectWindow*))); + connect(effects, SIGNAL(windowDamaged(EffectWindow*,QRect)), this, SLOT(slotWindowDamaged(EffectWindow*,QRect))); } TaskbarThumbnailEffect::~TaskbarThumbnailEffect() @@ -110,7 +111,7 @@ void TaskbarThumbnailEffect::paintWindow(EffectWindow* w, int mask, QRegion regi } } // End of function -void TaskbarThumbnailEffect::windowDamaged(EffectWindow* w, const QRect& damage) +void TaskbarThumbnailEffect::slotWindowDamaged(EffectWindow* w, const QRect& damage) { Q_UNUSED(damage); // Update the thumbnail if the window was damaged diff --git a/effects/taskbarthumbnail/taskbarthumbnail.h b/effects/taskbarthumbnail/taskbarthumbnail.h index 4c39b9d577..ef4a5f796b 100644 --- a/effects/taskbarthumbnail/taskbarthumbnail.h +++ b/effects/taskbarthumbnail/taskbarthumbnail.h @@ -38,12 +38,12 @@ public: virtual void prePaintScreen(ScreenPrePaintData& data, int time); virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time); virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); - virtual void windowDamaged(EffectWindow* w, const QRect& damage); virtual void propertyNotify(EffectWindow* w, long atom); public Q_SLOTS: void slotWindowAdded(EffectWindow *w); void slotWindowDeleted(EffectWindow *w); + void slotWindowDamaged(EffectWindow* w, const QRect& damage); private: struct Data { Window window; // thumbnail of this window diff --git a/effects/thumbnailaside/thumbnailaside.cpp b/effects/thumbnailaside/thumbnailaside.cpp index 692aeeec62..99bcf9a43d 100644 --- a/effects/thumbnailaside/thumbnailaside.cpp +++ b/effects/thumbnailaside/thumbnailaside.cpp @@ -40,6 +40,7 @@ ThumbnailAsideEffect::ThumbnailAsideEffect() connect(a, SIGNAL(triggered(bool)), this, SLOT(toggleCurrentThumbnail())); connect(effects, SIGNAL(windowClosed(EffectWindow*)), this, SLOT(slotWindowClosed(EffectWindow*))); connect(effects, SIGNAL(windowGeometryShapeChanged(EffectWindow*,QRect)), this, SLOT(slotWindowGeometryShapeChanged(EffectWindow*,QRect))); + connect(effects, SIGNAL(windowDamaged(EffectWindow*,QRect)), this, SLOT(slotWindowDamaged(EffectWindow*,QRect))); reconfigure(ReconfigureAll); } @@ -68,7 +69,7 @@ void ThumbnailAsideEffect::paintScreen(int mask, QRegion region, ScreenPaintData } } -void ThumbnailAsideEffect::windowDamaged(EffectWindow* w, const QRect&) +void ThumbnailAsideEffect::slotWindowDamaged(EffectWindow* w, const QRect&) { foreach (const Data & d, windows) { if (d.window == w) diff --git a/effects/thumbnailaside/thumbnailaside.h b/effects/thumbnailaside/thumbnailaside.h index 87106a7dbc..e1af63e0b7 100644 --- a/effects/thumbnailaside/thumbnailaside.h +++ b/effects/thumbnailaside/thumbnailaside.h @@ -43,11 +43,11 @@ public: ThumbnailAsideEffect(); virtual void reconfigure(ReconfigureFlags); virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data); - virtual void windowDamaged(EffectWindow* w, const QRect& damage); private slots: void toggleCurrentThumbnail(); void slotWindowClosed(EffectWindow *w); void slotWindowGeometryShapeChanged(EffectWindow *w, const QRect &old); + void slotWindowDamaged(EffectWindow* w, const QRect& damage); private: void addThumbnail(EffectWindow* w); void removeThumbnail(EffectWindow* w); diff --git a/libkwineffects/kwineffects.cpp b/libkwineffects/kwineffects.cpp index 412f9ef4a5..8c9fa3e858 100644 --- a/libkwineffects/kwineffects.cpp +++ b/libkwineffects/kwineffects.cpp @@ -135,10 +135,6 @@ void Effect::propertyNotify(EffectWindow* , long) { } -void Effect::windowDamaged(EffectWindow*, const QRect&) -{ -} - bool Effect::borderActivated(ElectricBorder) { return false; diff --git a/libkwineffects/kwineffects.h b/libkwineffects/kwineffects.h index c8c200be8b..8e23461a38 100644 --- a/libkwineffects/kwineffects.h +++ b/libkwineffects/kwineffects.h @@ -443,7 +443,6 @@ public: /** called when the geometry changed during moving/resizing. */ virtual void windowMoveResizeGeometryUpdate(EffectWindow* c, const QRect& geometry); virtual void windowInputMouseEvent(Window w, QEvent* e); - virtual void windowDamaged(EffectWindow* w, const QRect& r); virtual void grabbedKeyboardEvent(QKeyEvent* e); /** Receives events registered for using EffectsHandler::registerPropertyType(). @@ -895,6 +894,14 @@ Q_SIGNALS: * @since 4.7 **/ void windowUnminimized(EffectWindow *w); + /** + * Signal emitted when an area of a window is scheduled for repainting. + * Use this signal in an effect if another area needs to be synced as well. + * @param w The window which is scheduled for repainting + * @param r The damaged rect + * @since 4.7 + **/ + void windowDamaged(EffectWindow *w, const QRect &r); /** * Signal emitted when a tabbox is added. * An effect who wants to replace the tabbox with itself should use @link refTabBox. diff --git a/toplevel.h b/toplevel.h index 8e3dce270a..3bf9528a9e 100644 --- a/toplevel.h +++ b/toplevel.h @@ -137,6 +137,7 @@ public: signals: void opacityChanged(KWin::Toplevel* toplevel, qreal oldOpacity); + void damaged(KWin::Toplevel* toplevel, const QRect& damage); protected: virtual ~Toplevel();