slide further away if the user moves the active window
svn path=/trunk/KDE/kdebase/workspace/; revision=956891
This commit is contained in:
parent
6396ee5be6
commit
713e3b0c61
2 changed files with 62 additions and 32 deletions
|
@ -73,33 +73,7 @@ void SlideBackEffect::windowActivated( EffectWindow* w )
|
||||||
effects->setElevatedWindow( tmp, true );
|
effects->setElevatedWindow( tmp, true );
|
||||||
elevatedList.append( tmp );
|
elevatedList.append( tmp );
|
||||||
|
|
||||||
// Determine the shortest way:
|
QRect slideRect = getSlideDestination( w->geometry(), tmp->geometry() );
|
||||||
int leftSlide = w->geometry().left() - tmp->geometry().right() - 20;
|
|
||||||
int rightSlide = w->geometry().right() - tmp->geometry().left() + 20;
|
|
||||||
int upSlide = w->geometry().top() - tmp->geometry().bottom() - 20;
|
|
||||||
int downSlide = w->geometry().bottom() - tmp->geometry().top() + 20;
|
|
||||||
|
|
||||||
int horizSlide = leftSlide;
|
|
||||||
if( abs( horizSlide ) > abs( rightSlide ) )
|
|
||||||
{
|
|
||||||
horizSlide = rightSlide;
|
|
||||||
}
|
|
||||||
int vertSlide = upSlide;
|
|
||||||
if( abs( vertSlide ) > abs( downSlide ) )
|
|
||||||
{
|
|
||||||
vertSlide = downSlide;
|
|
||||||
}
|
|
||||||
|
|
||||||
QRect slideRect = tmp->geometry();
|
|
||||||
if( abs( horizSlide ) < abs( vertSlide ) )
|
|
||||||
{
|
|
||||||
slideRect.moveLeft( slideRect.x() + horizSlide );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
slideRect.moveTop( slideRect.y() + vertSlide );
|
|
||||||
}
|
|
||||||
|
|
||||||
motionManager.manage( tmp );
|
motionManager.manage( tmp );
|
||||||
motionManager.moveWindow( tmp, slideRect );
|
motionManager.moveWindow( tmp, slideRect );
|
||||||
destinationList.insert( tmp, slideRect );
|
destinationList.insert( tmp, slideRect );
|
||||||
|
@ -139,6 +113,37 @@ void SlideBackEffect::windowActivated( EffectWindow* w )
|
||||||
updateStackingOrder();
|
updateStackingOrder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QRect SlideBackEffect::getSlideDestination( const QRect &windowUnderGeometry, const QRect &windowOverGeometry)
|
||||||
|
{
|
||||||
|
// Determine the shortest way:
|
||||||
|
int leftSlide = windowUnderGeometry.left() - windowOverGeometry.right() - 20;
|
||||||
|
int rightSlide = windowUnderGeometry.right() - windowOverGeometry.left() + 20;
|
||||||
|
int upSlide = windowUnderGeometry.top() - windowOverGeometry.bottom() - 20;
|
||||||
|
int downSlide = windowUnderGeometry.bottom() - windowOverGeometry.top() + 20;
|
||||||
|
|
||||||
|
int horizSlide = leftSlide;
|
||||||
|
if( abs( horizSlide ) > abs( rightSlide ) )
|
||||||
|
{
|
||||||
|
horizSlide = rightSlide;
|
||||||
|
}
|
||||||
|
int vertSlide = upSlide;
|
||||||
|
if( abs( vertSlide ) > abs( downSlide ) )
|
||||||
|
{
|
||||||
|
vertSlide = downSlide;
|
||||||
|
}
|
||||||
|
|
||||||
|
QRect slideRect = windowOverGeometry;
|
||||||
|
if( abs( horizSlide ) < abs( vertSlide ) )
|
||||||
|
{
|
||||||
|
slideRect.moveLeft( slideRect.x() + horizSlide );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
slideRect.moveTop( slideRect.y() + vertSlide );
|
||||||
|
}
|
||||||
|
return slideRect;
|
||||||
|
}
|
||||||
|
|
||||||
void SlideBackEffect::updateStackingOrder()
|
void SlideBackEffect::updateStackingOrder()
|
||||||
{
|
{
|
||||||
usableOldStackingOrder = usableWindows( effects->stackingOrder() );
|
usableOldStackingOrder = usableWindows( effects->stackingOrder() );
|
||||||
|
@ -219,9 +224,34 @@ void SlideBackEffect::postPaintWindow( EffectWindow* w )
|
||||||
if(( abs( motionManager.transformedGeometry( w ).x() - destinationList[w].x() ) < 1 ) &&
|
if(( abs( motionManager.transformedGeometry( w ).x() - destinationList[w].x() ) < 1 ) &&
|
||||||
( abs( motionManager.transformedGeometry( w ).y() - destinationList[w].y() ) < 1 ) )
|
( abs( motionManager.transformedGeometry( w ).y() - destinationList[w].y() ) < 1 ) )
|
||||||
{
|
{
|
||||||
// Move the window back where it belongs
|
// If we are still intersecting with the activeWindow it is moving. slide to somewhere else
|
||||||
motionManager.moveWindow( w, w->geometry() );
|
// restore the stacking order of all windows not intersecting any more except panels
|
||||||
destinationList.remove( w );
|
if( coveringWindows.contains( w ) )
|
||||||
|
{
|
||||||
|
foreach( EffectWindow *tmp, elevatedList )
|
||||||
|
{
|
||||||
|
if( coveringWindows.contains( tmp ) )
|
||||||
|
{
|
||||||
|
QRect newDestination = getSlideDestination( effects->activeWindow()->geometry(), tmp->geometry() );
|
||||||
|
motionManager.moveWindow( tmp, newDestination );
|
||||||
|
destinationList[tmp] = newDestination;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if( !tmp->isDock() )
|
||||||
|
{
|
||||||
|
effects->setElevatedWindow( tmp, false );
|
||||||
|
elevatedList.removeAll( tmp );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Move the window back where it belongs
|
||||||
|
motionManager.moveWindow( w, w->geometry() );
|
||||||
|
destinationList.remove( w );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -246,8 +276,8 @@ void SlideBackEffect::postPaintWindow( EffectWindow* w )
|
||||||
foreach( EffectWindow *tmp, elevatedList )
|
foreach( EffectWindow *tmp, elevatedList )
|
||||||
{
|
{
|
||||||
effects->setElevatedWindow( tmp, false );
|
effects->setElevatedWindow( tmp, false );
|
||||||
elevatedList.clear();
|
|
||||||
}
|
}
|
||||||
|
elevatedList.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
// Include with base class for effects.
|
// Include with base class for effects.
|
||||||
#include <kwineffects.h>
|
#include <kwineffects.h>
|
||||||
|
|
||||||
|
|
||||||
namespace KWin
|
namespace KWin
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -58,6 +57,7 @@ class SlideBackEffect
|
||||||
QHash<EffectWindow *, QRect> destinationList;
|
QHash<EffectWindow *, QRect> destinationList;
|
||||||
bool disabled;
|
bool disabled;
|
||||||
|
|
||||||
|
QRect getSlideDestination( const QRect &windowUnderGeometry, const QRect &windowOverGeometry);
|
||||||
void updateStackingOrder();
|
void updateStackingOrder();
|
||||||
bool isWindowOnTop( EffectWindow *w );
|
bool isWindowOnTop( EffectWindow *w );
|
||||||
bool isWindowUsable( EffectWindow *w );
|
bool isWindowUsable( EffectWindow *w );
|
||||||
|
|
Loading…
Reference in a new issue