dwm-movethrow-6.2.diff (3247B)
1 From cb4947f8dfd02a5103c9e28d60a428bf81088796 Mon Sep 17 00:00:00 2001 2 From: Randoragon <randoragongamedev@gmail.com> 3 Date: Tue, 30 Jun 2020 11:13:55 +0200 4 Subject: [PATCH] windowthrow patch 5 6 This patch is heavily inspired by the moveplace patch. It allows you to 7 "throw" windows in 4 directions, which makes them floating (if not 8 floating already) and then moves them in the chosen direction until they 9 hit the border of the screen. Unlike moveplace, the windows get to keep 10 their original size. Additionally, there's a "middle direction" defined 11 which simply centers a window on the screen. 12 --- 13 config.def.h | 4 ++++ 14 dwm.c | 38 ++++++++++++++++++++++++++++++++++++++ 15 2 files changed, 42 insertions(+) 16 17 diff --git a/config.def.h b/config.def.h 18 index 1c0b587..e873d28 100644 19 --- a/config.def.h 20 +++ b/config.def.h 21 @@ -84,6 +84,11 @@ static Key keys[] = { 22 { MODKEY, XK_period, focusmon, {.i = +1 } }, 23 { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, 24 { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, 25 + { MODKEY|ShiftMask, XK_Up, movethrow, {.ui = WIN_N }}, 26 + { MODKEY|ShiftMask, XK_Down, movethrow, {.ui = WIN_S }}, 27 + { MODKEY|ShiftMask, XK_Left, movethrow, {.ui = WIN_W }}, 28 + { MODKEY|ShiftMask, XK_Right, movethrow, {.ui = WIN_E }}, 29 + { MODKEY|ShiftMask, XK_m, movethrow, {.ui = WIN_C }}, 30 TAGKEYS( XK_1, 0) 31 TAGKEYS( XK_2, 1) 32 TAGKEYS( XK_3, 2) 33 diff --git a/dwm.c b/dwm.c 34 index 4465af1..df1eb05 100644 35 --- a/dwm.c 36 +++ b/dwm.c 37 @@ -66,6 +66,7 @@ enum { NetSupported, NetWMName, NetWMState, NetWMCheck, 38 enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */ 39 enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, 40 ClkClientWin, ClkRootWin, ClkLast }; /* clicks */ 41 +enum { DIR_N, DIR_W, DIR_C, DIR_E, DIR_S, }; /* coordinates for movethrow */ 42 43 typedef union { 44 int i; 45 @@ -1192,6 +1193,44 @@ movemouse(const Arg *arg) 46 } 47 } 48 49 +void 50 +movethrow(const Arg *arg) 51 +{ 52 + Client *c; 53 + int nh, nw, nx, ny; 54 + c = selmon->sel; 55 + if (selmon->lt[selmon->sellt]->arrange && !c->isfloating) 56 + togglefloating(NULL); 57 + nw = c->w; 58 + nh = c->h; 59 + switch(arg->ui) { 60 + case DIR_N: 61 + nx = c->x; 62 + ny = selmon->wy; 63 + break; 64 + case DIR_E: 65 + nx = selmon->wx + selmon->ww - c->w - c->bw*2; 66 + ny = c->y; 67 + break; 68 + case DIR_S: 69 + nx = c->x; 70 + ny = selmon->wy + selmon->wh - c->h - c->bw*2; 71 + break; 72 + case DIR_W: 73 + nx = selmon->wx; 74 + ny = c->y; 75 + break; 76 + case DIR_C: 77 + nx = selmon->wx + ((selmon->ww - c->w - c->bw*2) / 2); 78 + ny = selmon->wy + ((selmon->wh - c->h - c->bw*2) / 2); 79 + break; 80 + default: 81 + return; 82 + } 83 + resize(c, nx, ny, nw, nh, True); 84 + XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, nw/2, nh/2); 85 +} 86 + 87 Client * 88 nexttiled(Client *c) 89 { 90 -- 91 2.27.0 92