opt: optimize the oldmon record

This commit is contained in:
DreamMaoMao 2025-07-07 23:15:17 +08:00
parent bb4a202ae3
commit 84c0a8f3d0

View file

@ -2466,10 +2466,12 @@ void closemon(Monitor *m) {
} else { } else {
client_change_mon(c, selmon); client_change_mon(c, selmon);
} }
// record the oldmonname which is used to restore
if (c->oldmonname[0] == '\0') {
client_update_oldmonname_record(c, m); client_update_oldmonname_record(c, m);
} }
} }
}
if (selmon) { if (selmon) {
focusclient(focustop(selmon), 1); focusclient(focustop(selmon), 1);
printstatus(); printstatus();
@ -5684,7 +5686,7 @@ void tagsilent(const Arg *arg) {
} }
void client_update_oldmonname_record(Client *c, Monitor *m) { void client_update_oldmonname_record(Client *c, Monitor *m) {
if (!c || c->iskilling || !client_surface(c)->mapped || c->mon == m) if (!c || c->iskilling || !client_surface(c)->mapped)
return; return;
memset(c->oldmonname, 0, sizeof(c->oldmonname)); memset(c->oldmonname, 0, sizeof(c->oldmonname));
strncpy(c->oldmonname, m->wlr_output->name, sizeof(c->oldmonname) - 1); strncpy(c->oldmonname, m->wlr_output->name, sizeof(c->oldmonname) - 1);