From db2151af64196c48c5966f24170f8e3d90513c7a Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Tue, 16 Dec 2025 11:34:52 +0800 Subject: [PATCH] fix: crash when focusmon to invalid monitor --- src/dispatch/bind_define.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/dispatch/bind_define.h b/src/dispatch/bind_define.h index 92e264e..6544cab 100644 --- a/src/dispatch/bind_define.h +++ b/src/dispatch/bind_define.h @@ -173,15 +173,17 @@ int toggle_trackpad_enable(const Arg *arg) { int focusmon(const Arg *arg) { Client *c = NULL; Monitor *m = NULL; + Monitor *tm = NULL; if (arg->i != UNDIR) { - m = dirtomon(arg->i); + tm = dirtomon(arg->i); } else if (arg->v) { wl_list_for_each(m, &mons, link) { if (!m->wlr_output->enabled) { continue; } if (regex_match(arg->v, m->wlr_output->name)) { + tm = m; break; } } @@ -189,10 +191,10 @@ int focusmon(const Arg *arg) { return 0; } - if (!m || !m->wlr_output->enabled || m == selmon) + if (!tm || !tm->wlr_output->enabled || tm == selmon) return 0; - selmon = m; + selmon = tm; if (warpcursor) { warp_cursor_to_selmon(selmon); }