From ab6f2ba1fd5bb35c565f59955e3e3f991f56d7dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Fri, 25 Feb 2011 22:06:02 +0100 Subject: [PATCH] EffectsHandler emits windowAdded signal All previously existing windowAdded methods are renamed to slotWindowAdded. EffectsHandlerImpl is connected to Workspace's clientAdded signal, which is emitted a little bit earlier than the previous direct method call. This might change behavior. Another signal is added to Workspace to signal that an unmanaged is added. --- effects.cpp | 12 +++++++++--- effects.h | 6 +++++- effects/blur/blur.cpp | 3 ++- effects/blur/blur.h | 5 ++++- effects/dashboard/dashboard.cpp | 3 ++- effects/dashboard/dashboard.h | 5 ++++- effects/desktopgrid/desktopgrid.cpp | 3 ++- effects/desktopgrid/desktopgrid.h | 2 +- effects/fade/fade.cpp | 3 ++- effects/fade/fade.h | 5 ++++- effects/flipswitch/flipswitch.cpp | 3 ++- effects/flipswitch/flipswitch.h | 2 +- effects/glide/glide.cpp | 3 ++- effects/glide/glide.h | 5 ++++- effects/highlightwindow/highlightwindow.cpp | 3 ++- effects/highlightwindow/highlightwindow.h | 5 ++++- effects/logout/logout.cpp | 3 ++- effects/logout/logout.h | 4 +++- effects/presentwindows/presentwindows.cpp | 3 ++- effects/presentwindows/presentwindows.h | 3 ++- effects/scalein/scalein.cpp | 8 +++++++- effects/scalein/scalein.h | 5 ++++- effects/sheet/sheet.cpp | 3 ++- effects/sheet/sheet.h | 5 ++++- effects/slideback/slideback.cpp | 3 ++- effects/slideback/slideback.h | 5 ++++- effects/slidingpopups/slidingpopups.cpp | 3 ++- effects/slidingpopups/slidingpopups.h | 5 ++++- effects/taskbarthumbnail/taskbarthumbnail.cpp | 3 ++- effects/taskbarthumbnail/taskbarthumbnail.h | 7 +++++-- effects/wobblywindows/wobblywindows.cpp | 3 ++- effects/wobblywindows/wobblywindows.h | 5 ++++- libkwineffects/kwineffects.cpp | 4 ---- libkwineffects/kwineffects.h | 7 ++++++- workspace.cpp | 5 +---- workspace.h | 1 + 36 files changed, 109 insertions(+), 44 deletions(-) diff --git a/effects.cpp b/effects.cpp index 7ed4a559d4..209fc8e660 100644 --- a/effects.cpp +++ b/effects.cpp @@ -97,6 +97,8 @@ EffectsHandlerImpl::EffectsHandlerImpl(CompositingType type) { Workspace *ws = Workspace::self(); connect(ws, SIGNAL(currentDesktopChanged(int)), this, SLOT(slotDesktopChanged(int))); + connect(ws, SIGNAL(clientAdded(KWin::Client*)), this, SLOT(slotClientAdded(KWin::Client*))); + connect(ws, SIGNAL(unmanagedAdded(KWin::Unmanaged*)), this, SLOT(slotUnmanagedAdded(KWin::Unmanaged*))); reconfigure(); } @@ -281,10 +283,14 @@ void EffectsHandlerImpl::windowOpacityChanged(EffectWindow* c, double old_opacit ep.second->windowOpacityChanged(c, old_opacity); } -void EffectsHandlerImpl::windowAdded(EffectWindow* c) +void EffectsHandlerImpl::slotClientAdded(Client *c) { - foreach (const EffectPair & ep, loaded_effects) - ep.second->windowAdded(c); + emit windowAdded(c->effectWindow()); +} + +void EffectsHandlerImpl::slotUnmanagedAdded(Unmanaged *u) +{ + emit windowAdded(u->effectWindow()); } void EffectsHandlerImpl::windowDeleted(EffectWindow* c) diff --git a/effects.h b/effects.h index ef09ff0328..c294ff17c7 100644 --- a/effects.h +++ b/effects.h @@ -36,6 +36,9 @@ class KService; namespace KWin { +class Client; +class Unmanaged; + class EffectsHandlerImpl : public EffectsHandler { Q_OBJECT @@ -157,7 +160,6 @@ public: void windowUserMovedResized(EffectWindow* c, bool first, bool last); void windowMoveResizeGeometryUpdate(EffectWindow* c, const QRect& geometry); void windowOpacityChanged(EffectWindow* c, double old_opacity); - void windowAdded(EffectWindow* c); void windowClosed(EffectWindow* c); void windowDeleted(EffectWindow* c); void windowActivated(EffectWindow* c); @@ -193,6 +195,8 @@ public: protected Q_SLOTS: void slotDesktopChanged(int old); + void slotClientAdded(KWin::Client *c); + void slotUnmanagedAdded(KWin::Unmanaged *u); protected: KLibrary* findEffectLibrary(KService* service); diff --git a/effects/blur/blur.cpp b/effects/blur/blur.cpp index ca5deaf15a..38fc71ca8a 100644 --- a/effects/blur/blur.cpp +++ b/effects/blur/blur.cpp @@ -57,6 +57,7 @@ BlurEffect::BlurEffect() } else { XDeleteProperty(display(), rootWindow(), net_wm_blur_region); } + connect(effects, SIGNAL(windowAdded(EffectWindow*)), this, SLOT(slotWindowAdded(EffectWindow*))); } BlurEffect::~BlurEffect() @@ -106,7 +107,7 @@ void BlurEffect::updateBlurRegion(EffectWindow *w) const w->setData(WindowBlurBehindRole, region); } -void BlurEffect::windowAdded(EffectWindow *w) +void BlurEffect::slotWindowAdded(EffectWindow *w) { updateBlurRegion(w); } diff --git a/effects/blur/blur.h b/effects/blur/blur.h index e3f1cb2472..4759e7bc41 100644 --- a/effects/blur/blur.h +++ b/effects/blur/blur.h @@ -33,6 +33,7 @@ class BlurShader; class BlurEffect : public KWin::Effect { + Q_OBJECT public: BlurEffect(); ~BlurEffect(); @@ -40,12 +41,14 @@ public: static bool supported(); void reconfigure(ReconfigureFlags flags); - void windowAdded(EffectWindow *w); void propertyNotify(EffectWindow *w, long atom); void paintScreen(int mask, QRegion region, ScreenPaintData &data); void drawWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data); void paintEffectFrame(EffectFrame *frame, QRegion region, double opacity, double frameOpacity); +public Q_SLOTS: + void slotWindowAdded(EffectWindow *w); + private: QRect expand(const QRect &rect) const; QRegion expand(const QRegion ®ion) const; diff --git a/effects/dashboard/dashboard.cpp b/effects/dashboard/dashboard.cpp index 41f6a65621..6bb2c294e2 100644 --- a/effects/dashboard/dashboard.cpp +++ b/effects/dashboard/dashboard.cpp @@ -35,6 +35,7 @@ DashboardEffect::DashboardEffect() // read settings reconfigure(ReconfigureAll); + connect(effects, SIGNAL(windowAdded(EffectWindow*)), this, SLOT(slotWindowAdded(EffectWindow*))); } DashboardEffect::~DashboardEffect() @@ -171,7 +172,7 @@ void DashboardEffect::windowActivated(EffectWindow *w) } } -void DashboardEffect::windowAdded(EffectWindow* w) +void DashboardEffect::slotWindowAdded(EffectWindow* w) { propertyNotify(w, atom); diff --git a/effects/dashboard/dashboard.h b/effects/dashboard/dashboard.h index ee6be61d7f..b3c6c67089 100644 --- a/effects/dashboard/dashboard.h +++ b/effects/dashboard/dashboard.h @@ -32,6 +32,7 @@ namespace KWin class DashboardEffect : public KWin::Effect { + Q_OBJECT public: DashboardEffect(); ~DashboardEffect(); @@ -42,8 +43,10 @@ public: virtual void reconfigure(ReconfigureFlags); virtual void unpropagate(); virtual void windowActivated(EffectWindow *w); - virtual void windowAdded(EffectWindow* c); virtual void windowClosed(EffectWindow* c); + +public Q_SLOTS: + void slotWindowAdded(EffectWindow* c); private: bool blur; bool isDashboard(EffectWindow* w); diff --git a/effects/desktopgrid/desktopgrid.cpp b/effects/desktopgrid/desktopgrid.cpp index 1a33e0f110..3e9dc02668 100644 --- a/effects/desktopgrid/desktopgrid.cpp +++ b/effects/desktopgrid/desktopgrid.cpp @@ -73,6 +73,7 @@ DesktopGridEffect::DesktopGridEffect() shortcut = a->globalShortcut(); connect(a, SIGNAL(triggered(bool)), this, SLOT(toggle())); connect(a, SIGNAL(globalShortcutChanged(QKeySequence)), this, SLOT(globalShortcutChanged(QKeySequence))); + connect(effects, SIGNAL(windowAdded(EffectWindow*)), this, SLOT(slotWindowAdded(EffectWindow*))); // Load all other configuration details reconfigure(ReconfigureAll); @@ -368,7 +369,7 @@ void DesktopGridEffect::paintWindow(EffectWindow* w, int mask, QRegion region, W //----------------------------------------------------------------------------- // User interaction -void DesktopGridEffect::windowAdded(EffectWindow* w) +void DesktopGridEffect::slotWindowAdded(EffectWindow* w) { if (!activated) return; diff --git a/effects/desktopgrid/desktopgrid.h b/effects/desktopgrid/desktopgrid.h index 76ea364bcf..6374d97251 100644 --- a/effects/desktopgrid/desktopgrid.h +++ b/effects/desktopgrid/desktopgrid.h @@ -73,7 +73,6 @@ public: virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); virtual void windowClosed(EffectWindow* w); virtual void windowDeleted(EffectWindow* w); - virtual void windowAdded(EffectWindow* w); virtual void windowGeometryShapeChanged(EffectWindow* w, const QRect& old); virtual void windowInputMouseEvent(Window w, QEvent* e); virtual void grabbedKeyboardEvent(QKeyEvent* e); @@ -89,6 +88,7 @@ private slots: void globalShortcutChanged(const QKeySequence& seq); void slotAddDesktop(); void slotRemoveDesktop(); + void slotWindowAdded(EffectWindow* w); private: QPointF scalePos(const QPoint& pos, int desktop, int screen = -1) const; diff --git a/effects/fade/fade.cpp b/effects/fade/fade.cpp index d735aa1ab5..2ef8a9de7b 100644 --- a/effects/fade/fade.cpp +++ b/effects/fade/fade.cpp @@ -30,6 +30,7 @@ KWIN_EFFECT(fade, FadeEffect) FadeEffect::FadeEffect() { reconfigure(ReconfigureAll); + connect(effects, SIGNAL(windowAdded(EffectWindow*)), this, SLOT(slotWindowAdded(EffectWindow*))); } void FadeEffect::reconfigure(ReconfigureFlags) @@ -153,7 +154,7 @@ void FadeEffect::windowOpacityChanged(EffectWindow* w, double old_opacity) w->addRepaintFull(); } -void FadeEffect::windowAdded(EffectWindow* w) +void FadeEffect::slotWindowAdded(EffectWindow* w) { if (!fadeWindows || !isFadeWindow(w)) return; diff --git a/effects/fade/fade.h b/effects/fade/fade.h index 1a20bf73c0..ebd9a55b25 100644 --- a/effects/fade/fade.h +++ b/effects/fade/fade.h @@ -29,6 +29,7 @@ namespace KWin class FadeEffect : public Effect { + Q_OBJECT public: FadeEffect(); virtual void reconfigure(ReconfigureFlags); @@ -38,11 +39,13 @@ public: // TODO react also on virtual desktop changes virtual void windowOpacityChanged(EffectWindow* c, double old_opacity); - virtual void windowAdded(EffectWindow* c); virtual void windowClosed(EffectWindow* c); virtual void windowDeleted(EffectWindow* c); bool isFadeWindow(EffectWindow* w); + +public Q_SLOTS: + void slotWindowAdded(EffectWindow* c); private: class WindowInfo; QHash< const EffectWindow*, WindowInfo > windows; diff --git a/effects/flipswitch/flipswitch.cpp b/effects/flipswitch/flipswitch.cpp index f86b16b1e3..d66507ea80 100644 --- a/effects/flipswitch/flipswitch.cpp +++ b/effects/flipswitch/flipswitch.cpp @@ -69,6 +69,7 @@ FlipSwitchEffect::FlipSwitchEffect() m_shortcutAll = b->globalShortcut(); connect(b, SIGNAL(triggered(bool)), this, SLOT(toggleActiveAllDesktops())); connect(b, SIGNAL(globalShortcutChanged(QKeySequence)), this, SLOT(globalShortcutChangedAll(QKeySequence))); + connect(effects, SIGNAL(windowAdded(EffectWindow*)), this, SLOT(slotWindowAdded(EffectWindow*))); } FlipSwitchEffect::~FlipSwitchEffect() @@ -576,7 +577,7 @@ void FlipSwitchEffect::tabBoxUpdated() // Window adding/removing handling //************************************************************* -void FlipSwitchEffect::windowAdded(EffectWindow* w) +void FlipSwitchEffect::slotWindowAdded(EffectWindow* w) { if (m_active && isSelectableWindow(w)) { m_windows[ w ] = new ItemInfo(); diff --git a/effects/flipswitch/flipswitch.h b/effects/flipswitch/flipswitch.h index bccb934201..d1d009e887 100644 --- a/effects/flipswitch/flipswitch.h +++ b/effects/flipswitch/flipswitch.h @@ -47,7 +47,6 @@ public: virtual void tabBoxAdded(int mode); virtual void tabBoxClosed(); virtual void tabBoxUpdated(); - virtual void windowAdded(EffectWindow* w); virtual void windowClosed(EffectWindow* w); virtual bool borderActivated(ElectricBorder border); virtual void grabbedKeyboardEvent(QKeyEvent* e); @@ -58,6 +57,7 @@ private Q_SLOTS: void toggleActiveAllDesktops(); void globalShortcutChangedCurrent(QKeySequence shortcut); void globalShortcutChangedAll(QKeySequence shortcut); + void slotWindowAdded(EffectWindow* w); private: class ItemInfo; diff --git a/effects/glide/glide.cpp b/effects/glide/glide.cpp index 2bc3bf98ce..bce0d5bd19 100644 --- a/effects/glide/glide.cpp +++ b/effects/glide/glide.cpp @@ -37,6 +37,7 @@ static const int IsGlideWindow = 0x22A982D4; GlideEffect::GlideEffect() { reconfigure(ReconfigureAll); + connect(effects, SIGNAL(windowAdded(EffectWindow*)), this, SLOT(slotWindowAdded(EffectWindow*))); } bool GlideEffect::supported() @@ -159,7 +160,7 @@ void GlideEffect::postPaintWindow(EffectWindow* w) effects->postPaintWindow(w); } -void GlideEffect::windowAdded(EffectWindow* w) +void GlideEffect::slotWindowAdded(EffectWindow* w) { if (!isGlideWindow(w)) return; diff --git a/effects/glide/glide.h b/effects/glide/glide.h index 9a1aebd37c..c8d8f58f6e 100644 --- a/effects/glide/glide.h +++ b/effects/glide/glide.h @@ -31,6 +31,7 @@ namespace KWin class GlideEffect : public Effect { + Q_OBJECT public: GlideEffect(); virtual void reconfigure(ReconfigureFlags); @@ -39,11 +40,13 @@ public: virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); virtual void postPaintWindow(EffectWindow* w); - virtual void windowAdded(EffectWindow* c); virtual void windowClosed(EffectWindow* c); virtual void windowDeleted(EffectWindow* c); static bool supported(); +public Q_SLOTS: + void slotWindowAdded(EffectWindow* c); + private: class WindowInfo; typedef QMap< const EffectWindow*, WindowInfo > InfoHash; diff --git a/effects/highlightwindow/highlightwindow.cpp b/effects/highlightwindow/highlightwindow.cpp index 8e78b027ce..e70ad8547d 100644 --- a/effects/highlightwindow/highlightwindow.cpp +++ b/effects/highlightwindow/highlightwindow.cpp @@ -38,6 +38,7 @@ HighlightWindowEffect::HighlightWindowEffect() // Announce support by creating a dummy version on the root window unsigned char dummy = 0; XChangeProperty(display(), rootWindow(), m_atom, m_atom, 8, PropModeReplace, &dummy, 1); + connect(effects, SIGNAL(windowAdded(EffectWindow*)), this, SLOT(slotWindowAdded(EffectWindow*))); } HighlightWindowEffect::~HighlightWindowEffect() @@ -103,7 +104,7 @@ void HighlightWindowEffect::paintWindow(EffectWindow* w, int mask, QRegion regio effects->paintWindow(w, mask, region, data); } -void HighlightWindowEffect::windowAdded(EffectWindow* w) +void HighlightWindowEffect::slotWindowAdded(EffectWindow* w) { if (!m_highlightedWindows.isEmpty()) { // The effect is activated thus we need to add it to the opacity hash diff --git a/effects/highlightwindow/highlightwindow.h b/effects/highlightwindow/highlightwindow.h index a96623c2c7..1c3781b9b7 100644 --- a/effects/highlightwindow/highlightwindow.h +++ b/effects/highlightwindow/highlightwindow.h @@ -29,6 +29,7 @@ namespace KWin class HighlightWindowEffect : public Effect { + Q_OBJECT public: HighlightWindowEffect(); virtual ~HighlightWindowEffect(); @@ -36,12 +37,14 @@ public: virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time); virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); - virtual void windowAdded(EffectWindow* w); virtual void windowClosed(EffectWindow* w); virtual void windowDeleted(EffectWindow* w); virtual void propertyNotify(EffectWindow* w, long atom); +public Q_SLOTS: + void slotWindowAdded(EffectWindow* w); + private: void prepareHighlighting(); void finishHighlighting(); diff --git a/effects/logout/logout.cpp b/effects/logout/logout.cpp index 3a9588e1b2..fc6961162b 100644 --- a/effects/logout/logout.cpp +++ b/effects/logout/logout.cpp @@ -60,6 +60,7 @@ LogoutEffect::LogoutEffect() blurTarget = NULL; #endif reconfigure(ReconfigureAll); + connect(effects, SIGNAL(windowAdded(EffectWindow*)), this, SLOT(slotWindowAdded(EffectWindow*))); } LogoutEffect::~LogoutEffect() @@ -292,7 +293,7 @@ void LogoutEffect::postPaintScreen() effects->postPaintScreen(); } -void LogoutEffect::windowAdded(EffectWindow* w) +void LogoutEffect::slotWindowAdded(EffectWindow* w) { if (isLogoutDialog(w)) { logoutWindow = w; diff --git a/effects/logout/logout.h b/effects/logout/logout.h index 1567edb88d..7dc7700683 100644 --- a/effects/logout/logout.h +++ b/effects/logout/logout.h @@ -35,6 +35,7 @@ class GLTexture; class LogoutEffect : public Effect { + Q_OBJECT public: LogoutEffect(); ~LogoutEffect(); @@ -43,10 +44,11 @@ public: virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data); virtual void postPaintScreen(); virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); - virtual void windowAdded(EffectWindow* w); virtual void windowClosed(EffectWindow* w); virtual void windowDeleted(EffectWindow* w); virtual void propertyNotify(EffectWindow* w, long a); +public Q_SLOTS: + void slotWindowAdded(EffectWindow* w); private: bool isLogoutDialog(EffectWindow* w); double progress; // 0-1 diff --git a/effects/presentwindows/presentwindows.cpp b/effects/presentwindows/presentwindows.cpp index a07bf62baa..17da9834ad 100644 --- a/effects/presentwindows/presentwindows.cpp +++ b/effects/presentwindows/presentwindows.cpp @@ -98,6 +98,7 @@ PresentWindowsEffect::PresentWindowsEffect() connect(c, SIGNAL(globalShortcutChanged(QKeySequence)), this, SLOT(globalShortcutChangedClass(QKeySequence))); shortcutClass = c->globalShortcut(); reconfigure(ReconfigureAll); + connect(effects, SIGNAL(windowAdded(EffectWindow*)), this, SLOT(slotWindowAdded(EffectWindow*))); } PresentWindowsEffect::~PresentWindowsEffect() @@ -357,7 +358,7 @@ void PresentWindowsEffect::paintWindow(EffectWindow *w, int mask, QRegion region //----------------------------------------------------------------------------- // User interaction -void PresentWindowsEffect::windowAdded(EffectWindow *w) +void PresentWindowsEffect::slotWindowAdded(EffectWindow *w) { if (!m_activated) return; diff --git a/effects/presentwindows/presentwindows.h b/effects/presentwindows/presentwindows.h index 3302654a3d..68cb1a41bd 100644 --- a/effects/presentwindows/presentwindows.h +++ b/effects/presentwindows/presentwindows.h @@ -102,7 +102,6 @@ public: virtual void paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data); // User interaction - virtual void windowAdded(EffectWindow *w); virtual void windowClosed(EffectWindow *w); virtual void windowDeleted(EffectWindow *w); virtual void windowGeometryShapeChanged(EffectWindow* w, const QRect& old); @@ -160,6 +159,8 @@ public slots: void globalShortcutChanged(const QKeySequence& seq); void globalShortcutChangedAll(const QKeySequence& seq); void globalShortcutChangedClass(const QKeySequence& seq); + // EffectsHandler + void slotWindowAdded(EffectWindow *w); private slots: void closeWindow(); diff --git a/effects/scalein/scalein.cpp b/effects/scalein/scalein.cpp index dd1a1a2bb7..7de73aab74 100644 --- a/effects/scalein/scalein.cpp +++ b/effects/scalein/scalein.cpp @@ -25,6 +25,12 @@ namespace KWin KWIN_EFFECT(scalein, ScaleInEffect) +ScaleInEffect::ScaleInEffect() + : Effect() +{ + connect(effects, SIGNAL(windowAdded(EffectWindow*)), this, SLOT(slotWindowAdded(EffectWindow*))); +} + void ScaleInEffect::prePaintScreen(ScreenPrePaintData& data, int time) { if (!mTimeLineWindows.isEmpty()) @@ -73,7 +79,7 @@ void ScaleInEffect::postPaintWindow(EffectWindow* w) effects->postPaintWindow(w); } -void ScaleInEffect::windowAdded(EffectWindow* c) +void ScaleInEffect::slotWindowAdded(EffectWindow* c) { if (c->isOnCurrentDesktop()) { mTimeLineWindows[ c ].setDuration(animationTime(250)); diff --git a/effects/scalein/scalein.h b/effects/scalein/scalein.h index bf378c4099..d894d30f1d 100644 --- a/effects/scalein/scalein.h +++ b/effects/scalein/scalein.h @@ -29,14 +29,17 @@ namespace KWin class ScaleInEffect : public Effect { + Q_OBJECT public: + ScaleInEffect(); 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 postPaintWindow(EffectWindow* w); // TODO react also on virtual desktop changes - virtual void windowAdded(EffectWindow* c); virtual void windowClosed(EffectWindow* c); +public Q_SLOTS: + void slotWindowAdded(EffectWindow* c); private: bool isScaleWindow(EffectWindow* w); QHash< const EffectWindow*, TimeLine > mTimeLineWindows; diff --git a/effects/sheet/sheet.cpp b/effects/sheet/sheet.cpp index 86d9663afc..58ec71f60a 100644 --- a/effects/sheet/sheet.cpp +++ b/effects/sheet/sheet.cpp @@ -36,6 +36,7 @@ static const int IsSheetWindow = 0x22A982D5; SheetEffect::SheetEffect() { reconfigure(ReconfigureAll); + connect(effects, SIGNAL(windowAdded(EffectWindow*)), this, SLOT(slotWindowAdded(EffectWindow*))); } bool SheetEffect::supported() @@ -117,7 +118,7 @@ void SheetEffect::postPaintWindow(EffectWindow* w) effects->postPaintWindow(w); } -void SheetEffect::windowAdded(EffectWindow* w) +void SheetEffect::slotWindowAdded(EffectWindow* w) { if (!isSheetWindow(w)) return; diff --git a/effects/sheet/sheet.h b/effects/sheet/sheet.h index 233f736bf6..2bec947cd9 100644 --- a/effects/sheet/sheet.h +++ b/effects/sheet/sheet.h @@ -30,6 +30,7 @@ namespace KWin class SheetEffect : public Effect { + Q_OBJECT public: SheetEffect(); virtual void reconfigure(ReconfigureFlags); @@ -38,11 +39,13 @@ public: virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); virtual void postPaintWindow(EffectWindow* w); - virtual void windowAdded(EffectWindow* c); virtual void windowClosed(EffectWindow* c); virtual void windowDeleted(EffectWindow* c); static bool supported(); + +public Q_SLOTS: + void slotWindowAdded(EffectWindow* c); private: class WindowInfo; typedef QMap< const EffectWindow*, WindowInfo > InfoMap; diff --git a/effects/slideback/slideback.cpp b/effects/slideback/slideback.cpp index 9b23d9c846..d869f42cae 100644 --- a/effects/slideback/slideback.cpp +++ b/effects/slideback/slideback.cpp @@ -33,6 +33,7 @@ SlideBackEffect::SlideBackEffect() updateStackingOrder(); disabled = false; unminimizedWindow = NULL; + connect(effects, SIGNAL(windowAdded(EffectWindow*)), this, SLOT(slotWindowAdded(EffectWindow*))); } static inline bool windowsShareDesktop(EffectWindow *w1, EffectWindow *w2) @@ -287,7 +288,7 @@ void SlideBackEffect::windowDeleted(EffectWindow* w) } } -void SlideBackEffect::windowAdded(KWin::EffectWindow* w) +void SlideBackEffect::slotWindowAdded(EffectWindow *w) { Q_UNUSED(w); updateStackingOrder(); diff --git a/effects/slideback/slideback.h b/effects/slideback/slideback.h index c4a2e4c9c5..2fe3cb4404 100644 --- a/effects/slideback/slideback.h +++ b/effects/slideback/slideback.h @@ -30,6 +30,7 @@ namespace KWin class SlideBackEffect : public Effect { + Q_OBJECT public: SlideBackEffect(); @@ -43,12 +44,14 @@ public: virtual void postPaintScreen(); virtual void windowDeleted(EffectWindow* w); - virtual void windowAdded(EffectWindow* w); virtual void windowUnminimized(EffectWindow* w); virtual void clientGroupItemSwitched(EffectWindow* from, EffectWindow* to); virtual void tabBoxClosed(); +public Q_SLOTS: + void slotWindowAdded(EffectWindow *w); + private: WindowMotionManager motionManager; diff --git a/effects/slidingpopups/slidingpopups.cpp b/effects/slidingpopups/slidingpopups.cpp index 529db58f8c..23fdd7b198 100644 --- a/effects/slidingpopups/slidingpopups.cpp +++ b/effects/slidingpopups/slidingpopups.cpp @@ -38,6 +38,7 @@ SlidingPopupsEffect::SlidingPopupsEffect() // TODO hackish way to announce support, make better after 4.0 unsigned char dummy = 0; XChangeProperty(display(), rootWindow(), mAtom, mAtom, 8, PropModeReplace, &dummy, 1); + connect(effects, SIGNAL(windowAdded(EffectWindow*)), this, SLOT(slotWindowAdded(EffectWindow*))); } SlidingPopupsEffect::~SlidingPopupsEffect() @@ -131,7 +132,7 @@ void SlidingPopupsEffect::postPaintWindow(EffectWindow* w) } } -void SlidingPopupsEffect::windowAdded(EffectWindow* w) +void SlidingPopupsEffect::slotWindowAdded(EffectWindow *w) { propertyNotify(w, mAtom); if (w->isOnCurrentDesktop() && mWindowsData.contains(w)) { diff --git a/effects/slidingpopups/slidingpopups.h b/effects/slidingpopups/slidingpopups.h index c341ba710e..eb35ec692d 100644 --- a/effects/slidingpopups/slidingpopups.h +++ b/effects/slidingpopups/slidingpopups.h @@ -30,6 +30,7 @@ namespace KWin class SlidingPopupsEffect : public Effect { + Q_OBJECT public: SlidingPopupsEffect(); ~SlidingPopupsEffect(); @@ -38,10 +39,12 @@ public: virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); virtual void postPaintWindow(EffectWindow* w); // TODO react also on virtual desktop changes - virtual void windowAdded(EffectWindow* c); virtual void windowClosed(EffectWindow* c); virtual void windowDeleted(EffectWindow* c); virtual void propertyNotify(EffectWindow* w, long a); + +public Q_SLOTS: + void slotWindowAdded(EffectWindow *c); private: enum Position { West = 0, diff --git a/effects/taskbarthumbnail/taskbarthumbnail.cpp b/effects/taskbarthumbnail/taskbarthumbnail.cpp index ca030dbc72..d8e35033be 100644 --- a/effects/taskbarthumbnail/taskbarthumbnail.cpp +++ b/effects/taskbarthumbnail/taskbarthumbnail.cpp @@ -43,6 +43,7 @@ TaskbarThumbnailEffect::TaskbarThumbnailEffect() // TODO hackish way to announce support, make better after 4.0 unsigned char dummy = 0; XChangeProperty(display(), rootWindow(), atom, atom, 8, PropModeReplace, &dummy, 1); + connect(effects, SIGNAL(windowAdded(EffectWindow*)), this, SLOT(slotWindowAdded(EffectWindow*))); } TaskbarThumbnailEffect::~TaskbarThumbnailEffect() @@ -118,7 +119,7 @@ void TaskbarThumbnailEffect::windowDamaged(EffectWindow* w, const QRect& damage) effects->addRepaint(thumb.rect.translated(window->pos())); } -void TaskbarThumbnailEffect::windowAdded(EffectWindow* w) +void TaskbarThumbnailEffect::slotWindowAdded(EffectWindow* w) { propertyNotify(w, atom); // read initial value } diff --git a/effects/taskbarthumbnail/taskbarthumbnail.h b/effects/taskbarthumbnail/taskbarthumbnail.h index 08f12ac643..4bbf6f64b9 100644 --- a/effects/taskbarthumbnail/taskbarthumbnail.h +++ b/effects/taskbarthumbnail/taskbarthumbnail.h @@ -29,8 +29,9 @@ namespace KWin { class TaskbarThumbnailEffect - : public QObject, public Effect + : public Effect { + Q_OBJECT public: TaskbarThumbnailEffect(); virtual ~TaskbarThumbnailEffect(); @@ -38,9 +39,11 @@ public: 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 windowAdded(EffectWindow* w); virtual void windowDeleted(EffectWindow* w); virtual void propertyNotify(EffectWindow* w, long atom); + +public Q_SLOTS: + void slotWindowAdded(EffectWindow *w); private: struct Data { Window window; // thumbnail of this window diff --git a/effects/wobblywindows/wobblywindows.cpp b/effects/wobblywindows/wobblywindows.cpp index badd18ad06..b04f95faae 100644 --- a/effects/wobblywindows/wobblywindows.cpp +++ b/effects/wobblywindows/wobblywindows.cpp @@ -165,6 +165,7 @@ KWIN_EFFECT_SUPPORTED(wobblywindows, WobblyWindowsEffect::supported()) WobblyWindowsEffect::WobblyWindowsEffect() { reconfigure(ReconfigureAll); + connect(effects, SIGNAL(windowAdded(EffectWindow*)), this, SLOT(slotWindowAdded(EffectWindow*))); } WobblyWindowsEffect::~WobblyWindowsEffect() @@ -460,7 +461,7 @@ void WobblyWindowsEffect::stepMovedResized(EffectWindow* w) } } -void WobblyWindowsEffect::windowAdded(EffectWindow* w) +void WobblyWindowsEffect::slotWindowAdded(EffectWindow* w) { if (m_openEffectEnabled && w->data(WindowAddedGrabRole).value() != this) { if (windows.contains(w)) { diff --git a/effects/wobblywindows/wobblywindows.h b/effects/wobblywindows/wobblywindows.h index 3a3711132a..4c91d4cc36 100644 --- a/effects/wobblywindows/wobblywindows.h +++ b/effects/wobblywindows/wobblywindows.h @@ -24,6 +24,7 @@ struct ParameterSet; **/ class WobblyWindowsEffect : public Effect { + Q_OBJECT public: WobblyWindowsEffect(); @@ -35,7 +36,6 @@ public: virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); virtual void postPaintScreen(); virtual void windowUserMovedResized(EffectWindow* c, bool first, bool last); - virtual void windowAdded(EffectWindow* w); virtual void windowClosed(EffectWindow* w); // Wobbly model parameters @@ -58,6 +58,9 @@ public: static bool supported(); +public Q_SLOTS: + void slotWindowAdded(EffectWindow *w); + private: void startMovedResized(EffectWindow* w); diff --git a/libkwineffects/kwineffects.cpp b/libkwineffects/kwineffects.cpp index 731b8e9977..2f4eb47078 100644 --- a/libkwineffects/kwineffects.cpp +++ b/libkwineffects/kwineffects.cpp @@ -131,10 +131,6 @@ void Effect::windowOpacityChanged(EffectWindow*, double) { } -void Effect::windowAdded(EffectWindow*) -{ -} - void Effect::windowClosed(EffectWindow*) { } diff --git a/libkwineffects/kwineffects.h b/libkwineffects/kwineffects.h index de4be0ab66..5767c5e46e 100644 --- a/libkwineffects/kwineffects.h +++ b/libkwineffects/kwineffects.h @@ -445,7 +445,6 @@ public: /** called when the geometry changed during moving/resizing. */ virtual void windowMoveResizeGeometryUpdate(EffectWindow* c, const QRect& geometry); virtual void windowOpacityChanged(EffectWindow* c, double old_opacity); - virtual void windowAdded(EffectWindow* c); virtual void windowClosed(EffectWindow* c); virtual void windowDeleted(EffectWindow* c); virtual void windowActivated(EffectWindow* c); @@ -839,6 +838,12 @@ Q_SIGNALS: * @since 4.7 **/ void desktopChanged(int oldDesktop, int newDesktop); + /** + * Signal emitted when a new window has been added to the Workspace. + * @param w The added window + * @since 4.7 + **/ + void windowAdded(EffectWindow *w); protected: QVector< EffectPair > loaded_effects; diff --git a/workspace.cpp b/workspace.cpp index 8e2d7a2794..f0e21b6fc9 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -564,8 +564,6 @@ Client* Workspace::createClient(Window w, bool is_mapped) if (scene) scene->windowAdded(c); - if (effects) - static_cast(effects)->windowAdded(c->effectWindow()); return c; } @@ -581,8 +579,7 @@ Unmanaged* Workspace::createUnmanaged(Window w) addUnmanaged(c, Allowed); if (scene) scene->windowAdded(c); - if (effects) - static_cast(effects)->windowAdded(c->effectWindow()); + emit unmanagedAdded(c); return c; } diff --git a/workspace.h b/workspace.h index fe97c776c4..623a0520f3 100644 --- a/workspace.h +++ b/workspace.h @@ -910,6 +910,7 @@ signals: void clientRemoved(KWin::Client*); void clientActivated(KWin::Client*); void groupAdded(KWin::Group*); + void unmanagedAdded(KWin::Unmanaged*); private: void init();