From 911098ee76a06d06540293bf6550be20633408c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Sat, 12 Mar 2011 12:34:59 +0100 Subject: [PATCH] WindowGeometryShapeChanged becomes a signal --- client.cpp | 14 ++++++-------- client.h | 1 + effects.cpp | 22 +++++++++++++++++----- effects.h | 3 ++- effects/boxswitch/boxswitch.cpp | 3 ++- effects/boxswitch/boxswitch.h | 2 +- effects/desktopgrid/desktopgrid.cpp | 3 ++- effects/desktopgrid/desktopgrid.h | 2 +- effects/presentwindows/presentwindows.cpp | 3 ++- effects/presentwindows/presentwindows.h | 2 +- effects/thumbnailaside/thumbnailaside.cpp | 3 ++- effects/thumbnailaside/thumbnailaside.h | 2 +- events.cpp | 6 ++---- geometry.cpp | 6 ++---- libkwineffects/kwineffects.cpp | 4 ---- libkwineffects/kwineffects.h | 18 ++++++++++++++++-- unmanaged.h | 1 + 17 files changed, 59 insertions(+), 36 deletions(-) diff --git a/client.cpp b/client.cpp index 78bd1efde2..d4b9dc7e5a 100644 --- a/client.cpp +++ b/client.cpp @@ -366,8 +366,7 @@ void Client::updateDecoration(bool check_workspace_pos, bool force) discardWindowPixmap(); if (scene != NULL) scene->windowGeometryShapeChanged(this); - if (effects != NULL) - static_cast(effects)->windowGeometryShapeChanged(effectWindow(), oldgeom); + emit clientGeometryShapeChanged(this, oldgeom); } else destroyDecoration(); if (check_workspace_pos) @@ -396,8 +395,9 @@ void Client::destroyDecoration() discardWindowPixmap(); if (scene != NULL && !deleting) scene->windowGeometryShapeChanged(this); - if (effects != NULL && !deleting) - static_cast(effects)->windowGeometryShapeChanged(effectWindow(), oldgeom); + if (!deleting) { + emit clientGeometryShapeChanged(this, oldgeom); + } } } @@ -739,8 +739,7 @@ void Client::updateShape() } if (scene != NULL) scene->windowGeometryShapeChanged(this); - if (effects != NULL) - static_cast(effects)->windowGeometryShapeChanged(effectWindow(), geometry()); + emit clientGeometryShapeChanged(this, geometry()); } static Window shape_helper_window = None; @@ -818,8 +817,7 @@ void Client::setMask(const QRegion& reg, int mode) } if (scene != NULL) scene->windowGeometryShapeChanged(this); - if (effects != NULL) - static_cast(effects)->windowGeometryShapeChanged(effectWindow(), geometry()); + emit clientGeometryShapeChanged(this, geometry()); updateShape(); } diff --git a/client.h b/client.h index f36adbde13..40e08c8bb8 100644 --- a/client.h +++ b/client.h @@ -498,6 +498,7 @@ signals: void clientMaximizedStateChanged(KWin::Client*, KDecorationDefines::MaximizeMode); void clientMinimized(KWin::Client* client, bool animate); void clientUnminimized(KWin::Client* client, bool animate); + void clientGeometryShapeChanged(KWin::Client* client, const QRect& old); // To make workspace-client calls, a few slots are also // required diff --git a/effects.cpp b/effects.cpp index c2c401dbd1..4689422857 100644 --- a/effects.cpp +++ b/effects.cpp @@ -134,12 +134,14 @@ void EffectsHandlerImpl::setupClientConnections(Client* c) connect(c, SIGNAL(opacityChanged(KWin::Toplevel*,qreal)), this, SLOT(slotOpacityChanged(KWin::Toplevel*,qreal))); 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))); } 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))); } void EffectsHandlerImpl::reconfigure() @@ -395,12 +397,22 @@ void EffectsHandlerImpl::windowDamaged(EffectWindow* w, const QRect& r) ep.second->windowDamaged(w, r); } -void EffectsHandlerImpl::windowGeometryShapeChanged(EffectWindow* w, const QRect& old) +void EffectsHandlerImpl::slotClientGeometryShapeChanged(Client* c, const QRect& old) { - if (w == NULL) // during late cleanup effectWindow() may be already NULL - return; // in some functions that may still call this - foreach (const EffectPair & ep, loaded_effects) - ep.second->windowGeometryShapeChanged(w, old); + // during late cleanup effectWindow() may be already NULL + // in some functions that may still call this + if (c == NULL || c->effectWindow() == NULL) + return; + emit windowGeometryShapeChanged(c->effectWindow(), old); +} + +void EffectsHandlerImpl::slotUnmanagedGeometryShapeChanged(Unmanaged* u, const QRect& old) +{ + // during late cleanup effectWindow() may be already NULL + // in some functions that may still call this + if (u == NULL || u->effectWindow() == NULL) + return; + emit windowGeometryShapeChanged(u->effectWindow(), old); } void EffectsHandlerImpl::setActiveFullScreenEffect(Effect* e) diff --git a/effects.h b/effects.h index 31ed151684..9b315d54c8 100644 --- a/effects.h +++ b/effects.h @@ -160,7 +160,6 @@ public: void startPaint(); void windowMoveResizeGeometryUpdate(EffectWindow* c, const QRect& geometry); void windowDamaged(EffectWindow* w, const QRect& r); - void windowGeometryShapeChanged(EffectWindow* w, const QRect& old); bool borderActivated(ElectricBorder border); void mouseChanged(const QPoint& pos, const QPoint& oldpos, Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons, @@ -197,6 +196,8 @@ protected Q_SLOTS: void slotOpacityChanged(KWin::Toplevel *t, qreal oldOpacity); void slotClientMinimized(KWin::Client *c, bool animate); void slotClientUnminimized(KWin::Client *c, bool animate); + void slotClientGeometryShapeChanged(KWin::Client *c, const QRect &old); + void slotUnmanagedGeometryShapeChanged(KWin::Unmanaged *u, const QRect &old); protected: KLibrary* findEffectLibrary(KService* service); diff --git a/effects/boxswitch/boxswitch.cpp b/effects/boxswitch/boxswitch.cpp index c243f1d049..98edd4f09d 100644 --- a/effects/boxswitch/boxswitch.cpp +++ b/effects/boxswitch/boxswitch.cpp @@ -61,6 +61,7 @@ BoxSwitchEffect::BoxSwitchEffect() connect(effects, SIGNAL(tabBoxAdded(int)), this, SLOT(slotTabBoxAdded(int))); 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))); } BoxSwitchEffect::~BoxSwitchEffect() @@ -273,7 +274,7 @@ void BoxSwitchEffect::windowDamaged(EffectWindow* w, const QRect& damage) } } -void BoxSwitchEffect::windowGeometryShapeChanged(EffectWindow* w, const QRect& old) +void BoxSwitchEffect::slotWindowGeometryShapeChanged(EffectWindow* w, const QRect& old) { if (mActivated) { if (mMode == TabBoxWindowsMode || mMode == TabBoxWindowsAlternativeMode) { diff --git a/effects/boxswitch/boxswitch.h b/effects/boxswitch/boxswitch.h index 61ffed5f60..daa4f162fe 100644 --- a/effects/boxswitch/boxswitch.h +++ b/effects/boxswitch/boxswitch.h @@ -54,7 +54,6 @@ public: virtual void windowInputMouseEvent(Window w, QEvent* e); virtual void windowDamaged(EffectWindow* w, const QRect& damage); - virtual void windowGeometryShapeChanged(EffectWindow* w, const QRect& old); 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 slotTabBoxAdded(int mode); void slotTabBoxClosed(); void slotTabBoxUpdated(); + void slotWindowGeometryShapeChanged(EffectWindow *w, const QRect &old); private: class ItemInfo; diff --git a/effects/desktopgrid/desktopgrid.cpp b/effects/desktopgrid/desktopgrid.cpp index a8cf93481a..b798c9b2f3 100644 --- a/effects/desktopgrid/desktopgrid.cpp +++ b/effects/desktopgrid/desktopgrid.cpp @@ -77,6 +77,7 @@ DesktopGridEffect::DesktopGridEffect() connect(effects, SIGNAL(windowClosed(EffectWindow*)), this, SLOT(slotWindowClosed(EffectWindow*))); connect(effects, SIGNAL(windowDeleted(EffectWindow*)), this, SLOT(slotWindowDeleted(EffectWindow*))); connect(effects, SIGNAL(numberDesktopsChanged(int)), this, SLOT(slotNumberDesktopsChanged(int))); + connect(effects, SIGNAL(windowGeometryShapeChanged(EffectWindow*,QRect)), this, SLOT(slotWindowGeometryShapeChanged(EffectWindow*,QRect))); // Load all other configuration details reconfigure(ReconfigureAll); @@ -439,7 +440,7 @@ void DesktopGridEffect::slotWindowDeleted(EffectWindow* w) } } -void DesktopGridEffect::windowGeometryShapeChanged(EffectWindow* w, const QRect& old) +void DesktopGridEffect::slotWindowGeometryShapeChanged(EffectWindow* w, const QRect& old) { Q_UNUSED(old) if (!activated) diff --git a/effects/desktopgrid/desktopgrid.h b/effects/desktopgrid/desktopgrid.h index ea08abcee4..b8b254eac6 100644 --- a/effects/desktopgrid/desktopgrid.h +++ b/effects/desktopgrid/desktopgrid.h @@ -71,7 +71,6 @@ public: virtual void postPaintScreen(); virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time); virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); - virtual void windowGeometryShapeChanged(EffectWindow* w, const QRect& old); virtual void windowInputMouseEvent(Window w, QEvent* e); virtual void grabbedKeyboardEvent(QKeyEvent* e); virtual bool borderActivated(ElectricBorder border); @@ -89,6 +88,7 @@ private slots: void slotWindowClosed(EffectWindow *w); void slotWindowDeleted(EffectWindow *w); void slotNumberDesktopsChanged(int old); + void slotWindowGeometryShapeChanged(EffectWindow *w, const QRect &old); private: QPointF scalePos(const QPoint& pos, int desktop, int screen = -1) const; diff --git a/effects/presentwindows/presentwindows.cpp b/effects/presentwindows/presentwindows.cpp index f6980fcef8..e1a6c4c53e 100644 --- a/effects/presentwindows/presentwindows.cpp +++ b/effects/presentwindows/presentwindows.cpp @@ -101,6 +101,7 @@ PresentWindowsEffect::PresentWindowsEffect() 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(windowGeometryShapeChanged(EffectWindow*,QRect)), this, SLOT(slotWindowGeometryShapeChanged(EffectWindow*,QRect))); connect(effects, SIGNAL(tabBoxAdded(int)), this, SLOT(slotTabBoxAdded(int))); connect(effects, SIGNAL(tabBoxClosed()), this, SLOT(slotTabBoxClosed())); connect(effects, SIGNAL(tabBoxUpdated()), this, SLOT(slotTabBoxUpdated())); @@ -419,7 +420,7 @@ void PresentWindowsEffect::slotWindowDeleted(EffectWindow *w) m_motionManager.unmanage(w); } -void PresentWindowsEffect::windowGeometryShapeChanged(EffectWindow* w, const QRect& old) +void PresentWindowsEffect::slotWindowGeometryShapeChanged(EffectWindow* w, const QRect& old) { Q_UNUSED(old) if (!m_activated) diff --git a/effects/presentwindows/presentwindows.h b/effects/presentwindows/presentwindows.h index abd02b850c..ebcd992982 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 windowGeometryShapeChanged(EffectWindow* w, const QRect& old); virtual bool borderActivated(ElectricBorder border); virtual void windowInputMouseEvent(Window w, QEvent *e); virtual void grabbedKeyboardEvent(QKeyEvent *e); @@ -155,6 +154,7 @@ public slots: void slotWindowAdded(EffectWindow *w); void slotWindowClosed(EffectWindow *w); void slotWindowDeleted(EffectWindow *w); + void slotWindowGeometryShapeChanged(EffectWindow *w, const QRect &old); // Tab box void slotTabBoxAdded(int mode); void slotTabBoxClosed(); diff --git a/effects/thumbnailaside/thumbnailaside.cpp b/effects/thumbnailaside/thumbnailaside.cpp index 51ea8834a3..692aeeec62 100644 --- a/effects/thumbnailaside/thumbnailaside.cpp +++ b/effects/thumbnailaside/thumbnailaside.cpp @@ -39,6 +39,7 @@ ThumbnailAsideEffect::ThumbnailAsideEffect() a->setGlobalShortcut(KShortcut(Qt::CTRL + Qt::META + Qt::Key_T)); 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))); reconfigure(ReconfigureAll); } @@ -75,7 +76,7 @@ void ThumbnailAsideEffect::windowDamaged(EffectWindow* w, const QRect&) } } -void ThumbnailAsideEffect::windowGeometryShapeChanged(EffectWindow* w, const QRect& old) +void ThumbnailAsideEffect::slotWindowGeometryShapeChanged(EffectWindow* w, const QRect& old) { foreach (const Data & d, windows) { if (d.window == w) { diff --git a/effects/thumbnailaside/thumbnailaside.h b/effects/thumbnailaside/thumbnailaside.h index a27b9b57d6..87106a7dbc 100644 --- a/effects/thumbnailaside/thumbnailaside.h +++ b/effects/thumbnailaside/thumbnailaside.h @@ -44,10 +44,10 @@ public: virtual void reconfigure(ReconfigureFlags); virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data); virtual void windowDamaged(EffectWindow* w, const QRect& damage); - virtual void windowGeometryShapeChanged(EffectWindow* w, const QRect& old); private slots: void toggleCurrentThumbnail(); void slotWindowClosed(EffectWindow *w); + void slotWindowGeometryShapeChanged(EffectWindow *w, const QRect &old); private: void addThumbnail(EffectWindow* w); void removeThumbnail(EffectWindow* w); diff --git a/events.cpp b/events.cpp index e4b595afe1..1d928d5f67 100644 --- a/events.cpp +++ b/events.cpp @@ -1636,8 +1636,7 @@ bool Unmanaged::windowEvent(XEvent* e) addWorkspaceRepaint(geometry()); // in case shape change removes part of this window if (scene != NULL) scene->windowGeometryShapeChanged(this); - if (effects != NULL) - static_cast(effects)->windowGeometryShapeChanged(effectWindow(), geometry()); + emit unmanagedGeometryShapeChanged(this, geometry()); } #ifdef HAVE_XDAMAGE if (e->type == Extensions::damageNotifyEvent()) @@ -1672,8 +1671,7 @@ void Unmanaged::configureNotifyEvent(XConfigureEvent* e) discardWindowPixmap(); if (scene != NULL) scene->windowGeometryShapeChanged(this); - if (effects != NULL) - static_cast(effects)->windowGeometryShapeChanged(effectWindow(), old); + emit unmanagedGeometryShapeChanged(this, old); } } diff --git a/geometry.cpp b/geometry.cpp index afa7c3448e..53df22101d 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -1913,8 +1913,7 @@ void Client::setGeometry(int x, int y, int w, int h, ForceGeometry_t force, bool discardWindowPixmap(); if (scene != NULL) scene->windowGeometryShapeChanged(this); - if (effects != NULL) - static_cast(effects)->windowGeometryShapeChanged(effectWindow(), geom_before_block); + emit clientGeometryShapeChanged(this, geom_before_block); } const QRect deco_rect = decorationRect().translated(geom.x(), geom.y()); addWorkspaceRepaint(deco_rect_before_block); @@ -1991,8 +1990,7 @@ void Client::plainResize(int w, int h, ForceGeometry_t force, bool emitJs) discardWindowPixmap(); if (scene != NULL) scene->windowGeometryShapeChanged(this); - if (effects != NULL) - static_cast(effects)->windowGeometryShapeChanged(effectWindow(), geom_before_block); + emit clientGeometryShapeChanged(this, geom_before_block); const QRect deco_rect = decorationRect().translated(geom.x(), geom.y()); addWorkspaceRepaint(deco_rect_before_block); addWorkspaceRepaint(deco_rect); diff --git a/libkwineffects/kwineffects.cpp b/libkwineffects/kwineffects.cpp index b34f853d22..99e89e0eb6 100644 --- a/libkwineffects/kwineffects.cpp +++ b/libkwineffects/kwineffects.cpp @@ -139,10 +139,6 @@ void Effect::windowDamaged(EffectWindow*, const QRect&) { } -void Effect::windowGeometryShapeChanged(EffectWindow*, const QRect&) -{ -} - bool Effect::borderActivated(ElectricBorder) { return false; diff --git a/libkwineffects/kwineffects.h b/libkwineffects/kwineffects.h index fe6cfc3096..de55f1438b 100644 --- a/libkwineffects/kwineffects.h +++ b/libkwineffects/kwineffects.h @@ -444,7 +444,6 @@ public: 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 windowGeometryShapeChanged(EffectWindow* w, const QRect& old); virtual void mouseChanged(const QPoint& pos, const QPoint& oldpos, Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons, Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers); @@ -856,14 +855,29 @@ Q_SIGNALS: * @since 4.7 **/ void windowDeleted(EffectWindow *w); - /** Signal emitted when window moved/resized or once after it's finished. + /** + * Signal emitted when window moved/resized or once after it's finished. * If both @p first and @p last are true, @p w got maximized/restored. + * This signal is emitted during user interaction and not when the window + * changes it's size itself. The latter case triggers the windowGeometryShapeChanged signal. * @param w The window which is being moved or resized * @param first @c true if first change * @param last @c true if last change, that is move/resize finished. + * @see windowGeometryShapeChanged * @since 4.7 **/ void windowUserMovedResized(EffectWindow *w, bool first, bool last); + /** + * Signal emitted when the geometry or shape of a window changed. + * This is caused if the window changes geometry without user interaction. + * E.g. the decoration is changed. This is in opposite to windowUserMovedResized + * which is caused by direct user interaction. + * @param w The window whose geometry changed + * @param old The previous geometry + * @see windowUserMovedResized + * @since 4.7 + **/ + void windowGeometryShapeChanged(EffectWindow *w, const QRect &old); /** * Signal emitted when the windows opacity is changed. * @param w The window whose opacity level is changed. diff --git a/unmanaged.h b/unmanaged.h index c801c4b3de..777deaae7b 100644 --- a/unmanaged.h +++ b/unmanaged.h @@ -48,6 +48,7 @@ protected: virtual bool shouldUnredirect() const; Q_SIGNALS: void unmanagedClosed(KWin::Unmanaged*); + void unmanagedGeometryShapeChanged(KWin::Unmanaged*, const QRect&); private: virtual ~Unmanaged(); // use release() // handlers for X11 events