On Wed, Jun 11, 2008 at 10:16:40AM -0500, Kevin Monceaux wrote:
> On Wed, 11 Jun 2008, Enno "Gottox" Boland wrote:
> 
> >dwm is keyboard driven. Except that moving windows in floating layout
> >can only be done by mouse. But adding this feature by hand should be
> >~10 lines of code.
> 
> At best I'm a novice C programmer.  I have no problem editing config.h to 
> customize DWM but am on shaky ground beyond that.  After my previous post 
> I found a move/resize patch on SuckLess.org that enables moving/resizing 
> of floating windows via the keyboard.  There is a 5.0 version of the patch 
> but it fails when I try to apply it to the current DWM version from the 
> Mercurial archive.  Is 5.0 only available via Mercural?  I couldn't find a 
> 5.0 tarball on the sight.

See attached config.def.h patch which allows kb-driven resizals
and movements in hg tip (1266).

It uses Mod1-{Left,Right,Up,Down} for moving windows around, and
Mod1-Shift-{Left,Right,Up,Down} for resizing.

-- 
 Anselm R. Garbe >< http://www.suckless.org/ >< GPG key: 0D73F361
diff -r 2902c669f75b config.def.h
--- a/config.def.h	Wed Jun 11 17:01:30 2008 +0100
+++ b/config.def.h	Wed Jun 11 17:05:27 2008 +0100
@@ -32,6 +32,17 @@ static Layout layouts[] = {
 	{ "><>",      NULL }, /* no layout function means floating behavior */
 };
 
+static void
+kbmvresize(const Arg *arg) {
+	if(!sel || (lt->arrange && !sel->isfloating))
+		return;
+
+	resize(sel, sel->x + ((int *)arg->v)[0],
+	            sel->y + ((int *)arg->v)[1],
+	            sel->w + ((int *)arg->v)[2],
+	            sel->h + ((int *)arg->v)[3], True);
+}
+
 /* key definitions */
 #define MODKEY Mod1Mask
 #define TAGKEYS(KEY,TAG) \
@@ -45,6 +56,14 @@ static Layout layouts[] = {
 
 static Key keys[] = {
 	/* modifier                     key        function        argument */
+	{ MODKEY,                       XK_Left,   kbmvresize,     {.v = (int []){ -40, 0, 0, 0 } } },
+	{ MODKEY,                       XK_Up,     kbmvresize,     {.v = (int []){ 0, -40, 0, 0 } } },
+	{ MODKEY,                       XK_Right,  kbmvresize,     {.v = (int []){ 40, 0, 0, 0 } } },
+	{ MODKEY,                       XK_Down,   kbmvresize,     {.v = (int []){ 0, 40, 0, 0 } } },
+	{ MODKEY|ShiftMask,             XK_Left,   kbmvresize,     {.v = (int []){ 0, 0, -40, 0 } } },
+	{ MODKEY|ShiftMask,             XK_Up,     kbmvresize,     {.v = (int []){ 0, 0, 0, -40 } } },
+	{ MODKEY|ShiftMask,             XK_Right,  kbmvresize,     {.v = (int []){ 0, 0, 40, 0 } } },
+	{ MODKEY|ShiftMask,             XK_Down,   kbmvresize,     {.v = (int []){ 0, 0, 0, 40 } } },
 	{ MODKEY,                       XK_p,      spawn,          {.v = (char *[]){"dmenu_run", "-fn", FONT, "-nb", NORMBGCOLOR, "-nf", NORMFGCOLOR, "-sb", SELBGCOLOR, "-sf", SELFGCOLOR, NULL}} },
 	{ MODKEY|ShiftMask,             XK_Return, spawn,          {.v = (char *[]){"uxterm", NULL}} },
 	{ MODKEY,                       XK_b,      togglebar,      {0}},

Reply via email to