opt: optimize focusmon

This commit is contained in:
DreamMaoMao 2025-03-30 17:44:36 +08:00
parent 32453bf9d5
commit 26dc1995d5

View file

@ -3173,18 +3173,20 @@ void focusclient(Client *c, int lift) {
client_activate_surface(client_surface(c), 1); client_activate_surface(client_surface(c), 1);
} }
void // 0.5 void focusmon(const Arg *arg) {
focusmon(const Arg *arg) { Client *c;
int i = 0, nmons = wl_list_length(&mons); int i = 0, nmons = wl_list_length(&mons);
if (nmons) { if (nmons) {
do /* don't switch to disabled mons */ do /* don't switch to disabled mons */
selmon = dirtomon(arg->i); selmon = dirtomon(arg->i);
while (!selmon->wlr_output->enabled && i++ < nmons); while (!selmon->wlr_output->enabled && i++ < nmons);
if (!selmon->wlr_output->enabled)
selmon = NULL;
} }
warp_cursor_to_selmon(selmon); warp_cursor_to_selmon(selmon);
focusclient(focustop(selmon), 1); c = focustop(selmon);
if(!c)
selmon->sel = NULL;
else
focusclient(c, 1);
} }
void // 17 void // 17