X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=client.c;h=efa96695d16247aebdeb5e6c2ab4ce96f4119f5c;hb=c8e57332d1a5167d213af0fc9438ff2b56c74fbb;hp=d5bc30eba90bf642b0318c2817608bbe14716087;hpb=05c10c5776738fdfe73c1e66e14c869e2e5e338d;p=dwm.git diff --git a/client.c b/client.c index d5bc30e..efa9669 100644 --- a/client.c +++ b/client.c @@ -54,19 +54,6 @@ grabbuttons(Client *c, Bool focused) { GrabModeAsync, GrabModeSync, None, None); } -static void -resizetitle(Client *c) { - c->tw = textw(c->name); - if(c->tw > c->w) - c->tw = c->w + 2; - c->tx = c->x + c->w - c->tw + 2; - c->ty = c->y; - if(isvisible(c)) - XMoveResizeWindow(dpy, c->twin, c->tx, c->ty, c->tw, c->th); - else - XMoveResizeWindow(dpy, c->twin, c->tx + 2 * sw, c->ty, c->tw, c->th); -} - static int xerrordummy(Display *dsply, XErrorEvent *ee) { return 0; @@ -81,6 +68,23 @@ ban(Client *c) { } void +configure(Client *c) { + XEvent synev; + + synev.type = ConfigureNotify; + synev.xconfigure.display = dpy; + synev.xconfigure.event = c->win; + synev.xconfigure.window = c->win; + synev.xconfigure.x = c->x; + synev.xconfigure.y = c->y; + synev.xconfigure.width = c->w; + synev.xconfigure.height = c->h; + synev.xconfigure.border_width = c->border; + synev.xconfigure.above = None; + XSendEvent(dpy, c->win, True, NoEventMask, &synev); +} + +void focus(Client *c) { Client *old; @@ -210,12 +214,12 @@ manage(Window w, XWindowAttributes *wa) { c->border = 0; updatesize(c); - if(c->x + c->w + 2 > sw) - c->x = sw - c->w - 2; - if(c->x < 0) - c->x = 0; - if(c->y + c->h + 2 > sh) - c->y = sh - c->h - 2; + if(c->x + c->w + 2 * BORDERPX > sw) + c->x = sw - c->w - 2 * BORDERPX; + if(c->x < sx) + c->x = sx; + if(c->y + c->h + 2 * BORDERPX > sh) + c->y = sh - c->h - 2 * BORDERPX; if(c->h != sh && c->y < bh) c->y = bh; @@ -233,11 +237,13 @@ manage(Window w, XWindowAttributes *wa) { CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa); grabbuttons(c, False); + updatetitle(c); settags(c, getclient(trans)); if(!c->isfloat) c->isfloat = trans || (c->maxw && c->minw && c->maxw == c->minw && c->maxh == c->minh); + resizetitle(c); if(clients) clients->prev = c; @@ -245,7 +251,6 @@ manage(Window w, XWindowAttributes *wa) { c->snext = stack; stack = clients = c; - updatetitle(c); ban(c); XMapWindow(dpy, c->win); XMapWindow(dpy, c->twin); @@ -280,8 +285,8 @@ resize(Client *c, Bool sizehints, Corner sticky) { c->y = bottom - c->h; /* offscreen appearance fixes */ - if(c->x + c->w < 0) - c->x = 0; + if(c->x + c->w < sx) + c->x = sx; if(c->y + c->h < bh) c->y = bh; if(c->x > sw) @@ -297,12 +302,26 @@ resize(Client *c, Bool sizehints, Corner sticky) { if(c->w == sw && c->h == sh) wc.border_width = 0; else - wc.border_width = 1; + wc.border_width = BORDERPX; XConfigureWindow(dpy, c->win, CWX | CWY | CWWidth | CWHeight | CWBorderWidth, &wc); + configure(c); XSync(dpy, False); } void +resizetitle(Client *c) { + c->tw = textw(c->name); + if(c->tw > c->w) + c->tw = c->w + 2 * BORDERPX; + c->tx = c->x + c->w - c->tw + 2 * BORDERPX; + c->ty = c->y; + if(isvisible(c)) + XMoveResizeWindow(dpy, c->twin, c->tx, c->ty, c->tw, c->th); + else + XMoveResizeWindow(dpy, c->twin, c->tx + 2 * sw, c->ty, c->tw, c->th); +} + +void updatesize(Client *c) { long msize; XSizeHints size; @@ -364,7 +383,6 @@ updatetitle(Client *c) { } } XFree(name.value); - resizetitle(c); } void