diff --git a/docs/bindings/keys.md b/docs/bindings/keys.md index 2adbd4880..ef5398c87 100644 --- a/docs/bindings/keys.md +++ b/docs/bindings/keys.md @@ -110,6 +110,7 @@ bindr=Super,Super_L,spawn,rofi -show run | `focusdir` | `left/right/up/down` | Focus window in direction. | | `focus_window_or_workspace` | `left/right/up/down` | Focus window in direction or switch to next/previous workspace. | | `focusstack` | `next/prev` | Cycle focus within the stack. | +| `focus_first_tiled` | - | Focus the first visible tiled window in layout order. | | `focuslast` | - | Focus the previously active window. | | `exchange_client` | `left/right/up/down` | Swap window with neighbor in direction. | | `exchange_stack_client` | `next/prev` | Exchange window position in stack. | diff --git a/src/config/parse_config.h b/src/config/parse_config.h index 1195896c9..b3d6862a8 100644 --- a/src/config/parse_config.h +++ b/src/config/parse_config.h @@ -1022,6 +1022,8 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value, if (strcmp(func_name, "focusstack") == 0) { func = focusstack; (*arg).i = parse_circle_direction(arg_value); + } else if (strcmp(func_name, "focus_first_tiled") == 0) { + func = focus_first_tiled; } else if (strcmp(func_name, "groupfocus") == 0) { func = groupfocus; (*arg).i = parse_circle_direction(arg_value); diff --git a/src/dispatch/bind_declare.h b/src/dispatch/bind_declare.h index 5f8c54839..95bff6d71 100644 --- a/src/dispatch/bind_declare.h +++ b/src/dispatch/bind_declare.h @@ -41,6 +41,7 @@ void toggleglobal(const Arg *arg); void incnmaster(const Arg *arg); void focusmon(const Arg *arg); void focusstack(const Arg *arg); +void focus_first_tiled(const Arg *arg); void groupfocus(const Arg *arg); void chvt(const Arg *arg); void reload_config(const Arg *arg); diff --git a/src/dispatch/bind_define.h b/src/dispatch/bind_define.h index 47a864e39..a76572462 100644 --- a/src/dispatch/bind_define.h +++ b/src/dispatch/bind_define.h @@ -379,6 +379,26 @@ void focusstack(const Arg *arg) { return; } +void focus_first_tiled(const Arg *arg) { + Client *c = NULL; + + if (!selmon || !selmon->pertag->ltidxs[selmon->pertag->curtag]->arrange) + return; + + wl_list_for_each(c, &clients, link) { + if (VISIBLEON(c, selmon) && ISFAKETILED(c)) + break; + } + + if (&c->link == &clients || c == selmon->sel) + return; + + focusclient(c, 1); + if (config.warpcursor) + warp_cursor(c); + return; +} + void groupfocus(const Arg *arg) { Client *c = arg->tc ? arg->tc : selmon->sel; if (!c || !c->mon)