fix: windowrule option monitor apply error

This commit is contained in:
DreamMaoMao 2025-07-18 10:59:19 +08:00
parent b697e94fb4
commit 59c9bbbc90
2 changed files with 23 additions and 12 deletions

View file

@ -50,7 +50,7 @@ typedef struct {
int isunglobal;
int isglobal;
int isoverlay;
int monitor;
const char *monitor;
int offsetx;
int offsety;
int width;
@ -1416,7 +1416,7 @@ void parse_config_line(Config *config, const char *line) {
rule->isoverlay = -1;
rule->isterm = -1;
rule->noswallow = -1;
rule->monitor = -1;
rule->monitor = NULL;
rule->offsetx = 0;
rule->offsety = 0;
rule->nofadein = -1;
@ -1460,7 +1460,7 @@ void parse_config_line(Config *config, const char *line) {
} else if (strcmp(key, "tags") == 0) {
rule->tags = 1 << (atoi(val) - 1);
} else if (strcmp(key, "monitor") == 0) {
rule->monitor = atoi(val);
rule->monitor = strdup(val);
} else if (strcmp(key, "offsetx") == 0) {
rule->offsetx = atoi(val);
} else if (strcmp(key, "offsety") == 0) {
@ -1953,10 +1953,21 @@ void free_config(void) {
if (config.window_rules) {
for (int i = 0; i < config.window_rules_count; i++) {
ConfigWinRule *rule = &config.window_rules[i];
free((void *)rule->id);
free((void *)rule->title);
free((void *)rule->animation_type_open);
free((void *)rule->animation_type_close);
if (rule->id)
free((void *)rule->id);
if (rule->title)
free((void *)rule->title);
if (rule->animation_type_open)
free((void *)rule->animation_type_open);
if (rule->animation_type_close)
free((void *)rule->animation_type_close);
if (rule->monitor)
free((void *)rule->monitor);
rule->id = NULL;
rule->title = NULL;
rule->animation_type_open = NULL;
rule->animation_type_close = NULL;
rule->monitor = NULL;
// 释放 globalkeybinding 的 arg.v如果动态分配
if (rule->globalkeybinding.arg.v) {
free((void *)rule->globalkeybinding.arg.v);