impl comboview_spawn_on_empty

This commit is contained in:
salivala 2025-11-11 12:34:09 -05:00
parent 64d8764f58
commit e1dc0c5b61
3 changed files with 38 additions and 2 deletions

View file

@ -1014,6 +1014,10 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value,
func = spawn_on_empty; func = spawn_on_empty;
(*arg).v = strdup(arg_value); // 注意:之后需要释放这个内存 (*arg).v = strdup(arg_value); // 注意:之后需要释放这个内存
(*arg).ui = 1 << (atoi(arg_value2) - 1); (*arg).ui = 1 << (atoi(arg_value2) - 1);
} else if (strcmp(func_name, "comboview_spawn_on_empty") == 0) {
func = comboview_spawn_on_empty;
(*arg).v = strdup(arg_value); // 注意:之后需要释放这个内存
(*arg).ui = 1 << (atoi(arg_value2) - 1);
} else if (strcmp(func_name, "quit") == 0) { } else if (strcmp(func_name, "quit") == 0) {
func = quit; func = quit;
} else if (strcmp(func_name, "create_virtual_output") == 0) { } else if (strcmp(func_name, "create_virtual_output") == 0) {

View file

@ -23,6 +23,7 @@ int tagmon(const Arg *arg);
int spawn(const Arg *arg); int spawn(const Arg *arg);
int spawn_shell(const Arg *arg); int spawn_shell(const Arg *arg);
int spawn_on_empty(const Arg *arg); int spawn_on_empty(const Arg *arg);
int comboview_spawn_on_empty(const Arg *arg);
int setkeymode(const Arg *arg); int setkeymode(const Arg *arg);
int switch_keyboard_layout(const Arg *arg); int switch_keyboard_layout(const Arg *arg);
int setlayout(const Arg *arg); int setlayout(const Arg *arg);

View file

@ -810,6 +810,37 @@ int spawn_on_empty(const Arg *arg) {
return 0; return 0;
} }
comboview_spawn_on_empty(const Arg *arg) {
unsigned int newtags = arg->ui & TAGMASK;
bool is_empty = true;
Client *c = NULL;
if (!newtags || !selmon)
return 0;
wl_list_for_each(c, &clients, link) {
if (arg->ui & c->tags && c->mon == selmon) {
is_empty = false;
break;
}
}
if (tag_combo) {
selmon->tagset[selmon->seltags] |= newtags;
focusclient(focustop(selmon), 1);
arrange(selmon, false);
} else {
tag_combo = true;
view(&(Arg){.ui = newtags}, false);
}
if (is_empty) {
spawn(arg);
}
printstatus();
return 0;
}
int switch_keyboard_layout(const Arg *arg) { int switch_keyboard_layout(const Arg *arg) {
if (!kb_group || !kb_group->wlr_group || !seat) { if (!kb_group || !kb_group->wlr_group || !seat) {
wlr_log(WLR_ERROR, "Invalid keyboard group or seat"); wlr_log(WLR_ERROR, "Invalid keyboard group or seat");