X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=dwm.c;h=235365b47176cf660098db4e69af90e84b54bace;hb=32c5046635da102dd3b6789462234e3147b190ab;hp=b61bbf593786af72774021d4f9db578a52e86669;hpb=5d2385b636d496645be4c703f04a365c637379c5;p=dwm.git diff --git a/dwm.c b/dwm.c index b61bbf5..235365b 100644 --- a/dwm.c +++ b/dwm.c @@ -105,7 +105,6 @@ typedef struct { typedef struct { const char *symbol; void (*arrange)(void); - void (*updategeom)(void); } Layout; typedef struct { @@ -171,7 +170,6 @@ void spawn(const void *arg); void tag(const void *arg); uint textnw(const char *text, uint len); void tile(void); -void tileresize(Client *c, int x, int y, int w, int h); void togglebar(const void *arg); void togglefloating(const void *arg); void togglelayout(const void *arg); @@ -183,7 +181,6 @@ void unmapnotify(XEvent *e); void updatebar(void); void updategeom(void); void updatesizehints(Client *c); -void updatetilegeom(void); void updatetitle(Client *c); void updatewmhints(Client *c); void view(const void *arg); @@ -196,8 +193,7 @@ void zoom(const void *arg); /* variables */ char stext[256]; int screen, sx, sy, sw, sh; -int bx, by, bw, bh, blw, wx, wy, ww, wh; -int mx, my, mw, mh, tx, ty, tw, th; +int by, bh, blw, wx, wy, ww, wh; uint seltags = 0; int (*xerrorxlib)(Display *, XErrorEvent *); uint numlockmask = 0; @@ -216,7 +212,7 @@ void (*handler[LASTEvent]) (XEvent *) = { [UnmapNotify] = unmapnotify }; Atom wmatom[WMLast], netatom[NetLast]; -Bool domax = False; +Bool ismax = False; Bool otherwm, readin; Bool running = True; uint tagset[] = {1, 1}; /* after start, first tag is selected */ @@ -277,7 +273,7 @@ arrange(void) { } focus(NULL); - if(lt->arrange && !domax) + if(lt->arrange && !ismax) lt->arrange(); restack(); } @@ -332,7 +328,7 @@ buttonpress(XEvent *e) { } else if((c = getclient(ev->window))) { focus(c); - if(CLEANMASK(ev->state) != MODKEY || domax) + if(CLEANMASK(ev->state) != MODKEY || ismax) return; if(ev->button == Button1) movemouse(c); @@ -504,16 +500,16 @@ drawbar(void) { } if(blw > 0) { dc.w = blw; - drawtext(lt->symbol, dc.norm, domax); + drawtext(lt->symbol, dc.norm, ismax); x = dc.x + dc.w; } else x = dc.x; dc.w = TEXTW(stext); - dc.x = bw - dc.w; + dc.x = ww - dc.w; if(dc.x < x) { dc.x = x; - dc.w = bw - x; + dc.w = ww - x; } drawtext(stext, dc.norm, False); if((dc.w = dc.x - x) > bh) { @@ -525,7 +521,7 @@ drawbar(void) { else drawtext(NULL, dc.norm, False); } - XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0); + XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, ww, bh, 0, 0); XSync(dpy, False); } @@ -633,7 +629,7 @@ focus(Client *c) { } sel = c; if(c) { - if(domax) { + if(ismax) { XMoveResizeWindow(dpy, c->win, wx, wy, ww - 2 * c->bw, wh - 2 * c->bw); c->ismax = True; } @@ -1126,6 +1122,10 @@ resize(Client *c, int x, int y, int w, int h, Bool sizehints) { x = sx; if(y + h + 2 * c->bw < sy) y = sy; + if(h < bh) + h = bh; + if(w < bh) + w = bh; if(c->x != x || c->y != y || c->w != w || c->h != h || c->isbanned || c->ismax) { c->isbanned = c->ismax = False; c->x = wc.x = x; @@ -1194,9 +1194,9 @@ restack(void) { drawbar(); if(!sel) return; - if(domax || sel->isfloating || !lt->arrange) + if(ismax || sel->isfloating || !lt->arrange) XRaiseWindow(dpy, sel->win); - if(!domax && lt->arrange) { + if(!ismax && lt->arrange) { wc.stack_mode = Below; wc.sibling = barwin; for(c = stack; c; c = c->snext) @@ -1315,7 +1315,6 @@ setmfact(const void *arg) { if(d < 0.1 || d > 0.9) return; mfact = d; - updatetilegeom(); arrange(); } @@ -1373,7 +1372,7 @@ setup(void) { wa.background_pixmap = ParentRelative; wa.event_mask = ButtonPressMask|ExposureMask; - barwin = XCreateWindow(dpy, root, bx, by, bw, bh, 0, DefaultDepth(dpy, screen), + barwin = XCreateWindow(dpy, root, wx, by, ww, bh, 0, DefaultDepth(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen), CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa); XDefineCursor(dpy, barwin, cursor[CurNormal]); @@ -1439,7 +1438,7 @@ textnw(const char *text, uint len) { void tile(void) { - int x, y, h, w; + int x, y, h, w, mw; uint i, n; Client *c; @@ -1449,42 +1448,29 @@ tile(void) { /* master */ c = nexttiled(clients); - - if(n == 1) - tileresize(c, wx, wy, ww - 2 * c->bw, wh - 2 * c->bw); - else - tileresize(c, mx, my, mw - 2 * c->bw, mh - 2 * c->bw); + mw = mfact * ww; + resize(c, wx, wy, ((n == 1) ? ww : mw) - 2 * c->bw, wh - 2 * c->bw, resizehints); if(--n == 0) return; /* tile stack */ - x = (tx > c->x + c->w) ? c->x + c->w + 2 * c->bw : tw; - y = ty; - w = (tx > c->x + c->w) ? wx + ww - x : tw; - h = th / n; + x = (wx + mw > c->x + c->w) ? c->x + c->w + 2 * c->bw : ww - mw; + y = wy; + w = (wx + mw > c->x + c->w) ? wx + ww - x : ww - mw; + h = wh / n; if(h < bh) - h = th; + h = wh; for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) { - if(i + 1 == n) /* remainder */ - tileresize(c, x, y, w - 2 * c->bw, (ty + th) - y - 2 * c->bw); - else - tileresize(c, x, y, w - 2 * c->bw, h - 2 * c->bw); - if(h != th) + resize(c, x, y, w - 2 * c->bw, /* remainder */ ((i + 1 == n) + ? (wy + wh) - y : h) - 2 * c->bw, resizehints); + if(h != wh) y = c->y + c->h + 2 * c->bw; } } void -tileresize(Client *c, int x, int y, int w, int h) { - resize(c, x, y, w, h, resizehints); - if(resizehints && ((c->h < bh) || (c->h > h) || (c->w < bh) || (c->w > w))) - /* client doesn't accept size constraints */ - resize(c, x, y, w, h, False); -} - -void togglebar(const void *arg) { showbar = !showbar; updategeom(); @@ -1526,7 +1512,7 @@ togglelayout(const void *arg) { void togglemax(const void *arg) { - domax = !domax; + ismax = !ismax; arrange(); } @@ -1581,8 +1567,8 @@ void updatebar(void) { if(dc.drawable != 0) XFreePixmap(dpy, dc.drawable); - dc.drawable = XCreatePixmap(dpy, root, bw, bh, DefaultDepth(dpy, screen)); - XMoveResizeWindow(dpy, barwin, bx, by, bw, bh); + dc.drawable = XCreatePixmap(dpy, root, ww, bh, DefaultDepth(dpy, screen)); + XMoveResizeWindow(dpy, barwin, wx, by, ww, bh); } void @@ -1609,15 +1595,8 @@ updategeom(void) { wh = showbar ? sh - bh : sh; } - /* bar geometry */ - bx = wx; + /* bar position */ by = showbar ? (topbar ? wy - bh : wy + wh) : -bh; - bw = ww; - - /* update layout geometries */ - for(i = 0; i < LENGTH(layouts); i++) - if(layouts[i].updategeom) - layouts[i].updategeom(); } void @@ -1673,21 +1652,6 @@ updatesizehints(Client *c) { } void -updatetilegeom(void) { - /* master area geometry */ - mx = wx; - my = wy; - mw = mfact * ww; - mh = wh; - - /* tile area geometry */ - tx = mx + mw; - ty = wy; - tw = ww - mw; - th = wh; -} - -void updatetitle(Client *c) { if(!gettextprop(c->win, netatom[NetWMName], c->name, sizeof c->name)) gettextprop(c->win, wmatom[WMName], c->name, sizeof c->name);