CT: kill off-by-one bug in smart placement. Thanks to Michael Driscoll for
bug report, bug analysis and patch review. svn path=/trunk/kdebase/kwin/; revision=83151
This commit is contained in:
parent
6bfb54fe77
commit
5db5950bc1
1 changed files with 1241 additions and 1239 deletions
|
@ -1371,6 +1371,7 @@ void Workspace::smartPlacement(Client* c){
|
||||||
|
|
||||||
int cxl, cxr, cyt, cyb; //temp coords
|
int cxl, cxr, cyt, cyb; //temp coords
|
||||||
int xl, xr, yt, yb; //temp coords
|
int xl, xr, yt, yb; //temp coords
|
||||||
|
int basket; //temp holder
|
||||||
|
|
||||||
// get the maximum allowed windows space
|
// get the maximum allowed windows space
|
||||||
QRect maxRect = clientArea();
|
QRect maxRect = clientArea();
|
||||||
|
@ -1378,14 +1379,15 @@ void Workspace::smartPlacement(Client* c){
|
||||||
x_optimal = x; y_optimal = y;
|
x_optimal = x; y_optimal = y;
|
||||||
|
|
||||||
//client gabarit
|
//client gabarit
|
||||||
int ch = c->height(), cw = c->width();
|
int ch = c->height() - 1;
|
||||||
|
int cw = c->width() - 1;
|
||||||
|
|
||||||
bool first_pass = true; //CT lame flag. Don't like it. What else would do?
|
bool first_pass = true; //CT lame flag. Don't like it. What else would do?
|
||||||
|
|
||||||
//loop over possible positions
|
//loop over possible positions
|
||||||
do {
|
do {
|
||||||
//test if enough room in x and y directions
|
//test if enough room in x and y directions
|
||||||
if ( y + ch > maxRect.bottom() && ch <= maxRect.height())
|
if ( y + ch > maxRect.bottom() && ch < maxRect.height())
|
||||||
overlap = h_wrong; // this throws the algorithm to an exit
|
overlap = h_wrong; // this throws the algorithm to an exit
|
||||||
else if( x + cw > maxRect.right() )
|
else if( x + cw > maxRect.right() )
|
||||||
overlap = w_wrong;
|
overlap = w_wrong;
|
||||||
|
@ -1454,11 +1456,10 @@ void Workspace::smartPlacement(Client* c){
|
||||||
// determine the first non-overlapped x position
|
// determine the first non-overlapped x position
|
||||||
if( ( y < yb ) && ( yt < ch + y ) ) {
|
if( ( y < yb ) && ( yt < ch + y ) ) {
|
||||||
|
|
||||||
if( xr > x )
|
if( ( xr > x ) && ( possible > xr ) ) possible = xr;
|
||||||
possible = possible < xr ? possible : xr;
|
|
||||||
|
|
||||||
if( xl - cw > x )
|
basket = xl - cw;
|
||||||
possible = possible < xl - cw ? possible : xl - cw;
|
if( ( basket > x) && ( possible > basket ) ) possible = basket;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1481,17 +1482,18 @@ void Workspace::smartPlacement(Client* c){
|
||||||
xl = (*l)->x(); yt = (*l)->y();
|
xl = (*l)->x(); yt = (*l)->y();
|
||||||
xr = xl + (*l)->width(); yb = yt + (*l)->height();
|
xr = xl + (*l)->width(); yb = yt + (*l)->height();
|
||||||
|
|
||||||
if( yb > y)
|
// if not enough room to the left or right of the current tested client
|
||||||
possible = possible < yb ? possible : yb;
|
// determine the first non-overlapped y position
|
||||||
|
if( ( yb > y ) && ( possible > yb ) ) possible = yb;
|
||||||
|
|
||||||
if( yt - ch > y )
|
basket = yt - ch;
|
||||||
possible = possible < yt - ch ? possible : yt - ch;
|
if( (basket > y ) && ( possible > basket ) ) possible = basket;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
y = possible;
|
y = possible;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while( overlap != none && overlap != h_wrong && y< maxRect.bottom() );
|
while( ( overlap != none ) && ( overlap != h_wrong ) && ( y < maxRect.bottom() ) );
|
||||||
|
|
||||||
if(ch>= maxRect.height() )
|
if(ch>= maxRect.height() )
|
||||||
y_optimal=maxRect.top();
|
y_optimal=maxRect.top();
|
||||||
|
|
Loading…
Reference in a new issue