apply single tagset patch
The goat patch.
parent
6923c2bec5
commit
b4a8dea66d
218
dwm.c
218
dwm.c
|
|
@ -51,7 +51,7 @@
|
||||||
#define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
|
#define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
|
||||||
#define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \
|
#define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \
|
||||||
* MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
|
* MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
|
||||||
#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
|
#define ISVISIBLE(C, M) ((C->tags & M->tagset[M->seltags]))
|
||||||
#define LENGTH(X) (sizeof X / sizeof X[0])
|
#define LENGTH(X) (sizeof X / sizeof X[0])
|
||||||
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
|
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
|
||||||
#define WIDTH(X) ((X)->w + 2 * (X)->bw)
|
#define WIDTH(X) ((X)->w + 2 * (X)->bw)
|
||||||
|
|
@ -84,6 +84,7 @@ typedef struct {
|
||||||
const Arg arg;
|
const Arg arg;
|
||||||
} Button;
|
} Button;
|
||||||
|
|
||||||
|
typedef struct Clientlist Clientlist;
|
||||||
typedef struct Monitor Monitor;
|
typedef struct Monitor Monitor;
|
||||||
typedef struct Client Client;
|
typedef struct Client Client;
|
||||||
struct Client {
|
struct Client {
|
||||||
|
|
@ -127,9 +128,8 @@ struct Monitor {
|
||||||
unsigned int tagset[2];
|
unsigned int tagset[2];
|
||||||
int showbar;
|
int showbar;
|
||||||
int topbar;
|
int topbar;
|
||||||
Client *clients;
|
Clientlist *cl;
|
||||||
Client *sel;
|
Client *sel;
|
||||||
Client *stack;
|
|
||||||
Monitor *next;
|
Monitor *next;
|
||||||
Window barwin;
|
Window barwin;
|
||||||
const Layout *lt[2];
|
const Layout *lt[2];
|
||||||
|
|
@ -158,12 +158,18 @@ typedef struct {
|
||||||
void *dst;
|
void *dst;
|
||||||
} ResourcePref;
|
} ResourcePref;
|
||||||
|
|
||||||
|
struct Clientlist {
|
||||||
|
Client *clients;
|
||||||
|
Client *stack;
|
||||||
|
};
|
||||||
|
|
||||||
/* function declarations */
|
/* function declarations */
|
||||||
static void applyrules(Client *c);
|
static void applyrules(Client *c);
|
||||||
static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact);
|
static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact);
|
||||||
static void arrange(Monitor *m);
|
static void arrange(Monitor *m);
|
||||||
static void arrangemon(Monitor *m);
|
static void arrangemon(Monitor *m);
|
||||||
static void attach(Client *c);
|
static void attach(Client *c);
|
||||||
|
static void attachclients(Monitor *m);
|
||||||
static void attachstack(Client *c);
|
static void attachstack(Client *c);
|
||||||
static void buttonpress(XEvent *e);
|
static void buttonpress(XEvent *e);
|
||||||
static void checkotherwm(void);
|
static void checkotherwm(void);
|
||||||
|
|
@ -201,7 +207,7 @@ static void maprequest(XEvent *e);
|
||||||
static void monocle(Monitor *m);
|
static void monocle(Monitor *m);
|
||||||
static void motionnotify(XEvent *e);
|
static void motionnotify(XEvent *e);
|
||||||
static void movemouse(const Arg *arg);
|
static void movemouse(const Arg *arg);
|
||||||
static Client *nexttiled(Client *c);
|
static Client *nexttiled(Client *c, Monitor *m);
|
||||||
static void pop(Client *c);
|
static void pop(Client *c);
|
||||||
static void propertynotify(XEvent *e);
|
static void propertynotify(XEvent *e);
|
||||||
static void quit(const Arg *arg);
|
static void quit(const Arg *arg);
|
||||||
|
|
@ -298,6 +304,7 @@ static Display *dpy;
|
||||||
static Drw *drw;
|
static Drw *drw;
|
||||||
static Monitor *mons, *selmon;
|
static Monitor *mons, *selmon;
|
||||||
static Window root, wmcheckwin;
|
static Window root, wmcheckwin;
|
||||||
|
static Clientlist *cl;
|
||||||
|
|
||||||
/* configuration, allows nested code to access above variables */
|
/* configuration, allows nested code to access above variables */
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
@ -339,7 +346,7 @@ applyrules(Client *c)
|
||||||
{
|
{
|
||||||
c->isfloating = r->isfloating;
|
c->isfloating = r->isfloating;
|
||||||
c->tags |= r->tags;
|
c->tags |= r->tags;
|
||||||
for (m = mons; m && m->num != r->monitor; m = m->next);
|
for (m = mons; m && (m->tagset[m->seltags] & c->tags) == 0; m = m->next);
|
||||||
if (m)
|
if (m)
|
||||||
c->mon = m;
|
c->mon = m;
|
||||||
}
|
}
|
||||||
|
|
@ -478,8 +485,8 @@ bartabcalculate(
|
||||||
masteractive = 0, fulllayout = 0, floatlayout = 0,
|
masteractive = 0, fulllayout = 0, floatlayout = 0,
|
||||||
x, w, tgactive;
|
x, w, tgactive;
|
||||||
|
|
||||||
for (i = 0, c = m->clients; c; c = c->next) {
|
for (i = 0, c = m->cl->clients; c; c = c->next) {
|
||||||
if (!ISVISIBLE(c)) continue;
|
if (!ISVISIBLE(c, m)) continue;
|
||||||
if (c->isfloating) { clientsnfloating++; continue; }
|
if (c->isfloating) { clientsnfloating++; continue; }
|
||||||
if (m->sel == c) { masteractive = i < m->nmaster; }
|
if (m->sel == c) { masteractive = i < m->nmaster; }
|
||||||
if (i < m->nmaster) { clientsnmaster++; } else { clientsnstack++; }
|
if (i < m->nmaster) { clientsnmaster++; } else { clientsnstack++; }
|
||||||
|
|
@ -487,8 +494,8 @@ bartabcalculate(
|
||||||
}
|
}
|
||||||
for (i = 0; i < LENGTH(bartabfloatfns); i++) if (m ->lt[m->sellt]->arrange == bartabfloatfns[i]) { floatlayout = 1; break; }
|
for (i = 0; i < LENGTH(bartabfloatfns); i++) if (m ->lt[m->sellt]->arrange == bartabfloatfns[i]) { floatlayout = 1; break; }
|
||||||
for (i = 0; i < LENGTH(bartabmonfns); i++) if (m ->lt[m->sellt]->arrange == bartabmonfns[i]) { fulllayout = 1; break; }
|
for (i = 0; i < LENGTH(bartabmonfns); i++) if (m ->lt[m->sellt]->arrange == bartabmonfns[i]) { fulllayout = 1; break; }
|
||||||
for (c = m->clients, i = 0; c; c = c->next) {
|
for (c = m->cl->clients, i = 0; c; c = c->next) {
|
||||||
if (!ISVISIBLE(c)) continue;
|
if (!ISVISIBLE(c, m)) continue;
|
||||||
if (clientsnmaster + clientsnstack == 0 || floatlayout) {
|
if (clientsnmaster + clientsnstack == 0 || floatlayout) {
|
||||||
x = offx + (((m->mw - offx - sw) / (clientsnmaster + clientsnstack + clientsnfloating)) * i);
|
x = offx + (((m->mw - offx - sw) / (clientsnmaster + clientsnstack + clientsnfloating)) * i);
|
||||||
w = (m->mw - offx - sw) / (clientsnmaster + clientsnstack + clientsnfloating);
|
w = (m->mw - offx - sw) / (clientsnmaster + clientsnstack + clientsnfloating);
|
||||||
|
|
@ -515,9 +522,9 @@ void
|
||||||
arrange(Monitor *m)
|
arrange(Monitor *m)
|
||||||
{
|
{
|
||||||
if (m)
|
if (m)
|
||||||
showhide(m->stack);
|
showhide(m->cl->stack);
|
||||||
else for (m = mons; m; m = m->next)
|
else for (m = mons; m; m = m->next)
|
||||||
showhide(m->stack);
|
showhide(m->cl->stack);
|
||||||
if (m) {
|
if (m) {
|
||||||
arrangemon(m);
|
arrangemon(m);
|
||||||
restack(m);
|
restack(m);
|
||||||
|
|
@ -536,15 +543,49 @@ arrangemon(Monitor *m)
|
||||||
void
|
void
|
||||||
attach(Client *c)
|
attach(Client *c)
|
||||||
{
|
{
|
||||||
c->next = c->mon->clients;
|
c->next = c->mon->cl->clients;
|
||||||
c->mon->clients = c;
|
c->mon->cl->clients = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
attachclients(Monitor *m) {
|
||||||
|
/* attach clients to the specified monitor */
|
||||||
|
Monitor *tm;
|
||||||
|
Client *c;
|
||||||
|
unsigned int utags = 0;
|
||||||
|
Bool rmons = False;
|
||||||
|
if(!m)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* collect information about the tags in use */
|
||||||
|
for (tm = mons; tm; tm = tm->next)
|
||||||
|
if(tm != m)
|
||||||
|
utags |= tm->tagset[tm->seltags];
|
||||||
|
|
||||||
|
for (c = m->cl->clients; c; c = c->next)
|
||||||
|
if(ISVISIBLE(c, m)) {
|
||||||
|
/* if client is also visible on other tags that are displayed on
|
||||||
|
* other monitors, remove these tags */
|
||||||
|
if(c->tags & utags) {
|
||||||
|
c->tags = c->tags & m->tagset[m->seltags];
|
||||||
|
rmons = True;
|
||||||
|
}
|
||||||
|
unfocus(c, True);
|
||||||
|
c->mon = m;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rmons)
|
||||||
|
for (tm = mons; tm; tm = tm->next)
|
||||||
|
if(tm != m)
|
||||||
|
arrange(tm);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
attachstack(Client *c)
|
attachstack(Client *c)
|
||||||
{
|
{
|
||||||
c->snext = c->mon->stack;
|
c->snext = c->mon->cl->stack;
|
||||||
c->mon->stack = c;
|
c->mon->cl->stack = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -611,8 +652,8 @@ cleanup(void)
|
||||||
view(&a);
|
view(&a);
|
||||||
selmon->lt[selmon->sellt] = &foo;
|
selmon->lt[selmon->sellt] = &foo;
|
||||||
for (m = mons; m; m = m->next)
|
for (m = mons; m; m = m->next)
|
||||||
while (m->stack)
|
while (m->cl->stack)
|
||||||
unmanage(m->stack, 0);
|
unmanage(m->cl->stack, 0);
|
||||||
XUngrabKey(dpy, AnyKey, AnyModifier, root);
|
XUngrabKey(dpy, AnyKey, AnyModifier, root);
|
||||||
while (mons)
|
while (mons)
|
||||||
cleanupmon(mons);
|
cleanupmon(mons);
|
||||||
|
|
@ -699,7 +740,7 @@ configurenotify(XEvent *e)
|
||||||
drw_resize(drw, sw, bh);
|
drw_resize(drw, sw, bh);
|
||||||
updatebars();
|
updatebars();
|
||||||
for (m = mons; m; m = m->next) {
|
for (m = mons; m; m = m->next) {
|
||||||
for (c = m->clients; c; c = c->next)
|
for (c = m->cl->clients; c; c = c->next)
|
||||||
if (c->isfullscreen)
|
if (c->isfullscreen)
|
||||||
resizeclient(c, m->mx, m->my, m->mw, m->mh);
|
resizeclient(c, m->mx, m->my, m->mw, m->mh);
|
||||||
XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh);
|
XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh);
|
||||||
|
|
@ -745,7 +786,7 @@ configurerequest(XEvent *e)
|
||||||
c->y = m->my + (m->mh / 2 - HEIGHT(c) / 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)))
|
if ((ev->value_mask & (CWX|CWY)) && !(ev->value_mask & (CWWidth|CWHeight)))
|
||||||
configure(c);
|
configure(c);
|
||||||
if (ISVISIBLE(c))
|
if (ISVISIBLE(c, m))
|
||||||
XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
|
XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
|
||||||
} else
|
} else
|
||||||
configure(c);
|
configure(c);
|
||||||
|
|
@ -765,11 +806,32 @@ configurerequest(XEvent *e)
|
||||||
Monitor *
|
Monitor *
|
||||||
createmon(void)
|
createmon(void)
|
||||||
{
|
{
|
||||||
Monitor *m;
|
Monitor *m, *tm;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
|
/* bail out if the number of monitors exceeds the number of tags */
|
||||||
|
for (i=1, tm=mons; tm; i++, tm=tm->next);
|
||||||
|
if (i > LENGTH(tags)) {
|
||||||
|
fprintf(stderr, "dwm: failed to add monitor, number of tags exceeded\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
/* find the first tag that isn't in use */
|
||||||
|
for (i=0; i < LENGTH(tags); i++) {
|
||||||
|
for (tm=mons; tm && !(tm->tagset[tm->seltags] & (1<<i)); tm=tm->next);
|
||||||
|
if (!tm)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/* reassign all tags to monitors since there's currently no free tag for the
|
||||||
|
* new monitor */
|
||||||
|
if (i >= LENGTH(tags))
|
||||||
|
for (i=0, tm=mons; tm; tm=tm->next, i++) {
|
||||||
|
tm->seltags ^= 1;
|
||||||
|
tm->tagset[tm->seltags] = (1<<i) & TAGMASK;
|
||||||
|
}
|
||||||
|
|
||||||
m = ecalloc(1, sizeof(Monitor));
|
m = ecalloc(1, sizeof(Monitor));
|
||||||
m->tagset[0] = m->tagset[1] = 1;
|
m->cl = cl;
|
||||||
|
m->tagset[0] = m->tagset[1] = (1<<i) & TAGMASK;
|
||||||
m->mfact = mfact;
|
m->mfact = mfact;
|
||||||
m->nmaster = nmaster;
|
m->nmaster = nmaster;
|
||||||
m->showbar = showbar;
|
m->showbar = showbar;
|
||||||
|
|
@ -809,7 +871,7 @@ detach(Client *c)
|
||||||
{
|
{
|
||||||
Client **tc;
|
Client **tc;
|
||||||
|
|
||||||
for (tc = &c->mon->clients; *tc && *tc != c; tc = &(*tc)->next);
|
for (tc = &c->mon->cl->clients; *tc && *tc != c; tc = &(*tc)->next);
|
||||||
*tc = c->next;
|
*tc = c->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -818,11 +880,11 @@ detachstack(Client *c)
|
||||||
{
|
{
|
||||||
Client **tc, *t;
|
Client **tc, *t;
|
||||||
|
|
||||||
for (tc = &c->mon->stack; *tc && *tc != c; tc = &(*tc)->snext);
|
for (tc = &c->mon->cl->stack; *tc && *tc != c; tc = &(*tc)->snext);
|
||||||
*tc = c->snext;
|
*tc = c->snext;
|
||||||
|
|
||||||
if (c == c->mon->sel) {
|
if (c == c->mon->sel) {
|
||||||
for (t = c->mon->stack; t && !ISVISIBLE(t); t = t->snext);
|
for (t = c->mon->cl->stack; t && !ISVISIBLE(t, c->mon); t = t->snext);
|
||||||
c->mon->sel = t;
|
c->mon->sel = t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -861,7 +923,8 @@ drawbar(Monitor *m)
|
||||||
drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0);
|
drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (c = m->clients; c; c = c->next) {
|
resizebarwin(m);
|
||||||
|
for (c = m->cl->clients; c; c = c->next) {
|
||||||
occ |= c->tags;
|
occ |= c->tags;
|
||||||
if (c->isurgent)
|
if (c->isurgent)
|
||||||
urg |= c->tags;
|
urg |= c->tags;
|
||||||
|
|
@ -934,8 +997,8 @@ expose(XEvent *e)
|
||||||
void
|
void
|
||||||
focus(Client *c)
|
focus(Client *c)
|
||||||
{
|
{
|
||||||
if (!c || !ISVISIBLE(c))
|
if (!c || !ISVISIBLE(c, selmon))
|
||||||
for (c = selmon->stack; c && !ISVISIBLE(c); c = c->snext);
|
for (c = selmon->cl->stack; c && !ISVISIBLE(c, selmon); c = c->snext);
|
||||||
if (selmon->sel && selmon->sel != c)
|
if (selmon->sel && selmon->sel != c)
|
||||||
unfocus(selmon->sel, 0);
|
unfocus(selmon->sel, 0);
|
||||||
if (c) {
|
if (c) {
|
||||||
|
|
@ -988,16 +1051,16 @@ focusstack(const Arg *arg)
|
||||||
if (!selmon->sel || (selmon->sel->isfullscreen && lockfullscreen))
|
if (!selmon->sel || (selmon->sel->isfullscreen && lockfullscreen))
|
||||||
return;
|
return;
|
||||||
if (arg->i > 0) {
|
if (arg->i > 0) {
|
||||||
for (c = selmon->sel->next; c && !ISVISIBLE(c); c = c->next);
|
for (c = selmon->sel->next; c && !ISVISIBLE(c, selmon); c = c->next);
|
||||||
if (!c)
|
if (!c)
|
||||||
for (c = selmon->clients; c && !ISVISIBLE(c); c = c->next);
|
for (c = selmon->cl->clients; c && !ISVISIBLE(c, selmon); c = c->next);
|
||||||
} else {
|
} else {
|
||||||
for (i = selmon->clients; i != selmon->sel; i = i->next)
|
for (i = selmon->cl->clients; i != selmon->sel; i = i->next)
|
||||||
if (ISVISIBLE(i))
|
if (ISVISIBLE(i, selmon))
|
||||||
c = i;
|
c = i;
|
||||||
if (!c)
|
if (!c)
|
||||||
for (; i; i = i->next)
|
for (; i; i = i->next)
|
||||||
if (ISVISIBLE(i))
|
if (ISVISIBLE(i, selmon))
|
||||||
c = i;
|
c = i;
|
||||||
}
|
}
|
||||||
if (c) {
|
if (c) {
|
||||||
|
|
@ -1281,12 +1344,12 @@ monocle(Monitor *m)
|
||||||
unsigned int n = 0;
|
unsigned int n = 0;
|
||||||
Client *c;
|
Client *c;
|
||||||
|
|
||||||
for (c = m->clients; c; c = c->next)
|
for (c = m->cl->clients; c; c = c->next)
|
||||||
if (ISVISIBLE(c))
|
if (ISVISIBLE(c, m))
|
||||||
n++;
|
n++;
|
||||||
if (n > 0) /* override layout symbol */
|
if (n > 0) /* override layout symbol */
|
||||||
snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n);
|
snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n);
|
||||||
for (c = nexttiled(m->clients); c; c = nexttiled(c->next))
|
for (c = nexttiled(m->cl->clients, m); c; c = nexttiled(c->next, m))
|
||||||
resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0);
|
resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1368,9 +1431,9 @@ movemouse(const Arg *arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
Client *
|
Client *
|
||||||
nexttiled(Client *c)
|
nexttiled(Client *c, Monitor *m)
|
||||||
{
|
{
|
||||||
for (; c && (c->isfloating || !ISVISIBLE(c)); c = c->next);
|
for (; c && (c->isfloating || !ISVISIBLE(c, m)); c = c->next);
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1535,8 +1598,8 @@ restack(Monitor *m)
|
||||||
if (m->lt[m->sellt]->arrange) {
|
if (m->lt[m->sellt]->arrange) {
|
||||||
wc.stack_mode = Below;
|
wc.stack_mode = Below;
|
||||||
wc.sibling = m->barwin;
|
wc.sibling = m->barwin;
|
||||||
for (c = m->stack; c; c = c->snext)
|
for (c = m->cl->stack; c; c = c->snext)
|
||||||
if (!c->isfloating && ISVISIBLE(c)) {
|
if (!c->isfloating && ISVISIBLE(c, m)) {
|
||||||
XConfigureWindow(dpy, c->win, CWSibling|CWStackMode, &wc);
|
XConfigureWindow(dpy, c->win, CWSibling|CWStackMode, &wc);
|
||||||
wc.sibling = c->win;
|
wc.sibling = c->win;
|
||||||
}
|
}
|
||||||
|
|
@ -1666,11 +1729,9 @@ sendmon(Client *c, Monitor *m)
|
||||||
if (c->mon == m)
|
if (c->mon == m)
|
||||||
return;
|
return;
|
||||||
unfocus(c, 1);
|
unfocus(c, 1);
|
||||||
detach(c);
|
|
||||||
detachstack(c);
|
detachstack(c);
|
||||||
c->mon = m;
|
c->mon = m;
|
||||||
c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
|
c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
|
||||||
attach(c);
|
|
||||||
attachstack(c);
|
attachstack(c);
|
||||||
setclienttagprop(c);
|
setclienttagprop(c);
|
||||||
focus(NULL);
|
focus(NULL);
|
||||||
|
|
@ -1804,6 +1865,8 @@ setup(void)
|
||||||
screen = DefaultScreen(dpy);
|
screen = DefaultScreen(dpy);
|
||||||
sw = DisplayWidth(dpy, screen);
|
sw = DisplayWidth(dpy, screen);
|
||||||
sh = DisplayHeight(dpy, screen);
|
sh = DisplayHeight(dpy, screen);
|
||||||
|
if(!(cl = (Clientlist *)calloc(1, sizeof(Clientlist))))
|
||||||
|
die("fatal: could not malloc() %u bytes\n", sizeof(Clientlist));
|
||||||
root = RootWindow(dpy, screen);
|
root = RootWindow(dpy, screen);
|
||||||
drw = drw_create(dpy, screen, root, sw, sh);
|
drw = drw_create(dpy, screen, root, sw, sh);
|
||||||
if (!drw_fontset_create(drw, fonts, LENGTH(fonts)))
|
if (!drw_fontset_create(drw, fonts, LENGTH(fonts)))
|
||||||
|
|
@ -1880,7 +1943,7 @@ showhide(Client *c)
|
||||||
{
|
{
|
||||||
if (!c)
|
if (!c)
|
||||||
return;
|
return;
|
||||||
if (ISVISIBLE(c)) {
|
if (ISVISIBLE(c, c->mon)) {
|
||||||
/* show clients top down */
|
/* show clients top down */
|
||||||
window_map(dpy, c, 1);
|
window_map(dpy, c, 1);
|
||||||
showhide(c->snext);
|
showhide(c->snext);
|
||||||
|
|
@ -1938,8 +2001,26 @@ setclienttagprop(Client *c)
|
||||||
void
|
void
|
||||||
tag(const Arg *arg)
|
tag(const Arg *arg)
|
||||||
{
|
{
|
||||||
|
Monitor *m;
|
||||||
|
unsigned int newtags;
|
||||||
Client *c;
|
Client *c;
|
||||||
|
|
||||||
if (selmon->sel && arg->ui & TAGMASK) {
|
if (selmon->sel && arg->ui & TAGMASK) {
|
||||||
|
newtags = arg->ui & TAGMASK;
|
||||||
|
for (m = mons; m; m = m->next)
|
||||||
|
/* if tag is visible on another monitor, move client to the new monitor */
|
||||||
|
if (m != selmon && m->tagset[m->seltags] & newtags) {
|
||||||
|
/* prevent moving client to all tags (MODKEY-Shift-0) when multiple monitors are connected */
|
||||||
|
if(newtags & selmon->tagset[selmon->seltags])
|
||||||
|
return;
|
||||||
|
selmon->sel->tags = newtags;
|
||||||
|
selmon->sel->mon = m;
|
||||||
|
arrange(m);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/* workaround in case just one monitor is connected */
|
||||||
|
|
||||||
|
|
||||||
c = selmon->sel;
|
c = selmon->sel;
|
||||||
selmon->sel->tags = arg->ui & TAGMASK;
|
selmon->sel->tags = arg->ui & TAGMASK;
|
||||||
setclienttagprop(c);
|
setclienttagprop(c);
|
||||||
|
|
@ -1962,7 +2043,7 @@ tile(Monitor *m)
|
||||||
unsigned int i, n, h, mw, my, ty;
|
unsigned int i, n, h, mw, my, ty;
|
||||||
Client *c;
|
Client *c;
|
||||||
|
|
||||||
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
|
for (n = 0, c = nexttiled(m->cl->clients, m); c; c = nexttiled(c->next, m), n++);
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
@ -1970,7 +2051,7 @@ tile(Monitor *m)
|
||||||
mw = m->nmaster ? m->ww * m->mfact : 0;
|
mw = m->nmaster ? m->ww * m->mfact : 0;
|
||||||
else
|
else
|
||||||
mw = m->ww;
|
mw = m->ww;
|
||||||
for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
|
for (i = my = ty = 0, c = nexttiled(m->cl->clients, m); c; c = nexttiled(c->next, m), i++)
|
||||||
if (i < m->nmaster) {
|
if (i < m->nmaster) {
|
||||||
h = (m->wh - my) / (MIN(n, m->nmaster) - i);
|
h = (m->wh - my) / (MIN(n, m->nmaster) - i);
|
||||||
resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
|
resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
|
||||||
|
|
@ -2010,12 +2091,17 @@ togglefloating(const Arg *arg)
|
||||||
void
|
void
|
||||||
toggletag(const Arg *arg)
|
toggletag(const Arg *arg)
|
||||||
{
|
{
|
||||||
|
Monitor *m;
|
||||||
unsigned int newtags;
|
unsigned int newtags;
|
||||||
|
|
||||||
if (!selmon->sel)
|
if (!selmon->sel)
|
||||||
return;
|
return;
|
||||||
newtags = selmon->sel->tags ^ (arg->ui & TAGMASK);
|
newtags = selmon->sel->tags ^ (arg->ui & TAGMASK);
|
||||||
if (newtags) {
|
if (newtags) {
|
||||||
|
/* prevent adding tags that are in use on other monitors */
|
||||||
|
for (m = mons; m; m = m->next)
|
||||||
|
if (m != selmon && newtags & m->tagset[m->seltags])
|
||||||
|
return;
|
||||||
selmon->sel->tags = newtags;
|
selmon->sel->tags = newtags;
|
||||||
setclienttagprop(selmon->sel);
|
setclienttagprop(selmon->sel);
|
||||||
focus(NULL);
|
focus(NULL);
|
||||||
|
|
@ -2155,7 +2241,7 @@ updateclientlist()
|
||||||
|
|
||||||
XDeleteProperty(dpy, root, netatom[NetClientList]);
|
XDeleteProperty(dpy, root, netatom[NetClientList]);
|
||||||
for (m = mons; m; m = m->next)
|
for (m = mons; m; m = m->next)
|
||||||
for (c = m->clients; c; c = c->next)
|
for (c = m->cl->clients; c; c = c->next)
|
||||||
XChangeProperty(dpy, root, netatom[NetClientList],
|
XChangeProperty(dpy, root, netatom[NetClientList],
|
||||||
XA_WINDOW, 32, PropModeAppend,
|
XA_WINDOW, 32, PropModeAppend,
|
||||||
(unsigned char *) &(c->win), 1);
|
(unsigned char *) &(c->win), 1);
|
||||||
|
|
@ -2186,8 +2272,10 @@ updategeom(void)
|
||||||
/* new monitors if nn > n */
|
/* new monitors if nn > n */
|
||||||
for (i = n; i < nn; i++) {
|
for (i = n; i < nn; i++) {
|
||||||
for (m = mons; m && m->next; m = m->next);
|
for (m = mons; m && m->next; m = m->next);
|
||||||
if (m)
|
if (m) {
|
||||||
m->next = createmon();
|
m->next = createmon();
|
||||||
|
attachclients(m->next);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
mons = createmon();
|
mons = createmon();
|
||||||
}
|
}
|
||||||
|
|
@ -2207,16 +2295,13 @@ updategeom(void)
|
||||||
/* removed monitors if n > nn */
|
/* removed monitors if n > nn */
|
||||||
for (i = nn; i < n; i++) {
|
for (i = nn; i < n; i++) {
|
||||||
for (m = mons; m && m->next; m = m->next);
|
for (m = mons; m && m->next; m = m->next);
|
||||||
while ((c = m->clients)) {
|
|
||||||
dirty = 1;
|
|
||||||
m->clients = c->next;
|
|
||||||
detachstack(c);
|
|
||||||
c->mon = mons;
|
|
||||||
attach(c);
|
|
||||||
attachstack(c);
|
|
||||||
}
|
|
||||||
if (m == selmon)
|
if (m == selmon)
|
||||||
selmon = mons;
|
selmon = mons;
|
||||||
|
for (c = m->cl->clients; c; c = c->next) {
|
||||||
|
dirty = True;
|
||||||
|
if (c->mon == m)
|
||||||
|
c->mon = selmon;
|
||||||
|
}
|
||||||
cleanupmon(m);
|
cleanupmon(m);
|
||||||
}
|
}
|
||||||
free(unique);
|
free(unique);
|
||||||
|
|
@ -2395,11 +2480,29 @@ window_unmap(Display *dpy, Window win, Window root, int iconify)
|
||||||
void
|
void
|
||||||
view(const Arg *arg)
|
view(const Arg *arg)
|
||||||
{
|
{
|
||||||
|
Monitor *m;
|
||||||
|
unsigned int newtagset = selmon->tagset[selmon->seltags ^ 1];
|
||||||
int i;
|
int i;
|
||||||
unsigned int tmptag;
|
unsigned int tmptag;
|
||||||
|
|
||||||
if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
|
if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
|
||||||
return;
|
return;
|
||||||
|
/* swap tags when trying to display a tag from another monitor */
|
||||||
|
if (arg->ui & TAGMASK)
|
||||||
|
newtagset = arg->ui & TAGMASK;
|
||||||
|
for (m = mons; m; m = m->next)
|
||||||
|
if (m != selmon && newtagset & m->tagset[m->seltags]) {
|
||||||
|
/* prevent displaying all tags (MODKEY-0) when multiple monitors
|
||||||
|
* are connected */
|
||||||
|
if (newtagset & selmon->tagset[selmon->seltags])
|
||||||
|
return;
|
||||||
|
m->sel = selmon->sel;
|
||||||
|
m->seltags ^= 1;
|
||||||
|
m->tagset[m->seltags] = selmon->tagset[selmon->seltags];
|
||||||
|
attachclients(m);
|
||||||
|
arrange(m);
|
||||||
|
break;
|
||||||
|
}
|
||||||
selmon->seltags ^= 1; /* toggle sel tagset */
|
selmon->seltags ^= 1; /* toggle sel tagset */
|
||||||
if (arg->ui & TAGMASK) {
|
if (arg->ui & TAGMASK) {
|
||||||
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
|
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
|
||||||
|
|
@ -2426,8 +2529,9 @@ view(const Arg *arg)
|
||||||
if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag])
|
if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag])
|
||||||
togglebar(NULL);
|
togglebar(NULL);
|
||||||
|
|
||||||
focus(NULL);
|
attachclients(selmon);
|
||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
|
focus(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
Client *
|
Client *
|
||||||
|
|
@ -2437,7 +2541,7 @@ wintoclient(Window w)
|
||||||
Monitor *m;
|
Monitor *m;
|
||||||
|
|
||||||
for (m = mons; m; m = m->next)
|
for (m = mons; m; m = m->next)
|
||||||
for (c = m->clients; c; c = c->next)
|
for (c = m->cl->clients; c; c = c->next)
|
||||||
if (c->win == w)
|
if (c->win == w)
|
||||||
return c;
|
return c;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -2503,7 +2607,7 @@ zoom(const Arg *arg)
|
||||||
|
|
||||||
if (!selmon->lt[selmon->sellt]->arrange || !c || c->isfloating)
|
if (!selmon->lt[selmon->sellt]->arrange || !c || c->isfloating)
|
||||||
return;
|
return;
|
||||||
if (c == nexttiled(selmon->clients) && !(c = nexttiled(c->next)))
|
if (c == nexttiled(selmon->cl->clients, selmon) && !(c = nexttiled(c->next, selmon)))
|
||||||
return;
|
return;
|
||||||
pop(c);
|
pop(c);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue