This commit is contained in:
Hoàng Vương 2026-06-23 08:44:25 +08:00 committed by GitHub
commit 056ac08100
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 26 additions and 0 deletions

View file

@ -1061,6 +1061,8 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value,
} else if (strcmp(func_name, "killclient") == 0) {
func = killclient;
(*arg).i = parse_force(arg_value);
} else if (strcmp(func_name, "smartkillclient") == 0) {
func = smartkillclient;
} else if (strcmp(func_name, "centerwin") == 0) {
func = centerwin;
} else if (strcmp(func_name, "focuslast") == 0) {

View file

@ -34,6 +34,7 @@ int32_t moveresize(const Arg *arg);
int32_t exchange_client(const Arg *arg);
int32_t exchange_stack_client(const Arg *arg);
int32_t killclient(const Arg *arg);
int32_t smartkillclient(const Arg *arg);
int32_t toggleglobal(const Arg *arg);
int32_t incnmaster(const Arg *arg);
int32_t focusmon(const Arg *arg);

View file

@ -360,6 +360,28 @@ int32_t killclient(const Arg *arg) {
return 0;
}
int32_t smartkillclient(const Arg *arg) {
Client *c = arg->tc ? arg->tc : (selmon ? selmon->sel : NULL);
if (!c)
return 0;
uint32_t newtags = c->tags & ~(c->mon->tagset[c->mon->seltags] & TAGMASK);
// Kill the client if it's single-tag, or if removing the tag(s) would leave
// it on none
if (__builtin_popcount(c->tags & TAGMASK) <= 1 || !newtags) {
pending_kill_client(c);
return 0;
}
// Remove the client from the currently viewed tag(s) on its own monitor
// (the one that changed) while keeping focus on the user's active monitor.
c->tags = newtags;
focusclient(focustop(selmon), 1);
arrange(c->mon, false, false);
printstatus(IPC_WATCH_ARRANGGE);
return 0;
}
int32_t moveresize(const Arg *arg) {
const char *cursors[] = {"nw-resize", "ne-resize", "sw-resize",
"se-resize"};