X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=dwm.c;h=402b2b9e1b8d029e755c6e36df3f6b4f52dcfce7;hb=a372248b803e92e6e781d26703a7fee96550ef3a;hp=f955d44c5ddfb95317e2bb357a3129c9d7f9e7d5;hpb=d0b4575bf47bb848b09edbd5c5a0f27e889a976a;p=dwm.git diff --git a/dwm.c b/dwm.c index f955d44..402b2b9 100644 --- a/dwm.c +++ b/dwm.c @@ -433,9 +433,9 @@ buttonpress(XEvent *e) { } if(ev->window == selmon->barwin) { i = x = 0; - do { + do x += TEXTW(tags[i]); - } while(ev->x >= x && ++i < LENGTH(tags)); + while(ev->x >= x && ++i < LENGTH(tags)); if(i < LENGTH(tags)) { click = ClkTagBar; arg.ui = 1 << i; @@ -632,9 +632,9 @@ configurerequest(XEvent *e) { c->h = ev->height; } if((c->x + c->w) > m->mx + m->mw && c->isfloating) - c->x = m->mx + (m->mw / 2 - c->w / 2); /* center in x direction */ + c->x = m->mx + (m->mw / 2 - WIDTH(c) / 2); /* center in x direction */ if((c->y + c->h) > m->my + m->mh && c->isfloating) - c->y = m->my + (m->mh / 2 - c->h / 2); /* center in y direction */ + c->y = m->my + (m->mh / 2 - HEIGHT(c) / 2); /* center in y direction */ if((ev->value_mask & (CWX|CWY)) && !(ev->value_mask & (CWWidth|CWHeight))) configure(c); if(ISVISIBLE(c)) @@ -720,12 +720,10 @@ dirtomon(int dir) { if(!(m = selmon->next)) m = mons; } - else { - if(selmon == mons) - for(m = mons; m->next; m = m->next); - else - for(m = mons; m->next != selmon; m = m->next); - } + else if(selmon == mons) + for(m = mons; m->next; m = m->next); + else + for(m = mons; m->next != selmon; m = m->next); return m; } @@ -1017,12 +1015,11 @@ grabkeys(void) { KeyCode code; XUngrabKey(dpy, AnyKey, AnyModifier, root); - for(i = 0; i < LENGTH(keys); i++) { + for(i = 0; i < LENGTH(keys); i++) if((code = XKeysymToKeycode(dpy, keys[i].keysym))) for(j = 0; j < LENGTH(modifiers); j++) XGrabKey(dpy, code, keys[i].mod | modifiers[j], root, True, GrabModeAsync, GrabModeAsync); - } } } @@ -1031,7 +1028,6 @@ initfont(const char *fontstr) { char *def, **missing; int n; - missing = NULL; dc.font.set = XCreateFontSet(dpy, fontstr, &missing, &n, &def); if(missing) { while(n--) @@ -1127,7 +1123,7 @@ manage(Window w, XWindowAttributes *wa) { c->h = c->oldh = wa->height; c->oldbw = wa->border_width; if(c->w == c->mon->mw && c->h == c->mon->mh) { - c->isfloating = True; + c->isfloating = True; // regression with flash, XXXX c->x = c->mon->mx; c->y = c->mon->my; c->bw = 0; @@ -1311,6 +1307,7 @@ ptrtomon(int x, int y) { return m; return selmon; } + void quit(const Arg *arg) { running = False; @@ -1415,10 +1412,9 @@ run(void) { XEvent ev; /* main event loop */ XSync(dpy, False); - while(running && !XNextEvent(dpy, &ev)) { + while(running && !XNextEvent(dpy, &ev)) if(handler[ev.type]) handler[ev.type](&ev); /* call handler */ - } } void @@ -1663,9 +1659,9 @@ tile(Monitor *m) { if(--n == 0) return; /* tile stack */ - x = (m->wx + mw > c->x + c->w) ? c->x + c->w + 2 * c->bw : m->wx + mw; + x = (m->wx > c->x) ? c->x + mw + 2 * c->bw : m->wx + mw; y = m->wy; - w = (m->wx + mw > c->x + c->w) ? m->wx + m->ww - x : m->ww - mw; + w = (m->wx > c->x) ? m->wx + m->ww - x : m->ww - mw; h = m->wh / n; if(h < bh) h = m->wh;