mirror of
https://github.com/mintycube/dwm.git
synced 2024-10-22 14:05:45 +02:00
Adding placedir patch ref. #407
This commit is contained in:
parent
5a0c5e617f
commit
01244cc1b9
@ -19,6 +19,8 @@ Browsing patches? There is a [map of patches](https://coggle.it/diagram/X9IiSSM6
|
|||||||
|
|
||||||
### Changelog:
|
### Changelog:
|
||||||
|
|
||||||
|
2024-01-31 - Added the placedir patch
|
||||||
|
|
||||||
2023-12-22 - Added the do-not-die-on-color-allocation-failure patch
|
2023-12-22 - Added the do-not-die-on-color-allocation-failure patch
|
||||||
|
|
||||||
2023-12-01 - Added the sendmoncenter patch
|
2023-12-01 - Added the sendmoncenter patch
|
||||||
@ -601,6 +603,9 @@ Browsing patches? There is a [map of patches](https://coggle.it/diagram/X9IiSSM6
|
|||||||
- [pertag](https://dwm.suckless.org/patches/pertag/)
|
- [pertag](https://dwm.suckless.org/patches/pertag/)
|
||||||
- adds nmaster, mfact, layouts and more per tag rather than per monitor
|
- adds nmaster, mfact, layouts and more per tag rather than per monitor
|
||||||
|
|
||||||
|
- [placedir](https://github.com/bakkeby/patches/wiki/placedir)
|
||||||
|
- allows tiled windows to be moved in any direction (up, down, left, right)
|
||||||
|
|
||||||
- [placemouse](https://github.com/bakkeby/patches/wiki/placemouse)
|
- [placemouse](https://github.com/bakkeby/patches/wiki/placemouse)
|
||||||
- lets the user change the position of a client in the stack using the mouse.
|
- lets the user change the position of a client in the stack using the mouse.
|
||||||
|
|
||||||
|
18
config.def.h
18
config.def.h
@ -930,6 +930,12 @@ static const Key keys[] = {
|
|||||||
{ MODKEY, XK_Up, focusdir, {.i = 2 } }, // up
|
{ MODKEY, XK_Up, focusdir, {.i = 2 } }, // up
|
||||||
{ MODKEY, XK_Down, focusdir, {.i = 3 } }, // down
|
{ MODKEY, XK_Down, focusdir, {.i = 3 } }, // down
|
||||||
#endif // FOCUSDIR_PATCH
|
#endif // FOCUSDIR_PATCH
|
||||||
|
#if PLACEDIR_PATCH
|
||||||
|
{ MODKEY|ControlMask, XK_Left, placedir, {.i = 0 } }, // left
|
||||||
|
{ MODKEY|ControlMask, XK_Right, placedir, {.i = 1 } }, // right
|
||||||
|
{ MODKEY|ControlMask, XK_Up, placedir, {.i = 2 } }, // up
|
||||||
|
{ MODKEY|ControlMask, XK_Down, placedir, {.i = 3 } }, // down
|
||||||
|
#endif // PLACEDIR_PATCH
|
||||||
#if SWAPFOCUS_PATCH && PERTAG_PATCH
|
#if SWAPFOCUS_PATCH && PERTAG_PATCH
|
||||||
{ MODKEY, XK_s, swapfocus, {.i = -1 } },
|
{ MODKEY, XK_s, swapfocus, {.i = -1 } },
|
||||||
#endif // SWAPFOCUS_PATCH
|
#endif // SWAPFOCUS_PATCH
|
||||||
@ -1037,8 +1043,8 @@ static const Key keys[] = {
|
|||||||
{ MODKEY|Mod4Mask, XK_backslash, shiftviewclients, { .i = +1 } },
|
{ MODKEY|Mod4Mask, XK_backslash, shiftviewclients, { .i = +1 } },
|
||||||
#endif // SHIFTVIEW_CLIENTS_PATCH
|
#endif // SHIFTVIEW_CLIENTS_PATCH
|
||||||
#if SHIFTBOTH_PATCH
|
#if SHIFTBOTH_PATCH
|
||||||
{ MODKEY|ControlMask, XK_Left, shiftboth, { .i = -1 } }, // note keybinding conflict with focusadjacenttag tagandviewtoleft
|
{ MODKEY|ControlMask, XK_Left, shiftboth, { .i = -1 } }, // note keybinding conflict with focusadjacenttag tagandviewtoleft placedir
|
||||||
{ MODKEY|ControlMask, XK_Right, shiftboth, { .i = +1 } }, // note keybinding conflict with focusadjacenttag tagandviewtoright
|
{ MODKEY|ControlMask, XK_Right, shiftboth, { .i = +1 } }, // note keybinding conflict with focusadjacenttag tagandviewtoright placedir
|
||||||
#endif // SHIFTBOTH_PATCH
|
#endif // SHIFTBOTH_PATCH
|
||||||
#if SHIFTSWAPTAGS_PATCH && SWAPTAGS_PATCH
|
#if SHIFTSWAPTAGS_PATCH && SWAPTAGS_PATCH
|
||||||
{ MODKEY|Mod4Mask|ShiftMask, XK_Left, shiftswaptags, { .i = -1 } },
|
{ MODKEY|Mod4Mask|ShiftMask, XK_Left, shiftswaptags, { .i = -1 } },
|
||||||
@ -1144,8 +1150,8 @@ static const Key keys[] = {
|
|||||||
{ MODKEY, XK_Right, viewtoright, {0} }, // note keybinding conflict with focusdir
|
{ MODKEY, XK_Right, viewtoright, {0} }, // note keybinding conflict with focusdir
|
||||||
{ MODKEY|ShiftMask, XK_Left, tagtoleft, {0} }, // note keybinding conflict with shifttag
|
{ MODKEY|ShiftMask, XK_Left, tagtoleft, {0} }, // note keybinding conflict with shifttag
|
||||||
{ MODKEY|ShiftMask, XK_Right, tagtoright, {0} }, // note keybinding conflict with shifttag
|
{ MODKEY|ShiftMask, XK_Right, tagtoright, {0} }, // note keybinding conflict with shifttag
|
||||||
{ MODKEY|ControlMask, XK_Left, tagandviewtoleft, {0} },
|
{ MODKEY|ControlMask, XK_Left, tagandviewtoleft, {0} }, // note keybinding conflict with placedir
|
||||||
{ MODKEY|ControlMask, XK_Right, tagandviewtoright, {0} },
|
{ MODKEY|ControlMask, XK_Right, tagandviewtoright, {0} }, // note keybinding conflict with placedir
|
||||||
#endif // FOCUSADJACENTTAG_PATCH
|
#endif // FOCUSADJACENTTAG_PATCH
|
||||||
#if TAGALL_PATCH
|
#if TAGALL_PATCH
|
||||||
{ MODKEY|ShiftMask, XK_F1, tagall, {.v = "F1"} },
|
{ MODKEY|ShiftMask, XK_F1, tagall, {.v = "F1"} },
|
||||||
@ -1184,8 +1190,8 @@ static const Key keys[] = {
|
|||||||
#if BAR_TAGGRID_PATCH
|
#if BAR_TAGGRID_PATCH
|
||||||
{ MODKEY|ControlMask, XK_Up, switchtag, { .ui = SWITCHTAG_UP | SWITCHTAG_VIEW } },
|
{ MODKEY|ControlMask, XK_Up, switchtag, { .ui = SWITCHTAG_UP | SWITCHTAG_VIEW } },
|
||||||
{ MODKEY|ControlMask, XK_Down, switchtag, { .ui = SWITCHTAG_DOWN | SWITCHTAG_VIEW } },
|
{ MODKEY|ControlMask, XK_Down, switchtag, { .ui = SWITCHTAG_DOWN | SWITCHTAG_VIEW } },
|
||||||
{ MODKEY|ControlMask, XK_Right, switchtag, { .ui = SWITCHTAG_RIGHT | SWITCHTAG_VIEW } },
|
{ MODKEY|ControlMask, XK_Right, switchtag, { .ui = SWITCHTAG_RIGHT | SWITCHTAG_VIEW } }, // note keybinding conflict with placedir
|
||||||
{ MODKEY|ControlMask, XK_Left, switchtag, { .ui = SWITCHTAG_LEFT | SWITCHTAG_VIEW } },
|
{ MODKEY|ControlMask, XK_Left, switchtag, { .ui = SWITCHTAG_LEFT | SWITCHTAG_VIEW } }, // note keybinding conflict with placedir
|
||||||
{ MODKEY|Mod4Mask, XK_Up, switchtag, { .ui = SWITCHTAG_UP | SWITCHTAG_TAG | SWITCHTAG_VIEW } },
|
{ MODKEY|Mod4Mask, XK_Up, switchtag, { .ui = SWITCHTAG_UP | SWITCHTAG_TAG | SWITCHTAG_VIEW } },
|
||||||
{ MODKEY|Mod4Mask, XK_Down, switchtag, { .ui = SWITCHTAG_DOWN | SWITCHTAG_TAG | SWITCHTAG_VIEW } },
|
{ MODKEY|Mod4Mask, XK_Down, switchtag, { .ui = SWITCHTAG_DOWN | SWITCHTAG_TAG | SWITCHTAG_VIEW } },
|
||||||
{ MODKEY|Mod4Mask, XK_Right, switchtag, { .ui = SWITCHTAG_RIGHT | SWITCHTAG_TAG | SWITCHTAG_VIEW } },
|
{ MODKEY|Mod4Mask, XK_Right, switchtag, { .ui = SWITCHTAG_RIGHT | SWITCHTAG_TAG | SWITCHTAG_VIEW } },
|
||||||
|
@ -208,6 +208,9 @@
|
|||||||
#if PERTAG_PATCH
|
#if PERTAG_PATCH
|
||||||
#include "pertag.c"
|
#include "pertag.c"
|
||||||
#endif
|
#endif
|
||||||
|
#if PLACEDIR_PATCH
|
||||||
|
#include "placedir.c"
|
||||||
|
#endif
|
||||||
#if PLACEMOUSE_PATCH
|
#if PLACEMOUSE_PATCH
|
||||||
#include "placemouse.c"
|
#include "placemouse.c"
|
||||||
#endif
|
#endif
|
||||||
|
@ -207,6 +207,9 @@
|
|||||||
#if PERTAG_PATCH
|
#if PERTAG_PATCH
|
||||||
#include "pertag.h"
|
#include "pertag.h"
|
||||||
#endif
|
#endif
|
||||||
|
#if PLACEDIR_PATCH
|
||||||
|
#include "placedir.h"
|
||||||
|
#endif
|
||||||
#if PLACEMOUSE_PATCH
|
#if PLACEMOUSE_PATCH
|
||||||
#include "placemouse.h"
|
#include "placemouse.h"
|
||||||
#endif
|
#endif
|
||||||
|
96
patch/placedir.c
Normal file
96
patch/placedir.c
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
void
|
||||||
|
placedir(const Arg *arg)
|
||||||
|
{
|
||||||
|
Client *s = selmon->sel, *f = NULL, *c, *next, *fprior, *sprior;
|
||||||
|
|
||||||
|
if (!s || s->isfloating)
|
||||||
|
return;
|
||||||
|
|
||||||
|
unsigned int score = -1;
|
||||||
|
unsigned int client_score;
|
||||||
|
int dist;
|
||||||
|
int dirweight = 20;
|
||||||
|
|
||||||
|
next = s->next;
|
||||||
|
if (!next)
|
||||||
|
next = s->mon->clients;
|
||||||
|
for (c = next; c != s; c = next) {
|
||||||
|
|
||||||
|
next = c->next;
|
||||||
|
if (!next)
|
||||||
|
next = s->mon->clients;
|
||||||
|
|
||||||
|
if (!ISVISIBLE(c)) // || HIDDEN(c)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
switch (arg->i) {
|
||||||
|
case 0: // left
|
||||||
|
dist = s->x - c->x - c->w;
|
||||||
|
client_score =
|
||||||
|
dirweight * MIN(abs(dist), abs(dist + s->mon->ww)) +
|
||||||
|
abs(s->y - c->y);
|
||||||
|
break;
|
||||||
|
case 1: // right
|
||||||
|
dist = c->x - s->x - s->w;
|
||||||
|
client_score =
|
||||||
|
dirweight * MIN(abs(dist), abs(dist + s->mon->ww)) +
|
||||||
|
abs(c->y - s->y);
|
||||||
|
break;
|
||||||
|
case 2: // up
|
||||||
|
dist = s->y - c->y - c->h;
|
||||||
|
client_score =
|
||||||
|
dirweight * MIN(abs(dist), abs(dist + s->mon->wh)) +
|
||||||
|
abs(s->x - c->x);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
case 3: // down
|
||||||
|
dist = c->y - s->y - s->h;
|
||||||
|
client_score =
|
||||||
|
dirweight * MIN(abs(dist), abs(dist + s->mon->wh)) +
|
||||||
|
abs(c->x - s->x);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (((arg->i == 0 || arg->i == 2) && client_score <= score) || client_score < score) {
|
||||||
|
score = client_score;
|
||||||
|
f = c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (f && f != s) {
|
||||||
|
for (fprior = f->mon->clients; fprior && fprior->next != f; fprior = fprior->next);
|
||||||
|
for (sprior = s->mon->clients; sprior && sprior->next != s; sprior = sprior->next);
|
||||||
|
|
||||||
|
if (s == fprior) {
|
||||||
|
next = f->next;
|
||||||
|
if (sprior)
|
||||||
|
sprior->next = f;
|
||||||
|
else
|
||||||
|
f->mon->clients = f;
|
||||||
|
f->next = s;
|
||||||
|
s->next = next;
|
||||||
|
} else if (f == sprior) {
|
||||||
|
next = s->next;
|
||||||
|
if (fprior)
|
||||||
|
fprior->next = s;
|
||||||
|
else
|
||||||
|
s->mon->clients = s;
|
||||||
|
s->next = f;
|
||||||
|
f->next = next;
|
||||||
|
} else { // clients are not adjacent to each other
|
||||||
|
next = f->next;
|
||||||
|
f->next = s->next;
|
||||||
|
s->next = next;
|
||||||
|
if (fprior)
|
||||||
|
fprior->next = s;
|
||||||
|
else
|
||||||
|
s->mon->clients = s;
|
||||||
|
if (sprior)
|
||||||
|
sprior->next = f;
|
||||||
|
else
|
||||||
|
f->mon->clients = f;
|
||||||
|
}
|
||||||
|
|
||||||
|
arrange(f->mon);
|
||||||
|
}
|
||||||
|
}
|
1
patch/placedir.h
Normal file
1
patch/placedir.h
Normal file
@ -0,0 +1 @@
|
|||||||
|
static void placedir(const Arg *arg);
|
@ -908,6 +908,12 @@
|
|||||||
*/
|
*/
|
||||||
#define PERTAGBAR_PATCH 0
|
#define PERTAGBAR_PATCH 0
|
||||||
|
|
||||||
|
/* Similar to the focusdir patch this patch allow users to move a window in any direction
|
||||||
|
* in the tiled stack (up, down, left, right).
|
||||||
|
* https://github.com/bakkeby/patches/wiki/placedir
|
||||||
|
*/
|
||||||
|
#define PLACEDIR_PATCH 0
|
||||||
|
|
||||||
/* This patch lets you change the position of a client in the stack using the mouse.
|
/* This patch lets you change the position of a client in the stack using the mouse.
|
||||||
* https://github.com/bakkeby/patches/wiki/placemouse
|
* https://github.com/bakkeby/patches/wiki/placemouse
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user