JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
fixed issue Sander reported
[dwm.git] / client.c
index 050e8a3..0309eac 100644 (file)
--- a/client.c
+++ b/client.c
@@ -261,9 +261,9 @@ manage(Window w, XWindowAttributes *wa)
        if(trans && (tc = getclient(trans))) {
                c->x = (tc->x + tc->w / 2) - (c->w / 2);
                c->y = (tc->y + tc->h / 2) - (c->h / 2);
-               if(c->x < 0 || c->x >= sw)
+               if((c->x + c->w < 0) || (c->x >= sw))
                        c->x = (sw / 2) - (c->w / 2);
-               if(c->y < 0 || c->y >= sh)
+               if((c->y + c->h < 0) || (c->y >= sh))
                        c->y = ((sh - bh) / 2) - (c->h / 2) + bh;
        }
        else {
@@ -285,7 +285,6 @@ resize(Client *c, Bool sizehints, Corner sticky)
 {
        int bottom = c->y + c->h;
        int right = c->x + c->w;
-       /*XConfigureEvent e;*/
        XWindowChanges wc;
 
        if(sizehints) {
@@ -302,9 +301,9 @@ resize(Client *c, Bool sizehints, Corner sticky)
                if(c->maxh && c->h > c->maxh)
                        c->h = c->maxh;
        }
-       if(c->x > right) /* might happen on restart */
-               c->x = right - c->w;
-       if(c->y > bottom)
+       if(c->x > sw) /* might happen on restart */
+               c->x = sw - c->w;
+       if(c->y > sh)
                c->y = bottom - c->h;
        if(sticky == TopRight || sticky == BotRight)
                c->x = right - c->w;