made arrange() Monitor-dependent as well, fixed the movemouse/resizemouse issues
This commit is contained in:
parent
9cb9c32ee7
commit
dd21823536
52
dwm.c
52
dwm.c
|
@ -130,7 +130,7 @@ struct Monitor {
|
||||||
|
|
||||||
/* function declarations */
|
/* function declarations */
|
||||||
void applyrules(Client *c);
|
void applyrules(Client *c);
|
||||||
void arrange(void);
|
void arrange(Monitor *m);
|
||||||
void attach(Client *c);
|
void attach(Client *c);
|
||||||
void attachstack(Client *c);
|
void attachstack(Client *c);
|
||||||
void ban(Client *c);
|
void ban(Client *c);
|
||||||
|
@ -299,7 +299,8 @@ applyrules(Client *c) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
arrange(void) {
|
arrange(Monitor *m) {
|
||||||
|
unsigned int i;
|
||||||
Client *c;
|
Client *c;
|
||||||
|
|
||||||
for(c = clients; c; c = c->next)
|
for(c = clients; c; c = c->next)
|
||||||
|
@ -308,9 +309,13 @@ arrange(void) {
|
||||||
else
|
else
|
||||||
ban(c);
|
ban(c);
|
||||||
|
|
||||||
selmonitor->layout->arrange(selmonitor);
|
if(m)
|
||||||
|
m->layout->arrange(m);
|
||||||
|
else
|
||||||
|
for(i = 0; i < mcount; i++)
|
||||||
|
m->layout->arrange(&monitors[i]);
|
||||||
focus(NULL);
|
focus(NULL);
|
||||||
restack(selmonitor);
|
restack(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -485,7 +490,7 @@ configurenotify(XEvent *e) {
|
||||||
dc.drawable = XCreatePixmap(dpy, root, DisplayWidth(root, screen), bh, DefaultDepth(dpy, screen));
|
dc.drawable = XCreatePixmap(dpy, root, DisplayWidth(root, screen), bh, DefaultDepth(dpy, screen));
|
||||||
XResizeWindow(dpy, m->barwin, m->sw, bh);
|
XResizeWindow(dpy, m->barwin, m->sw, bh);
|
||||||
updatebarpos(m);
|
updatebarpos(m);
|
||||||
arrange();
|
arrange(m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1078,7 +1083,7 @@ manage(Window w, XWindowAttributes *wa) {
|
||||||
|
|
||||||
applyrules(c);
|
applyrules(c);
|
||||||
|
|
||||||
m = selmonitor;
|
m = c->monitor;
|
||||||
|
|
||||||
c->x = wa->x + m->sx;
|
c->x = wa->x + m->sx;
|
||||||
c->y = wa->y + m->sy;
|
c->y = wa->y + m->sy;
|
||||||
|
@ -1122,7 +1127,7 @@ manage(Window w, XWindowAttributes *wa) {
|
||||||
ban(c);
|
ban(c);
|
||||||
XMapWindow(dpy, c->win);
|
XMapWindow(dpy, c->win);
|
||||||
setclientstate(c, NormalState);
|
setclientstate(c, NormalState);
|
||||||
arrange();
|
arrange(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1201,7 +1206,7 @@ movemouse(Client *c) {
|
||||||
ny = m->way;
|
ny = m->way;
|
||||||
else if(abs((m->way + m->wah) - (ny + c->h + 2 * c->border)) < SNAP)
|
else if(abs((m->way + m->wah) - (ny + c->h + 2 * c->border)) < SNAP)
|
||||||
ny = m->way + m->wah - c->h - 2 * c->border;
|
ny = m->way + m->wah - c->h - 2 * c->border;
|
||||||
if((m->layout->arrange != floating) && (abs(nx - c->x) > SNAP || abs(ny - c->y) > SNAP))
|
if(!c->isfloating && (m->layout->arrange != floating) && (abs(nx - c->x) > SNAP || abs(ny - c->y) > SNAP))
|
||||||
togglefloating(NULL);
|
togglefloating(NULL);
|
||||||
if((m->layout->arrange == floating) || c->isfloating)
|
if((m->layout->arrange == floating) || c->isfloating)
|
||||||
resize(c, nx, ny, c->w, c->h, False);
|
resize(c, nx, ny, c->w, c->h, False);
|
||||||
|
@ -1230,7 +1235,7 @@ propertynotify(XEvent *e) {
|
||||||
case XA_WM_TRANSIENT_FOR:
|
case XA_WM_TRANSIENT_FOR:
|
||||||
XGetTransientForHint(dpy, c->win, &trans);
|
XGetTransientForHint(dpy, c->win, &trans);
|
||||||
if(!c->isfloating && (c->isfloating = (getclient(trans) != NULL)))
|
if(!c->isfloating && (c->isfloating = (getclient(trans) != NULL)))
|
||||||
arrange();
|
arrange(c->monitor);
|
||||||
break;
|
break;
|
||||||
case XA_WM_NORMAL_HINTS:
|
case XA_WM_NORMAL_HINTS:
|
||||||
updatesizehints(c);
|
updatesizehints(c);
|
||||||
|
@ -1262,7 +1267,7 @@ reapply(const char *arg) {
|
||||||
memcpy(c->tags, zerotags, sizeof zerotags);
|
memcpy(c->tags, zerotags, sizeof zerotags);
|
||||||
applyrules(c);
|
applyrules(c);
|
||||||
}
|
}
|
||||||
arrange();
|
arrange(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1366,7 +1371,7 @@ resizemouse(Client *c) {
|
||||||
nw = 1;
|
nw = 1;
|
||||||
if((nh = ev.xmotion.y - ocy - 2 * c->border + 1) <= 0)
|
if((nh = ev.xmotion.y - ocy - 2 * c->border + 1) <= 0)
|
||||||
nh = 1;
|
nh = 1;
|
||||||
if((m->layout->arrange != floating) && (abs(nw - c->w) > SNAP || abs(nh - c->h) > SNAP))
|
if(!c->isfloating && (m->layout->arrange != floating) && (abs(nw - c->w) > SNAP || abs(nh - c->h) > SNAP))
|
||||||
togglefloating(NULL);
|
togglefloating(NULL);
|
||||||
if((m->layout->arrange == floating) || c->isfloating)
|
if((m->layout->arrange == floating) || c->isfloating)
|
||||||
resize(c, c->x, c->y, nw, nh, True);
|
resize(c, c->x, c->y, nw, nh, True);
|
||||||
|
@ -1518,7 +1523,7 @@ setlayout(const char *arg) {
|
||||||
m->layout = &layouts[i];
|
m->layout = &layouts[i];
|
||||||
}
|
}
|
||||||
if(sel)
|
if(sel)
|
||||||
arrange();
|
arrange(m);
|
||||||
else
|
else
|
||||||
drawbar(m);
|
drawbar(m);
|
||||||
}
|
}
|
||||||
|
@ -1544,7 +1549,7 @@ setmwfact(const char *arg) {
|
||||||
else if(m->mwfact > 0.9)
|
else if(m->mwfact > 0.9)
|
||||||
m->mwfact = 0.9;
|
m->mwfact = 0.9;
|
||||||
}
|
}
|
||||||
arrange();
|
arrange(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1697,7 +1702,7 @@ tag(const char *arg) {
|
||||||
for(i = 0; i < LENGTH(tags); i++)
|
for(i = 0; i < LENGTH(tags); i++)
|
||||||
sel->tags[i] = (NULL == arg);
|
sel->tags[i] = (NULL == arg);
|
||||||
sel->tags[idxoftag(arg)] = True;
|
sel->tags[idxoftag(arg)] = True;
|
||||||
arrange();
|
arrange(sel->monitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int
|
unsigned int
|
||||||
|
@ -1769,7 +1774,7 @@ togglebar(const char *arg) {
|
||||||
else
|
else
|
||||||
bpos = BarOff;
|
bpos = BarOff;
|
||||||
updatebarpos(monitorat());
|
updatebarpos(monitorat());
|
||||||
arrange();
|
arrange(monitorat());
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1779,7 +1784,7 @@ togglefloating(const char *arg) {
|
||||||
sel->isfloating = !sel->isfloating;
|
sel->isfloating = !sel->isfloating;
|
||||||
if(sel->isfloating)
|
if(sel->isfloating)
|
||||||
resize(sel, sel->x, sel->y, sel->w, sel->h, True);
|
resize(sel, sel->x, sel->y, sel->w, sel->h, True);
|
||||||
arrange();
|
arrange(sel->monitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1793,13 +1798,12 @@ toggletag(const char *arg) {
|
||||||
for(j = 0; j < LENGTH(tags) && !sel->tags[j]; j++);
|
for(j = 0; j < LENGTH(tags) && !sel->tags[j]; j++);
|
||||||
if(j == LENGTH(tags))
|
if(j == LENGTH(tags))
|
||||||
sel->tags[i] = True; /* at least one tag must be enabled */
|
sel->tags[i] = True; /* at least one tag must be enabled */
|
||||||
arrange();
|
arrange(sel->monitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
toggleview(const char *arg) {
|
toggleview(const char *arg) {
|
||||||
unsigned int i, j;
|
unsigned int i, j;
|
||||||
|
|
||||||
Monitor *m = monitorat();
|
Monitor *m = monitorat();
|
||||||
|
|
||||||
i = idxoftag(arg);
|
i = idxoftag(arg);
|
||||||
|
@ -1807,7 +1811,7 @@ toggleview(const char *arg) {
|
||||||
for(j = 0; j < LENGTH(tags) && !m->seltags[j]; j++);
|
for(j = 0; j < LENGTH(tags) && !m->seltags[j]; j++);
|
||||||
if(j == LENGTH(tags))
|
if(j == LENGTH(tags))
|
||||||
m->seltags[i] = True; /* at least one tag must be viewed */
|
m->seltags[i] = True; /* at least one tag must be viewed */
|
||||||
arrange();
|
arrange(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1838,7 +1842,7 @@ unmanage(Client *c) {
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
XSetErrorHandler(xerror);
|
XSetErrorHandler(xerror);
|
||||||
XUngrabServer(dpy);
|
XUngrabServer(dpy);
|
||||||
arrange();
|
arrange(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1988,7 +1992,7 @@ view(const char *arg) {
|
||||||
if(memcmp(m->seltags, tmp, sizeof initags) != 0) {
|
if(memcmp(m->seltags, tmp, sizeof initags) != 0) {
|
||||||
memcpy(m->prevtags, m->seltags, sizeof initags);
|
memcpy(m->prevtags, m->seltags, sizeof initags);
|
||||||
memcpy(m->seltags, tmp, sizeof initags);
|
memcpy(m->seltags, tmp, sizeof initags);
|
||||||
arrange();
|
arrange(m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2001,7 +2005,7 @@ viewprevtag(const char *arg) {
|
||||||
memcpy(tmp, m->seltags, sizeof initags);
|
memcpy(tmp, m->seltags, sizeof initags);
|
||||||
memcpy(m->seltags, m->prevtags, sizeof initags);
|
memcpy(m->seltags, m->prevtags, sizeof initags);
|
||||||
memcpy(m->prevtags, tmp, sizeof initags);
|
memcpy(m->prevtags, tmp, sizeof initags);
|
||||||
arrange();
|
arrange(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -2016,7 +2020,7 @@ zoom(const char *arg) {
|
||||||
detach(c);
|
detach(c);
|
||||||
attach(c);
|
attach(c);
|
||||||
focus(c);
|
focus(c);
|
||||||
arrange();
|
arrange(c->monitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -2035,7 +2039,7 @@ movetomonitor(const char *arg) {
|
||||||
|
|
||||||
memcpy(sel->tags, sel->monitor->seltags, sizeof initags);
|
memcpy(sel->tags, sel->monitor->seltags, sizeof initags);
|
||||||
resize(sel, sel->monitor->wax, sel->monitor->way, sel->w, sel->h, True);
|
resize(sel, sel->monitor->wax, sel->monitor->way, sel->w, sel->h, True);
|
||||||
arrange();
|
arrange(sel->monitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in a new issue