diff options
diff --git a/config.def.h b/config.def.h index 3430d29..2e00524 100644 --- a/config.def.h +++ b/config.def.h @@ -34,7 +34,7 @@ static int log_level = WLR_ERROR; static const Menu menus[] = { /* command feed function action function */ - { "wmenu -i -l 10 -p Windows", menuwinfeed, menuwinaction }, + { "wmenu -b -i -l 10 -p Windows", menuwinfeed, menuwinaction }, }; static const Rule rules[] = { @@ -136,7 +136,7 @@ static const enum libinput_config_tap_button_map button_map = LIBINPUT_CONFIG_TA /* commands */ static const char *termcmd[] = { "ghostty", NULL }; -static const char *menucmd[] = { "wmenu-run", NULL }; +static const char *menucmd[] = { "wmenu-run", "-b", NULL }; static const Key keys[] = { /* Note that Shift changes certain key codes: 2 -> at, etc. */ @@ -144,12 +144,10 @@ static const Key keys[] = { { MODKEY, XKB_KEY_p, spawn, {.v = menucmd} }, { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} }, { MODKEY, XKB_KEY_b, togglebar, {0} }, - { MODKEY, XKB_KEY_j, focusstack, {.i = +1} }, - { MODKEY, XKB_KEY_k, focusstack, {.i = -1} }, { MODKEY, XKB_KEY_i, incnmaster, {.i = +1} }, { MODKEY, XKB_KEY_d, incnmaster, {.i = -1} }, - { MODKEY, XKB_KEY_h, setmfact, {.f = -0.05f} }, - { MODKEY, XKB_KEY_l, setmfact, {.f = +0.05f} }, + { MODKEY, XKB_KEY_plus, setmfact, {.f = -0.05f} }, + { MODKEY, XKB_KEY_minus, setmfact, {.f = +0.05f} }, { MODKEY, XKB_KEY_Return, zoom, {0} }, { MODKEY, XKB_KEY_Tab, view, {0} }, { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_c, killclient, {0} }, @@ -167,6 +165,10 @@ static const Key keys[] = { { MODKEY, XKB_KEY_period, focusmon, {.i = WLR_DIRECTION_RIGHT} }, { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_less, tagmon, {.i = WLR_DIRECTION_LEFT} }, { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_greater, tagmon, {.i = WLR_DIRECTION_RIGHT} }, + { MODKEY, XKB_KEY_h, focusdir, {.ui = 0} }, + { MODKEY, XKB_KEY_l, focusdir, {.ui = 1} }, + { MODKEY, XKB_KEY_k, focusdir, {.ui = 2} }, + { MODKEY, XKB_KEY_j, focusdir, {.ui = 3} }, TAGKEYS( XKB_KEY_1, XKB_KEY_exclam, 0), TAGKEYS( XKB_KEY_2, XKB_KEY_at, 1), TAGKEYS( XKB_KEY_3, XKB_KEY_numbersign, 2), @@ -2,6 +2,7 @@ * See LICENSE file for copyright and license details. */ #include <fcntl.h> +#include <limits.h> #include <getopt.h> #include <libinput.h> #include <linux/input-event-codes.h> @@ -329,6 +330,7 @@ static void drawbars(void); static void focusclient(Client *c, int lift); static void focusmon(const Arg *arg); static void focusstack(const Arg *arg); +static void focusdir(const Arg *arg); static Client *focustop(Monitor *m); static void fullscreennotify(struct wl_listener *listener, void *data); static void gpureset(struct wl_listener *listener, void *data); @@ -1861,6 +1863,49 @@ focusstack(const Arg *arg) focusclient(c, 1); } +void focusdir(const Arg *arg) +{ + /* Focus the left, right, up, down client relative to the current focused client on selmon */ + Client *c, *sel = focustop(selmon); + int dist=INT_MAX; + Client *newsel = NULL; + int newdist=INT_MAX; + if (!sel || sel->isfullscreen) + return; + + wl_list_for_each(c, &clients, link) { + if (!VISIBLEON(c, selmon)) + continue; /* skip non visible windows */ + + if (arg->ui == 0 && sel->geom.x <= c->geom.x) { + /* Client isn't on our left */ + continue; + } + if (arg->ui == 1 && sel->geom.x >= c->geom.x) { + /* Client isn't on our right */ + continue; + } + if (arg->ui == 2 && sel->geom.y <= c->geom.y) { + /* Client isn't above us */ + continue; + } + if (arg->ui == 3 && (sel->geom.y >= c->geom.y || sel->geom.x != c->geom.x) ) { + /* Client isn't below us */ + continue; + } + + dist=abs(sel->geom.x-c->geom.x)+abs(sel->geom.y-c->geom.y); + if (dist < newdist){ + newdist = dist; + newsel=c; + } + } + if (newsel != NULL){ + focusclient(newsel, 1); + } +} + + /* We probably should change the name of this: it sounds like it * will focus the topmost client of this mon, when actually will * only return that client */ |