some more polishing/consistency changes

new_dwm
anselm@anselm1 17 years ago
parent 62b18fb9d4
commit a62630ae92

79
dwm.c

@ -198,7 +198,7 @@ void toggleview(const char *arg);
void unban(Client *c); void unban(Client *c);
void unmanage(Client *c); void unmanage(Client *c);
void unmapnotify(XEvent *e); void unmapnotify(XEvent *e);
void updatebarpos(Monitor *s); void updatebarpos(Monitor *m);
void updatesizehints(Client *c); void updatesizehints(Client *c);
void updatetitle(Client *c); void updatetitle(Client *c);
void view(const char *arg); void view(const char *arg);
@ -336,12 +336,12 @@ buttonpress(XEvent *e) {
Client *c; Client *c;
XButtonPressedEvent *ev = &e->xbutton; XButtonPressedEvent *ev = &e->xbutton;
Monitor s = monitors[monitorat(-1, -1)]; Monitor *m = &monitors[monitorat(-1, -1)];
if(ev->window == s.barwin) { if(ev->window == m->barwin) {
x = 0; x = 0;
for(i = 0; i < LENGTH(tags); i++) { for(i = 0; i < LENGTH(tags); i++) {
x += textw(&s, tags[i]); x += textw(m, tags[i]);
if(ev->x < x) { if(ev->x < x) {
if(ev->button == Button1) { if(ev->button == Button1) {
if(ev->state & MODKEY) if(ev->state & MODKEY)
@ -366,20 +366,20 @@ buttonpress(XEvent *e) {
if(CLEANMASK(ev->state) != MODKEY) if(CLEANMASK(ev->state) != MODKEY)
return; return;
if(ev->button == Button1) { if(ev->button == Button1) {
if((s.layout->arrange == floating) || c->isfloating) if((m->layout->arrange == floating) || c->isfloating)
restack(); restack();
else else
togglefloating(NULL); togglefloating(NULL);
movemouse(c); movemouse(c);
} }
else if(ev->button == Button2) { else if(ev->button == Button2) {
if((floating != s.layout->arrange) && c->isfloating) if((floating != m->layout->arrange) && c->isfloating)
togglefloating(NULL); togglefloating(NULL);
else else
zoom(NULL); zoom(NULL);
} }
else if(ev->button == Button3 && !c->isfixed) { else if(ev->button == Button3 && !c->isfixed) {
if((floating == s.layout->arrange) || c->isfloating) if((floating == m->layout->arrange) || c->isfloating)
restack(); restack();
else else
togglefloating(NULL); togglefloating(NULL);
@ -565,20 +565,20 @@ detachstack(Client *c) {
void void
drawbar(void) { drawbar(void) {
int i, x, s; int i, j, x;
for(s = 0; s < mcount; ++s) { for(i = 0; i < mcount; i++) {
Monitor *m = &monitors[s]; Monitor *m = &monitors[i];
m->dc.x = 0; m->dc.x = 0;
for(i = 0; i < LENGTH(tags); i++) { for(j = 0; j < LENGTH(tags); j++) {
m->dc.w = textw(m, tags[i]); m->dc.w = textw(m, tags[j]);
if(m->seltags[i]) { if(m->seltags[j]) {
drawtext(m, tags[i], m->dc.sel); drawtext(m, tags[j], m->dc.sel);
drawsquare(m, sel && sel->tags[i] && sel->monitor == selmonitor, isoccupied(m, i), m->dc.sel); drawsquare(m, sel && sel->tags[j] && sel->monitor == selmonitor, isoccupied(m, j), m->dc.sel);
} }
else { else {
drawtext(m, tags[i], m->dc.norm); drawtext(m, tags[j], m->dc.norm);
drawsquare(m, sel && sel->tags[i] && sel->monitor == selmonitor, isoccupied(m, i), m->dc.norm); drawsquare(m, sel && sel->tags[j] && sel->monitor == selmonitor, isoccupied(m, j), m->dc.norm);
} }
m->dc.x += m->dc.w; m->dc.x += m->dc.w;
} }
@ -1336,10 +1336,10 @@ resizemouse(Client *c) {
void void
restack(void) { restack(void) {
unsigned int i;
Client *c; Client *c;
XEvent ev; XEvent ev;
XWindowChanges wc; XWindowChanges wc;
int s;
drawbar(); drawbar();
if(!sel) if(!sel)
@ -1353,8 +1353,8 @@ restack(void) {
XConfigureWindow(dpy, sel->win, CWSibling | CWStackMode, &wc); XConfigureWindow(dpy, sel->win, CWSibling | CWStackMode, &wc);
wc.sibling = sel->win; wc.sibling = sel->win;
} }
for(s = 0; s < mcount; s++) { for(i = 0; i < mcount; i++) {
for(c = nexttiled(clients, &monitors[s]); c; c = nexttiled(c->next, &monitors[s])) { for(c = nexttiled(clients, &monitors[i]); c; c = nexttiled(c->next, &monitors[i])) {
if(c == sel) if(c == sel)
continue; continue;
XConfigureWindow(dpy, c->win, CWSibling | CWStackMode, &wc); XConfigureWindow(dpy, c->win, CWSibling | CWStackMode, &wc);
@ -1676,39 +1676,38 @@ textw(Monitor *m, const char *text) {
void void
tile(void) { tile(void) {
unsigned int i, n, nx, ny, nw, nh, mw, th; unsigned int i, j, n, nx, ny, nw, nh, mw, th;
int s;
Client *c, *mc; Client *c, *mc;
domwfact = dozoom = True; domwfact = dozoom = True;
nw = 0; /* gcc stupidity requires this */ nw = 0; /* gcc stupidity requires this */
for (s = 0; s < mcount; s++) { for (i = 0; i < mcount; i++) {
Monitor *m = &monitors[s]; Monitor *m = &monitors[i];
for(n = 0, c = nexttiled(clients, m); c; c = nexttiled(c->next, m)) for(n = 0, c = nexttiled(clients, m); c; c = nexttiled(c->next, m))
n++; n++;
for(i = 0, c = mc = nexttiled(clients, m); c; c = nexttiled(c->next, m)) { for(j = 0, c = mc = nexttiled(clients, m); c; c = nexttiled(c->next, m)) {
/* window geoms */ /* window geoms */
mw = (n == 1) ? m->waw : m->mwfact * m->waw; mw = (n == 1) ? m->waw : m->mwfact * m->waw;
th = (n > 1) ? m->wah / (n - 1) : 0; th = (n > 1) ? m->wah / (n - 1) : 0;
if(n > 1 && th < bh) if(n > 1 && th < bh)
th = m->wah; th = m->wah;
if(i == 0) { /* master */ if(j == 0) { /* master */
nx = m->wax; nx = m->wax;
ny = m->way; ny = m->way;
nw = mw - 2 * c->border; nw = mw - 2 * c->border;
nh = m->wah - 2 * c->border; nh = m->wah - 2 * c->border;
} }
else { /* tile window */ else { /* tile window */
if(i == 1) { if(j == 1) {
ny = m->way; ny = m->way;
nx += mc->w + 2 * mc->border; nx += mc->w + 2 * mc->border;
nw = m->waw - mw - 2 * c->border; nw = m->waw - mw - 2 * c->border;
} }
if(i + 1 == n) /* remainder */ if(j + 1 == n) /* remainder */
nh = (m->way + m->wah) - ny - 2 * c->border; nh = (m->way + m->wah) - ny - 2 * c->border;
else else
nh = th - 2 * c->border; nh = th - 2 * c->border;
@ -1720,7 +1719,7 @@ tile(void) {
if(n > 1 && th != m->wah) if(n > 1 && th != m->wah)
ny = c->y + c->h + 2 * c->border; ny = c->y + c->h + 2 * c->border;
i++; j++;
} }
} }
} }
@ -1813,25 +1812,25 @@ unmapnotify(XEvent *e) {
} }
void void
updatebarpos(Monitor *s) { updatebarpos(Monitor *m) {
XEvent ev; XEvent ev;
s->wax = s->sx; m->wax = m->sx;
s->way = s->sy; m->way = m->sy;
s->wah = s->sh; m->wah = m->sh;
s->waw = s->sw; m->waw = m->sw;
switch(bpos) { switch(bpos) {
default: default:
s->wah -= bh; m->wah -= bh;
s->way += bh; m->way += bh;
XMoveWindow(dpy, s->barwin, s->sx, s->sy); XMoveWindow(dpy, m->barwin, m->sx, m->sy);
break; break;
case BarBot: case BarBot:
s->wah -= bh; m->wah -= bh;
XMoveWindow(dpy, s->barwin, s->sx, s->sy + s->wah); XMoveWindow(dpy, m->barwin, m->sx, m->sy + m->wah);
break; break;
case BarOff: case BarOff:
XMoveWindow(dpy, s->barwin, s->sx, s->sy - bh); XMoveWindow(dpy, m->barwin, m->sx, m->sy - bh);
break; break;
} }
XSync(dpy, False); XSync(dpy, False);

Loading…
Cancel
Save