From 91d37b1d092c4d0cdfff59c197636930a1c36e51 Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Mon, 17 Feb 2025 08:58:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dtag=20rule?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复tag rule --- maomao.c | 13 ++++++++++--- parse_config.h | 8 ++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/maomao.c b/maomao.c index f5ffed28..52451647 100644 --- a/maomao.c +++ b/maomao.c @@ -1201,7 +1201,6 @@ arrange(Monitor *m, bool want_animation) { if (!m->wlr_output->enabled) return; - wl_list_for_each(c, &clients, link) { if (c->iskilling) @@ -2073,11 +2072,20 @@ createmon(struct wl_listener *listener, void *data) { m->pertag = calloc(1, sizeof(Pertag)); m->pertag->curtag = m->pertag->prevtag = 1; - for (i = 0; i <= LENGTH(tags); i++) { + for (i = 1; i <= LENGTH(tags); i++) { m->pertag->nmasters[i] = m->nmaster; m->pertag->mfacts[i] = m->mfact; m->pertag->ltidxs[i] = m->lt; + + if(strlen(config.tags[i-1].layout_name) > 0) { + for (jk = 0; jk < LENGTH(layouts); jk++) { + if(strcmp(layouts[jk].name , config.tags[i-1].layout_name) == 0) { + m->pertag->ltidxs[i] = &layouts[jk]; + } + } + } + } printstatus(); @@ -5556,7 +5564,6 @@ void view(const Arg *arg, bool want_animation) { if (!selmon || (arg->ui != ~0 && selmon->isoverview)) { return; } - if ((selmon->tagset[selmon->seltags] & arg->ui & TAGMASK) != 0) { want_animation = false; } diff --git a/parse_config.h b/parse_config.h index 9cbeeb12..309db8a3 100644 --- a/parse_config.h +++ b/parse_config.h @@ -100,7 +100,7 @@ typedef struct { struct { int id; - char name[256]; + char layout_name[256]; } tags[9]; ConfigWinRule *window_rules; @@ -494,11 +494,11 @@ void parse_config_line(Config *config, const char *line) { } } else if (strcmp(key, "tags") == 0) { int id; - char name[256]; - if (sscanf(value, "id:%d,name:%255[^\n]", &id, name) == 2) { + char layout_name[256]; + if (sscanf(value, "id:%d,layout_name:%255[^\n]", &id, layout_name) == 2) { if (id >= 1 && id <= 9) { config->tags[id - 1].id = id; - strncpy(config->tags[id - 1].name, name, sizeof(config->tags[id - 1].name)); + strncpy(config->tags[id - 1].layout_name, layout_name, sizeof(config->tags[id - 1].layout_name)); } else { fprintf(stderr, "Error: Invalid tag id: %d\n", id); }