--------------Boundary-00=_EVMQ5INPC40A85AQGNEH Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit ---------- Forwarded Message ---------- Subject: smart placement patch (kdebase/kwin/workspace.cpp) Date: Mon, 12 Feb 2001 02:04:59 -0700 From: Michael Driscoll To: ettrich@kde.org Hello Matthias! I use 'smart' window placement and have always been a little annoyed at the way it leaves a 1-pixel gap along the right and bottom edges of the screen when placing windows. I stared at smartPlacement() for a long time today and I think I understand it now :) Here is a patch that fixes this off-by-one error, I have tested it and it seems to work correctly. The idea is that if you have a left coord of 'l' and a width of 'w' the right coord is not 'l + w' but is actually 'l + (w - 1)'. -- Michael Driscoll fenris@ulf.edgemail.com ------------------------------------------------------- --------------Boundary-00=_EVMQ5INPC40A85AQGNEH Content-Type: text/plain; charset="us-ascii"; name="Attachment: 1" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="workspace.diff" Index: kdebase/kwin/workspace.cpp =================================================================== RCS file: /home/kde/kdebase/kwin/workspace.cpp,v retrieving revision 1.212 diff -u -3 -p -r1.212 workspace.cpp --- kdebase/kwin/workspace.cpp 2001/02/10 00:27:26 1.212 +++ kdebase/kwin/workspace.cpp 2001/02/12 08:55:54 @@ -1379,21 +1379,23 @@ void Workspace::smartPlacement(Client* c //client gabarit int ch = c->height(), cw = c->width(); + // "delta coords" are the difference between maximum and minimum coords + int dh = ch - 1, dw = cw - 1; bool first_pass = true; //CT lame flag. Don't like it. What else would do? //loop over possible positions do { //test if enough room in x and y directions - if ( y + ch > maxRect.bottom() && ch <= maxRect.height()) + if ( y + dh > maxRect.bottom() && ch <= maxRect.height()) overlap = h_wrong; // this throws the algorithm to an exit - else if( x + cw > maxRect.right() ) + else if( x + dw > maxRect.right() ) overlap = w_wrong; else { overlap = none; //initialize - cxl = x; cxr = x + cw; - cyt = y; cyb = y + ch; + cxl = x; cxr = x + dw; + cyt = y; cyb = y + dh; QValueList::ConstIterator l; for(l = clients.begin(); l != clients.end() ; ++l ) { if((*l)->isOnDesktop(currentDesktop()) && (*l) != desktop_client && @@ -1438,7 +1440,7 @@ void Workspace::smartPlacement(Client* c if ( overlap > none ) { possible = maxRect.right(); - if ( possible - cw > x) possible -= cw; + if ( possible - dw > x) possible -= dw; // compare to the position of each client on the current desk QValueList::ConstIterator l; @@ -1470,7 +1472,7 @@ void Workspace::smartPlacement(Client* c x = maxRect.left(); possible = maxRect.bottom(); - if ( possible - ch > y ) possible -= ch; + if ( possible - dh > y ) possible -= dh; //test the position of each window on current desk QValueList::ConstIterator l; --------------Boundary-00=_EVMQ5INPC40A85AQGNEH--