Compare commits
No commits in common. "c361ca2c0d14da589ab46d259bc09064f45b9465" and "e1874b34c107866bb76cb171142bd7890017ce76" have entirely different histories.
c361ca2c0d
...
e1874b34c1
101
dwm.c
101
dwm.c
@ -224,7 +224,6 @@ static void pop(Client *c);
|
||||
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 resetlayout(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);
|
||||
@ -274,9 +273,6 @@ 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);
|
||||
@ -600,15 +596,9 @@ buttonpress(XEvent *e)
|
||||
}
|
||||
if (ev->window == selmon->barwin) {
|
||||
i = x = 0;
|
||||
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;
|
||||
do
|
||||
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;
|
||||
@ -942,15 +932,12 @@ drawbar(Monitor *m)
|
||||
for (c = m->clients; c; c = c->next) {
|
||||
if (ISVISIBLE(c))
|
||||
n++;
|
||||
occ |= c->tags == TAGMASK ? 0 : c->tags;
|
||||
occ |= 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 ? SchemeNorm : SchemeNorm]);
|
||||
drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
|
||||
@ -1810,35 +1797,6 @@ resetlayout(const Arg *arg)
|
||||
|
||||
selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag] = nmaster;
|
||||
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
|
||||
@ -2352,12 +2310,14 @@ showhide(Client *c)
|
||||
return;
|
||||
if (ISVISIBLE(c)) {
|
||||
/* show clients top down */
|
||||
window_map(dpy, c, 1);
|
||||
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);
|
||||
showhide(c->snext);
|
||||
} else {
|
||||
/* hide clients bottom up */
|
||||
showhide(c->snext);
|
||||
window_unmap(dpy, c->win, root, 1);
|
||||
XMoveWindow(dpy, c->win, WIDTH(c) * -2, c->y);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2484,7 +2444,7 @@ toggleextrabar(const Arg *arg)
|
||||
{
|
||||
selmon->extrabar = !selmon->extrabar;
|
||||
updatebarpos(selmon);
|
||||
XMoveResizeWindow(dpy, selmon->extrabarwin, selmon->wx + sp, selmon->eby - vp ,selmon->ww - 2 * sp, bh);
|
||||
XMoveResizeWindow(dpy, selmon->extrabarwin, selmon->wx, selmon->eby, selmon->ww, bh);
|
||||
arrange(selmon);
|
||||
}
|
||||
|
||||
@ -2935,51 +2895,6 @@ 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)
|
||||
{
|
||||
|
@ -1,48 +0,0 @@
|
||||
: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);
|
@ -1,58 +0,0 @@
|
||||
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)
|
||||
{
|
@ -1,83 +0,0 @@
|
||||
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