Compare commits
2 Commits
master
...
patch/shif
| Author | SHA1 | Date | |
|---|---|---|---|
| c7119cafbc | |||
| 588274b548 |
2
LICENSE
2
LICENSE
@ -1,6 +1,5 @@
|
|||||||
MIT/X Consortium License
|
MIT/X Consortium License
|
||||||
|
|
||||||
© 2010-2026 Hiltjo Posthuma <hiltjo@codemadness.org>
|
|
||||||
© 2006-2019 Anselm R Garbe <anselm@garbe.ca>
|
© 2006-2019 Anselm R Garbe <anselm@garbe.ca>
|
||||||
© 2006-2009 Jukka Salmi <jukka at salmi dot ch>
|
© 2006-2009 Jukka Salmi <jukka at salmi dot ch>
|
||||||
© 2006-2007 Sander van Dijk <a dot h dot vandijk at gmail dot com>
|
© 2006-2007 Sander van Dijk <a dot h dot vandijk at gmail dot com>
|
||||||
@ -12,6 +11,7 @@ MIT/X Consortium License
|
|||||||
© 2008 Martin Hurton <martin dot hurton at gmail dot com>
|
© 2008 Martin Hurton <martin dot hurton at gmail dot com>
|
||||||
© 2008 Neale Pickett <neale dot woozle dot org>
|
© 2008 Neale Pickett <neale dot woozle dot org>
|
||||||
© 2009 Mate Nagy <mnagy at port70 dot net>
|
© 2009 Mate Nagy <mnagy at port70 dot net>
|
||||||
|
© 2010-2016 Hiltjo Posthuma <hiltjo@codemadness.org>
|
||||||
© 2010-2012 Connor Lane Smith <cls@lubutu.com>
|
© 2010-2012 Connor Lane Smith <cls@lubutu.com>
|
||||||
© 2011 Christoph Lohmann <20h@r-36.net>
|
© 2011 Christoph Lohmann <20h@r-36.net>
|
||||||
© 2015-2016 Quentin Rameau <quinq@fifth.space>
|
© 2015-2016 Quentin Rameau <quinq@fifth.space>
|
||||||
|
|||||||
@ -36,7 +36,6 @@ static const float mfact = 0.55; /* factor of master area size [0.05..0.95]
|
|||||||
static const int nmaster = 1; /* number of clients in master area */
|
static const int nmaster = 1; /* number of clients in master area */
|
||||||
static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
|
static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
|
||||||
static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
|
static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
|
||||||
static const int refreshrate = 120; /* refresh rate (per second) for client move/resize */
|
|
||||||
|
|
||||||
static const Layout layouts[] = {
|
static const Layout layouts[] = {
|
||||||
/* symbol arrange function */
|
/* symbol arrange function */
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
# dwm version
|
# dwm version
|
||||||
VERSION = 6.8
|
VERSION = 6.5
|
||||||
|
|
||||||
# Customize below to fit your system
|
# Customize below to fit your system
|
||||||
|
|
||||||
|
|||||||
29
drw.c
29
drw.c
@ -178,7 +178,8 @@ drw_clr_create(Drw *drw, Clr *dest, const char *clrname)
|
|||||||
die("error, cannot allocate color '%s'", clrname);
|
die("error, cannot allocate color '%s'", clrname);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create color schemes. */
|
/* Wrapper to create color schemes. The caller has to call free(3) on the
|
||||||
|
* returned color scheme when done using it. */
|
||||||
Clr *
|
Clr *
|
||||||
drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
|
drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
|
||||||
{
|
{
|
||||||
@ -186,7 +187,7 @@ drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
|
|||||||
Clr *ret;
|
Clr *ret;
|
||||||
|
|
||||||
/* need at least two colors for a scheme */
|
/* need at least two colors for a scheme */
|
||||||
if (!drw || !clrnames || clrcount < 2 || !(ret = ecalloc(clrcount, sizeof(Clr))))
|
if (!drw || !clrnames || clrcount < 2 || !(ret = ecalloc(clrcount, sizeof(XftColor))))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
for (i = 0; i < clrcount; i++)
|
for (i = 0; i < clrcount; i++)
|
||||||
@ -194,30 +195,6 @@ drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
drw_clr_free(Drw *drw, Clr *c)
|
|
||||||
{
|
|
||||||
if (!drw || !c)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* c is typedef XftColor Clr */
|
|
||||||
XftColorFree(drw->dpy, DefaultVisual(drw->dpy, drw->screen),
|
|
||||||
DefaultColormap(drw->dpy, drw->screen), c);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
drw_scm_free(Drw *drw, Clr *scm, size_t clrcount)
|
|
||||||
{
|
|
||||||
size_t i;
|
|
||||||
|
|
||||||
if (!drw || !scm)
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (i = 0; i < clrcount; i++)
|
|
||||||
drw_clr_free(drw, &scm[i]);
|
|
||||||
free(scm);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
drw_setfontset(Drw *drw, Fnt *set)
|
drw_setfontset(Drw *drw, Fnt *set)
|
||||||
{
|
{
|
||||||
|
|||||||
2
drw.h
2
drw.h
@ -40,9 +40,7 @@ void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned in
|
|||||||
|
|
||||||
/* Colorscheme abstraction */
|
/* Colorscheme abstraction */
|
||||||
void drw_clr_create(Drw *drw, Clr *dest, const char *clrname);
|
void drw_clr_create(Drw *drw, Clr *dest, const char *clrname);
|
||||||
void drw_clr_free(Drw *drw, Clr *c);
|
|
||||||
Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount);
|
Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount);
|
||||||
void drw_scm_free(Drw *drw, Clr *scm, size_t clrcount);
|
|
||||||
|
|
||||||
/* Cursor abstraction */
|
/* Cursor abstraction */
|
||||||
Cur *drw_cur_create(Drw *drw, int shape);
|
Cur *drw_cur_create(Drw *drw, int shape);
|
||||||
|
|||||||
198
dwm-shif-tools-6.2.diff
Normal file
198
dwm-shif-tools-6.2.diff
Normal file
@ -0,0 +1,198 @@
|
|||||||
|
From d57c8508c9f26be40667d402a2daaa2b27ae759f Mon Sep 17 00:00:00 2001
|
||||||
|
From: explosion-mental <explosion0mental@gmail.com>
|
||||||
|
Date: Wed, 11 Aug 2021 21:05:44 -0500
|
||||||
|
Subject: [PATCH] shift-tools - shifttag, moves the current selected client to
|
||||||
|
the adjacent tag - shifttagclients, moves the current selected client to the
|
||||||
|
adjacent tag that has at least one client else acts as shifttag -
|
||||||
|
shiftview, view adjacent tag - shiftviewclients, view the closes tag that has
|
||||||
|
a client. If none acts as shiftview - shiftboth, shifttag and shiftview.
|
||||||
|
Basically moves the window to the next/prev tag and follows it. -
|
||||||
|
shiftswaptags, its a shift implementation on the swaptags function (see
|
||||||
|
https://github.com/moizifty/DWM-Build/blob/65379c62640788881486401a0d8c79333751b02f/config.h#L48
|
||||||
|
for more details), which in short 'swaps tags' (swaps all clients with
|
||||||
|
the clients on the adjacent tag). A pretty useful example of this is
|
||||||
|
chosing a tag empty and sending all your clients to that tag. - swapfunction
|
||||||
|
is the 'helper' function for the shiftswaptags. remember that these functions
|
||||||
|
**shift**, which means you can go from tag 1 to 9 or 9 to 1. Also remember
|
||||||
|
that the default argument is 1 and you can change it.
|
||||||
|
|
||||||
|
---
|
||||||
|
config.def.h | 9 ++++
|
||||||
|
shift-tools.c | 135 ++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
2 files changed, 144 insertions(+)
|
||||||
|
create mode 100644 shift-tools.c
|
||||||
|
|
||||||
|
diff --git a/config.def.h b/config.def.h
|
||||||
|
index 1c0b587..1390d17 100644
|
||||||
|
--- a/config.def.h
|
||||||
|
+++ b/config.def.h
|
||||||
|
@@ -58,9 +58,14 @@ static const Layout layouts[] = {
|
||||||
|
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
|
||||||
|
static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
|
||||||
|
static const char *termcmd[] = { "st", NULL };
|
||||||
|
+#include "shift-tools.c"
|
||||||
|
|
||||||
|
static Key keys[] = {
|
||||||
|
/* modifier key function argument */
|
||||||
|
+ { MODKEY, XK_o, shiftviewclients, { .i = +1 } },
|
||||||
|
+ { MODKEY|ShiftMask, XK_o, shiftview, { .i = +1 } },
|
||||||
|
+ { MODKEY|ShiftMask, XK_i, shiftview, { .i = -1 } },
|
||||||
|
+ { MODKEY, XK_i, shiftviewclients, { .i = -1 } },
|
||||||
|
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
|
||||||
|
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
|
||||||
|
{ MODKEY, XK_b, togglebar, {0} },
|
||||||
|
@@ -69,6 +74,10 @@ static Key keys[] = {
|
||||||
|
{ MODKEY, XK_i, incnmaster, {.i = +1 } },
|
||||||
|
{ MODKEY, XK_d, incnmaster, {.i = -1 } },
|
||||||
|
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
|
||||||
|
+ { MODKEY|ShiftMask, XK_h, shiftboth, { .i = -1 } },
|
||||||
|
+ { MODKEY|ControlMask, XK_h, shiftswaptags, { .i = -1 } },
|
||||||
|
+ { MODKEY|ControlMask, XK_l, shiftswaptags, { .i = +1 } },
|
||||||
|
+ { MODKEY|ShiftMask, XK_l, shiftboth, { .i = +1 } },
|
||||||
|
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
|
||||||
|
{ MODKEY, XK_Return, zoom, {0} },
|
||||||
|
{ MODKEY, XK_Tab, view, {0} },
|
||||||
|
diff --git a/shift-tools.c b/shift-tools.c
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..cf130c8
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/shift-tools.c
|
||||||
|
@@ -0,0 +1,135 @@
|
||||||
|
+/* Sends a window to the next/prev tag */
|
||||||
|
+void
|
||||||
|
+shifttag(const Arg *arg)
|
||||||
|
+{
|
||||||
|
+ Arg shifted;
|
||||||
|
+ shifted.ui = selmon->tagset[selmon->seltags];
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+ if (arg->i > 0) /* left circular shift */
|
||||||
|
+ shifted.ui = ((shifted.ui << arg->i) | (shifted.ui >> (LENGTH(tags) - arg->i)));
|
||||||
|
+ else /* right circular shift */
|
||||||
|
+ shifted.ui = (shifted.ui >> (- arg->i) | shifted.ui << (LENGTH(tags) + arg->i));
|
||||||
|
+ tag(&shifted);
|
||||||
|
+}
|
||||||
|
+/* Sends a window to the next/prev tag that has a client, else it moves it to the next/prev one. */
|
||||||
|
+void
|
||||||
|
+shifttagclients(const Arg *arg)
|
||||||
|
+{
|
||||||
|
+
|
||||||
|
+ Arg shifted;
|
||||||
|
+ Client *c;
|
||||||
|
+ unsigned int tagmask = 0;
|
||||||
|
+ shifted.ui = selmon->tagset[selmon->seltags];
|
||||||
|
+
|
||||||
|
+ for (c = selmon->clients; c; c = c->next)
|
||||||
|
+ if (!(c->tags))
|
||||||
|
+ tagmask = tagmask | c->tags;
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+ if (arg->i > 0) /* left circular shift */
|
||||||
|
+ do {
|
||||||
|
+ shifted.ui = (shifted.ui << arg->i)
|
||||||
|
+ | (shifted.ui >> (LENGTH(tags) - arg->i));
|
||||||
|
+ } while (tagmask && !(shifted.ui & tagmask));
|
||||||
|
+ else /* right circular shift */
|
||||||
|
+ do {
|
||||||
|
+ shifted.ui = (shifted.ui >> (- arg->i)
|
||||||
|
+ | shifted.ui << (LENGTH(tags) + arg->i));
|
||||||
|
+ } while (tagmask && !(shifted.ui & tagmask));
|
||||||
|
+ tag(&shifted);
|
||||||
|
+}
|
||||||
|
+/* Navigate to the next/prev tag */
|
||||||
|
+void
|
||||||
|
+shiftview(const Arg *arg)
|
||||||
|
+{
|
||||||
|
+ Arg shifted;
|
||||||
|
+ shifted.ui = selmon->tagset[selmon->seltags];
|
||||||
|
+
|
||||||
|
+ if (arg->i > 0) /* left circular shift */
|
||||||
|
+ shifted.ui = (shifted.ui << arg->i) | (shifted.ui >> (LENGTH(tags) - arg->i));
|
||||||
|
+ else /* right circular shift */
|
||||||
|
+ shifted.ui = (shifted.ui >> (- arg->i) | shifted.ui << (LENGTH(tags) + arg->i));
|
||||||
|
+ view(&shifted);
|
||||||
|
+}
|
||||||
|
+/* Navigate to the next/prev tag that has a client, else moves it to the next/prev tag */
|
||||||
|
+void
|
||||||
|
+shiftviewclients(const Arg *arg)
|
||||||
|
+{
|
||||||
|
+ Arg shifted;
|
||||||
|
+ Client *c;
|
||||||
|
+ unsigned int tagmask = 0;
|
||||||
|
+ shifted.ui = selmon->tagset[selmon->seltags];
|
||||||
|
+
|
||||||
|
+ for (c = selmon->clients; c; c = c->next)
|
||||||
|
+ if (!(c->tags))
|
||||||
|
+ tagmask = tagmask | c->tags;
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+ if (arg->i > 0) /* left circular shift */
|
||||||
|
+ do {
|
||||||
|
+ shifted.ui = (shifted.ui << arg->i)
|
||||||
|
+ | (shifted.ui >> (LENGTH(tags) - arg->i));
|
||||||
|
+ } while (tagmask && !(shifted.ui & tagmask));
|
||||||
|
+ else /* right circular shift */
|
||||||
|
+ do {
|
||||||
|
+ shifted.ui = (shifted.ui >> (- arg->i)
|
||||||
|
+ | shifted.ui << (LENGTH(tags) + arg->i));
|
||||||
|
+ } while (tagmask && !(shifted.ui & tagmask));
|
||||||
|
+ view(&shifted);
|
||||||
|
+}
|
||||||
|
+/* move the current active window to the next/prev tag and view it. More like following the window */
|
||||||
|
+void
|
||||||
|
+shiftboth(const Arg *arg)
|
||||||
|
+{
|
||||||
|
+ Arg shifted;
|
||||||
|
+ shifted.ui = selmon->tagset[selmon->seltags];
|
||||||
|
+
|
||||||
|
+ if (arg->i > 0) /* left circular shift */
|
||||||
|
+ shifted.ui = ((shifted.ui << arg->i) | (shifted.ui >> (LENGTH(tags) - arg->i)));
|
||||||
|
+ else /* right circular shift */
|
||||||
|
+ shifted.ui = ((shifted.ui >> (- arg->i) | shifted.ui << (LENGTH(tags) + arg->i)));
|
||||||
|
+ tag(&shifted);
|
||||||
|
+ view(&shifted);
|
||||||
|
+}
|
||||||
|
+//helper function for shiftswaptags.
|
||||||
|
+//see: https://github.com/moizifty/DWM-Build/blob/65379c62640788881486401a0d8c79333751b02f/config.h#L48
|
||||||
|
+void
|
||||||
|
+swaptags(const Arg *arg)
|
||||||
|
+{
|
||||||
|
+ Client *c;
|
||||||
|
+ unsigned int newtag = arg->ui & TAGMASK;
|
||||||
|
+ unsigned int curtag = selmon->tagset[selmon->seltags];
|
||||||
|
+
|
||||||
|
+ if (newtag == curtag || !curtag || (curtag & (curtag-1)))
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
+ for (c = selmon->clients; c != NULL; c = c->next) {
|
||||||
|
+ if ((c->tags & newtag) || (c->tags & curtag))
|
||||||
|
+ c->tags ^= curtag ^ newtag;
|
||||||
|
+
|
||||||
|
+ if (!c->tags)
|
||||||
|
+ c->tags = newtag;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ //move to the swaped tag
|
||||||
|
+ //selmon->tagset[selmon->seltags] = newtag;
|
||||||
|
+
|
||||||
|
+ focus(NULL);
|
||||||
|
+ arrange(selmon);
|
||||||
|
+}
|
||||||
|
+/* swaps "tags" (all the clients) with the next/prev tag. */
|
||||||
|
+void
|
||||||
|
+shiftswaptags(const Arg *arg)
|
||||||
|
+{
|
||||||
|
+ Arg shifted;
|
||||||
|
+ shifted.ui = selmon->tagset[selmon->seltags];
|
||||||
|
+
|
||||||
|
+ if (arg->i > 0) /* left circular shift */
|
||||||
|
+ shifted.ui = ((shifted.ui << arg->i) | (shifted.ui >> (LENGTH(tags) - arg->i)));
|
||||||
|
+ else /* right circular shift */
|
||||||
|
+ shifted.ui = ((shifted.ui >> (- arg->i) | shifted.ui << (LENGTH(tags) + arg->i)));
|
||||||
|
+ swaptags(&shifted);
|
||||||
|
+ // uncomment if you also want to "go" (view) the tag where the the clients are going
|
||||||
|
+ //view(&shifted);
|
||||||
|
+}
|
||||||
|
--
|
||||||
|
2.32.0
|
||||||
|
|
||||||
33
dwm.c
33
dwm.c
@ -440,7 +440,7 @@ buttonpress(XEvent *e)
|
|||||||
arg.ui = 1 << i;
|
arg.ui = 1 << i;
|
||||||
} else if (ev->x < x + TEXTW(selmon->ltsymbol))
|
} else if (ev->x < x + TEXTW(selmon->ltsymbol))
|
||||||
click = ClkLtSymbol;
|
click = ClkLtSymbol;
|
||||||
else if (ev->x > selmon->ww - (int)TEXTW(stext) + lrpad - 2)
|
else if (ev->x > selmon->ww - (int)TEXTW(stext))
|
||||||
click = ClkStatusText;
|
click = ClkStatusText;
|
||||||
else
|
else
|
||||||
click = ClkWinTitle;
|
click = ClkWinTitle;
|
||||||
@ -486,7 +486,7 @@ cleanup(void)
|
|||||||
for (i = 0; i < CurLast; i++)
|
for (i = 0; i < CurLast; i++)
|
||||||
drw_cur_free(drw, cursor[i]);
|
drw_cur_free(drw, cursor[i]);
|
||||||
for (i = 0; i < LENGTH(colors); i++)
|
for (i = 0; i < LENGTH(colors); i++)
|
||||||
drw_scm_free(drw, scheme[i], 3);
|
free(scheme[i]);
|
||||||
free(scheme);
|
free(scheme);
|
||||||
XDestroyWindow(dpy, wmcheckwin);
|
XDestroyWindow(dpy, wmcheckwin);
|
||||||
drw_free(drw);
|
drw_free(drw);
|
||||||
@ -863,15 +863,14 @@ focusstack(const Arg *arg)
|
|||||||
Atom
|
Atom
|
||||||
getatomprop(Client *c, Atom prop)
|
getatomprop(Client *c, Atom prop)
|
||||||
{
|
{
|
||||||
int format;
|
int di;
|
||||||
unsigned long nitems, dl;
|
unsigned long dl;
|
||||||
unsigned char *p = NULL;
|
unsigned char *p = NULL;
|
||||||
Atom da, atom = None;
|
Atom da, atom = None;
|
||||||
|
|
||||||
if (XGetWindowProperty(dpy, c->win, prop, 0L, sizeof atom, False, XA_ATOM,
|
if (XGetWindowProperty(dpy, c->win, prop, 0L, sizeof atom, False, XA_ATOM,
|
||||||
&da, &format, &nitems, &dl, &p) == Success && p) {
|
&da, &di, &dl, &dl, &p) == Success && p) {
|
||||||
if (nitems > 0 && format == 32)
|
atom = *(Atom *)p;
|
||||||
atom = *(long *)p;
|
|
||||||
XFree(p);
|
XFree(p);
|
||||||
}
|
}
|
||||||
return atom;
|
return atom;
|
||||||
@ -897,10 +896,10 @@ getstate(Window w)
|
|||||||
Atom real;
|
Atom real;
|
||||||
|
|
||||||
if (XGetWindowProperty(dpy, w, wmatom[WMState], 0L, 2L, False, wmatom[WMState],
|
if (XGetWindowProperty(dpy, w, wmatom[WMState], 0L, 2L, False, wmatom[WMState],
|
||||||
&real, &format, &n, &extra, &p) != Success)
|
&real, &format, &n, &extra, (unsigned char **)&p) != Success)
|
||||||
return -1;
|
return -1;
|
||||||
if (n != 0 && format == 32)
|
if (n != 0)
|
||||||
result = *(long *)p;
|
result = *p;
|
||||||
XFree(p);
|
XFree(p);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -1172,7 +1171,7 @@ movemouse(const Arg *arg)
|
|||||||
handler[ev.type](&ev);
|
handler[ev.type](&ev);
|
||||||
break;
|
break;
|
||||||
case MotionNotify:
|
case MotionNotify:
|
||||||
if ((ev.xmotion.time - lasttime) <= (1000 / refreshrate))
|
if ((ev.xmotion.time - lasttime) <= (1000 / 60))
|
||||||
continue;
|
continue;
|
||||||
lasttime = ev.xmotion.time;
|
lasttime = ev.xmotion.time;
|
||||||
|
|
||||||
@ -1326,7 +1325,7 @@ resizemouse(const Arg *arg)
|
|||||||
handler[ev.type](&ev);
|
handler[ev.type](&ev);
|
||||||
break;
|
break;
|
||||||
case MotionNotify:
|
case MotionNotify:
|
||||||
if ((ev.xmotion.time - lasttime) <= (1000 / refreshrate))
|
if ((ev.xmotion.time - lasttime) <= (1000 / 60))
|
||||||
continue;
|
continue;
|
||||||
lasttime = ev.xmotion.time;
|
lasttime = ev.xmotion.time;
|
||||||
|
|
||||||
@ -1429,8 +1428,6 @@ sendmon(Client *c, Monitor *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);
|
attach(c);
|
||||||
attachstack(c);
|
attachstack(c);
|
||||||
if (c->isfullscreen)
|
|
||||||
resizeclient(c, m->mx, m->my, m->mw, m->mh);
|
|
||||||
focus(NULL);
|
focus(NULL);
|
||||||
arrange(NULL);
|
arrange(NULL);
|
||||||
}
|
}
|
||||||
@ -1472,10 +1469,12 @@ sendevent(Client *c, Atom proto)
|
|||||||
void
|
void
|
||||||
setfocus(Client *c)
|
setfocus(Client *c)
|
||||||
{
|
{
|
||||||
if (!c->neverfocus)
|
if (!c->neverfocus) {
|
||||||
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
|
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
|
||||||
XChangeProperty(dpy, root, netatom[NetActiveWindow], XA_WINDOW, 32,
|
XChangeProperty(dpy, root, netatom[NetActiveWindow],
|
||||||
PropModeReplace, (unsigned char *)&c->win, 1);
|
XA_WINDOW, 32, PropModeReplace,
|
||||||
|
(unsigned char *) &(c->win), 1);
|
||||||
|
}
|
||||||
sendevent(c, wmatom[WMTakeFocus]);
|
sendevent(c, wmatom[WMTakeFocus]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
135
shift-tools.c
Normal file
135
shift-tools.c
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
/* Sends a window to the next/prev tag */
|
||||||
|
void
|
||||||
|
shifttag(const Arg *arg)
|
||||||
|
{
|
||||||
|
Arg shifted;
|
||||||
|
shifted.ui = selmon->tagset[selmon->seltags];
|
||||||
|
|
||||||
|
|
||||||
|
if (arg->i > 0) /* left circular shift */
|
||||||
|
shifted.ui = ((shifted.ui << arg->i) | (shifted.ui >> (LENGTH(tags) - arg->i)));
|
||||||
|
else /* right circular shift */
|
||||||
|
shifted.ui = (shifted.ui >> (- arg->i) | shifted.ui << (LENGTH(tags) + arg->i));
|
||||||
|
tag(&shifted);
|
||||||
|
}
|
||||||
|
/* Sends a window to the next/prev tag that has a client, else it moves it to the next/prev one. */
|
||||||
|
void
|
||||||
|
shifttagclients(const Arg *arg)
|
||||||
|
{
|
||||||
|
|
||||||
|
Arg shifted;
|
||||||
|
Client *c;
|
||||||
|
unsigned int tagmask = 0;
|
||||||
|
shifted.ui = selmon->tagset[selmon->seltags];
|
||||||
|
|
||||||
|
for (c = selmon->clients; c; c = c->next)
|
||||||
|
if (!(c->tags))
|
||||||
|
tagmask = tagmask | c->tags;
|
||||||
|
|
||||||
|
|
||||||
|
if (arg->i > 0) /* left circular shift */
|
||||||
|
do {
|
||||||
|
shifted.ui = (shifted.ui << arg->i)
|
||||||
|
| (shifted.ui >> (LENGTH(tags) - arg->i));
|
||||||
|
} while (tagmask && !(shifted.ui & tagmask));
|
||||||
|
else /* right circular shift */
|
||||||
|
do {
|
||||||
|
shifted.ui = (shifted.ui >> (- arg->i)
|
||||||
|
| shifted.ui << (LENGTH(tags) + arg->i));
|
||||||
|
} while (tagmask && !(shifted.ui & tagmask));
|
||||||
|
tag(&shifted);
|
||||||
|
}
|
||||||
|
/* Navigate to the next/prev tag */
|
||||||
|
void
|
||||||
|
shiftview(const Arg *arg)
|
||||||
|
{
|
||||||
|
Arg shifted;
|
||||||
|
shifted.ui = selmon->tagset[selmon->seltags];
|
||||||
|
|
||||||
|
if (arg->i > 0) /* left circular shift */
|
||||||
|
shifted.ui = (shifted.ui << arg->i) | (shifted.ui >> (LENGTH(tags) - arg->i));
|
||||||
|
else /* right circular shift */
|
||||||
|
shifted.ui = (shifted.ui >> (- arg->i) | shifted.ui << (LENGTH(tags) + arg->i));
|
||||||
|
view(&shifted);
|
||||||
|
}
|
||||||
|
/* Navigate to the next/prev tag that has a client, else moves it to the next/prev tag */
|
||||||
|
void
|
||||||
|
shiftviewclients(const Arg *arg)
|
||||||
|
{
|
||||||
|
Arg shifted;
|
||||||
|
Client *c;
|
||||||
|
unsigned int tagmask = 0;
|
||||||
|
shifted.ui = selmon->tagset[selmon->seltags];
|
||||||
|
|
||||||
|
for (c = selmon->clients; c; c = c->next)
|
||||||
|
if (!(c->tags))
|
||||||
|
tagmask = tagmask | c->tags;
|
||||||
|
|
||||||
|
|
||||||
|
if (arg->i > 0) /* left circular shift */
|
||||||
|
do {
|
||||||
|
shifted.ui = (shifted.ui << arg->i)
|
||||||
|
| (shifted.ui >> (LENGTH(tags) - arg->i));
|
||||||
|
} while (tagmask && !(shifted.ui & tagmask));
|
||||||
|
else /* right circular shift */
|
||||||
|
do {
|
||||||
|
shifted.ui = (shifted.ui >> (- arg->i)
|
||||||
|
| shifted.ui << (LENGTH(tags) + arg->i));
|
||||||
|
} while (tagmask && !(shifted.ui & tagmask));
|
||||||
|
view(&shifted);
|
||||||
|
}
|
||||||
|
/* move the current active window to the next/prev tag and view it. More like following the window */
|
||||||
|
void
|
||||||
|
shiftboth(const Arg *arg)
|
||||||
|
{
|
||||||
|
Arg shifted;
|
||||||
|
shifted.ui = selmon->tagset[selmon->seltags];
|
||||||
|
|
||||||
|
if (arg->i > 0) /* left circular shift */
|
||||||
|
shifted.ui = ((shifted.ui << arg->i) | (shifted.ui >> (LENGTH(tags) - arg->i)));
|
||||||
|
else /* right circular shift */
|
||||||
|
shifted.ui = ((shifted.ui >> (- arg->i) | shifted.ui << (LENGTH(tags) + arg->i)));
|
||||||
|
tag(&shifted);
|
||||||
|
view(&shifted);
|
||||||
|
}
|
||||||
|
//helper function for shiftswaptags.
|
||||||
|
//see: https://github.com/moizifty/DWM-Build/blob/65379c62640788881486401a0d8c79333751b02f/config.h#L48
|
||||||
|
void
|
||||||
|
swaptags(const Arg *arg)
|
||||||
|
{
|
||||||
|
Client *c;
|
||||||
|
unsigned int newtag = arg->ui & TAGMASK;
|
||||||
|
unsigned int curtag = selmon->tagset[selmon->seltags];
|
||||||
|
|
||||||
|
if (newtag == curtag || !curtag || (curtag & (curtag-1)))
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (c = selmon->clients; c != NULL; c = c->next) {
|
||||||
|
if ((c->tags & newtag) || (c->tags & curtag))
|
||||||
|
c->tags ^= curtag ^ newtag;
|
||||||
|
|
||||||
|
if (!c->tags)
|
||||||
|
c->tags = newtag;
|
||||||
|
}
|
||||||
|
|
||||||
|
//move to the swaped tag
|
||||||
|
//selmon->tagset[selmon->seltags] = newtag;
|
||||||
|
|
||||||
|
focus(NULL);
|
||||||
|
arrange(selmon);
|
||||||
|
}
|
||||||
|
/* swaps "tags" (all the clients) with the next/prev tag. */
|
||||||
|
void
|
||||||
|
shiftswaptags(const Arg *arg)
|
||||||
|
{
|
||||||
|
Arg shifted;
|
||||||
|
shifted.ui = selmon->tagset[selmon->seltags];
|
||||||
|
|
||||||
|
if (arg->i > 0) /* left circular shift */
|
||||||
|
shifted.ui = ((shifted.ui << arg->i) | (shifted.ui >> (LENGTH(tags) - arg->i)));
|
||||||
|
else /* right circular shift */
|
||||||
|
shifted.ui = ((shifted.ui >> (- arg->i) | shifted.ui << (LENGTH(tags) + arg->i)));
|
||||||
|
swaptags(&shifted);
|
||||||
|
// uncomment if you also want to "go" (view) the tag where the the clients are going
|
||||||
|
//view(&shifted);
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user