From 79843b730b50672311a7191ab69cc305bfab339c Mon Sep 17 00:00:00 2001 From: Abhinav Prasai Date: Mon, 25 Aug 2025 16:18:34 +0100 Subject: add focused checking to prevent crash and make clangd option --- src/sxwm.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/sxwm.c b/src/sxwm.c index f7ac401..f1fc94f 100644 --- a/src/sxwm.c +++ b/src/sxwm.c @@ -575,7 +575,9 @@ void focus_next_mon(void) return; } - current_mon = focused->mon; + if (focused) { + current_mon = focused->mon; + } int target_mon = (current_mon + 1) % n_mons; /* find the first window on the target monitor in current workspace */ @@ -614,7 +616,9 @@ void focus_prev_mon(void) return; /* only one monitor, nothing to switch to */ } - current_mon = focused->mon; + if (focused) { + current_mon = focused->mon; + } int target_mon = (current_mon - 1 + n_mons) % n_mons; /* find the first window on the target monitor in current workspace */ -- cgit v1.2.3