From 68d958c237ed7ab76e2de8e82ea60af2ec396da6 Mon Sep 17 00:00:00 2001 From: Lucas Murray Date: Mon, 29 Sep 2008 02:25:02 +0000 Subject: [PATCH] Added reset methods to WindowMotionManager. Fixed bug in present windows when if there is only one window on a Xinerama screen it is zoomed into nothingness when using the natural layout. CCBUG: 171812 svn path=/trunk/KDE/kdebase/workspace/; revision=865798 --- effects/presentwindows.cpp | 7 +++++++ lib/kwineffects.cpp | 28 ++++++++++++++++++++++++++++ lib/kwineffects.h | 11 +++++++++++ 3 files changed, 46 insertions(+) diff --git a/effects/presentwindows.cpp b/effects/presentwindows.cpp index 5bb44f2de5..92b6864d8e 100644 --- a/effects/presentwindows.cpp +++ b/effects/presentwindows.cpp @@ -730,6 +730,13 @@ void PresentWindowsEffect::calculateWindowTransformationsKompose( EffectWindowLi void PresentWindowsEffect::calculateWindowTransformationsNatural( EffectWindowList windowlist, int screen ) { + if( windowlist.count() == 1 ) + { // No idea why this is needed but if there is only one window on a Xinerama screen + // then the window is scaled into nothingness at (0,0) if its position isn't reset. + m_motionManager.reset( windowlist[0] ); + return; + } + // As we are using pseudo-random movement (See "slot") we need to make sure the list // is always sorted the same way no matter which window is currently active. qSort( windowlist ); diff --git a/lib/kwineffects.cpp b/lib/kwineffects.cpp index 41671345b9..9edb67ece0 100644 --- a/lib/kwineffects.cpp +++ b/lib/kwineffects.cpp @@ -1153,6 +1153,34 @@ void WindowMotionManager::calculate( int time ) } } +void WindowMotionManager::reset() + { + if( !m_managedWindows.count() ) + return; + + EffectWindowList windows = m_managedWindows.keys(); + + for( int i = 0; i < windows.size(); i++ ) + { + EffectWindow *w = windows.at( i ); + m_managedWindows[ w ].translation.setTarget( w->pos() ); + m_managedWindows[ w ].translation.finish(); + m_managedWindows[ w ].scale.setTarget( QPointF( 1.0, 1.0 )); + m_managedWindows[ w ].scale.finish(); + } + } + +void WindowMotionManager::reset( EffectWindow *w ) + { + if( !m_managedWindows.contains( w )) + return; + + m_managedWindows[ w ].translation.setTarget( w->pos() ); + m_managedWindows[ w ].translation.finish(); + m_managedWindows[ w ].scale.setTarget( QPointF( 1.0, 1.0 )); + m_managedWindows[ w ].scale.finish(); + } + void WindowMotionManager::apply( EffectWindow *w, WindowPaintData &data ) { if( !m_managedWindows.contains( w )) diff --git a/lib/kwineffects.h b/lib/kwineffects.h index a8caee5cd7..2845f3e5d7 100644 --- a/lib/kwineffects.h +++ b/lib/kwineffects.h @@ -1315,6 +1315,17 @@ class KWIN_EXPORT WindowMotionManager * WindowPrePaintData::setTransformed() */ void apply( EffectWindow *w, WindowPaintData &data ); + /** + * Set all motion targets and values back to where the + * windows were before transformations. The same as + * unmanaging then remanaging all windows. + */ + void reset(); + /** + * Resets the motion target and current value of a single + * window. + */ + void reset( EffectWindow *w ); /** * As the manager to move the window to the target position