sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

dwm-swaptags-6.2.diff (2117B)


      1 From 9513cc776dc8114967988d4abc32fd7f37446ddb Mon Sep 17 00:00:00 2001
      2 From: fossy <fossy@dnmx.org>
      3 Date: Sun, 28 Nov 2021 21:34:37 +0100
      4 Subject: [PATCH] Move function and it's prototype from config.def.h to dwm.c
      5 
      6 ---
      7  config.def.h |  3 ++-
      8  dwm.c        | 23 +++++++++++++++++++++++
      9  2 files changed, 25 insertions(+), 1 deletion(-)
     10 
     11 diff --git a/config.def.h b/config.def.h
     12 index a2ac963..f31a66d 100644
     13 --- a/config.def.h
     14 +++ b/config.def.h
     15 @@ -50,7 +50,8 @@ static const Layout layouts[] = {
     16  	{ MODKEY,                       KEY,      view,           {.ui = 1 << TAG} }, \
     17  	{ MODKEY|ControlMask,           KEY,      toggleview,     {.ui = 1 << TAG} }, \
     18  	{ MODKEY|ShiftMask,             KEY,      tag,            {.ui = 1 << TAG} }, \
     19 -	{ MODKEY|ControlMask|ShiftMask, KEY,      toggletag,      {.ui = 1 << TAG} },
     20 +	{ MODKEY|ControlMask|ShiftMask, KEY,      toggletag,      {.ui = 1 << TAG} }, \
     21 +  { Mod4Mask|ShiftMask,           KEY,      swaptags,       {.ui = 1 << TAG} },
     22  
     23  /* helper for spawning shell commands in the pre dwm-5.0 fashion */
     24  #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
     25 diff --git a/dwm.c b/dwm.c
     26 index 5e4d494..d11addd 100644
     27 --- a/dwm.c
     28 +++ b/dwm.c
     29 @@ -234,6 +234,7 @@ static int xerror(Display *dpy, XErrorEvent *ee);
     30  static int xerrordummy(Display *dpy, XErrorEvent *ee);
     31  static int xerrorstart(Display *dpy, XErrorEvent *ee);
     32  static void zoom(const Arg *arg);
     33 +static void swaptags(const Arg *arg);
     34  
     35  /* variables */
     36  static const char broken[] = "broken";
     37 @@ -2127,6 +2128,28 @@ zoom(const Arg *arg)
     38  	pop(c);
     39  }
     40  
     41 +void
     42 +swaptags(const Arg *arg)
     43 +{
     44 +	unsigned int newtag = arg->ui & TAGMASK;
     45 +	unsigned int curtag = selmon->tagset[selmon->seltags];
     46 +
     47 +	if (newtag == curtag || !curtag || (curtag & (curtag-1)))
     48 +		return;
     49 +
     50 +	for (Client *c = selmon->clients; c != NULL; c = c->next) {
     51 +		if((c->tags & newtag) || (c->tags & curtag))
     52 +			c->tags ^= curtag ^ newtag;
     53 +
     54 +		if(!c->tags) c->tags = newtag;
     55 +	}
     56 +
     57 +	selmon->tagset[selmon->seltags] = newtag;
     58 +
     59 +	focus(NULL);
     60 +	arrange(selmon);
     61 +}
     62 +
     63  int
     64  main(int argc, char *argv[])
     65  {
     66 -- 
     67 2.34.1
     68