From 640fdc7b6df8a1596616ddc7df809e595fed1d22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Sat, 12 Mar 2011 19:18:19 +0100 Subject: [PATCH] PropertyNotify becomes a signal --- effects.cpp | 15 ++++++++++++--- effects.h | 3 ++- effects/blur/blur.cpp | 3 ++- effects/blur/blur.h | 2 +- effects/highlightwindow/highlightwindow.cpp | 5 +++-- effects/highlightwindow/highlightwindow.h | 3 +-- effects/logout/logout.cpp | 3 ++- effects/logout/logout.h | 2 +- effects/presentwindows/presentwindows.cpp | 3 ++- effects/presentwindows/presentwindows.h | 5 ++--- effects/slidingpopups/slidingpopups.cpp | 7 ++++--- effects/slidingpopups/slidingpopups.h | 2 +- effects/taskbarthumbnail/taskbarthumbnail.cpp | 5 +++-- effects/taskbarthumbnail/taskbarthumbnail.h | 2 +- events.cpp | 7 +++---- libkwineffects/kwineffects.cpp | 4 ---- libkwineffects/kwineffects.h | 19 +++++++++++-------- toplevel.h | 1 + workspace.h | 1 + 19 files changed, 53 insertions(+), 39 deletions(-) diff --git a/effects.cpp b/effects.cpp index 254a90d46..a3ae53744 100644 --- a/effects.cpp +++ b/effects.cpp @@ -105,6 +105,7 @@ EffectsHandlerImpl::EffectsHandlerImpl(CompositingType type) connect(ws, SIGNAL(numberDesktopsChanged(int)), SIGNAL(numberDesktopsChanged(int))); connect(ws, SIGNAL(mouseChanged(QPoint,QPoint,Qt::MouseButtons,Qt::MouseButtons,Qt::KeyboardModifiers,Qt::KeyboardModifiers)), SIGNAL(mouseChanged(QPoint,QPoint,Qt::MouseButtons,Qt::MouseButtons,Qt::KeyboardModifiers,Qt::KeyboardModifiers))); + connect(ws, SIGNAL(propertyNotify(long)), this, SLOT(slotPropertyNotify(long))); connect(ws->tabBox(), SIGNAL(tabBoxAdded(int)), SIGNAL(tabBoxAdded(int))); connect(ws->tabBox(), SIGNAL(tabBoxUpdated()), SIGNAL(tabBoxUpdated())); connect(ws->tabBox(), SIGNAL(tabBoxClosed()), SIGNAL(tabBoxClosed())); @@ -138,6 +139,7 @@ void EffectsHandlerImpl::setupClientConnections(Client* c) 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))); + connect(c, SIGNAL(propertyNotify(KWin::Toplevel*,long)), this, SLOT(slotPropertyNotify(KWin::Toplevel*,long))); } void EffectsHandlerImpl::setupUnmanagedConnections(Unmanaged* u) @@ -146,6 +148,7 @@ void EffectsHandlerImpl::setupUnmanagedConnections(Unmanaged* u) 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))); + connect(u, SIGNAL(propertyNotify(KWin::Toplevel*,long)), this, SLOT(slotPropertyNotify(KWin::Toplevel*,long))); } void EffectsHandlerImpl::reconfigure() @@ -492,12 +495,18 @@ bool EffectsHandlerImpl::hasKeyboardGrab() const return keyboard_grab_effect != NULL; } -void EffectsHandlerImpl::propertyNotify(EffectWindow* c, long atom) +void EffectsHandlerImpl::slotPropertyNotify(Toplevel* t, long int atom) { if (!registered_atoms.contains(atom)) return; - foreach (const EffectPair & ep, loaded_effects) - ep.second->propertyNotify(c, atom); + emit propertyNotify(t->effectWindow(), atom); +} + +void EffectsHandlerImpl::slotPropertyNotify(long int atom) +{ + if (!registered_atoms.contains(atom)) + return; + emit propertyNotify(NULL, atom); } void EffectsHandlerImpl::registerPropertyType(long atom, bool reg) diff --git a/effects.h b/effects.h index e87145f51..c3f67d25f 100644 --- a/effects.h +++ b/effects.h @@ -162,7 +162,6 @@ public: bool borderActivated(ElectricBorder border); void grabbedKeyboardEvent(QKeyEvent* e); bool hasKeyboardGrab() const; - void propertyNotify(EffectWindow* c, long atom); bool loadEffect(const QString& name); void toggleEffect(const QString& name); @@ -195,6 +194,8 @@ protected Q_SLOTS: void slotClientGeometryShapeChanged(KWin::Client *c, const QRect &old); void slotUnmanagedGeometryShapeChanged(KWin::Unmanaged *u, const QRect &old); void slotWindowDamaged(KWin::Toplevel *t, const QRect& r); + void slotPropertyNotify(KWin::Toplevel *t, long atom); + void slotPropertyNotify(long atom); protected: KLibrary* findEffectLibrary(KService* service); diff --git a/effects/blur/blur.cpp b/effects/blur/blur.cpp index 38fc71ca8..3a2afe853 100644 --- a/effects/blur/blur.cpp +++ b/effects/blur/blur.cpp @@ -58,6 +58,7 @@ BlurEffect::BlurEffect() XDeleteProperty(display(), rootWindow(), net_wm_blur_region); } connect(effects, SIGNAL(windowAdded(EffectWindow*)), this, SLOT(slotWindowAdded(EffectWindow*))); + connect(effects, SIGNAL(propertyNotify(EffectWindow*,long)), this, SLOT(slotPropertyNotify(EffectWindow*,long))); } BlurEffect::~BlurEffect() @@ -112,7 +113,7 @@ void BlurEffect::slotWindowAdded(EffectWindow *w) updateBlurRegion(w); } -void BlurEffect::propertyNotify(EffectWindow *w, long atom) +void BlurEffect::slotPropertyNotify(EffectWindow *w, long atom) { if (w && atom == net_wm_blur_region) updateBlurRegion(w); diff --git a/effects/blur/blur.h b/effects/blur/blur.h index 4759e7bc4..fbe099741 100644 --- a/effects/blur/blur.h +++ b/effects/blur/blur.h @@ -41,13 +41,13 @@ public: static bool supported(); void reconfigure(ReconfigureFlags flags); - 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); + void slotPropertyNotify(EffectWindow *w, long atom); private: QRect expand(const QRect &rect) const; diff --git a/effects/highlightwindow/highlightwindow.cpp b/effects/highlightwindow/highlightwindow.cpp index 2ee28b5cd..b17562009 100644 --- a/effects/highlightwindow/highlightwindow.cpp +++ b/effects/highlightwindow/highlightwindow.cpp @@ -41,6 +41,7 @@ HighlightWindowEffect::HighlightWindowEffect() connect(effects, SIGNAL(windowAdded(EffectWindow*)), this, SLOT(slotWindowAdded(EffectWindow*))); connect(effects, SIGNAL(windowClosed(EffectWindow*)), this, SLOT(slotWindowClosed(EffectWindow*))); connect(effects, SIGNAL(windowDeleted(EffectWindow*)), this, SLOT(slotWindowDeleted(EffectWindow*))); + connect(effects, SIGNAL(propertyNotify(EffectWindow*,long)), this, SLOT(slotPropertyNotify(EffectWindow*,long))); } HighlightWindowEffect::~HighlightWindowEffect() @@ -115,7 +116,7 @@ void HighlightWindowEffect::slotWindowAdded(EffectWindow* w) else m_windowOpacity[w] = 1.0; } - propertyNotify(w, m_atom); // Check initial value + slotPropertyNotify(w, m_atom); // Check initial value } void HighlightWindowEffect::slotWindowClosed(EffectWindow* w) @@ -129,7 +130,7 @@ void HighlightWindowEffect::slotWindowDeleted(EffectWindow* w) m_windowOpacity.remove(w); } -void HighlightWindowEffect::propertyNotify(EffectWindow* w, long a) +void HighlightWindowEffect::slotPropertyNotify(EffectWindow* w, long a) { if (a != m_atom) return; // Not our atom diff --git a/effects/highlightwindow/highlightwindow.h b/effects/highlightwindow/highlightwindow.h index 4965ed500..c13a887b6 100644 --- a/effects/highlightwindow/highlightwindow.h +++ b/effects/highlightwindow/highlightwindow.h @@ -37,12 +37,11 @@ public: virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time); virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); - virtual void propertyNotify(EffectWindow* w, long atom); - public Q_SLOTS: void slotWindowAdded(EffectWindow* w); void slotWindowClosed(EffectWindow *w); void slotWindowDeleted(EffectWindow *w); + void slotPropertyNotify(EffectWindow* w, long atom); private: void prepareHighlighting(); diff --git a/effects/logout/logout.cpp b/effects/logout/logout.cpp index 9c88b2a5d..02dde1caa 100644 --- a/effects/logout/logout.cpp +++ b/effects/logout/logout.cpp @@ -63,6 +63,7 @@ LogoutEffect::LogoutEffect() connect(effects, SIGNAL(windowAdded(EffectWindow*)), this, SLOT(slotWindowAdded(EffectWindow*))); connect(effects, SIGNAL(windowClosed(EffectWindow*)), this, SLOT(slotWindowClosed(EffectWindow*))); connect(effects, SIGNAL(windowDeleted(EffectWindow*)), this, SLOT(slotWindowDeleted(EffectWindow*))); + connect(effects, SIGNAL(propertyNotify(EffectWindow*,long)), this, SLOT(slotPropertyNotify(EffectWindow*,long))); } LogoutEffect::~LogoutEffect() @@ -366,7 +367,7 @@ void LogoutEffect::renderVignetting() } #endif -void LogoutEffect::propertyNotify(EffectWindow* w, long a) +void LogoutEffect::slotPropertyNotify(EffectWindow* w, long a) { if (w || a != logoutAtom) return; // Not our atom diff --git a/effects/logout/logout.h b/effects/logout/logout.h index 767dcd6ec..555fe01d1 100644 --- a/effects/logout/logout.h +++ b/effects/logout/logout.h @@ -44,11 +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 propertyNotify(EffectWindow* w, long a); public Q_SLOTS: void slotWindowAdded(EffectWindow* w); void slotWindowClosed(EffectWindow *w); void slotWindowDeleted(EffectWindow *w); + void slotPropertyNotify(EffectWindow *w, long a); private: bool isLogoutDialog(EffectWindow* w); double progress; // 0-1 diff --git a/effects/presentwindows/presentwindows.cpp b/effects/presentwindows/presentwindows.cpp index e1a6c4c53..67a2ca7cb 100644 --- a/effects/presentwindows/presentwindows.cpp +++ b/effects/presentwindows/presentwindows.cpp @@ -106,6 +106,7 @@ PresentWindowsEffect::PresentWindowsEffect() connect(effects, SIGNAL(tabBoxClosed()), this, SLOT(slotTabBoxClosed())); connect(effects, SIGNAL(tabBoxUpdated()), this, SLOT(slotTabBoxUpdated())); connect(effects, SIGNAL(tabBoxKeyEvent(QKeyEvent*)), this, SLOT(slotTabBoxKeyEvent(QKeyEvent*))); + connect(effects, SIGNAL(propertyNotify(EffectWindow*,long)), this, SLOT(slotPropertyNotify(EffectWindow*,long))); } PresentWindowsEffect::~PresentWindowsEffect() @@ -741,7 +742,7 @@ void PresentWindowsEffect::slotTabBoxKeyEvent(QKeyEvent* event) //----------------------------------------------------------------------------- // Atom handling -void PresentWindowsEffect::propertyNotify(EffectWindow* w, long a) +void PresentWindowsEffect::slotPropertyNotify(EffectWindow* w, long a) { if (!w || (a != m_atomDesktop && a != m_atomWindows)) return; // Not our atom diff --git a/effects/presentwindows/presentwindows.h b/effects/presentwindows/presentwindows.h index ebcd99298..0edc683a6 100644 --- a/effects/presentwindows/presentwindows.h +++ b/effects/presentwindows/presentwindows.h @@ -106,9 +106,6 @@ public: virtual void windowInputMouseEvent(Window w, QEvent *e); virtual void grabbedKeyboardEvent(QKeyEvent *e); - // atoms - virtual void propertyNotify(EffectWindow* w, long atom); - enum { LayoutNatural, LayoutRegularGrid, LayoutFlexibleGrid }; // Layout modes enum PresentWindowsMode { ModeAllDesktops, // Shows windows of all desktops @@ -160,6 +157,8 @@ public slots: void slotTabBoxClosed(); void slotTabBoxUpdated(); void slotTabBoxKeyEvent(QKeyEvent* event); + // atoms + void slotPropertyNotify(EffectWindow* w, long atom); private slots: void closeWindow(); diff --git a/effects/slidingpopups/slidingpopups.cpp b/effects/slidingpopups/slidingpopups.cpp index 9df500a5a..300881b71 100644 --- a/effects/slidingpopups/slidingpopups.cpp +++ b/effects/slidingpopups/slidingpopups.cpp @@ -41,6 +41,7 @@ SlidingPopupsEffect::SlidingPopupsEffect() connect(effects, SIGNAL(windowAdded(EffectWindow*)), this, SLOT(slotWindowAdded(EffectWindow*))); connect(effects, SIGNAL(windowClosed(EffectWindow*)), this, SLOT(slotWindowClosed(EffectWindow*))); connect(effects, SIGNAL(windowDeleted(EffectWindow*)), this, SLOT(slotWindowDeleted(EffectWindow*))); + connect(effects, SIGNAL(propertyNotify(EffectWindow*,long)), this, SLOT(slotPropertyNotify(EffectWindow*,long))); } SlidingPopupsEffect::~SlidingPopupsEffect() @@ -136,7 +137,7 @@ void SlidingPopupsEffect::postPaintWindow(EffectWindow* w) void SlidingPopupsEffect::slotWindowAdded(EffectWindow *w) { - propertyNotify(w, mAtom); + slotPropertyNotify(w, mAtom); if (w->isOnCurrentDesktop() && mWindowsData.contains(w)) { mAppearingWindows[ w ].setDuration(mWindowsData[ w ].fadeInDuration); mAppearingWindows[ w ].setProgress(0.0); @@ -151,7 +152,7 @@ void SlidingPopupsEffect::slotWindowAdded(EffectWindow *w) void SlidingPopupsEffect::slotWindowClosed(EffectWindow* w) { - propertyNotify(w, mAtom); + slotPropertyNotify(w, mAtom); if (w->isOnCurrentDesktop() && !w->isMinimized() && mWindowsData.contains(w)) { w->refWindow(); mAppearingWindows.remove(w); @@ -174,7 +175,7 @@ void SlidingPopupsEffect::slotWindowDeleted(EffectWindow* w) effects->addRepaint(w->geometry()); } -void SlidingPopupsEffect::propertyNotify(EffectWindow* w, long a) +void SlidingPopupsEffect::slotPropertyNotify(EffectWindow* w, long a) { if (!w || a != mAtom) return; diff --git a/effects/slidingpopups/slidingpopups.h b/effects/slidingpopups/slidingpopups.h index 29f44166b..10533608a 100644 --- a/effects/slidingpopups/slidingpopups.h +++ b/effects/slidingpopups/slidingpopups.h @@ -39,12 +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 propertyNotify(EffectWindow* w, long a); public Q_SLOTS: void slotWindowAdded(EffectWindow *c); void slotWindowClosed(EffectWindow *c); void slotWindowDeleted(EffectWindow *w); + void slotPropertyNotify(EffectWindow *w, long a); private: enum Position { West = 0, diff --git a/effects/taskbarthumbnail/taskbarthumbnail.cpp b/effects/taskbarthumbnail/taskbarthumbnail.cpp index 99f38d888..8f0ccc12a 100644 --- a/effects/taskbarthumbnail/taskbarthumbnail.cpp +++ b/effects/taskbarthumbnail/taskbarthumbnail.cpp @@ -46,6 +46,7 @@ TaskbarThumbnailEffect::TaskbarThumbnailEffect() 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))); + connect(effects, SIGNAL(propertyNotify(EffectWindow*,long)), this, SLOT(slotPropertyNotify(EffectWindow*,long))); } TaskbarThumbnailEffect::~TaskbarThumbnailEffect() @@ -123,7 +124,7 @@ void TaskbarThumbnailEffect::slotWindowDamaged(EffectWindow* w, const QRect& dam void TaskbarThumbnailEffect::slotWindowAdded(EffectWindow* w) { - propertyNotify(w, atom); // read initial value + slotPropertyNotify(w, atom); // read initial value } void TaskbarThumbnailEffect::slotWindowDeleted(EffectWindow* w) @@ -131,7 +132,7 @@ void TaskbarThumbnailEffect::slotWindowDeleted(EffectWindow* w) thumbnails.remove(w); } -void TaskbarThumbnailEffect::propertyNotify(EffectWindow* w, long a) +void TaskbarThumbnailEffect::slotPropertyNotify(EffectWindow* w, long a) { if (!w || a != atom) return; diff --git a/effects/taskbarthumbnail/taskbarthumbnail.h b/effects/taskbarthumbnail/taskbarthumbnail.h index ef4a5f796..5412fe9a7 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 propertyNotify(EffectWindow* w, long atom); public Q_SLOTS: void slotWindowAdded(EffectWindow *w); void slotWindowDeleted(EffectWindow *w); void slotWindowDamaged(EffectWindow* w, const QRect& damage); + void slotPropertyNotify(EffectWindow *w, long atom); private: struct Data { Window window; // thumbnail of this window diff --git a/events.cpp b/events.cpp index 1d928d5f6..955644f3b 100644 --- a/events.cpp +++ b/events.cpp @@ -301,9 +301,9 @@ bool Workspace::workspaceEvent(XEvent * e) } // We want to pass root window property events to effects - if (e->type == PropertyNotify && e->xany.window == rootWindow() && effects) { + if (e->type == PropertyNotify && e->xany.window == rootWindow()) { XPropertyEvent* re = &e->xproperty; - static_cast< EffectsHandlerImpl* >(effects)->propertyNotify(NULL, re->atom); + emit propertyNotify(re->atom); } } if (movingClient != NULL && movingClient->moveResizeGrabWindow() == e->xany.window @@ -1691,8 +1691,7 @@ void Toplevel::propertyNotifyEvent(XPropertyEvent* e) getWindowRole(); break; } - if (effects) - static_cast< EffectsHandlerImpl* >(effects)->propertyNotify(effectWindow(), e->atom); + emit propertyNotify(this, e->atom); } // **************************************** diff --git a/libkwineffects/kwineffects.cpp b/libkwineffects/kwineffects.cpp index 8c9fa3e85..66a007d9b 100644 --- a/libkwineffects/kwineffects.cpp +++ b/libkwineffects/kwineffects.cpp @@ -131,10 +131,6 @@ void Effect::grabbedKeyboardEvent(QKeyEvent*) { } -void Effect::propertyNotify(EffectWindow* , long) -{ -} - bool Effect::borderActivated(ElectricBorder) { return false; diff --git a/libkwineffects/kwineffects.h b/libkwineffects/kwineffects.h index 8e23461a3..a6b5e5ff6 100644 --- a/libkwineffects/kwineffects.h +++ b/libkwineffects/kwineffects.h @@ -444,14 +444,6 @@ public: virtual void windowMoveResizeGeometryUpdate(EffectWindow* c, const QRect& geometry); virtual void windowInputMouseEvent(Window w, QEvent* e); virtual void grabbedKeyboardEvent(QKeyEvent* e); - /** - Receives events registered for using EffectsHandler::registerPropertyType(). - Use readProperty() to get the property data. - Note that the property may be already set on the window, so doing the same - processing from windowAdded() (e.g. simply calling propertyNotify() from it) - is usually needed. - */ - virtual void propertyNotify(EffectWindow* w, long atom); virtual bool borderActivated(ElectricBorder border); @@ -960,6 +952,17 @@ Q_SIGNALS: void mouseChanged(const QPoint& pos, const QPoint& oldpos, Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons, Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers); + /** + * Receives events registered for using @link registerPropertyType. + * Use readProperty() to get the property data. + * Note that the property may be already set on the window, so doing the same + * processing from windowAdded() (e.g. simply calling propertyNotify() from it) + * is usually needed. + * @param w The window whose property changed, is @c null if it is a root window property + * @param atom The property + * @since 4.7 + */ + void propertyNotify(EffectWindow* w, long atom); protected: QVector< EffectPair > loaded_effects; diff --git a/toplevel.h b/toplevel.h index 3bf9528a9..9eb5de8c9 100644 --- a/toplevel.h +++ b/toplevel.h @@ -138,6 +138,7 @@ public: signals: void opacityChanged(KWin::Toplevel* toplevel, qreal oldOpacity); void damaged(KWin::Toplevel* toplevel, const QRect& damage); + void propertyNotify(KWin::Toplevel* toplevel, long a); protected: virtual ~Toplevel(); diff --git a/workspace.h b/workspace.h index 13360aa61..a9db6ecee 100644 --- a/workspace.h +++ b/workspace.h @@ -932,6 +932,7 @@ signals: void mouseChanged(const QPoint& pos, const QPoint& oldpos, Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons, Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers); + void propertyNotify(long a); private: void init();