JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
applied Sanders doc changes, added a PHONY line and changed the output of config...
[dwm.git] / client.c
index fd91af5..f4ed1a0 100644 (file)
--- a/client.c
+++ b/client.c
@@ -3,7 +3,6 @@
  * See LICENSE file for license details.
  */
 #include "dwm.h"
-
 #include <stdlib.h>
 #include <string.h>
 #include <X11/Xatom.h>
@@ -19,7 +18,7 @@ resizetitle(Client *c)
        c->tw = 0;
        for(i = 0; i < TLast; i++)
                if(c->tags[i])
-                       c->tw += textw(c->tags[i]);
+                       c->tw += textw(tags[i]);
        c->tw += textw(c->name);
        if(c->tw > c->w)
                c->tw = c->w + 2;
@@ -191,7 +190,7 @@ killclient(Arg *arg)
 {
        if(!sel)
                return;
-       if(sel->proto & WM_PROTOCOL_DELWIN)
+       if(sel->proto & PROTODELWIN)
                sendevent(sel->win, wmatom[WMProtocols], wmatom[WMDelete]);
        else
                XKillClient(dpy, sel->win);
@@ -219,26 +218,25 @@ manage(Window w, XWindowAttributes *wa)
        c->h = wa->height;
        c->th = bh;
 
-       if(c->y < bh)
+       c->border = 0;
+       setsize(c);
+
+       if(c->h != sh && c->y < bh)
                c->y = c->ty = bh;
 
-       c->border = 1;
        c->proto = getproto(c->win);
-       setsize(c);
        XSelectInput(dpy, c->win,
                StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
        XGetTransientForHint(dpy, c->win, &trans);
        twa.override_redirect = 1;
        twa.background_pixmap = ParentRelative;
-       twa.event_mask = ExposureMask;
+       twa.event_mask = ExposureMask | EnterWindowMask;
 
        c->title = XCreateWindow(dpy, root, c->tx, c->ty, c->tw, c->th,
                        0, DefaultDepth(dpy, screen), CopyFromParent,
                        DefaultVisual(dpy, screen),
                        CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
 
-       settags(c);
-
        if(clients)
                clients->prev = c;
        c->next = clients;
@@ -251,11 +249,11 @@ manage(Window w, XWindowAttributes *wa)
        XGrabButton(dpy, Button3, MODKEY, c->win, False, BUTTONMASK,
                        GrabModeAsync, GrabModeSync, None, None);
 
+       settags(c);
        if(!c->isfloat)
-               c->isfloat = trans || (c->maxw && c->minw &&
-                               (c->maxw == c->minw) && (c->maxh == c->minh));
-
-
+               c->isfloat = trans
+                       || (c->maxw && c->minw &&
+                               c->maxw == c->minw && c->maxh == c->minh);
        settitle(c);
        arrange(NULL);
 
@@ -271,7 +269,8 @@ resize(Client *c, Bool sizehints, Corner sticky)
 {
        int bottom = c->y + c->h;
        int right = c->x + c->w;
-       XConfigureEvent e;
+       /*XConfigureEvent e;*/
+       XWindowChanges wc;
 
        if(sizehints) {
                if(c->incw)
@@ -287,30 +286,25 @@ resize(Client *c, Bool sizehints, Corner sticky)
                if(c->maxh && c->h > c->maxh)
                        c->h = c->maxh;
        }
-       if(c->x > sw) /* might happen on restart */
-               c->x = sw - c->w;
-       if(c->y > sh)
-               c->y = sh - c->h;
+       if(c->x > right) /* might happen on restart */
+               c->x = right - c->w;
+       if(c->y > bottom)
+               c->y = bottom - c->h;
        if(sticky == TopRight || sticky == BotRight)
                c->x = right - c->w;
        if(sticky == BotLeft || sticky == BotRight)
                c->y = bottom - c->h;
 
        resizetitle(c);
-       XSetWindowBorderWidth(dpy, c->win, 1);
-       XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
-
-       e.type = ConfigureNotify;
-       e.event = c->win;
-       e.window = c->win;
-       e.x = c->x;
-       e.y = c->y;
-       e.width = c->w;
-       e.height = c->h;
-       e.border_width = c->border;
-       e.above = None;
-       e.override_redirect = False;
-       XSendEvent(dpy, c->win, False, StructureNotifyMask, (XEvent *)&e);
+       wc.x = c->x;
+       wc.y = c->y;
+       wc.width = c->w;
+       wc.height = c->h;
+       if(c->w == sw && c->h == sh)
+               wc.border_width = 0;
+       else
+               wc.border_width = 1;
+       XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
        XSync(dpy, False);
 }
 
@@ -397,8 +391,8 @@ togglemax(Arg *arg)
                oh = sel->h;
                sel->x = sx;
                sel->y = sy + bh;
-               sel->w = sw - 2 * sel->border;
-               sel->h = sh - 2 * sel->border - bh;
+               sel->w = sw - 2;
+               sel->h = sh - 2 - bh;
 
                higher(sel);
                resize(sel, False, TopLeft);