Compare commits
No commits in common. "16a1efc7872b0f958351e565426a40520590c3c2" and "52750297f1355a9c604f0ee550995e0fe61ec6e0" have entirely different histories.
16a1efc787
...
52750297f1
@ -5,7 +5,6 @@ static const unsigned int borderpx = 1; /* border pixel of windows */
|
|||||||
static const unsigned int snap = 32; /* snap pixel */
|
static const unsigned int snap = 32; /* snap pixel */
|
||||||
static const int showbar = 1; /* 0 means no bar */
|
static const int showbar = 1; /* 0 means no bar */
|
||||||
static const int topbar = 1; /* 0 means bottom bar */
|
static const int topbar = 1; /* 0 means bottom bar */
|
||||||
static const Bool viewontag = True;
|
|
||||||
static const char *fonts[] = {
|
static const char *fonts[] = {
|
||||||
"Hack Nerd Font Mono:size=12",
|
"Hack Nerd Font Mono:size=12",
|
||||||
"Noto Color Emoji:size=12"
|
"Noto Color Emoji:size=12"
|
||||||
|
126
dwm.c
126
dwm.c
@ -113,7 +113,6 @@ typedef struct {
|
|||||||
void (*arrange)(Monitor *);
|
void (*arrange)(Monitor *);
|
||||||
} Layout;
|
} Layout;
|
||||||
|
|
||||||
typedef struct Pertag Pertag;
|
|
||||||
struct Monitor {
|
struct Monitor {
|
||||||
char ltsymbol[16];
|
char ltsymbol[16];
|
||||||
float mfact;
|
float mfact;
|
||||||
@ -137,7 +136,6 @@ struct Monitor {
|
|||||||
Monitor *next;
|
Monitor *next;
|
||||||
Window barwin;
|
Window barwin;
|
||||||
const Layout *lt[2];
|
const Layout *lt[2];
|
||||||
Pertag *pertag;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -222,7 +220,6 @@ static void show(const Arg *arg);
|
|||||||
static void showall(const Arg *arg);
|
static void showall(const Arg *arg);
|
||||||
static void showwin(Client *c);
|
static void showwin(Client *c);
|
||||||
static void showhide(Client *c);
|
static void showhide(Client *c);
|
||||||
static int solitary(Client *c);
|
|
||||||
static void spawn(const Arg *arg);
|
static void spawn(const Arg *arg);
|
||||||
static void tag(const Arg *arg);
|
static void tag(const Arg *arg);
|
||||||
static void tagmon(const Arg *arg);
|
static void tagmon(const Arg *arg);
|
||||||
@ -294,15 +291,6 @@ static Window root, wmcheckwin;
|
|||||||
/* configuration, allows nested code to access above variables */
|
/* configuration, allows nested code to access above variables */
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
struct Pertag {
|
|
||||||
unsigned int curtag, prevtag; /* current and previous tag */
|
|
||||||
int nmasters[LENGTH(tags) + 1]; /* number of windows in master area */
|
|
||||||
float mfacts[LENGTH(tags) + 1]; /* mfacts per tag */
|
|
||||||
unsigned int sellts[LENGTH(tags) + 1]; /* selected layouts */
|
|
||||||
const Layout *ltidxs[LENGTH(tags) + 1][2]; /* matrix of tags and layouts indexes */
|
|
||||||
int showbars[LENGTH(tags) + 1]; /* display bar for the current tag */
|
|
||||||
};
|
|
||||||
|
|
||||||
/* compile-time check if all tags fit into an unsigned int bit array. */
|
/* compile-time check if all tags fit into an unsigned int bit array. */
|
||||||
struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
|
struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
|
||||||
|
|
||||||
@ -465,15 +453,9 @@ buttonpress(XEvent *e)
|
|||||||
}
|
}
|
||||||
if (ev->window == selmon->barwin) {
|
if (ev->window == selmon->barwin) {
|
||||||
i = x = 0;
|
i = x = 0;
|
||||||
unsigned int occ = 0;
|
do
|
||||||
for(c = m->clients; c; c=c->next)
|
|
||||||
occ |= c->tags;
|
|
||||||
do {
|
|
||||||
/* Do not reserve space for vacant tags */
|
|
||||||
if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
|
|
||||||
continue;
|
|
||||||
x += TEXTW(tags[i]);
|
x += TEXTW(tags[i]);
|
||||||
} while (ev->x >= x && ++i < LENGTH(tags));
|
while (ev->x >= x && ++i < LENGTH(tags));
|
||||||
if (i < LENGTH(tags)) {
|
if (i < LENGTH(tags)) {
|
||||||
click = ClkTagBar;
|
click = ClkTagBar;
|
||||||
arg.ui = 1 << i;
|
arg.ui = 1 << i;
|
||||||
@ -687,7 +669,6 @@ Monitor *
|
|||||||
createmon(void)
|
createmon(void)
|
||||||
{
|
{
|
||||||
Monitor *m;
|
Monitor *m;
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
m = ecalloc(1, sizeof(Monitor));
|
m = ecalloc(1, sizeof(Monitor));
|
||||||
m->tagset[0] = m->tagset[1] = 1;
|
m->tagset[0] = m->tagset[1] = 1;
|
||||||
@ -698,20 +679,6 @@ createmon(void)
|
|||||||
m->lt[0] = &layouts[0];
|
m->lt[0] = &layouts[0];
|
||||||
m->lt[1] = &layouts[1 % LENGTH(layouts)];
|
m->lt[1] = &layouts[1 % LENGTH(layouts)];
|
||||||
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
|
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
|
||||||
m->pertag = ecalloc(1, sizeof(Pertag));
|
|
||||||
m->pertag->curtag = m->pertag->prevtag = 1;
|
|
||||||
|
|
||||||
for (i = 0; i <= LENGTH(tags); i++) {
|
|
||||||
m->pertag->nmasters[i] = m->nmaster;
|
|
||||||
m->pertag->mfacts[i] = m->mfact;
|
|
||||||
|
|
||||||
m->pertag->ltidxs[i][0] = m->lt[0];
|
|
||||||
m->pertag->ltidxs[i][1] = m->lt[1];
|
|
||||||
m->pertag->sellts[i] = m->sellt;
|
|
||||||
|
|
||||||
m->pertag->showbars[i] = m->showbar;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -791,12 +758,13 @@ drawbar(Monitor *m)
|
|||||||
}
|
}
|
||||||
x = 0;
|
x = 0;
|
||||||
for (i = 0; i < LENGTH(tags); i++) {
|
for (i = 0; i < LENGTH(tags); i++) {
|
||||||
/* Do not draw vacant tags */
|
|
||||||
if(!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
|
|
||||||
continue;
|
|
||||||
w = TEXTW(tags[i]);
|
w = TEXTW(tags[i]);
|
||||||
drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
|
drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
|
||||||
drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
|
drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
|
||||||
|
if (occ & 1 << i)
|
||||||
|
drw_rect(drw, x + boxs, boxs, boxw, boxw,
|
||||||
|
m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
|
||||||
|
urg & 1 << i);
|
||||||
x += w;
|
x += w;
|
||||||
}
|
}
|
||||||
w = TEXTW(m->ltsymbol);
|
w = TEXTW(m->ltsymbol);
|
||||||
@ -900,11 +868,7 @@ focus(Client *c)
|
|||||||
detachstack(c);
|
detachstack(c);
|
||||||
attachstack(c);
|
attachstack(c);
|
||||||
grabbuttons(c, 1);
|
grabbuttons(c, 1);
|
||||||
/* Avoid flickering when another client appears and the border
|
|
||||||
* is restored */
|
|
||||||
if (!solitary(c)) {
|
|
||||||
XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel);
|
XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel);
|
||||||
}
|
|
||||||
setfocus(c);
|
setfocus(c);
|
||||||
} else {
|
} else {
|
||||||
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
|
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
|
||||||
@ -1137,7 +1101,7 @@ hidewin(Client *c) {
|
|||||||
void
|
void
|
||||||
incnmaster(const Arg *arg)
|
incnmaster(const Arg *arg)
|
||||||
{
|
{
|
||||||
selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag] = MAX(selmon->nmaster + arg->i, 0);
|
selmon->nmaster = MAX(selmon->nmaster + arg->i, 0);
|
||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1519,11 +1483,6 @@ resizeclient(Client *c, int x, int y, int w, int h)
|
|||||||
c->oldw = c->w; c->w = wc.width = w;
|
c->oldw = c->w; c->w = wc.width = w;
|
||||||
c->oldh = c->h; c->h = wc.height = h;
|
c->oldh = c->h; c->h = wc.height = h;
|
||||||
wc.border_width = c->bw;
|
wc.border_width = c->bw;
|
||||||
if (solitary(c)) {
|
|
||||||
c->w = wc.width += c->bw * 2;
|
|
||||||
c->h = wc.height += c->bw * 2;
|
|
||||||
wc.border_width = 0;
|
|
||||||
}
|
|
||||||
XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
|
XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
|
||||||
configure(c);
|
configure(c);
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
@ -1833,9 +1792,9 @@ void
|
|||||||
setlayout(const Arg *arg)
|
setlayout(const Arg *arg)
|
||||||
{
|
{
|
||||||
if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
|
if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
|
||||||
selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag] ^= 1;
|
selmon->sellt ^= 1;
|
||||||
if (arg && arg->v)
|
if (arg && arg->v)
|
||||||
selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt] = (Layout *)arg->v;
|
selmon->lt[selmon->sellt] = (Layout *)arg->v;
|
||||||
strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol);
|
strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol);
|
||||||
if (selmon->sel)
|
if (selmon->sel)
|
||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
@ -1854,7 +1813,7 @@ setmfact(const Arg *arg)
|
|||||||
f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0;
|
f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0;
|
||||||
if (f < 0.05 || f > 0.95)
|
if (f < 0.05 || f > 0.95)
|
||||||
return;
|
return;
|
||||||
selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag] = f;
|
selmon->mfact = f;
|
||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2002,15 +1961,6 @@ showhide(Client *c)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
solitary(Client *c)
|
|
||||||
{
|
|
||||||
return ((nexttiled(c->mon->clients) == c && !nexttiled(c->next))
|
|
||||||
|| &monocle == c->mon->lt[c->mon->sellt]->arrange)
|
|
||||||
&& !c->isfullscreen && !c->isfloating
|
|
||||||
&& NULL != c->mon->lt[c->mon->sellt]->arrange;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
spawn(const Arg *arg)
|
spawn(const Arg *arg)
|
||||||
{
|
{
|
||||||
@ -2040,8 +1990,6 @@ tag(const Arg *arg)
|
|||||||
selmon->sel->tags = arg->ui & TAGMASK;
|
selmon->sel->tags = arg->ui & TAGMASK;
|
||||||
focus(NULL);
|
focus(NULL);
|
||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
if(viewontag)
|
|
||||||
view(arg);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2084,7 +2032,7 @@ tile(Monitor *m)
|
|||||||
void
|
void
|
||||||
togglebar(const Arg *arg)
|
togglebar(const Arg *arg)
|
||||||
{
|
{
|
||||||
selmon->showbar = selmon->pertag->showbars[selmon->pertag->curtag] = !selmon->showbar;
|
selmon->showbar = !selmon->showbar;
|
||||||
updatebarpos(selmon);
|
updatebarpos(selmon);
|
||||||
XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
|
XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
|
||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
@ -2123,33 +2071,9 @@ void
|
|||||||
toggleview(const Arg *arg)
|
toggleview(const Arg *arg)
|
||||||
{
|
{
|
||||||
unsigned int newtagset = selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK);
|
unsigned int newtagset = selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK);
|
||||||
int i;
|
|
||||||
|
|
||||||
if (newtagset) {
|
if (newtagset) {
|
||||||
selmon->tagset[selmon->seltags] = newtagset;
|
selmon->tagset[selmon->seltags] = newtagset;
|
||||||
|
|
||||||
if (newtagset == ~0) {
|
|
||||||
selmon->pertag->prevtag = selmon->pertag->curtag;
|
|
||||||
selmon->pertag->curtag = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* test if the user did not select the same tag */
|
|
||||||
if (!(newtagset & 1 << (selmon->pertag->curtag - 1))) {
|
|
||||||
selmon->pertag->prevtag = selmon->pertag->curtag;
|
|
||||||
for (i = 0; !(newtagset & 1 << i); i++) ;
|
|
||||||
selmon->pertag->curtag = i + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* apply settings for this view */
|
|
||||||
selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag];
|
|
||||||
selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag];
|
|
||||||
selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag];
|
|
||||||
selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt];
|
|
||||||
selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1];
|
|
||||||
|
|
||||||
if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag])
|
|
||||||
togglebar(NULL);
|
|
||||||
|
|
||||||
focus(NULL);
|
focus(NULL);
|
||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
}
|
}
|
||||||
@ -2464,37 +2388,11 @@ updatewmhints(Client *c)
|
|||||||
void
|
void
|
||||||
view(const Arg *arg)
|
view(const Arg *arg)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
unsigned int tmptag;
|
|
||||||
|
|
||||||
if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
|
if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
|
||||||
return;
|
return;
|
||||||
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;
|
||||||
selmon->pertag->prevtag = selmon->pertag->curtag;
|
|
||||||
|
|
||||||
if (arg->ui == ~0)
|
|
||||||
selmon->pertag->curtag = 0;
|
|
||||||
else {
|
|
||||||
for (i = 0; !(arg->ui & 1 << i); i++) ;
|
|
||||||
selmon->pertag->curtag = i + 1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
tmptag = selmon->pertag->prevtag;
|
|
||||||
selmon->pertag->prevtag = selmon->pertag->curtag;
|
|
||||||
selmon->pertag->curtag = tmptag;
|
|
||||||
}
|
|
||||||
|
|
||||||
selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag];
|
|
||||||
selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag];
|
|
||||||
selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag];
|
|
||||||
selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt];
|
|
||||||
selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1];
|
|
||||||
|
|
||||||
if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag])
|
|
||||||
togglebar(NULL);
|
|
||||||
|
|
||||||
focus(NULL);
|
focus(NULL);
|
||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
}
|
}
|
||||||
|
@ -1,39 +0,0 @@
|
|||||||
diff --git a/dwm.c b/dwm.c
|
|
||||||
index a96f33c..f2da729 100644
|
|
||||||
--- a/dwm.c
|
|
||||||
+++ b/dwm.c
|
|
||||||
@@ -432,9 +432,15 @@ buttonpress(XEvent *e)
|
|
||||||
}
|
|
||||||
if (ev->window == selmon->barwin) {
|
|
||||||
i = x = 0;
|
|
||||||
- do
|
|
||||||
+ unsigned int occ = 0;
|
|
||||||
+ for(c = m->clients; c; c=c->next)
|
|
||||||
+ occ |= c->tags;
|
|
||||||
+ do {
|
|
||||||
+ /* Do not reserve space for vacant tags */
|
|
||||||
+ if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
|
|
||||||
+ continue;
|
|
||||||
x += TEXTW(tags[i]);
|
|
||||||
- while (ev->x >= x && ++i < LENGTH(tags));
|
|
||||||
+ } while (ev->x >= x && ++i < LENGTH(tags));
|
|
||||||
if (i < LENGTH(tags)) {
|
|
||||||
click = ClkTagBar;
|
|
||||||
arg.ui = 1 << i;
|
|
||||||
@@ -719,13 +725,12 @@ drawbar(Monitor *m)
|
|
||||||
}
|
|
||||||
x = 0;
|
|
||||||
for (i = 0; i < LENGTH(tags); i++) {
|
|
||||||
+ /* Do not draw vacant tags */
|
|
||||||
+ if(!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
|
|
||||||
+ continue;
|
|
||||||
w = TEXTW(tags[i]);
|
|
||||||
drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
|
|
||||||
drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
|
|
||||||
- if (occ & 1 << i)
|
|
||||||
- drw_rect(drw, x + boxs, boxs, boxw, boxw,
|
|
||||||
- m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
|
|
||||||
- urg & 1 << i);
|
|
||||||
x += w;
|
|
||||||
}
|
|
||||||
w = blw = TEXTW(m->ltsymbol);
|
|
@ -1,53 +0,0 @@
|
|||||||
diff --git dwm.c dwm.c
|
|
||||||
index 0fc328a..4a767bd 100644
|
|
||||||
--- dwm.c
|
|
||||||
+++ dwm.c
|
|
||||||
@@ -206,6 +206,7 @@ static void setup(void);
|
|
||||||
static void seturgent(Client *c, int urg);
|
|
||||||
static void showhide(Client *c);
|
|
||||||
static void sigchld(int unused);
|
|
||||||
+static int solitary(Client *c);
|
|
||||||
static void spawn(const Arg *arg);
|
|
||||||
static void tag(const Arg *arg);
|
|
||||||
static void tagmon(const Arg *arg);
|
|
||||||
@@ -802,7 +803,11 @@ focus(Client *c)
|
|
||||||
detachstack(c);
|
|
||||||
attachstack(c);
|
|
||||||
grabbuttons(c, 1);
|
|
||||||
- XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel);
|
|
||||||
+ /* Avoid flickering when another client appears and the border
|
|
||||||
+ * is restored */
|
|
||||||
+ if (!solitary(c)) {
|
|
||||||
+ XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel);
|
|
||||||
+ }
|
|
||||||
setfocus(c);
|
|
||||||
} else {
|
|
||||||
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
|
|
||||||
@@ -1288,6 +1293,11 @@ resizeclient(Client *c, int x, int y, int w, int h)
|
|
||||||
c->oldw = c->w; c->w = wc.width = w;
|
|
||||||
c->oldh = c->h; c->h = wc.height = h;
|
|
||||||
wc.border_width = c->bw;
|
|
||||||
+ if (solitary(c)) {
|
|
||||||
+ c->w = wc.width += c->bw * 2;
|
|
||||||
+ c->h = wc.height += c->bw * 2;
|
|
||||||
+ wc.border_width = 0;
|
|
||||||
+ }
|
|
||||||
XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
|
|
||||||
configure(c);
|
|
||||||
XSync(dpy, False);
|
|
||||||
@@ -1642,6 +1652,15 @@ sigchld(int unused)
|
|
||||||
while (0 < waitpid(-1, NULL, WNOHANG));
|
|
||||||
}
|
|
||||||
|
|
||||||
+int
|
|
||||||
+solitary(Client *c)
|
|
||||||
+{
|
|
||||||
+ return ((nexttiled(c->mon->clients) == c && !nexttiled(c->next))
|
|
||||||
+ || &monocle == c->mon->lt[c->mon->sellt]->arrange)
|
|
||||||
+ && !c->isfullscreen && !c->isfloating
|
|
||||||
+ && NULL != c->mon->lt[c->mon->sellt]->arrange;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
void
|
|
||||||
spawn(const Arg *arg)
|
|
||||||
{
|
|
@ -1,177 +0,0 @@
|
|||||||
diff --git a/dwm.c b/dwm.c
|
|
||||||
index 664c527..ac8e4ec 100644
|
|
||||||
--- a/dwm.c
|
|
||||||
+++ b/dwm.c
|
|
||||||
@@ -111,6 +111,7 @@ typedef struct {
|
|
||||||
void (*arrange)(Monitor *);
|
|
||||||
} Layout;
|
|
||||||
|
|
||||||
+typedef struct Pertag Pertag;
|
|
||||||
struct Monitor {
|
|
||||||
char ltsymbol[16];
|
|
||||||
float mfact;
|
|
||||||
@@ -130,6 +131,7 @@ struct Monitor {
|
|
||||||
Monitor *next;
|
|
||||||
Window barwin;
|
|
||||||
const Layout *lt[2];
|
|
||||||
+ Pertag *pertag;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
@@ -272,6 +274,15 @@ static Window root, wmcheckwin;
|
|
||||||
/* configuration, allows nested code to access above variables */
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
+struct Pertag {
|
|
||||||
+ unsigned int curtag, prevtag; /* current and previous tag */
|
|
||||||
+ int nmasters[LENGTH(tags) + 1]; /* number of windows in master area */
|
|
||||||
+ float mfacts[LENGTH(tags) + 1]; /* mfacts per tag */
|
|
||||||
+ unsigned int sellts[LENGTH(tags) + 1]; /* selected layouts */
|
|
||||||
+ const Layout *ltidxs[LENGTH(tags) + 1][2]; /* matrix of tags and layouts indexes */
|
|
||||||
+ int showbars[LENGTH(tags) + 1]; /* display bar for the current tag */
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
/* compile-time check if all tags fit into an unsigned int bit array. */
|
|
||||||
struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
|
|
||||||
|
|
||||||
@@ -632,6 +643,7 @@ Monitor *
|
|
||||||
createmon(void)
|
|
||||||
{
|
|
||||||
Monitor *m;
|
|
||||||
+ unsigned int i;
|
|
||||||
|
|
||||||
m = ecalloc(1, sizeof(Monitor));
|
|
||||||
m->tagset[0] = m->tagset[1] = 1;
|
|
||||||
@@ -642,6 +654,20 @@ createmon(void)
|
|
||||||
m->lt[0] = &layouts[0];
|
|
||||||
m->lt[1] = &layouts[1 % LENGTH(layouts)];
|
|
||||||
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
|
|
||||||
+ m->pertag = ecalloc(1, sizeof(Pertag));
|
|
||||||
+ m->pertag->curtag = m->pertag->prevtag = 1;
|
|
||||||
+
|
|
||||||
+ for (i = 0; i <= LENGTH(tags); i++) {
|
|
||||||
+ m->pertag->nmasters[i] = m->nmaster;
|
|
||||||
+ m->pertag->mfacts[i] = m->mfact;
|
|
||||||
+
|
|
||||||
+ m->pertag->ltidxs[i][0] = m->lt[0];
|
|
||||||
+ m->pertag->ltidxs[i][1] = m->lt[1];
|
|
||||||
+ m->pertag->sellts[i] = m->sellt;
|
|
||||||
+
|
|
||||||
+ m->pertag->showbars[i] = m->showbar;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
return m;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -967,7 +993,7 @@ grabkeys(void)
|
|
||||||
void
|
|
||||||
incnmaster(const Arg *arg)
|
|
||||||
{
|
|
||||||
- selmon->nmaster = MAX(selmon->nmaster + arg->i, 0);
|
|
||||||
+ selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag] = MAX(selmon->nmaster + arg->i, 0);
|
|
||||||
arrange(selmon);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1502,9 +1528,9 @@ void
|
|
||||||
setlayout(const Arg *arg)
|
|
||||||
{
|
|
||||||
if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
|
|
||||||
- selmon->sellt ^= 1;
|
|
||||||
+ selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag] ^= 1;
|
|
||||||
if (arg && arg->v)
|
|
||||||
- selmon->lt[selmon->sellt] = (Layout *)arg->v;
|
|
||||||
+ selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt] = (Layout *)arg->v;
|
|
||||||
strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol);
|
|
||||||
if (selmon->sel)
|
|
||||||
arrange(selmon);
|
|
||||||
@@ -1523,7 +1549,7 @@ setmfact(const Arg *arg)
|
|
||||||
f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0;
|
|
||||||
if (f < 0.05 || f > 0.95)
|
|
||||||
return;
|
|
||||||
- selmon->mfact = f;
|
|
||||||
+ selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag] = f;
|
|
||||||
arrange(selmon);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1702,7 +1728,7 @@ tile(Monitor *m)
|
|
||||||
void
|
|
||||||
togglebar(const Arg *arg)
|
|
||||||
{
|
|
||||||
- selmon->showbar = !selmon->showbar;
|
|
||||||
+ selmon->showbar = selmon->pertag->showbars[selmon->pertag->curtag] = !selmon->showbar;
|
|
||||||
updatebarpos(selmon);
|
|
||||||
XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
|
|
||||||
arrange(selmon);
|
|
||||||
@@ -1741,9 +1767,33 @@ void
|
|
||||||
toggleview(const Arg *arg)
|
|
||||||
{
|
|
||||||
unsigned int newtagset = selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK);
|
|
||||||
+ int i;
|
|
||||||
|
|
||||||
if (newtagset) {
|
|
||||||
selmon->tagset[selmon->seltags] = newtagset;
|
|
||||||
+
|
|
||||||
+ if (newtagset == ~0) {
|
|
||||||
+ selmon->pertag->prevtag = selmon->pertag->curtag;
|
|
||||||
+ selmon->pertag->curtag = 0;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ /* test if the user did not select the same tag */
|
|
||||||
+ if (!(newtagset & 1 << (selmon->pertag->curtag - 1))) {
|
|
||||||
+ selmon->pertag->prevtag = selmon->pertag->curtag;
|
|
||||||
+ for (i = 0; !(newtagset & 1 << i); i++) ;
|
|
||||||
+ selmon->pertag->curtag = i + 1;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ /* apply settings for this view */
|
|
||||||
+ selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag];
|
|
||||||
+ selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag];
|
|
||||||
+ selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag];
|
|
||||||
+ selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt];
|
|
||||||
+ selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1];
|
|
||||||
+
|
|
||||||
+ if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag])
|
|
||||||
+ togglebar(NULL);
|
|
||||||
+
|
|
||||||
focus(NULL);
|
|
||||||
arrange(selmon);
|
|
||||||
}
|
|
||||||
@@ -2038,11 +2088,37 @@ updatewmhints(Client *c)
|
|
||||||
void
|
|
||||||
view(const Arg *arg)
|
|
||||||
{
|
|
||||||
+ int i;
|
|
||||||
+ unsigned int tmptag;
|
|
||||||
+
|
|
||||||
if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
|
|
||||||
return;
|
|
||||||
selmon->seltags ^= 1; /* toggle sel tagset */
|
|
||||||
- if (arg->ui & TAGMASK)
|
|
||||||
+ if (arg->ui & TAGMASK) {
|
|
||||||
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
|
|
||||||
+ selmon->pertag->prevtag = selmon->pertag->curtag;
|
|
||||||
+
|
|
||||||
+ if (arg->ui == ~0)
|
|
||||||
+ selmon->pertag->curtag = 0;
|
|
||||||
+ else {
|
|
||||||
+ for (i = 0; !(arg->ui & 1 << i); i++) ;
|
|
||||||
+ selmon->pertag->curtag = i + 1;
|
|
||||||
+ }
|
|
||||||
+ } else {
|
|
||||||
+ tmptag = selmon->pertag->prevtag;
|
|
||||||
+ selmon->pertag->prevtag = selmon->pertag->curtag;
|
|
||||||
+ selmon->pertag->curtag = tmptag;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag];
|
|
||||||
+ selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag];
|
|
||||||
+ selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag];
|
|
||||||
+ selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt];
|
|
||||||
+ selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1];
|
|
||||||
+
|
|
||||||
+ if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag])
|
|
||||||
+ togglebar(NULL);
|
|
||||||
+
|
|
||||||
focus(NULL);
|
|
||||||
arrange(selmon);
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
diff -r 0d86faf4b05c config.def.h
|
|
||||||
--- a/config.def.h Sun Jul 25 09:58:25 2010 +0100
|
|
||||||
+++ b/config.def.h Sun Jul 25 16:32:38 2010 +0200
|
|
||||||
@@ -12,6 +12,7 @@
|
|
||||||
static const unsigned int snap = 32; /* snap pixel */
|
|
||||||
static const Bool showbar = True; /* False means no bar */
|
|
||||||
static const Bool topbar = True; /* False means bottom bar */
|
|
||||||
+static const Bool viewontag = True; /* Switch view on tag switch */
|
|
||||||
|
|
||||||
/* tagging */
|
|
||||||
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
|
|
||||||
diff -r 0d86faf4b05c dwm.c
|
|
||||||
--- a/dwm.c Sun Jul 25 09:58:25 2010 +0100
|
|
||||||
+++ b/dwm.c Sun Jul 25 16:32:38 2010 +0200
|
|
||||||
@@ -1613,6 +1613,8 @@
|
|
||||||
if(selmon->sel && arg->ui & TAGMASK) {
|
|
||||||
selmon->sel->tags = arg->ui & TAGMASK;
|
|
||||||
arrange(selmon);
|
|
||||||
+ if(viewontag)
|
|
||||||
+ view(arg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user