myvxwm

[fork] my vxwm config (optimised for my T480)
git clone https://git.lukeonline.net/repos/myvxwm
Log | Files | Refs | README | LICENSE

commit bbe5769caf7c058db35ab466ed18ffbb08a2ac3f
parent 2c84e0ed5f07ec6d2dec50a695bad8d5ccd4cc56
Author: wh1tepearl <wh1tepearl@gmail.com>
Date:   Mon, 23 Feb 2026 22:16:39 +0000

add directional focus

Diffstat:
Mconfig.def.h | 14++++++++++----
Mmodules.def.h | 1+
Amodules/directionalfocus/directionalfocus.c | 71+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amodules/directionalfocus/directionalfocus.h | 1+
Mmodules/vxwm_includes.c | 4++++
Mmodules/vxwm_includes.h | 4++++
6 files changed, 91 insertions(+), 4 deletions(-)

diff --git a/config.def.h b/config.def.h @@ -165,10 +165,10 @@ static const Key keys[] = { { MODKEY|ShiftMask, XK_equal, setgaps, {.i = 0 } }, #endif #if MOVE_RESIZE_WITH_KEYBOARD -{ MODKEY, XK_Down, moveresize, {.v = (int []){ 0, MOVE_WITH_KEYBOARD_STEP, 0, 0 }}}, -{ MODKEY, XK_Up, moveresize, {.v = (int []){ 0, -MOVE_WITH_KEYBOARD_STEP, 0, 0 }}}, -{ MODKEY, XK_Right, moveresize, {.v = (int []){ MOVE_WITH_KEYBOARD_STEP, 0, 0, 0 }}}, -{ MODKEY, XK_Left, moveresize, {.v = (int []){ -MOVE_WITH_KEYBOARD_STEP, 0, 0, 0 }}}, +{ MODKEY|Mod1Mask, XK_Down, moveresize, {.v = (int []){ 0, MOVE_WITH_KEYBOARD_STEP, 0, 0 }}}, +{ MODKEY|Mod1Mask, XK_Up, moveresize, {.v = (int []){ 0, -MOVE_WITH_KEYBOARD_STEP, 0, 0 }}}, +{ MODKEY|Mod1Mask, XK_Right, moveresize, {.v = (int []){ MOVE_WITH_KEYBOARD_STEP, 0, 0, 0 }}}, +{ MODKEY|Mod1Mask, XK_Left, moveresize, {.v = (int []){ -MOVE_WITH_KEYBOARD_STEP, 0, 0, 0 }}}, { MODKEY|ControlMask, XK_Down, moveresize, {.v = (int []){ 0, 0, 0, RESIZE_WITH_KEYBOARD_STEP }}}, { MODKEY|ControlMask, XK_Up, moveresize, {.v = (int []){ 0, 0, 0, -RESIZE_WITH_KEYBOARD_STEP }}}, { MODKEY|ControlMask, XK_Right, moveresize, {.v = (int []){ 0, 0, RESIZE_WITH_KEYBOARD_STEP, 0 }}}, @@ -182,6 +182,12 @@ static const Key keys[] = { { MODKEY|ShiftMask, XK_Down, movecanvas, {.i = 3} }, // Move your position down { MODKEY|ShiftMask, XK_d, centerwindow, {0} }, #endif +#if DIRECTIONAL_FOCUS + { MODKEY, XK_Left, focusdir, {.i = 0 } }, // left + { MODKEY, XK_Right, focusdir, {.i = 1 } }, // right + { MODKEY, XK_Up, focusdir, {.i = 2 } }, // up + { MODKEY, XK_Down, focusdir, {.i = 3 } }, // down +#endif }; /* button definitions */ diff --git a/modules.def.h b/modules.def.h @@ -78,6 +78,7 @@ Even though this sounds complex, it is actually pretty lightweight ~250 l.o.c, a #define FULLSCREEN 0 // Support for toggling fullscreen. #define MOVE_IN_TILED 0 // Support for moving windows in tiled mode. #define EWMH_TAGS 0 // Support for EWMH tags, recommended if you want to use external bars with less pain +#define DIRECTIONAL_FOCUS 0 // yeah. diff --git a/modules/directionalfocus/directionalfocus.c b/modules/directionalfocus/directionalfocus.c @@ -0,0 +1,71 @@ +void +focusdir(const Arg *arg) +{ + Client *s = selmon->sel, *f = NULL, *c, *next; + + if (!s) + return; + + unsigned int score = -1; + unsigned int client_score; + int dist; + int dirweight = 20; + int isfloating = s->isfloating; + + 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) || c->isfloating != isfloating) // || 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) { + focus(f); +#if INFINITE_TAGS + centerwindow(NULL); +#endif +#if WARP_TO_CLIENT && WARP_TO_CENTER_OF_WINDOW_AFFECTED_BY_FOCUSSTACK + warptoclient(f); +#endif + restack(f->mon); + } +} diff --git a/modules/directionalfocus/directionalfocus.h b/modules/directionalfocus/directionalfocus.h @@ -0,0 +1 @@ +static void focusdir(const Arg *arg); diff --git a/modules/vxwm_includes.c b/modules/vxwm_includes.c @@ -39,3 +39,7 @@ #if MOVE_RESIZE_WITH_KEYBOARD #include "moveresizekbd/moveresizekbd.c" #endif + +#if DIRECTIONAL_FOCUS +#include "directionalfocus/directionalfocus.c" +#endif diff --git a/modules/vxwm_includes.h b/modules/vxwm_includes.h @@ -35,3 +35,7 @@ #if MOVE_RESIZE_WITH_KEYBOARD #include "moveresizekbd/moveresizekbd.h" #endif + +#if DIRECTIONAL_FOCUS +#include "directionalfocus/directionalfocus.h" +#endif