Re: [hackers] [dwm 6.4][movewithtag]

2023-01-23 Thread NRK
On Mon, Jan 23, 2023 at 08:56:13AM -0300, Dr. André Desgualdo Pereira wrote:
> I'm submitting a new patch to be appreciated and included on suckless site

You can push patches to the site directly yourself. See 
https://suckless.org/wiki/

- NRK



[hackers] [dwm 6.4][movewithtag]

2023-01-23 Thread Dr . André Desgualdo Pereira
I'm submitting a new patch to be appreciated and included on suckless site if 
developers found this useful for users.
This patch differs from viewontag patch because instead of changing the 
original behavior of tagging a window, it creates a new function with modified 
behavior. The modified behavior consists of a shortcut to tag a window and 
focus on its new tag.
Thank you so much for all the amazing software of suckless. 

-- 
André Desgualdo Pereira
des...@gmail.com
-- 
--- config.def.h	2023-01-21 07:22:27.659019476 -0300
+++ config_patched.h	2023-01-21 07:22:19.669437199 -0300
@@ -50,6 +50,7 @@ static const Layout layouts[] = {
 	{ MODKEY,   KEY,  view,   {.ui = 1 << TAG} }, \
 	{ MODKEY|ControlMask,   KEY,  toggleview, {.ui = 1 << TAG} }, \
 	{ MODKEY|ShiftMask, KEY,  tag,{.ui = 1 << TAG} }, \
+	{ Mod4Mask, KEY,  movewithtag,{.ui = 1 << TAG} }, \ /* change the key to Mod1Mask if MODKEY is defined to Mod4Mask above */
 	{ MODKEY|ControlMask|ShiftMask, KEY,  toggletag,  {.ui = 1 << TAG} },
 
 /* helper for spawning shell commands in the pre dwm-5.0 fashion */
--- dwm.c	2023-01-21 07:17:05.453254514 -0300
+++ dwm_patched.h	2023-01-21 07:24:10.998189290 -0300
@@ -208,6 +208,7 @@ static void showhide(Client *c);
 static void sigchld(int unused);
 static void spawn(const Arg *arg);
 static void tag(const Arg *arg);
+static void movewithtag(const Arg *arg);
 static void tagmon(const Arg *arg);
 static void tile(Monitor *m);
 static void togglebar(const Arg *arg);
@@ -1670,6 +1671,18 @@ tag(const Arg *arg)
 	}
 }
 
+void
+movewithtag(const Arg *arg)
+{
+	if (selmon->sel && arg->ui & TAGMASK) {
+		selmon->sel->tags = arg->ui & TAGMASK;
+		focus(NULL);
+		arrange(selmon);
+		if((arg->ui & TAGMASK) != TAGMASK)
+			view(arg);
+	}
+}
+
 void
 tagmon(const Arg *arg)
 {