feat: add dispatch focuslast

This commit is contained in:
DreamMaoMao 2025-06-15 15:55:18 +08:00
parent 4f78c06515
commit ba763332fc
3 changed files with 29 additions and 1 deletions

View file

@ -660,6 +660,8 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value,
func = tagtoright;
} else if (strcmp(func_name, "killclient") == 0) {
func = killclient;
} else if (strcmp(func_name, "focuslast") == 0) {
func = focuslast;
} else if (strcmp(func_name, "setlayout") == 0) {
func = setlayout;
(*arg).v = strdup(arg_value);

View file

@ -58,3 +58,4 @@ void toggle_named_scratchpad(const Arg *arg);
void toggle_render_border(const Arg *arg);
void create_virtual_output(const Arg *arg);
void destroy_all_virtual_output(const Arg *arg);
void focuslast(const Arg *arg);

View file

@ -4549,6 +4549,31 @@ void pending_kill_client(Client *c) {
client_send_close(c);
}
void focuslast(const Arg *arg) {
Client *c, *prev = NULL;
wl_list_for_each(c, &fstack, flink) {
if (c->iskilling || c->isminied || c->isunglobal)
continue;
if (c)
break;
}
struct wl_list *prev_node = c->flink.next;
prev = wl_container_of(prev_node, prev, flink);
unsigned int target;
if (prev) {
if (prev->mon != selmon) {
selmon = prev->mon;
warp_cursor_to_selmon(selmon);
}
target = get_tags_first_tag(prev->tags);
view(&(Arg){.ui = target}, true);
focusclient(prev, 1);
}
}
void killclient(const Arg *arg) {
Client *c;
c = selmon->sel;