Randomize direction even when filling gaps, fixes bug when all windows are the same size.

svn path=/trunk/KDE/kdebase/workspace/; revision=861791
This commit is contained in:
Lucas Murray 2008-09-17 08:19:16 +00:00
parent 2403ceabda
commit 034e66ae96

View file

@ -917,33 +917,31 @@ void PresentWindowsEffect::calculateWindowTransformationsNatural(EffectWindowLis
// alternate between each corner on that edge. We don't want to determine it // alternate between each corner on that edge. We don't want to determine it
// randomly as it will not produce consistant locations when using the filter. // randomly as it will not produce consistant locations when using the filter.
// Only move one window so we don't cause large amounts of unnecessary zooming // Only move one window so we don't cause large amounts of unnecessary zooming
// in some situations. We only need to do this if we are not expanding later. // in some situations. We need to do this even when expanding later just in case
// all windows are the same size.
// (We are using an old bounding rect for this, hopefully it doesn't matter) // (We are using an old bounding rect for this, hopefully it doesn't matter)
if( !fillGaps ) int xSection = ( mWindowData[ w ].area.x() - bounds.x() ) / ( bounds.width() / 3 );
int ySection = ( mWindowData[ w ].area.y() - bounds.y() ) / ( bounds.height() / 3 );
diff = QPoint( 0, 0 );
if( xSection != 1 || ySection != 1 ) // Remove this if you want the center to pull as well
{ {
int xSection = ( mWindowData[ w ].area.x() - bounds.x() ) / ( bounds.width() / 3 ); if( xSection == 1 )
int ySection = ( mWindowData[ w ].area.y() - bounds.y() ) / ( bounds.height() / 3 ); xSection = ( mWindowData[ w ].slot / 2 ? 2 : 0 );
diff = QPoint( 0, 0 ); if( ySection == 1 )
if( xSection != 1 || ySection != 1 ) // Remove this if you want the center to pull as well ySection = ( mWindowData[ w ].slot % 2 ? 2 : 0 );
{ }
if( xSection == 1 ) if( xSection == 0 && ySection == 0 )
xSection = ( mWindowData[ w ].slot / 2 ? 2 : 0 ); diff = QPoint( bounds.topLeft() - mWindowData[ w ].area.center() );
if( ySection == 1 ) if( xSection == 2 && ySection == 0 )
ySection = ( mWindowData[ w ].slot % 2 ? 2 : 0 ); diff = QPoint( bounds.topRight() - mWindowData[ w ].area.center() );
} if( xSection == 2 && ySection == 2 )
if( xSection == 0 && ySection == 0 ) diff = QPoint( bounds.bottomRight() - mWindowData[ w ].area.center() );
diff = QPoint( bounds.topLeft() - mWindowData[ w ].area.center() ); if( xSection == 0 && ySection == 2 )
if( xSection == 2 && ySection == 0 ) diff = QPoint( bounds.bottomLeft() - mWindowData[ w ].area.center() );
diff = QPoint( bounds.topRight() - mWindowData[ w ].area.center() ); if( diff.x() != 0 || diff.y() != 0 )
if( xSection == 2 && ySection == 2 ) {
diff = QPoint( bounds.bottomRight() - mWindowData[ w ].area.center() ); diff *= accuracy / double( diff.manhattanLength() );
if( xSection == 0 && ySection == 2 ) mWindowData[ w ].area.translate( diff );
diff = QPoint( bounds.bottomLeft() - mWindowData[ w ].area.center() );
if( diff.x() != 0 || diff.y() != 0 )
{
diff *= accuracy / double( diff.manhattanLength() );
mWindowData[ w ].area.translate( diff );
}
} }
// Update bounding rect // Update bounding rect