From 77f0f0eacafd32a88400238780e7fdfdac154279 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Fri, 30 Oct 2009 14:22:33 +0000 Subject: [PATCH] Adding the missing pieces for a nice and fast letterbox resizing as a replacement for the drawbound resizing. Perhaps we should not display the totally ugly drawbound when we have an active resize effect. CCBUG: 208770 CCBUG: 152638 svn path=/trunk/KDE/kdebase/workspace/; revision=1042711 --- effects.cpp | 6 ++++++ effects.h | 1 + effects/resize/resize.cpp | 14 ++++++++++++-- effects/resize/resize.h | 2 ++ geometry.cpp | 3 +++ lib/kwineffects.cpp | 4 ++++ lib/kwineffects.h | 4 +++- 7 files changed, 31 insertions(+), 3 deletions(-) diff --git a/effects.cpp b/effects.cpp index 13872286dc..d6eb1ea09d 100644 --- a/effects.cpp +++ b/effects.cpp @@ -208,6 +208,12 @@ void EffectsHandlerImpl::windowUserMovedResized( EffectWindow* c, bool first, bo ep.second->windowUserMovedResized( c, first, last ); } +void EffectsHandlerImpl::windowMoveResizeGeometryUpdate( EffectWindow* c, const QRect& geometry ) + { + foreach( const EffectPair &ep, loaded_effects ) + ep.second->windowMoveResizeGeometryUpdate( c, geometry ); + } + void EffectsHandlerImpl::windowOpacityChanged( EffectWindow* c, double old_opacity ) { if (!c) diff --git a/effects.h b/effects.h index c1dfcc4285..cf7711540a 100644 --- a/effects.h +++ b/effects.h @@ -139,6 +139,7 @@ class EffectsHandlerImpl : public EffectsHandler // 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 windowAdded( EffectWindow* c ); void windowClosed( EffectWindow* c ); diff --git a/effects/resize/resize.cpp b/effects/resize/resize.cpp index 711918073e..43edd88524 100644 --- a/effects/resize/resize.cpp +++ b/effects/resize/resize.cpp @@ -60,8 +60,8 @@ void ResizeEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Windo effects->paintWindow( w, mask, region, data ); if( m_active && w == m_resizeWindow ) { - QRegion intersection = m_originalWindowRect.intersected( w->geometry() ); - QRegion paintRegion = m_originalWindowRect.united( w->geometry() ).subtracted( intersection ); + QRegion intersection = m_originalWindowRect.intersected( m_currentGeometry ); + QRegion paintRegion = m_originalWindowRect.united( m_currentGeometry ).subtracted( intersection ); float alpha = 0.8f; QColor color = KColorScheme( QPalette::Normal, KColorScheme::Selection ).background().color(); @@ -113,6 +113,7 @@ void ResizeEffect::windowUserMovedResized( EffectWindow* w, bool first, bool las m_active = true; m_resizeWindow = w; m_originalWindowRect = w->geometry(); + m_currentGeometry = w->geometry(); w->addRepaintFull(); } if( m_active && w == m_resizeWindow && last ) @@ -123,4 +124,13 @@ void ResizeEffect::windowUserMovedResized( EffectWindow* w, bool first, bool las } } +void ResizeEffect::windowMoveResizeGeometryUpdate( EffectWindow* c, const QRect& geometry ) + { + if( m_active && c == m_resizeWindow ) + { + m_currentGeometry = geometry; + effects->addRepaintFull(); + } + } + } // namespace diff --git a/effects/resize/resize.h b/effects/resize/resize.h index 4e2057ad46..d2478adc97 100644 --- a/effects/resize/resize.h +++ b/effects/resize/resize.h @@ -35,11 +35,13 @@ class ResizeEffect virtual void prePaintScreen( ScreenPrePaintData& data, int time ); virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ); virtual void windowUserMovedResized( EffectWindow *w, bool first, bool last ); + virtual void windowMoveResizeGeometryUpdate(EffectWindow* c, const QRect& geometry); private: bool m_active; EffectWindow* m_resizeWindow; QRegion m_originalWindowRect; + QRect m_currentGeometry; }; } diff --git a/geometry.cpp b/geometry.cpp index 563138b027..20f9d12aeb 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -3209,7 +3209,10 @@ void Client::performMoveResize() drawbound( moveResizeGeom ); // they overlap; the paint event will come after this, } // so the geometry tip will be painted above the outline if( effects ) + { + static_cast(effects)->windowMoveResizeGeometryUpdate( effectWindow(), moveResizeGeom ); static_cast(effects)->windowUserMovedResized( effectWindow(), false, false ); + } } void Client::syncTimeout() diff --git a/lib/kwineffects.cpp b/lib/kwineffects.cpp index dffbb6cd7f..0afda04d3a 100644 --- a/lib/kwineffects.cpp +++ b/lib/kwineffects.cpp @@ -123,6 +123,10 @@ void Effect::windowUserMovedResized( EffectWindow* , bool, bool ) { } +void Effect::windowMoveResizeGeometryUpdate( EffectWindow* , const QRect& ) + { + } + void Effect::windowOpacityChanged( EffectWindow*, double ) { } diff --git a/lib/kwineffects.h b/lib/kwineffects.h index 5894e9e208..176a6c3a86 100644 --- a/lib/kwineffects.h +++ b/lib/kwineffects.h @@ -170,7 +170,7 @@ X-KDE-Library=kwin4_effect_cooleffect #define KWIN_EFFECT_API_MAKE_VERSION( major, minor ) (( major ) << 8 | ( minor )) #define KWIN_EFFECT_API_VERSION_MAJOR 0 -#define KWIN_EFFECT_API_VERSION_MINOR 105 +#define KWIN_EFFECT_API_VERSION_MINOR 106 #define KWIN_EFFECT_API_VERSION KWIN_EFFECT_API_MAKE_VERSION( \ KWIN_EFFECT_API_VERSION_MAJOR, KWIN_EFFECT_API_VERSION_MINOR ) @@ -384,6 +384,8 @@ class KWIN_EXPORT Effect /** 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 ); virtual void windowAdded( EffectWindow* c ); virtual void windowClosed( EffectWindow* c );