1
0

minor fix of the NetActiveWindow multi-monitor flaw, slight rearrangement

This commit is contained in:
Anselm R Garbe 2011-04-15 08:12:20 +00:00
parent 3c2d303c0e
commit d24837f1ad

107
dwm.c
View File

@ -520,6 +520,46 @@ clearurgent(Client *c) {
XFree(wmh); XFree(wmh);
} }
void
clientmessage(XEvent *e) {
XClientMessageEvent *cme = &e->xclient;
Client *c = wintoclient(cme->window);
if(!c)
return;
if(cme->message_type == netatom[NetWMState] && cme->data.l[1] == netatom[NetWMFullscreen]) {
if(cme->data.l[0]) {
XChangeProperty(dpy, cme->window, netatom[NetWMState], XA_ATOM, 32,
PropModeReplace, (unsigned char*)&netatom[NetWMFullscreen], 1);
c->oldstate = c->isfloating;
c->oldbw = c->bw;
c->bw = 0;
c->isfloating = True;
resizeclient(c, c->mon->mx, c->mon->my, c->mon->mw, c->mon->mh);
XRaiseWindow(dpy, c->win);
}
else {
XChangeProperty(dpy, cme->window, netatom[NetWMState], XA_ATOM, 32,
PropModeReplace, (unsigned char*)0, 0);
c->isfloating = c->oldstate;
c->bw = c->oldbw;
c->x = c->oldx;
c->y = c->oldy;
c->w = c->oldw;
c->h = c->oldh;
resizeclient(c, c->x, c->y, c->w, c->h);
arrange(c->mon);
}
}
else if(cme->message_type == netatom[NetActiveWindow]) {
if(!ISVISIBLE(c)) {
c->mon->seltags ^= 1;
c->mon->tagset[c->mon->seltags] = c->tags;
}
pop(c);
}
}
void void
configure(Client *c) { configure(Client *c) {
XConfigureEvent ce; XConfigureEvent ce;
@ -1212,14 +1252,12 @@ nexttiled(Client *c) {
return c; return c;
} }
Monitor * void
ptrtomon(int x, int y) { pop(Client *c) {
Monitor *m; detach(c);
attach(c);
for(m = mons; m; m = m->next) focus(c);
if(INRECT(x, y, m->wx, m->wy, m->ww, m->wh)) arrange(c->mon);
return m;
return selmon;
} }
void void
@ -1256,49 +1294,15 @@ propertynotify(XEvent *e) {
} }
} }
void Monitor *
clientmessage(XEvent *e) { ptrtomon(int x, int y) {
XClientMessageEvent *cme = &e->xclient; Monitor *m;
Client *c = wintoclient(cme->window);
if(!c) for(m = mons; m; m = m->next)
return; if(INRECT(x, y, m->wx, m->wy, m->ww, m->wh))
if(cme->message_type == netatom[NetWMState] && cme->data.l[1] == netatom[NetWMFullscreen]) { return m;
if(cme->data.l[0]) { return selmon;
XChangeProperty(dpy, cme->window, netatom[NetWMState], XA_ATOM, 32,
PropModeReplace, (unsigned char*)&netatom[NetWMFullscreen], 1);
c->oldstate = c->isfloating;
c->oldbw = c->bw;
c->bw = 0;
c->isfloating = True;
resizeclient(c, c->mon->mx, c->mon->my, c->mon->mw, c->mon->mh);
XRaiseWindow(dpy, c->win);
}
else {
XChangeProperty(dpy, cme->window, netatom[NetWMState], XA_ATOM, 32,
PropModeReplace, (unsigned char*)0, 0);
c->isfloating = c->oldstate;
c->bw = c->oldbw;
c->x = c->oldx;
c->y = c->oldy;
c->w = c->oldw;
c->h = c->oldh;
resizeclient(c, c->x, c->y, c->w, c->h);
arrange(c->mon);
}
}
else if(cme->message_type == netatom[NetActiveWindow]) {
if(!ISVISIBLE(c)) {
Arg a = { .ui = c->tags };
view(&a);
}
detach(c);
attach(c);
focus(c);
arrange(c->mon);
}
} }
void void
quit(const Arg *arg) { quit(const Arg *arg) {
running = False; running = False;
@ -2043,10 +2047,7 @@ zoom(const Arg *arg) {
if(c == nexttiled(selmon->clients)) if(c == nexttiled(selmon->clients))
if(!c || !(c = nexttiled(c->next))) if(!c || !(c = nexttiled(c->next)))
return; return;
detach(c); pop(c);
attach(c);
focus(c);
arrange(c->mon);
} }
int int