From cecd7dc2d9b513f7a980f949b05af403a8ba0c32 Mon Sep 17 00:00:00 2001 From: Zedhugh Chen Date: Tue, 3 Mar 2026 08:47:08 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20client=5Fmanage=20?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E4=B8=AD=20client=20=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96=20tag=20=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/client.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/client.c b/src/client.c index 22d2d39..0eeac66 100644 --- a/src/client.c +++ b/src/client.c @@ -159,9 +159,12 @@ static inline void client_init_geometry(client_t *c) { client_change_border_width(c, wm.border_width); } -static void client_init_tag_by_wm_desktop(client_t *client) { +static void client_init_tag_by_wm_desktop(client_t *client, uint32_t tag_mask) { uint32_t tag_index = 0; - if (!xwindow_get_wm_desktop(client->window, &tag_index)) return; + if (!xwindow_get_wm_desktop(client->window, &tag_index)) { + goto tag_fallback; + } + for (monitor_t *m = wm.monitor_list; m; m = m->next) { for (tag_t *tag = m->tag_list; tag; tag = tag->next) { if (tag->index == tag_index) { @@ -171,6 +174,9 @@ static void client_init_tag_by_wm_desktop(client_t *client) { } } } + +tag_fallback: + client->tags = tag_mask; } static void set_window_event_mask(xcb_window_t window, bool clean) { @@ -224,15 +230,14 @@ void client_manage(xcb_window_t window, if (c->transient_for_window && (transient_for_client = client_get_by_window( c->transient_for_window))) { c->monitor = transient_for_client->monitor; - c->tags = transient_for_client->tags; + client_init_tag_by_wm_desktop(c, transient_for_client->tags); } else { c->monitor = wm.current_monitor; - c->tags = c->monitor->selected_tag->mask; + client_init_tag_by_wm_desktop(c, c->monitor->selected_tag->mask); client_apply_rules(c, wm.rules, wm.rules_count); } client_init_geometry(c); - client_init_tag_by_wm_desktop(c); client_tags_apply(c); }