feat: added movestack 614dba01
Steve Simkins · 2025-11-09 10:49 5 file(s) · +58 −0
config.def.h +4 −0
72 72
	{ MODKEY,                       XK_l,      focusstack,     {.i = +1 } },
73 73
	{ MODKEY,                       XK_i,      incnmaster,     {.i = +1 } },
74 74
	{ MODKEY,                       XK_d,      incnmaster,     {.i = -1 } },
75 +
	{ MODKEY|ShiftMask,             XK_j,      movestack,      {.i = +1 } },
76 +
	{ MODKEY|ShiftMask,             XK_k,      movestack,      {.i = -1 } },
77 +
	{ MODKEY|ShiftMask,             XK_h,      movestack,      {.i = -1 } },
78 +
	{ MODKEY|ShiftMask,             XK_l,      movestack,      {.i = +1 } },
75 79
	// { MODKEY,                       XK_h,      setmfact,       {.f = -0.05} },
76 80
	// { MODKEY,                       XK_l,      setmfact,       {.f = +0.05} },
77 81
	{ MODKEY,                       XK_Return, zoom,           {0} },
config.h +4 −0
72 72
	{ MODKEY,                       XK_l,      focusstack,     {.i = +1 } },
73 73
	{ MODKEY,                       XK_i,      incnmaster,     {.i = +1 } },
74 74
	{ MODKEY,                       XK_d,      incnmaster,     {.i = -1 } },
75 +
	{ MODKEY|ShiftMask,             XK_j,      movestack,      {.i = +1 } },
76 +
	{ MODKEY|ShiftMask,             XK_k,      movestack,      {.i = -1 } },
77 +
	{ MODKEY|ShiftMask,             XK_h,      movestack,      {.i = -1 } },
78 +
	{ MODKEY|ShiftMask,             XK_l,      movestack,      {.i = +1 } },
75 79
	// { MODKEY,                       XK_h,      setmfact,       {.f = -0.05} },
76 80
	// { MODKEY,                       XK_l,      setmfact,       {.f = +0.05} },
77 81
	{ MODKEY,                       XK_Return, zoom,           {0} },
dwm +0 −0

Binary file — no preview.

dwm.c +50 −0
183 183
static void monocle(Monitor *m);
184 184
static void motionnotify(XEvent *e);
185 185
static void movemouse(const Arg *arg);
186 +
static void movestack(const Arg *arg);
186 187
static Client *nexttiled(Client *c);
187 188
static void pop(Client *c);
188 189
static void propertynotify(XEvent *e);
2137 2138
	if (c == nexttiled(selmon->clients) && !(c = nexttiled(c->next)))
2138 2139
		return;
2139 2140
	pop(c);
2141 +
}
2142 +
2143 +
void
2144 +
movestack(const Arg *arg) {
2145 +
	Client *c = NULL, *p = NULL, *pc = NULL, *i;
2146 +
2147 +
	if(arg->i > 0) {
2148 +
		/* find the client after selmon->sel */
2149 +
		for(c = selmon->sel->next; c && (!ISVISIBLE(c) || c->isfloating); c = c->next);
2150 +
		if(!c)
2151 +
			for(c = selmon->clients; c && (!ISVISIBLE(c) || c->isfloating); c = c->next);
2152 +
2153 +
	}
2154 +
	else {
2155 +
		/* find the client before selmon->sel */
2156 +
		for(i = selmon->clients; i != selmon->sel; i = i->next)
2157 +
			if(ISVISIBLE(i) && !i->isfloating)
2158 +
				c = i;
2159 +
		if(!c)
2160 +
			for(; i; i = i->next)
2161 +
				if(ISVISIBLE(i) && !i->isfloating)
2162 +
					c = i;
2163 +
	}
2164 +
	/* find the client before selmon->sel and c */
2165 +
	for(i = selmon->clients; i && (!p || !pc); i = i->next) {
2166 +
		if(i->next == selmon->sel)
2167 +
			p = i;
2168 +
		if(i->next == c)
2169 +
			pc = i;
2170 +
	}
2171 +
2172 +
	/* swap c and selmon->sel selmon->clients in the selmon->clients list */
2173 +
	if(c && c != selmon->sel) {
2174 +
		Client *temp = selmon->sel->next==c?selmon->sel:selmon->sel->next;
2175 +
		selmon->sel->next = c->next==selmon->sel?c:c->next;
2176 +
		c->next = temp;
2177 +
2178 +
		if(p && p != c)
2179 +
			p->next = c;
2180 +
		if(pc && pc != selmon->sel)
2181 +
			pc->next = selmon->sel;
2182 +
2183 +
		if(selmon->sel == selmon->clients)
2184 +
			selmon->clients = c;
2185 +
		else if(c == selmon->clients)
2186 +
			selmon->clients = selmon->sel;
2187 +
2188 +
		arrange(selmon);
2189 +
	}
2140 2190
}
2141 2191
2142 2192
int
dwm.o +0 −0

Binary file — no preview.