[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    PATCH: smart placement(kdebase/kwin/workspace.cpp)
From:       Matthias Ettrich <ettrich () trolltech ! com>
Date:       2001-02-14 8:14:02
[Download RAW message or body]

----------  Forwarded Message  ----------
Subject: smart placement patch (kdebase/kwin/workspace.cpp)
Date: Mon, 12 Feb 2001 02:04:59 -0700
From: Michael Driscoll <fenris@ulf.edgemail.com>
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

-------------------------------------------------------

["Attachment: 1" (text/plain)]

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<Client*>::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<Client*>::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<Client*>::ConstIterator l;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic