Compare commits
4 Commits
e1874b34c1
...
c361ca2c0d
Author | SHA1 | Date | |
---|---|---|---|
c361ca2c0d | |||
cd218b417b | |||
3fd2ae71f3 | |||
44206a27f3 |
101
dwm.c
101
dwm.c
@ -224,6 +224,7 @@ 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);
|
||||||
static Monitor *recttomon(int x, int y, int w, int h);
|
static Monitor *recttomon(int x, int y, int w, int h);
|
||||||
|
static void reorganizetags(const Arg *arg);
|
||||||
static void resetlayout(const Arg *arg);
|
static void resetlayout(const Arg *arg);
|
||||||
static void resize(Client *c, int x, int y, int w, int h, int interact);
|
static void resize(Client *c, int x, int y, int w, int h, int interact);
|
||||||
static void resizeclient(Client *c, int x, int y, int w, int h);
|
static void resizeclient(Client *c, int x, int y, int w, int h);
|
||||||
@ -273,6 +274,9 @@ static void updatetitle(Client *c);
|
|||||||
static void updatewindowtype(Client *c);
|
static void updatewindowtype(Client *c);
|
||||||
static void updatewmhints(Client *c);
|
static void updatewmhints(Client *c);
|
||||||
static void view(const Arg *arg);
|
static void view(const Arg *arg);
|
||||||
|
static void window_set_state(Display *dpy, Window win, long state);
|
||||||
|
static void window_map(Display *dpy, Client *c, int deiconify);
|
||||||
|
static void window_unmap(Display *dpy, Window win, Window root, int iconify);
|
||||||
static Client *wintoclient(Window w);
|
static Client *wintoclient(Window w);
|
||||||
static Monitor *wintomon(Window w);
|
static Monitor *wintomon(Window w);
|
||||||
static int xerror(Display *dpy, XErrorEvent *ee);
|
static int xerror(Display *dpy, XErrorEvent *ee);
|
||||||
@ -596,9 +600,15 @@ buttonpress(XEvent *e)
|
|||||||
}
|
}
|
||||||
if (ev->window == selmon->barwin) {
|
if (ev->window == selmon->barwin) {
|
||||||
i = x = 0;
|
i = x = 0;
|
||||||
do
|
unsigned int occ = 0;
|
||||||
|
for(c = m->clients; c; c=c->next)
|
||||||
|
occ |= c->tags == TAGMASK ? 0 : 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;
|
||||||
@ -932,12 +942,15 @@ drawbar(Monitor *m)
|
|||||||
for (c = m->clients; c; c = c->next) {
|
for (c = m->clients; c; c = c->next) {
|
||||||
if (ISVISIBLE(c))
|
if (ISVISIBLE(c))
|
||||||
n++;
|
n++;
|
||||||
occ |= c->tags;
|
occ |= c->tags == TAGMASK ? 0 : c->tags;
|
||||||
if (c->isurgent)
|
if (c->isurgent)
|
||||||
urg |= c->tags;
|
urg |= c->tags;
|
||||||
}
|
}
|
||||||
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 ? SchemeNorm : SchemeNorm]);
|
drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeNorm : 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);
|
||||||
@ -1797,6 +1810,35 @@ resetlayout(const Arg *arg)
|
|||||||
|
|
||||||
selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag] = nmaster;
|
selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag] = nmaster;
|
||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
|
|
||||||
|
reorganizetags(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
reorganizetags(const Arg *arg) {
|
||||||
|
Client *c;
|
||||||
|
unsigned int occ, unocc, i;
|
||||||
|
unsigned int tagdest[LENGTH(tags)];
|
||||||
|
|
||||||
|
occ = 0;
|
||||||
|
for (c = selmon->clients; c; c = c->next)
|
||||||
|
occ |= (1 << (ffs(c->tags)-1));
|
||||||
|
unocc = 0;
|
||||||
|
for (i = 0; i < LENGTH(tags); ++i) {
|
||||||
|
while (unocc < i && (occ & (1 << unocc)))
|
||||||
|
unocc++;
|
||||||
|
if (occ & (1 << i)) {
|
||||||
|
tagdest[i] = unocc;
|
||||||
|
occ &= ~(1 << i);
|
||||||
|
occ |= 1 << unocc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (c = selmon->clients; c; c = c->next)
|
||||||
|
c->tags = 1 << tagdest[ffs(c->tags)-1];
|
||||||
|
if (selmon->sel)
|
||||||
|
selmon->tagset[selmon->seltags] = selmon->sel->tags;
|
||||||
|
arrange(selmon);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -2310,14 +2352,12 @@ showhide(Client *c)
|
|||||||
return;
|
return;
|
||||||
if (ISVISIBLE(c)) {
|
if (ISVISIBLE(c)) {
|
||||||
/* show clients top down */
|
/* show clients top down */
|
||||||
XMoveWindow(dpy, c->win, c->x, c->y);
|
window_map(dpy, c, 1);
|
||||||
if ((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) && !c->isfullscreen)
|
|
||||||
resize(c, c->x, c->y, c->w, c->h, 0);
|
|
||||||
showhide(c->snext);
|
showhide(c->snext);
|
||||||
} else {
|
} else {
|
||||||
/* hide clients bottom up */
|
/* hide clients bottom up */
|
||||||
showhide(c->snext);
|
showhide(c->snext);
|
||||||
XMoveWindow(dpy, c->win, WIDTH(c) * -2, c->y);
|
window_unmap(dpy, c->win, root, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2444,7 +2484,7 @@ toggleextrabar(const Arg *arg)
|
|||||||
{
|
{
|
||||||
selmon->extrabar = !selmon->extrabar;
|
selmon->extrabar = !selmon->extrabar;
|
||||||
updatebarpos(selmon);
|
updatebarpos(selmon);
|
||||||
XMoveResizeWindow(dpy, selmon->extrabarwin, selmon->wx, selmon->eby, selmon->ww, bh);
|
XMoveResizeWindow(dpy, selmon->extrabarwin, selmon->wx + sp, selmon->eby - vp ,selmon->ww - 2 * sp, bh);
|
||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2895,6 +2935,51 @@ updatewmhints(Client *c)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
window_set_state(Display *dpy, Window win, long state)
|
||||||
|
{
|
||||||
|
long data[] = { state, None };
|
||||||
|
|
||||||
|
XChangeProperty(dpy, win, wmatom[WMState], wmatom[WMState], 32,
|
||||||
|
PropModeReplace, (unsigned char*)data, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
window_map(Display *dpy, Client *c, int deiconify)
|
||||||
|
{
|
||||||
|
Window win = c->win;
|
||||||
|
|
||||||
|
if (deiconify)
|
||||||
|
window_set_state(dpy, win, NormalState);
|
||||||
|
|
||||||
|
XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
|
||||||
|
XSetInputFocus(dpy, win, RevertToPointerRoot, CurrentTime);
|
||||||
|
XMapWindow(dpy, win);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
window_unmap(Display *dpy, Window win, Window root, int iconify)
|
||||||
|
{
|
||||||
|
static XWindowAttributes ca, ra;
|
||||||
|
|
||||||
|
XGrabServer(dpy);
|
||||||
|
XGetWindowAttributes(dpy, root, &ra);
|
||||||
|
XGetWindowAttributes(dpy, win, &ca);
|
||||||
|
|
||||||
|
/* Prevent UnmapNotify events */
|
||||||
|
XSelectInput(dpy, root, ra.your_event_mask & ~SubstructureNotifyMask);
|
||||||
|
XSelectInput(dpy, win, ca.your_event_mask & ~StructureNotifyMask);
|
||||||
|
|
||||||
|
XUnmapWindow(dpy, win);
|
||||||
|
|
||||||
|
if (iconify)
|
||||||
|
window_set_state(dpy, win, IconicState);
|
||||||
|
|
||||||
|
XSelectInput(dpy, root, ra.your_event_mask);
|
||||||
|
XSelectInput(dpy, win, ca.your_event_mask);
|
||||||
|
XUngrabServer(dpy);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
view(const Arg *arg)
|
view(const Arg *arg)
|
||||||
{
|
{
|
||||||
|
48
patches/appearance/dwm-hide_vacant_tags-6.4.diff
Normal file
48
patches/appearance/dwm-hide_vacant_tags-6.4.diff
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
:100644 100644 f1d86b2 0000000 M dwm.c
|
||||||
|
|
||||||
|
diff --git a/dwm.c b/dwm.c
|
||||||
|
index f1d86b2..d41cc14 100644
|
||||||
|
--- a/dwm.c
|
||||||
|
+++ b/dwm.c
|
||||||
|
@@ -433,9 +433,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 == TAGMASK ? 0 : 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;
|
||||||
|
@@ -715,19 +721,18 @@ drawbar(Monitor *m)
|
||||||
|
}
|
||||||
|
|
||||||
|
for (c = m->clients; c; c = c->next) {
|
||||||
|
- occ |= c->tags;
|
||||||
|
+ occ |= c->tags == TAGMASK ? 0 : c->tags;
|
||||||
|
if (c->isurgent)
|
||||||
|
urg |= c->tags;
|
||||||
|
}
|
||||||
|
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 = TEXTW(m->ltsymbol);
|
58
patches/behavior/dwm-reorganizetags-6.2.diff
Normal file
58
patches/behavior/dwm-reorganizetags-6.2.diff
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
diff --git a/config.def.h b/config.def.h
|
||||||
|
index 1c0b587..961a189 100644
|
||||||
|
--- a/config.def.h
|
||||||
|
+++ b/config.def.h
|
||||||
|
@@ -70,6 +70,7 @@ static Key keys[] = {
|
||||||
|
{ MODKEY, XK_d, incnmaster, {.i = -1 } },
|
||||||
|
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
|
||||||
|
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
|
||||||
|
+ { MODKEY, XK_r, reorganizetags, {0} },
|
||||||
|
{ MODKEY, XK_Return, zoom, {0} },
|
||||||
|
{ MODKEY, XK_Tab, view, {0} },
|
||||||
|
{ MODKEY|ShiftMask, XK_c, killclient, {0} },
|
||||||
|
diff --git a/dwm.c b/dwm.c
|
||||||
|
index 4465af1..723d675 100644
|
||||||
|
--- a/dwm.c
|
||||||
|
+++ b/dwm.c
|
||||||
|
@@ -188,6 +188,7 @@ static void pop(Client *);
|
||||||
|
static void propertynotify(XEvent *e);
|
||||||
|
static void quit(const Arg *arg);
|
||||||
|
static Monitor *recttomon(int x, int y, int w, int h);
|
||||||
|
+static void reorganizetags(const Arg *arg);
|
||||||
|
static void resize(Client *c, int x, int y, int w, int h, int interact);
|
||||||
|
static void resizeclient(Client *c, int x, int y, int w, int h);
|
||||||
|
static void resizemouse(const Arg *arg);
|
||||||
|
@@ -1265,6 +1266,33 @@ recttomon(int x, int y, int w, int h)
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
+void
|
||||||
|
+reorganizetags(const Arg *arg) {
|
||||||
|
+ Client *c;
|
||||||
|
+ unsigned int occ, unocc, i;
|
||||||
|
+ unsigned int tagdest[LENGTH(tags)];
|
||||||
|
+
|
||||||
|
+ occ = 0;
|
||||||
|
+ for (c = selmon->clients; c; c = c->next)
|
||||||
|
+ occ |= (1 << (ffs(c->tags)-1));
|
||||||
|
+ unocc = 0;
|
||||||
|
+ for (i = 0; i < LENGTH(tags); ++i) {
|
||||||
|
+ while (unocc < i && (occ & (1 << unocc)))
|
||||||
|
+ unocc++;
|
||||||
|
+ if (occ & (1 << i)) {
|
||||||
|
+ tagdest[i] = unocc;
|
||||||
|
+ occ &= ~(1 << i);
|
||||||
|
+ occ |= 1 << unocc;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ for (c = selmon->clients; c; c = c->next)
|
||||||
|
+ c->tags = 1 << tagdest[ffs(c->tags)-1];
|
||||||
|
+ if (selmon->sel)
|
||||||
|
+ selmon->tagset[selmon->seltags] = selmon->sel->tags;
|
||||||
|
+ arrange(selmon);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
void
|
||||||
|
resize(Client *c, int x, int y, int w, int h, int interact)
|
||||||
|
{
|
83
patches/behavior/dwm-windowmap-20221026.diff
Normal file
83
patches/behavior/dwm-windowmap-20221026.diff
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
diff --git a/dwm.c b/dwm.c
|
||||||
|
index e5efb6a..eaf0333 100644
|
||||||
|
--- a/dwm.c
|
||||||
|
+++ b/dwm.c
|
||||||
|
@@ -228,6 +228,9 @@ static void updatetitle(Client *c);
|
||||||
|
static void updatewindowtype(Client *c);
|
||||||
|
static void updatewmhints(Client *c);
|
||||||
|
static void view(const Arg *arg);
|
||||||
|
+static void window_set_state(Display *dpy, Window win, long state);
|
||||||
|
+static void window_map(Display *dpy, Client *c, int deiconify);
|
||||||
|
+static void window_unmap(Display *dpy, Window win, Window root, int iconify);
|
||||||
|
static Client *wintoclient(Window w);
|
||||||
|
static Monitor *wintomon(Window w);
|
||||||
|
static int xerror(Display *dpy, XErrorEvent *ee);
|
||||||
|
@@ -1617,14 +1620,12 @@ showhide(Client *c)
|
||||||
|
return;
|
||||||
|
if (ISVISIBLE(c)) {
|
||||||
|
/* show clients top down */
|
||||||
|
- XMoveWindow(dpy, c->win, c->x, c->y);
|
||||||
|
- if ((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) && !c->isfullscreen)
|
||||||
|
- resize(c, c->x, c->y, c->w, c->h, 0);
|
||||||
|
+ window_map(dpy, c, 1);
|
||||||
|
showhide(c->snext);
|
||||||
|
} else {
|
||||||
|
/* hide clients bottom up */
|
||||||
|
showhide(c->snext);
|
||||||
|
- XMoveWindow(dpy, c->win, WIDTH(c) * -2, c->y);
|
||||||
|
+ window_unmap(dpy, c->win, root, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -2032,6 +2033,51 @@ updatewmhints(Client *c)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+void
|
||||||
|
+window_set_state(Display *dpy, Window win, long state)
|
||||||
|
+{
|
||||||
|
+ long data[] = { state, None };
|
||||||
|
+
|
||||||
|
+ XChangeProperty(dpy, win, wmatom[WMState], wmatom[WMState], 32,
|
||||||
|
+ PropModeReplace, (unsigned char*)data, 2);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void
|
||||||
|
+window_map(Display *dpy, Client *c, int deiconify)
|
||||||
|
+{
|
||||||
|
+ Window win = c->win;
|
||||||
|
+
|
||||||
|
+ if (deiconify)
|
||||||
|
+ window_set_state(dpy, win, NormalState);
|
||||||
|
+
|
||||||
|
+ XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
|
||||||
|
+ XSetInputFocus(dpy, win, RevertToPointerRoot, CurrentTime);
|
||||||
|
+ XMapWindow(dpy, win);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void
|
||||||
|
+window_unmap(Display *dpy, Window win, Window root, int iconify)
|
||||||
|
+{
|
||||||
|
+ static XWindowAttributes ca, ra;
|
||||||
|
+
|
||||||
|
+ XGrabServer(dpy);
|
||||||
|
+ XGetWindowAttributes(dpy, root, &ra);
|
||||||
|
+ XGetWindowAttributes(dpy, win, &ca);
|
||||||
|
+
|
||||||
|
+ /* Prevent UnmapNotify events */
|
||||||
|
+ XSelectInput(dpy, root, ra.your_event_mask & ~SubstructureNotifyMask);
|
||||||
|
+ XSelectInput(dpy, win, ca.your_event_mask & ~StructureNotifyMask);
|
||||||
|
+
|
||||||
|
+ XUnmapWindow(dpy, win);
|
||||||
|
+
|
||||||
|
+ if (iconify)
|
||||||
|
+ window_set_state(dpy, win, IconicState);
|
||||||
|
+
|
||||||
|
+ XSelectInput(dpy, root, ra.your_event_mask);
|
||||||
|
+ XSelectInput(dpy, win, ca.your_event_mask);
|
||||||
|
+ XUngrabServer(dpy);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
void
|
||||||
|
view(const Arg *arg)
|
||||||
|
{
|
Loading…
Reference in New Issue
Block a user