diff --git a/README.md b/README.md index a6d94a8..fedd68e 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t ### Changelog: -2020-05-21 - Added the moveresize patch +2020-05-21 - Added the moveplace and moveresize patches 2020-05-03 - Added the shiftviewclients patch and the no transparent borders patch which removes opacity from window borders when the alpha patch is not used diff --git a/config.def.h b/config.def.h index 45432d0..bbb9ccb 100644 --- a/config.def.h +++ b/config.def.h @@ -927,33 +927,44 @@ static Key keys[] = { { MODKEY|Mod4Mask, XK_Right, switchtag, { .ui = SWITCHTAG_RIGHT | SWITCHTAG_TAG | SWITCHTAG_VIEW } }, { MODKEY|Mod4Mask, XK_Left, switchtag, { .ui = SWITCHTAG_LEFT | SWITCHTAG_TAG | SWITCHTAG_VIEW } }, #endif // TAGGRID_PATCH + #if MOVEPLACE_PATCH + { MODKEY, XK_KP_7, moveplace, {.ui = WIN_NW }}, /* XK_KP_Home, */ + { MODKEY, XK_KP_8, moveplace, {.ui = WIN_N }}, /* XK_KP_Up, */ + { MODKEY, XK_KP_9, moveplace, {.ui = WIN_NE }}, /* XK_KP_Prior, */ + { MODKEY, XK_KP_4, moveplace, {.ui = WIN_W }}, /* XK_KP_Left, */ + { MODKEY, XK_KP_5, moveplace, {.ui = WIN_C }}, /* XK_KP_Begin, */ + { MODKEY, XK_KP_6, moveplace, {.ui = WIN_E }}, /* XK_KP_Right, */ + { MODKEY, XK_KP_1, moveplace, {.ui = WIN_SW }}, /* XK_KP_End, */ + { MODKEY, XK_KP_2, moveplace, {.ui = WIN_S }}, /* XK_KP_Down, */ + { MODKEY, XK_KP_3, moveplace, {.ui = WIN_SE }}, /* XK_KP_Next, */ + #endif // MOVEPLACE_PATCH #if EXRESIZE_PATCH - { MODKEY, XK_KP_7, explace, {.ui = EX_NW }}, - { MODKEY, XK_KP_8, explace, {.ui = EX_N }}, - { MODKEY, XK_KP_9, explace, {.ui = EX_NE }}, - { MODKEY, XK_KP_4, explace, {.ui = EX_W }}, - { MODKEY, XK_KP_5, explace, {.ui = EX_C }}, - { MODKEY, XK_KP_6, explace, {.ui = EX_E }}, - { MODKEY, XK_KP_1, explace, {.ui = EX_SW }}, - { MODKEY, XK_KP_2, explace, {.ui = EX_S }}, - { MODKEY, XK_KP_3, explace, {.ui = EX_SE }}, + { MODKEY, XK_KP_7, explace, {.ui = EX_NW }}, /* XK_KP_Home, */ + { MODKEY, XK_KP_8, explace, {.ui = EX_N }}, /* XK_KP_Up, */ + { MODKEY, XK_KP_9, explace, {.ui = EX_NE }}, /* XK_KP_Prior, */ + { MODKEY, XK_KP_4, explace, {.ui = EX_W }}, /* XK_KP_Left, */ + { MODKEY, XK_KP_5, explace, {.ui = EX_C }}, /* XK_KP_Begin, */ + { MODKEY, XK_KP_6, explace, {.ui = EX_E }}, /* XK_KP_Right, */ + { MODKEY, XK_KP_1, explace, {.ui = EX_SW }}, /* XK_KP_End, */ + { MODKEY, XK_KP_2, explace, {.ui = EX_S }}, /* XK_KP_Down, */ + { MODKEY, XK_KP_3, explace, {.ui = EX_SE }}, /* XK_KP_Next, */ - { MODKEY|ShiftMask, XK_KP_8, exresize, {.v = (int []){ 0, 25 }}}, - { MODKEY|ShiftMask, XK_KP_2, exresize, {.v = (int []){ 0, -25 }}}, - { MODKEY|ShiftMask, XK_KP_6, exresize, {.v = (int []){ 25, 0 }}}, - { MODKEY|ShiftMask, XK_KP_4, exresize, {.v = (int []){ -25, 0 }}}, - { MODKEY|ShiftMask, XK_KP_5, exresize, {.v = (int []){ 25, 25 }}}, - { MODKEY|ShiftMask|ControlMask, XK_KP_5, exresize, {.v = (int []){ -25, -25 }}}, + { MODKEY|ShiftMask, XK_KP_8, exresize, {.v = (int []){ 0, 25 }}}, /* XK_KP_Up, */ + { MODKEY|ShiftMask, XK_KP_2, exresize, {.v = (int []){ 0, -25 }}}, /* XK_KP_Down, */ + { MODKEY|ShiftMask, XK_KP_6, exresize, {.v = (int []){ 25, 0 }}}, /* XK_KP_Right, */ + { MODKEY|ShiftMask, XK_KP_4, exresize, {.v = (int []){ -25, 0 }}}, /* XK_KP_Left, */ + { MODKEY|ShiftMask, XK_KP_5, exresize, {.v = (int []){ 25, 25 }}}, /* XK_KP_Begin, */ + { MODKEY|ShiftMask|ControlMask, XK_KP_5, exresize, {.v = (int []){ -25, -25 }}}, /* XK_KP_Begin, */ - { MODKEY|ControlMask, XK_KP_6, togglehorizontalexpand, {.i = +1} }, - { MODKEY|ControlMask, XK_KP_3, togglehorizontalexpand, {.i = 0} }, - { MODKEY|ControlMask, XK_KP_4, togglehorizontalexpand, {.i = -1} }, - { MODKEY|ControlMask, XK_KP_8, toggleverticalexpand, {.i = +1} }, - { MODKEY|ControlMask, XK_KP_1, toggleverticalexpand, {.i = 0} }, - { MODKEY|ControlMask, XK_KP_2, toggleverticalexpand, {.i = -1} }, - { MODKEY|ControlMask, XK_KP_9, togglemaximize, {.i = -1} }, - { MODKEY|ControlMask, XK_KP_7, togglemaximize, {.i = +1} }, - { MODKEY|ControlMask, XK_KP_5, togglemaximize, {.i = 0} }, + { MODKEY|ControlMask, XK_KP_6, togglehorizontalexpand, {.i = +1} }, /* XK_KP_Right, */ + { MODKEY|ControlMask, XK_KP_3, togglehorizontalexpand, {.i = 0} }, /* XK_KP_Next, */ + { MODKEY|ControlMask, XK_KP_4, togglehorizontalexpand, {.i = -1} }, /* XK_KP_Left, */ + { MODKEY|ControlMask, XK_KP_8, toggleverticalexpand, {.i = +1} }, /* XK_KP_Up, */ + { MODKEY|ControlMask, XK_KP_1, toggleverticalexpand, {.i = 0} }, /* XK_KP_End, */ + { MODKEY|ControlMask, XK_KP_2, toggleverticalexpand, {.i = -1} }, /* XK_KP_Down, */ + { MODKEY|ControlMask, XK_KP_9, togglemaximize, {.i = -1} }, /* XK_KP_Prior, */ + { MODKEY|ControlMask, XK_KP_7, togglemaximize, {.i = +1} }, /* XK_KP_Home, */ + { MODKEY|ControlMask, XK_KP_5, togglemaximize, {.i = 0} }, /* XK_KP_Begin, */ #endif // EXRESIZE_PATCH #if SETBORDERPX_PATCH { MODKEY|ControlMask, XK_minus, setborderpx, {.i = -1 } }, diff --git a/patch/include.c b/patch/include.c index 0b696cf..dc516fe 100644 --- a/patch/include.c +++ b/patch/include.c @@ -70,6 +70,9 @@ #if MDPCONTROL_PATCH #include "mdpcontrol.c" #endif +#if MOVEPLACE_PATCH +#include "moveplace.c" +#endif #if MOVERESIZE_PATCH #include "moveresize.c" #endif diff --git a/patch/include.h b/patch/include.h index 38821fa..5164236 100644 --- a/patch/include.h +++ b/patch/include.h @@ -73,6 +73,9 @@ #if MDPCONTROL_PATCH #include "mdpcontrol.h" #endif +#if MOVEPLACE_PATCH +#include "moveplace.h" +#endif #if MOVERESIZE_PATCH #include "moveresize.h" #endif diff --git a/patch/moveplace.c b/patch/moveplace.c new file mode 100644 index 0000000..fb9c099 --- /dev/null +++ b/patch/moveplace.c @@ -0,0 +1,29 @@ +void +moveplace(const Arg *arg) +{ + Client *c; + int nh, nw, nx, ny; + c = selmon->sel; + if (!c || (arg->ui >= 9)) + return; + if (selmon->lt[selmon->sellt]->arrange && !c->isfloating) + togglefloating(NULL); + nh = (selmon->wh / 3) - (c->bw * 2); + nw = (selmon->ww / 3) - (c->bw * 2); + nx = (arg->ui % 3) -1; + ny = (arg->ui / 3) -1; + if (nx < 0) + nx = selmon->wx; + else if(nx > 0) + nx = selmon->wx + selmon->ww - nw - c->bw*2; + else + nx = selmon->wx + selmon->ww/2 - nw/2 - c->bw; + if (ny <0) + ny = selmon->wy; + else if(ny > 0) + ny = selmon->wy + selmon->wh - nh - c->bw*2; + else + ny = selmon->wy + selmon->wh/2 - nh/2 - c->bw; + resize(c, nx, ny, nw, nh, True); + XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, nw/2, nh/2); +} \ No newline at end of file diff --git a/patch/moveplace.h b/patch/moveplace.h new file mode 100644 index 0000000..f921b8e --- /dev/null +++ b/patch/moveplace.h @@ -0,0 +1,3 @@ +enum { WIN_NW, WIN_N, WIN_NE, WIN_W, WIN_C, WIN_E, WIN_SW, WIN_S, WIN_SE }; + +static void moveplace(const Arg *arg); \ No newline at end of file diff --git a/patches.def.h b/patches.def.h index 1a81b81..7b8a1bb 100644 --- a/patches.def.h +++ b/patches.def.h @@ -334,6 +334,13 @@ */ #define MONOCLESYMBOL_PATCH 0 +/* Makes a window floating and 1/3rd the height and 1/3rd the width of the screen and is + * positioned in either the center or one of the 8 cardinal directions depending on which + * key is pressed. + * https://dwm.suckless.org/patches/moveplace/ + */ +#define MOVEPLACE_PATCH 0 + /* This patch allows you to move and resize dwm's clients using keyboard bindings. * https://dwm.suckless.org/patches/moveresize/ */