X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=client.c;h=f4ed1a067f860bc95c215919cc82a35a7d2cdbf2;hb=8cc7f3bace087dfb024a23115c211d82b35614ae;hp=45acf2e619acec3ae5c89adf4505513c65e52f94;hpb=937cabfa0aad7eef6d25e9d142a478163de200c5;p=dwm.git diff --git a/client.c b/client.c index 45acf2e..f4ed1a0 100644 --- a/client.c +++ b/client.c @@ -3,7 +3,6 @@ * See LICENSE file for license details. */ #include "dwm.h" - #include #include #include @@ -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,43 +218,42 @@ 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; clients = c; - XGrabButton(dpy, Button1, MODKEY, c->win, False, ButtonPressMask, + XGrabButton(dpy, Button1, MODKEY, c->win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); - XGrabButton(dpy, Button2, MODKEY, c->win, False, ButtonPressMask, + XGrabButton(dpy, Button2, MODKEY, c->win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); - XGrabButton(dpy, Button3, MODKEY, c->win, False, ButtonPressMask, + 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); @@ -416,20 +410,18 @@ togglemax(Arg *arg) void unmanage(Client *c) { - Client **l; - XGrabServer(dpy); XSetErrorHandler(xerrordummy); XUngrabButton(dpy, AnyButton, AnyModifier, c->win); XDestroyWindow(dpy, c->title); - for(l = &clients; *l && *l != c; l = &(*l)->next); if(c->prev) c->prev->next = c->next; if(c->next) c->next->prev = c->prev; - *l = c->next; + if(c == clients) + clients = c->next; if(sel == c) { sel = getnext(c->next); if(!sel) @@ -450,7 +442,7 @@ unmanage(Client *c) void zoom(Arg *arg) { - Client *c, **l; + Client *c; if(!sel) return; @@ -461,13 +453,10 @@ zoom(Arg *arg) } /* pop */ - for(l = &clients; *l && *l != sel; l = &(*l)->next); if(sel->prev) sel->prev->next = sel->next; if(sel->next) sel->next->prev = sel->prev; - *l = sel->next; - sel->prev = NULL; if(clients) clients->prev = sel;