From 00ce4c0f5772de04732ffcbb8fbca47221b1507e Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Wed, 3 Dec 2025 21:07:45 +0800 Subject: [PATCH] opt: optimize border color set when change monitor --- src/dispatch/bind_define.h | 6 +----- src/mango.c | 8 ++++++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/dispatch/bind_define.h b/src/dispatch/bind_define.h index a988345..1623b9f 100644 --- a/src/dispatch/bind_define.h +++ b/src/dispatch/bind_define.h @@ -172,7 +172,7 @@ int toggle_trackpad_enable(const Arg *arg) { } int focusmon(const Arg *arg) { - Client *c = NULL, *old_selmon_sel = NULL; + Client *c = NULL; Monitor *m = NULL; if (arg->i != UNDIR) { @@ -193,7 +193,6 @@ int focusmon(const Arg *arg) { if (!m || !m->wlr_output->enabled || m == selmon) return 0; - old_selmon_sel = selmon->sel; selmon = m; if (warpcursor) { warp_cursor_to_selmon(selmon); @@ -206,9 +205,6 @@ int focusmon(const Arg *arg) { } else focusclient(c, 1); - if (old_selmon_sel) { - client_set_unfocused_opacity_animation(old_selmon_sel); - } return 0; } diff --git a/src/mango.c b/src/mango.c index ea36753..5edf24e 100644 --- a/src/mango.c +++ b/src/mango.c @@ -3117,6 +3117,7 @@ void destroykeyboardgroup(struct wl_listener *listener, void *data) { void focusclient(Client *c, int lift) { Client *last_focus_client = NULL; + Monitor *um = NULL; struct wlr_surface *old_keyboard_focus_surface = seat->keyboard_state.focused_surface; @@ -3162,6 +3163,13 @@ void focusclient(Client *c, int lift) { client_set_unfocused_opacity_animation(last_focus_client); } + wl_list_for_each(um, &mons, link) { + if (um->wlr_output->enabled && um != selmon && um->sel && + !um->sel->iskilling) { + client_set_unfocused_opacity_animation(um->sel); + } + } + client_set_focused_opacity_animation(c); // decide whether need to re-arrange