From eeb10c69d5b351ae2a53ac942b50b97fc523e05c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Mon, 28 Feb 2011 21:03:13 +0100 Subject: [PATCH] Signal for windowUserMovedResize In core a new signal is added for maximizedState change of client. Other function calls remain as direct calls for the moment. --- client.h | 1 + effects.cpp | 12 +++++++++--- effects.h | 5 ++++- effects/cube/cubeslide.cpp | 3 ++- effects/cube/cubeslide.h | 2 +- effects/resize/resize.cpp | 3 ++- effects/resize/resize.h | 5 ++++- effects/snaphelper/snaphelper.cpp | 3 ++- effects/snaphelper/snaphelper.h | 2 +- effects/translucency/translucency.cpp | 3 ++- effects/translucency/translucency.h | 2 +- effects/windowgeometry/windowgeometry.cpp | 3 ++- effects/windowgeometry/windowgeometry.h | 2 +- effects/wobblywindows/wobblywindows.cpp | 3 ++- effects/wobblywindows/wobblywindows.h | 2 +- geometry.cpp | 9 ++++----- libkwineffects/kwineffects.cpp | 4 ---- libkwineffects/kwineffects.h | 10 ++++++++-- 18 files changed, 47 insertions(+), 27 deletions(-) diff --git a/client.h b/client.h index 74e98473b1..9ec6d7e411 100644 --- a/client.h +++ b/client.h @@ -495,6 +495,7 @@ signals: void s_activated(); void s_fullScreenSet(bool, bool); void clientClosed(KWin::Client*); + void clientMaximizedStateChanged(KWin::Client*, KDecorationDefines::MaximizeMode); // To make workspace-client calls, a few slots are also // required diff --git a/effects.cpp b/effects.cpp index 6e0c8cf5d4..e145e4e2f5 100644 --- a/effects.cpp +++ b/effects.cpp @@ -104,6 +104,7 @@ EffectsHandlerImpl::EffectsHandlerImpl(CompositingType type) // connect all clients foreach (Client *c, ws->clientList()) { connect(c, SIGNAL(clientClosed(KWin::Client*)), this, SLOT(slotClientClosed(KWin::Client*))); + connect(c, SIGNAL(clientMaximizedStateChanged(KWin::Client*,KDecorationDefines::MaximizeMode)), this, SLOT(slotClientMaximized(KWin::Client*,KDecorationDefines::MaximizeMode))); } foreach (Unmanaged *u, ws->unmanagedList()) { connect(u, SIGNAL(unmanagedClosed(KWin::Unmanaged*)), this, SLOT(slotUnmanagedClosed(KWin::Unmanaged*))); @@ -270,10 +271,14 @@ void EffectsHandlerImpl::startPaint() assert(current_transform == 0); } -void EffectsHandlerImpl::windowUserMovedResized(EffectWindow* c, bool first, bool last) +void EffectsHandlerImpl::slotClientMaximized(KWin::Client *c, KDecorationDefines::MaximizeMode maxMode) { - foreach (const EffectPair & ep, loaded_effects) - ep.second->windowUserMovedResized(c, first, last); + emit windowUserMovedResized(c->effectWindow(), true, true); +} + +void EffectsHandlerImpl::slotWindowUserMovedResized(EffectWindow* c, bool first, bool last) +{ + emit windowUserMovedResized(c, first, last); } void EffectsHandlerImpl::windowMoveResizeGeometryUpdate(EffectWindow* c, const QRect& geometry) @@ -295,6 +300,7 @@ void EffectsHandlerImpl::windowOpacityChanged(EffectWindow* c, double old_opacit void EffectsHandlerImpl::slotClientAdded(Client *c) { connect(c, SIGNAL(clientClosed(KWin::Client*)), this, SLOT(slotClientClosed(KWin::Client*))); + connect(c, SIGNAL(clientMaximizedStateChanged(KWin::Client*,KDecorationDefines::MaximizeMode)), this, SLOT(slotClientMaximized(KWin::Client*,KDecorationDefines::MaximizeMode))); emit windowAdded(c->effectWindow()); } diff --git a/effects.h b/effects.h index d2b655c9d4..28ab72f8d2 100644 --- a/effects.h +++ b/effects.h @@ -158,7 +158,6 @@ public: // internal (used by kwin core or compositing code) void startPaint(); - void windowUserMovedResized(EffectWindow* c, bool first, bool last); void windowMoveResizeGeometryUpdate(EffectWindow* c, const QRect& geometry); void windowOpacityChanged(EffectWindow* c, double old_opacity); void windowMinimized(EffectWindow* c); @@ -191,6 +190,9 @@ public: QList elevatedWindows() const; +public Q_SLOTS: + void slotWindowUserMovedResized(EffectWindow* c, bool first, bool last); + protected Q_SLOTS: void slotDesktopChanged(int old); void slotClientAdded(KWin::Client *c); @@ -199,6 +201,7 @@ protected Q_SLOTS: void slotUnmanagedClosed(KWin::Unmanaged *u); void slotClientActivated(KWin::Client *c); void slotDeletedRemoved(KWin::Deleted *d); + void slotClientMaximized(KWin::Client *c, KDecorationDefines::MaximizeMode maxMode); protected: KLibrary* findEffectLibrary(KService* service); diff --git a/effects/cube/cubeslide.cpp b/effects/cube/cubeslide.cpp index 2f44fbe6e2..d3c6f725de 100644 --- a/effects/cube/cubeslide.cpp +++ b/effects/cube/cubeslide.cpp @@ -39,6 +39,7 @@ CubeSlideEffect::CubeSlideEffect() , progressRestriction(0.0f) { connect(effects, SIGNAL(desktopChanged(int, int)), this, SLOT(slotDesktopChanged(int, int))); + connect(effects, SIGNAL(windowUserMovedResized(EffectWindow*,bool,bool)), this, SLOT(slotWindowUserMovedResized(EffectWindow*,bool,bool))); reconfigure(ReconfigureAll); } @@ -529,7 +530,7 @@ void CubeSlideEffect::slotDesktopChanged(int old, int current) } } -void CubeSlideEffect::windowUserMovedResized(EffectWindow* c, bool first, bool last) +void CubeSlideEffect::slotWindowUserMovedResized(EffectWindow* c, bool first, bool last) { if (!useWindowMoving) return; diff --git a/effects/cube/cubeslide.h b/effects/cube/cubeslide.h index 6485d3e607..9ed11aa244 100644 --- a/effects/cube/cubeslide.h +++ b/effects/cube/cubeslide.h @@ -41,12 +41,12 @@ 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 windowUserMovedResized(EffectWindow* c, bool first, bool last); static bool supported(); private Q_SLOTS: void slotDesktopChanged(int old, int current); + void slotWindowUserMovedResized(EffectWindow *w, bool first, bool last); private: enum RotationDirection { diff --git a/effects/resize/resize.cpp b/effects/resize/resize.cpp index 98567dc5b7..896667ffea 100644 --- a/effects/resize/resize.cpp +++ b/effects/resize/resize.cpp @@ -41,6 +41,7 @@ ResizeEffect::ResizeEffect() , m_resizeWindow(0) { reconfigure(ReconfigureAll); + connect(effects, SIGNAL(windowUserMovedResized(EffectWindow*,bool,bool)), this, SLOT(slotWindowUserMovedResized(EffectWindow*,bool,bool))); } ResizeEffect::~ResizeEffect() @@ -145,7 +146,7 @@ void ResizeEffect::reconfigure(ReconfigureFlags) m_features |= Outline; } -void ResizeEffect::windowUserMovedResized(EffectWindow* w, bool first, bool last) +void ResizeEffect::slotWindowUserMovedResized(EffectWindow* w, bool first, bool last) { if (first && last) { // not interested in maximized diff --git a/effects/resize/resize.h b/effects/resize/resize.h index cc59d719ec..a305918317 100644 --- a/effects/resize/resize.h +++ b/effects/resize/resize.h @@ -29,6 +29,7 @@ namespace KWin class ResizeEffect : public Effect { + Q_OBJECT public: ResizeEffect(); ~ResizeEffect(); @@ -39,9 +40,11 @@ public: virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time); virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); virtual void reconfigure(ReconfigureFlags); - virtual void windowUserMovedResized(EffectWindow *w, bool first, bool last); virtual void windowMoveResizeGeometryUpdate(EffectWindow* c, const QRect& geometry); +public Q_SLOTS: + void slotWindowUserMovedResized(EffectWindow *w, bool first, bool last); + private: enum Feature { TextureScale = 1 << 0, Outline = 1 << 1 }; bool m_active; diff --git a/effects/snaphelper/snaphelper.cpp b/effects/snaphelper/snaphelper.cpp index 7e75c46533..255937410c 100644 --- a/effects/snaphelper/snaphelper.cpp +++ b/effects/snaphelper/snaphelper.cpp @@ -36,6 +36,7 @@ SnapHelperEffect::SnapHelperEffect() m_timeline.setCurveShape(TimeLine::LinearCurve); reconfigure(ReconfigureAll); connect(effects, SIGNAL(windowClosed(EffectWindow*)), this, SLOT(slotWindowClosed(EffectWindow*))); + connect(effects, SIGNAL(windowUserMovedResized(EffectWindow*,bool,bool)), this, SLOT(slotWindowUserMovedResized(EffectWindow*,bool,bool))); /*if ( effects->compositingType() == XRenderCompositing ) { @@ -196,7 +197,7 @@ void SnapHelperEffect::slotWindowClosed(EffectWindow* w) } } -void SnapHelperEffect::windowUserMovedResized(EffectWindow* w, bool first, bool last) +void SnapHelperEffect::slotWindowUserMovedResized(EffectWindow* w, bool first, bool last) { if (first && !last && w->isMovable()) { m_active = true; diff --git a/effects/snaphelper/snaphelper.h b/effects/snaphelper/snaphelper.h index 771c4e4e65..c096644f7e 100644 --- a/effects/snaphelper/snaphelper.h +++ b/effects/snaphelper/snaphelper.h @@ -38,12 +38,12 @@ public: virtual void prePaintScreen(ScreenPrePaintData &data, int time); virtual void postPaintScreen(); - virtual void windowUserMovedResized(EffectWindow* w, bool first, bool last); static bool supported(); public Q_SLOTS: void slotWindowClosed(EffectWindow *w); + void slotWindowUserMovedResized(EffectWindow *w, bool first, bool last); private: bool m_active; diff --git a/effects/translucency/translucency.cpp b/effects/translucency/translucency.cpp index a46d3f2edf..d635732d94 100644 --- a/effects/translucency/translucency.cpp +++ b/effects/translucency/translucency.cpp @@ -35,6 +35,7 @@ TranslucencyEffect::TranslucencyEffect() reconfigure(ReconfigureAll); active = effects->activeWindow(); connect(effects, SIGNAL(windowActivated(EffectWindow*)), this, SLOT(slotWindowActivated(EffectWindow*))); + connect(effects, SIGNAL(windowUserMovedResized(EffectWindow*,bool,bool)), this, SLOT(slotWindowUserMovedResized(EffectWindow*,bool,bool))); } void TranslucencyEffect::reconfigure(ReconfigureFlags) @@ -176,7 +177,7 @@ bool TranslucencyEffect::isInactive(const EffectWindow* w) const return true; } -void TranslucencyEffect::windowUserMovedResized(EffectWindow* w, bool first, bool last) +void TranslucencyEffect::slotWindowUserMovedResized(EffectWindow* w, bool first, bool last) { if (moveresize != 1.0 && (first || last)) { moveresize_timeline.setProgress(0.0); diff --git a/effects/translucency/translucency.h b/effects/translucency/translucency.h index b782dc2c7d..f239b59480 100644 --- a/effects/translucency/translucency.h +++ b/effects/translucency/translucency.h @@ -33,12 +33,12 @@ class TranslucencyEffect public: TranslucencyEffect(); virtual void reconfigure(ReconfigureFlags); - virtual void windowUserMovedResized(EffectWindow* c, bool first, bool last); virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time); virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); public Q_SLOTS: void slotWindowActivated(EffectWindow* w); + void slotWindowUserMovedResized(EffectWindow *c, bool first, bool last); private: bool isInactive(const EffectWindow *w) const; diff --git a/effects/windowgeometry/windowgeometry.cpp b/effects/windowgeometry/windowgeometry.cpp index 3574d7f96a..ab4a819c92 100644 --- a/effects/windowgeometry/windowgeometry.cpp +++ b/effects/windowgeometry/windowgeometry.cpp @@ -60,6 +60,7 @@ WindowGeometry::WindowGeometry() a->setText(i18n("Toggle window geometry display (effect only)")); a->setGlobalShortcut(KShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_F11)); connect(a, SIGNAL(triggered(bool)), this, SLOT(toggle())); + connect(effects, SIGNAL(windowUserMovedResized(EffectWindow*,bool,bool)), this, SLOT(slotWindowUserMovedResized(EffectWindow*,bool,bool))); } WindowGeometry::~WindowGeometry() @@ -89,7 +90,7 @@ void WindowGeometry::toggle() iAmActivated = !iAmActivated; } -void WindowGeometry::windowUserMovedResized(EffectWindow* w, bool first, bool last) +void WindowGeometry::slotWindowUserMovedResized(EffectWindow* w, bool first, bool last) { if (first && last) // "maximized" return; diff --git a/effects/windowgeometry/windowgeometry.h b/effects/windowgeometry/windowgeometry.h index 993b4aee77..b795fa7e0b 100644 --- a/effects/windowgeometry/windowgeometry.h +++ b/effects/windowgeometry/windowgeometry.h @@ -38,11 +38,11 @@ public: } void reconfigure(ReconfigureFlags); void paintScreen(int mask, QRegion region, ScreenPaintData &data); - void windowUserMovedResized(EffectWindow* w, bool first, bool last); void windowMoveResizeGeometryUpdate(EffectWindow* c, const QRect& geometry); private slots: void toggle(); + void slotWindowUserMovedResized(EffectWindow *w, bool first, bool last); private: EffectWindow *myResizeWindow; EffectFrame *myMeasure[3]; diff --git a/effects/wobblywindows/wobblywindows.cpp b/effects/wobblywindows/wobblywindows.cpp index 27594b882e..529ab644fd 100644 --- a/effects/wobblywindows/wobblywindows.cpp +++ b/effects/wobblywindows/wobblywindows.cpp @@ -167,6 +167,7 @@ WobblyWindowsEffect::WobblyWindowsEffect() reconfigure(ReconfigureAll); connect(effects, SIGNAL(windowAdded(EffectWindow*)), this, SLOT(slotWindowAdded(EffectWindow*))); connect(effects, SIGNAL(windowClosed(EffectWindow*)), this, SLOT(slotWindowClosed(EffectWindow*))); + connect(effects, SIGNAL(windowUserMovedResized(EffectWindow*,bool,bool)), this, SLOT(slotWindowUserMovedResized(EffectWindow*,bool,bool))); } WobblyWindowsEffect::~WobblyWindowsEffect() @@ -358,7 +359,7 @@ void WobblyWindowsEffect::postPaintScreen() effects->postPaintScreen(); } -void WobblyWindowsEffect::windowUserMovedResized(EffectWindow* w, bool first, bool last) +void WobblyWindowsEffect::slotWindowUserMovedResized(EffectWindow* w, bool first, bool last) { if (!m_moveEffectEnabled || w->isSpecialWindow()) return; diff --git a/effects/wobblywindows/wobblywindows.h b/effects/wobblywindows/wobblywindows.h index ff16980293..8e5bb4d2fa 100644 --- a/effects/wobblywindows/wobblywindows.h +++ b/effects/wobblywindows/wobblywindows.h @@ -35,7 +35,6 @@ public: virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time); virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); virtual void postPaintScreen(); - virtual void windowUserMovedResized(EffectWindow* c, bool first, bool last); // Wobbly model parameters void setStiffness(qreal stiffness); @@ -60,6 +59,7 @@ public: public Q_SLOTS: void slotWindowAdded(EffectWindow *w); void slotWindowClosed(EffectWindow *w); + void slotWindowUserMovedResized(EffectWindow *w, bool first, bool last); private: diff --git a/geometry.cpp b/geometry.cpp index 99e190b16b..afa7c3448e 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -2092,8 +2092,7 @@ void Client::setMaximize(bool vertically, bool horizontally) max_mode & MaximizeVertical ? !vertically : vertically, max_mode & MaximizeHorizontal ? !horizontally : horizontally, false); - if (effects) - static_cast(effects)->windowUserMovedResized(effectWindow(), true, true); + emit clientMaximizedStateChanged(this, max_mode); // Update states of all other windows in this group if (clientGroup()) @@ -2645,7 +2644,7 @@ bool Client::startMoveResize() } Notify::raise(isResize() ? Notify::ResizeStart : Notify::MoveStart); if (effects) - static_cast(effects)->windowUserMovedResized(effectWindow(), true, false); + static_cast(effects)->slotWindowUserMovedResized(effectWindow(), true, false); if (options->electricBorders() == Options::ElectricMoveOnly || options->electricBorderMaximize() || options->electricBorderTiling()) @@ -2757,7 +2756,7 @@ void Client::finishMoveResize(bool cancel) Notify::raise(isResize() ? Notify::ResizeEnd : Notify::MoveEnd); if (effects) - static_cast(effects)->windowUserMovedResized(effectWindow(), false, true); + static_cast(effects)->slotWindowUserMovedResized(effectWindow(), false, true); } void Client::leaveMoveResize() @@ -3148,7 +3147,7 @@ void Client::performMoveResize() } if (effects) { static_cast(effects)->windowMoveResizeGeometryUpdate(effectWindow(), moveResizeGeom); - static_cast(effects)->windowUserMovedResized(effectWindow(), false, false); + static_cast(effects)->slotWindowUserMovedResized(effectWindow(), false, false); } } diff --git a/libkwineffects/kwineffects.cpp b/libkwineffects/kwineffects.cpp index 0b577dfaff..8749d2a3c8 100644 --- a/libkwineffects/kwineffects.cpp +++ b/libkwineffects/kwineffects.cpp @@ -119,10 +119,6 @@ void* Effect::proxy() return NULL; } -void Effect::windowUserMovedResized(EffectWindow* , bool, bool) -{ -} - void Effect::windowMoveResizeGeometryUpdate(EffectWindow* , const QRect&) { } diff --git a/libkwineffects/kwineffects.h b/libkwineffects/kwineffects.h index 264ddaf02b..ad72827be9 100644 --- a/libkwineffects/kwineffects.h +++ b/libkwineffects/kwineffects.h @@ -440,8 +440,6 @@ public: **/ virtual QRect transformWindowDamage(EffectWindow* w, const QRect& r); - /** called when moved/resized or once after it's finished */ - virtual void windowUserMovedResized(EffectWindow* c, bool first, bool last); /** called when the geometry changed during moving/resizing. */ virtual void windowMoveResizeGeometryUpdate(EffectWindow* c, const QRect& geometry); virtual void windowOpacityChanged(EffectWindow* c, double old_opacity); @@ -868,6 +866,14 @@ Q_SIGNALS: * @since 4.7 **/ void windowDeleted(EffectWindow *w); + /** 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. + * @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. + * @since 4.7 + **/ + void windowUserMovedResized(EffectWindow *w, bool first, bool last); protected: QVector< EffectPair > loaded_effects;