From 505e2a5bcb8bba6c6459aa2d91e0936181493be8 Mon Sep 17 00:00:00 2001 From: Zedhugh Chen Date: Sat, 23 Aug 2025 23:03:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=AA=97=E5=8F=A3=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=20tag=20=E9=94=99=E8=AF=AF=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config.h | 4 ++-- src/main.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/config.h b/src/config.h index c53a723..b520240 100644 --- a/src/config.h +++ b/src/config.h @@ -54,7 +54,7 @@ const layout_t layouts[] = { /* 默认 tags 规则 */ const rule_tag_t browser_tag[] = { - {.monitor_amount = 1, .tags = 1 << 1}, + {.monitor_index = 0, .tags = 1 << 1}, {0}, }; const rule_tag_t mpv_tag[] = { @@ -64,7 +64,7 @@ const rule_tag_t mpv_tag[] = { }; const rule_tag_t emacs_tag[] = { {.monitor_amount = 1, .monitor_index = 0, .tags = 1 << 2}, - {.monitor_amount = 2, .monitor_index = 0, .tags = 1 << 1}, + {.monitor_amount = 2, .monitor_index = 1, .tags = 1 << 1}, {0}, }; /* 新建窗口规则 */ diff --git a/src/main.c b/src/main.c index 7258a65..7fc9e39 100644 --- a/src/main.c +++ b/src/main.c @@ -168,7 +168,7 @@ static void print_rule(const rule_t *r) { bool2string(r->action.floating), bool2string(r->action.maximize), bool2string(r->action.fullscreen), bool2string(r->action.switch_to_tag)); - for (uint32_t i = 0; r->tag && r->tag[i].monitor_amount; i++) { + for (uint32_t i = 0; r->tag && r->tag[i].tags; i++) { const rule_tag_t *t = &r->tag[i]; printf("monitor amount: %u, monitor index: %u, tags: %b\n", t->monitor_amount, t->monitor_index, t->tags); @@ -583,11 +583,10 @@ void apply_rules(client_t *client) { const rule_tag_t *tag = NULL; for (uint32_t i = 0;; i++) { const rule_tag_t *t = &r->tag[i]; - if (!t->monitor_amount) break; + if (!t->tags) break; - if (t->monitor_amount == monitor_amount) { + if (!t->monitor_amount || t->monitor_amount == monitor_amount) { tag = t; - break; } } if (tag) { @@ -597,6 +596,7 @@ void apply_rules(client_t *client) { uint32_t tags_mask = get_tags_mask_of_monitor(m); client->tags = tag->tags & tags_mask; + client->monitor = m; } }