From 26dc1995d5fcba76a2bdc7653be88d2d160f49f9 Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Sun, 30 Mar 2025 17:44:36 +0800 Subject: [PATCH] opt: optimize focusmon --- maomao.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/maomao.c b/maomao.c index 847f309..46435e8 100644 --- a/maomao.c +++ b/maomao.c @@ -3173,18 +3173,20 @@ void focusclient(Client *c, int lift) { client_activate_surface(client_surface(c), 1); } -void // 0.5 -focusmon(const Arg *arg) { +void focusmon(const Arg *arg) { + Client *c; int i = 0, nmons = wl_list_length(&mons); if (nmons) { do /* don't switch to disabled mons */ selmon = dirtomon(arg->i); while (!selmon->wlr_output->enabled && i++ < nmons); - if (!selmon->wlr_output->enabled) - selmon = NULL; } warp_cursor_to_selmon(selmon); - focusclient(focustop(selmon), 1); + c = focustop(selmon); + if(!c) + selmon->sel = NULL; + else + focusclient(c, 1); } void // 17