diff --git a/maomao.c b/maomao.c index 2dc752d3..7ad74ad7 100644 --- a/maomao.c +++ b/maomao.c @@ -1109,23 +1109,22 @@ applyrulesgeom(Client *c) { const char *appid, *title; ConfigWinRule *r; int hit = 0; - int i; + int ji; if (!(appid = client_get_appid(c))) appid = broken; if (!(title = client_get_title(c))) title = broken; - for (i = 0; i < config.window_rules_count; i++) { - r = &config.window_rules[i]; - if ((!r->title || strstr(title, r->title)) && - (!r->id || strstr(appid, r->id)) && r->width != 0 && r->height != 0) { - c->geom.width = r->width; - c->geom.height = r->height; + for (ji = 0; ji < config.window_rules_count; ji++) { + r = &config.window_rules[ji]; + if ( (r->title && strstr(title, r->title)) || (r->id && strstr(appid, r->id))) { + c->geom.width = r->width > 0 ? r->width : c->geom.width; + c->geom.height = r->height > 0 ? r->height : c->geom.height; // 重新计算居中的坐标 + lognumtofile(r->width); c->geom = setclient_coordinate_center(c->geom); hit = 1; - break; } } return hit; @@ -1148,27 +1147,31 @@ applyrules(Client *c) { for (ji = 0; ji < config.window_rules_count; ji++) { r = &config.window_rules[ji]; - if ((!r->title || strstr(title, r->title)) && - (!r->id || strstr(appid, r->id))) { - c->isfloating = r->isfloating; - c->animation_type = r->animation_type; + + if ( (r->title && strstr(title, r->title)) || (r->id && strstr(appid, r->id))) { + c->isfloating = r->isfloating > 0 ? r->isfloating : c->isfloating; + logtofile("isfloating"); + lognumtofile(c->isfloating); + c->animation_type = r->animation_type == NULL ? c->animation_type : r->animation_type; c->scroller_proportion = r->scroller_proportion > 0 ? r->scroller_proportion : scroller_default_proportion; - c->isnoborder = r->isnoborder; - newtags |= r->tags; + c->isnoborder = r->isnoborder > 0 ? r->isnoborder : c->isnoborder; + newtags = r->tags > 0 ? r->tags|newtags : newtags; i = 0; wl_list_for_each(m, &mons, link) if (r->monitor == i++) mon = m; - if (c->isfloating && r->width != 0 && r->height != 0) { - c->geom.width = r->width; - c->geom.height = r->height; + if (c->isfloating) { + c->geom.width = r->width > 0 ? r->width : c->geom.width; + c->geom.height = r->height > 0 ? r->height : c->geom.height; // 重新计算居中的坐标 + logtofile("width"); + lognumtofile(c->geom.width); + lognumtofile(c->geom.height); c->geom = setclient_coordinate_center(c->geom); } - if (r->isfullscreen) { + if (r->isfullscreen && r->isfullscreen > 0) { c->isfullscreen = 1; c->ignore_clear_fullscreen = 1; } - break; } } diff --git a/parse_config.h b/parse_config.h index 5a740c5a..9fe34d41 100644 --- a/parse_config.h +++ b/parse_config.h @@ -13,8 +13,8 @@ typedef struct { const char *animation_type; int isnoborder; int monitor; - unsigned int width; - unsigned int height; + int width; + int height; } ConfigWinRule; typedef struct { @@ -506,6 +506,19 @@ void parse_config_line(Config *config, const char *line) { ConfigWinRule *rule = &config->window_rules[config->window_rules_count]; memset(rule, 0, sizeof(ConfigWinRule)); + rule->isfloating = -1; + rule->isfullscreen = -1; + rule->isnoborder = -1; + rule->monitor = -1; + rule->width = -1; + rule->height = -1; + rule->animation_type = NULL; + rule->scroller_proportion = -1; + rule->id = NULL; + rule->title = NULL; + rule->tags = 0; + + char *token = strtok(value, ","); while (token != NULL) { char *colon = strchr(token, ':'); @@ -518,6 +531,7 @@ void parse_config_line(Config *config, const char *line) { rule->isfloating = atoi(val); } else if (strcmp(key, "title") == 0) { rule->title = strdup(val); + logtofile(rule->title); } else if (strcmp(key, "appid") == 0) { rule->id = strdup(val); } else if (strcmp(key, "animation_type") == 0) { @@ -528,8 +542,10 @@ void parse_config_line(Config *config, const char *line) { rule->monitor = atoi(val); } else if (strcmp(key, "width") == 0) { rule->width = atoi(val); + lognumtofile(rule->width); } else if (strcmp(key, "height") == 0) { rule->height = atoi(val); + lognumtofile(rule->height); } else if (strcmp(key, "isnoborder") == 0) { rule->isnoborder = atoi(val); } else if (strcmp(key, "scroller_proportion") == 0) {