Adding moveplace patch

This commit is contained in:
bakkeby 2020-05-21 19:58:11 +02:00
parent 2cb3e697e4
commit fc8434abd1
7 changed files with 81 additions and 25 deletions

View File

@ -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

View File

@ -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 } },

View File

@ -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

View File

@ -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

29
patch/moveplace.c Normal file
View File

@ -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);
}

3
patch/moveplace.h Normal file
View File

@ -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);

View File

@ -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/
*/