void detach(Client *c);
void detachstack(Client *c);
void drawbar(void);
-void drawsquare(Monitor *, Bool filled, Bool empty, unsigned long col[ColLast]);
+void drawsquare(Monitor *, Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]);
void drawtext(Monitor *, const char *text, unsigned long col[ColLast], Bool invert);
void *emallocz(unsigned int size);
void enternotify(XEvent *e);
void grabkeys(void);
unsigned int idxoftag(const char *tag);
void initfont(Monitor*, const char *fontstr);
-Bool isoccupied(Monitor *m, unsigned int t);
+Bool isoccupied(unsigned int monitor, unsigned int t);
Bool isprotodel(Client *c);
-Bool isurgent(int monitor, unsigned int t);
+Bool isurgent(unsigned int monitor, unsigned int t);
Bool isvisible(Client *c, int monitor);
void keypress(XEvent *e);
void killclient(const char *arg);
if(CLEANMASK(ev->state) != MODKEY)
return;
if(ev->button == Button1) {
- if((m->layout->arrange == floating) || c->isfloating)
- restack();
- else
- togglefloating(NULL);
+ restack();
movemouse(c);
}
else if(ev->button == Button2) {
zoom(NULL);
}
else if(ev->button == Button3 && !c->isfixed) {
- if((floating == m->layout->arrange) || c->isfloating)
- restack();
- else
- togglefloating(NULL);
+ restack();
resizemouse(c);
}
}
void
drawbar(void) {
int i, j, x;
+ Client *c;
for(i = 0; i < mcount; i++) {
Monitor *m = &monitors[i];
m->dc.x = 0;
+ for(c = stack; c && !isvisible(c, i); c = c->snext);
+ fprintf(stderr, "m%d %s\n", i, c ? c->name : "NIL");
for(j = 0; j < LENGTH(tags); j++) {
m->dc.w = textw(m, tags[j]);
if(m->seltags[j]) {
drawtext(m, tags[j], m->dc.sel, isurgent(i, j));
- drawsquare(m, sel && sel->tags[j] && sel->monitor == selmonitor, isoccupied(m, j), m->dc.sel);
+ drawsquare(m, c && c->tags[j] && c->monitor == i,
+ isoccupied(i, j), isurgent(i, j), m->dc.sel);
}
else {
drawtext(m, tags[j], m->dc.norm, isurgent(i, j));
- drawsquare(m, sel && sel->tags[j] && sel->monitor == selmonitor, isoccupied(m, j), m->dc.norm);
+ drawsquare(m, c && c->tags[j] && c->monitor == i,
+ isoccupied(i, j), isurgent(i, j), m->dc.norm);
}
m->dc.x += m->dc.w;
}
m->dc.w = blw;
drawtext(m, m->layout->symbol, m->dc.norm, False);
x = m->dc.x + m->dc.w;
- m->dc.w = textw(m, stext);
- m->dc.x = m->sw - m->dc.w;
- if(m->dc.x < x) {
- m->dc.x = x;
- m->dc.w = m->sw - x;
+ if(i == selmonitor) {
+ m->dc.w = textw(m, stext);
+ m->dc.x = m->sw - m->dc.w;
+ if(m->dc.x < x) {
+ m->dc.x = x;
+ m->dc.w = m->sw - x;
+ }
+ drawtext(m, stext, m->dc.norm, False);
}
- drawtext(m, stext, m->dc.norm, False);
+ else
+ m->dc.x = m->sw;
if((m->dc.w = m->dc.x - x) > bh) {
m->dc.x = x;
- if(sel && sel->monitor == selmonitor) {
- drawtext(m, sel->name, m->dc.sel, False);
- drawsquare(m, False, sel->isfloating, m->dc.sel);
+ if(c) {
+ drawtext(m, c->name, m->dc.sel, False);
+ drawsquare(m, False, c->isfloating, False, m->dc.sel);
}
else
drawtext(m, NULL, m->dc.norm, False);
}
void
-drawsquare(Monitor *m, Bool filled, Bool empty, unsigned long col[ColLast]) {
+drawsquare(Monitor *m, Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]) {
int x;
XGCValues gcv;
XRectangle r = { m->dc.x, m->dc.y, m->dc.w, m->dc.h };
- gcv.foreground = col[ColFG];
+ gcv.foreground = col[invert ? ColBG : ColFG];
XChangeGC(dpy, m->dc.gc, GCForeground, &gcv);
x = (m->dc.font.ascent + m->dc.font.descent + 2) / 4;
r.x = m->dc.x + 1;
Client *c;
XCrossingEvent *ev = &e->xcrossing;
- if(ev->mode != NotifyNormal || ev->detail == NotifyInferior);
- //return;
+ if(ev->mode != NotifyNormal || ev->detail == NotifyInferior) {
+ if(!isxinerama || ev->window != monitors[selmonitor].root)
+ return;
+ }
if((c = getclient(ev->window)))
focus(c);
else {
}
else {
XSetInputFocus(dpy, m->root, RevertToPointerRoot, CurrentTime);
+ drawbar();
}
}
}
Bool
-isoccupied(Monitor *m, unsigned int t) {
+isoccupied(unsigned int monitor, unsigned int t) {
Client *c;
for(c = clients; c; c = c->next)
- if(c->tags[t] && c->monitor == selmonitor)
+ if(c->tags[t] && c->monitor == monitor)
return True;
return False;
}
}
Bool
-isurgent(int monitor, unsigned int t) {
+isurgent(unsigned int monitor, unsigned int t) {
Client *c;
for(c = clients; c; c = c->next)
isvisible(Client *c, int monitor) {
unsigned int i;
+ if(c->monitor != monitor)
+ return False;
for(i = 0; i < LENGTH(tags); i++)
- if(c->tags[i] && monitors[c->monitor].seltags[i] && c->monitor == monitor)
+ if(c->tags[i] && monitors[c->monitor].seltags[i])
return True;
return False;
}
XQueryPointer(dpy, monitors[selmonitor].root, &win, &win, &x, &y, &i, &i, &mask);
for(i = 0; i < mcount; i++) {
- fprintf(stderr, "checking monitor[%d]: %d %d %d %d\n", i, monitors[i].sx, monitors[i].sy, monitors[i].sw, monitors[i].sh);
if((x >= monitors[i].sx && x < monitors[i].sx + monitors[i].sw)
&& (y >= monitors[i].sy && y < monitors[i].sy + monitors[i].sh)) {
- fprintf(stderr, "%d,%d -> %d\n", x, y, i);
return i;
}
}
- fprintf(stderr, "?,? -> 0\n");
return 0;
}
ny = m->way;
else if(abs((m->way + m->wah) - (ny + c->h + 2 * c->border)) < SNAP)
ny = m->way + m->wah - c->h - 2 * c->border;
- resize(c, nx, ny, c->w, c->h, False);
+ if((monitors[selmonitor].layout->arrange != floating) && (abs(nx - c->x) > SNAP || abs(ny - c->y) > SNAP))
+ togglefloating(NULL);
+ if((monitors[selmonitor].layout->arrange == floating) || c->isfloating)
+ resize(c, nx, ny, c->w, c->h, False);
memcpy(c->tags, monitors[monitorat()].seltags, sizeof initags);
break;
}
nw = 1;
if((nh = ev.xmotion.y - ocy - 2 * c->border + 1) <= 0)
nh = 1;
- resize(c, c->x, c->y, nw, nh, True);
+ if((monitors[selmonitor].layout->arrange != floating) && (abs(nw - c->w) > SNAP || abs(nh - c->h) > SNAP))
+ togglefloating(NULL);
+ if((monitors[selmonitor].layout->arrange == floating) || c->isfloating)
+ resize(c, c->x, c->y, nw, nh, True);
break;
}
}
for(n = 0, c = nexttiled(clients, i); c; c = nexttiled(c->next, i))
n++;
+ /* window geoms */
+ mw = (n == 1) ? m->waw : m->mwfact * m->waw;
+ th = (n > 1) ? m->wah / (n - 1) : 0;
+ if(n > 1 && th < bh)
+ th = m->wah;
+
for(j = 0, c = mc = nexttiled(clients, i); c; c = nexttiled(c->next, i)) {
- /* window geoms */
- mw = (n == 1) ? m->waw : m->mwfact * m->waw;
- th = (n > 1) ? m->wah / (n - 1) : 0;
- if(n > 1 && th < bh)
- th = m->wah;
if(j == 0) { /* master */
nx = m->wax;
ny = m->way;
void
view(const char *arg) {
unsigned int i;
-
+ Bool tmp[LENGTH(tags)];
Monitor *m = &monitors[monitorat()];
- memcpy(m->prevtags, m->seltags, sizeof initags);
for(i = 0; i < LENGTH(tags); i++)
- m->seltags[i] = (NULL == arg);
- m->seltags[idxoftag(arg)] = True;
- arrange();
+ tmp[i] = (NULL == arg);
+ tmp[idxoftag(arg)] = True;
+ if(memcmp(m->seltags, tmp, sizeof initags) != 0) {
+ memcpy(m->prevtags, m->seltags, sizeof initags);
+ memcpy(m->seltags, tmp, sizeof initags);
+ arrange();
+ }
}
void