index.md (3732B)
1 moveresize 2 ========== 3 4 Description 5 ----------- 6 This changes allows you to move and resize dwm's clients using keyboard 7 bindings. 8 9 Usage 10 ----- 11 1. Put the following `moveresize()` function somewhere in your `dwm.c`, 12 **after** the line which includes the config.h file: 13 14 static void 15 moveresize(const Arg *arg) 16 { 17 XEvent ev; 18 Monitor *m = selmon; 19 20 if(!(m->sel && arg && arg->v && m->sel->isfloating)) 21 return; 22 23 resize(m->sel, m->sel->x + ((int *)arg->v)[0], 24 m->sel->y + ((int *)arg->v)[1], 25 m->sel->w + ((int *)arg->v)[2], 26 m->sel->h + ((int *)arg->v)[3], 27 True); 28 29 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); 30 } 31 32 2. Add a moveresize() function definition in dwm.c below the line: 33 static void movemouse(const Arg *arg); 34 35 static void moveresize(const Arg *arg); 36 37 3. Insert the bindings into the keys list. Here is an example which uses the 38 arrow keys to move (mod+arrow) or resize (mod+shift+arrow) the selected 39 client: 40 41 { MODKEY, XK_Down, moveresize, {.v = (int []){ 0, 25, 0, 0 }}}, 42 { MODKEY, XK_Up, moveresize, {.v = (int []){ 0, -25, 0, 0 }}}, 43 { MODKEY, XK_Right, moveresize, {.v = (int []){ 25, 0, 0, 0 }}}, 44 { MODKEY, XK_Left, moveresize, {.v = (int []){ -25, 0, 0, 0 }}}, 45 { MODKEY|ShiftMask, XK_Down, moveresize, {.v = (int []){ 0, 0, 0, 25 }}}, 46 { MODKEY|ShiftMask, XK_Up, moveresize, {.v = (int []){ 0, 0, 0, -25 }}}, 47 { MODKEY|ShiftMask, XK_Right, moveresize, {.v = (int []){ 0, 0, 25, 0 }}}, 48 { MODKEY|ShiftMask, XK_Left, moveresize, {.v = (int []){ 0, 0, -25, 0 }}}, 49 50 In latest version you can also add the following bindings to move client to the edge of screen (mod+ctrl+arrow) or resize client to edge of screen (mod+shift+ctrl+arrow). Pressing resize to edge of screen towards the same direction a second time, will resize client back to original size. 51 52 { MODKEY|ControlMask, XK_Up, moveresizeedge, {.v = "t"} }, 53 { MODKEY|ControlMask, XK_Down, moveresizeedge, {.v = "b"} }, 54 { MODKEY|ControlMask, XK_Left, moveresizeedge, {.v = "l"} }, 55 { MODKEY|ControlMask, XK_Right, moveresizeedge, {.v = "r"} }, 56 { MODKEY|ControlMask|ShiftMask, XK_Up, moveresizeedge, {.v = "T"} }, 57 { MODKEY|ControlMask|ShiftMask, XK_Down, moveresizeedge, {.v = "B"} }, 58 { MODKEY|ControlMask|ShiftMask, XK_Left, moveresizeedge, {.v = "L"} }, 59 { MODKEY|ControlMask|ShiftMask, XK_Right, moveresizeedge, {.v = "R"} }, 60 61 If you want to automatically toggle the client floating when move/resize, 62 then replace the second if statement in the moveresize function with this code: 63 64 if (!(m->sel && arg && arg->v)) 65 return; 66 if (m->lt[m->sellt]->arrange && !m->sel->isfloating) 67 togglefloating(NULL); 68 69 Multi-head 70 ---------- 71 From dwm 6.0 onward there's the following patch which is aware of the screen 72 sizes in a multi monitor setup. A second patch allows you to maximize windows. 73 74 75 Changelog 76 --------- 77 20201206: 78 * moversizeedge: taking into account `topbar` 79 * moversizeedge: correctly moves/resizes client on 2nd monitor 80 81 Download 82 -------- 83 * [dwm-moveresize-20221210-7ac106c.diff](dwm-moveresize-20221210-7ac106c.diff) 84 * [dwm-moveresize-20201206-cce77d8.diff](dwm-moveresize-20201206-cce77d8.diff) 85 * [dwm-moveresize-20200609-46c8838.diff](dwm-moveresize-20200609-46c8838.diff) 86 * [dwm-moveresize-6.2.diff](dwm-moveresize-6.2.diff) 87 * [dwm-moveresize-20160731-56a31dc.diff](dwm-moveresize-20160731-56a31dc.diff) 88 * [dwm-moveresize-6.1.diff](dwm-moveresize-6.1.diff) (2095b) (20140209) 89 * [dwm-moveresize-6.0.diff](dwm-moveresize-6.0.diff) (2025b) (20120406) 90 91 Authors 92 ------- 93 * Georgios Oxinos - <oxinosg@gmail.com> 94 * Claudio M. Alessi - <smoppy@gmail.com> 95 * Jan Christoph Ebersbach - <jceb@e-jc.de> 96 * howoz - <howoz@airmail.cc>