mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-04-07 08:21:36 -04:00
初步修复窗口规则
This commit is contained in:
parent
5defb68396
commit
3d3e838fc5
2 changed files with 40 additions and 21 deletions
41
maomao.c
41
maomao.c
|
|
@ -1109,23 +1109,22 @@ applyrulesgeom(Client *c) {
|
||||||
const char *appid, *title;
|
const char *appid, *title;
|
||||||
ConfigWinRule *r;
|
ConfigWinRule *r;
|
||||||
int hit = 0;
|
int hit = 0;
|
||||||
int i;
|
int ji;
|
||||||
|
|
||||||
if (!(appid = client_get_appid(c)))
|
if (!(appid = client_get_appid(c)))
|
||||||
appid = broken;
|
appid = broken;
|
||||||
if (!(title = client_get_title(c)))
|
if (!(title = client_get_title(c)))
|
||||||
title = broken;
|
title = broken;
|
||||||
|
|
||||||
for (i = 0; i < config.window_rules_count; i++) {
|
for (ji = 0; ji < config.window_rules_count; ji++) {
|
||||||
r = &config.window_rules[i];
|
r = &config.window_rules[ji];
|
||||||
if ((!r->title || strstr(title, r->title)) &&
|
if ( (r->title && strstr(title, r->title)) || (r->id && strstr(appid, r->id))) {
|
||||||
(!r->id || strstr(appid, r->id)) && r->width != 0 && r->height != 0) {
|
c->geom.width = r->width > 0 ? r->width : c->geom.width;
|
||||||
c->geom.width = r->width;
|
c->geom.height = r->height > 0 ? r->height : c->geom.height;
|
||||||
c->geom.height = r->height;
|
|
||||||
// 重新计算居中的坐标
|
// 重新计算居中的坐标
|
||||||
|
lognumtofile(r->width);
|
||||||
c->geom = setclient_coordinate_center(c->geom);
|
c->geom = setclient_coordinate_center(c->geom);
|
||||||
hit = 1;
|
hit = 1;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return hit;
|
return hit;
|
||||||
|
|
@ -1148,27 +1147,31 @@ applyrules(Client *c) {
|
||||||
|
|
||||||
for (ji = 0; ji < config.window_rules_count; ji++) {
|
for (ji = 0; ji < config.window_rules_count; ji++) {
|
||||||
r = &config.window_rules[ji];
|
r = &config.window_rules[ji];
|
||||||
if ((!r->title || strstr(title, r->title)) &&
|
|
||||||
(!r->id || strstr(appid, r->id))) {
|
if ( (r->title && strstr(title, r->title)) || (r->id && strstr(appid, r->id))) {
|
||||||
c->isfloating = r->isfloating;
|
c->isfloating = r->isfloating > 0 ? r->isfloating : c->isfloating;
|
||||||
c->animation_type = r->animation_type;
|
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->scroller_proportion = r->scroller_proportion > 0 ? r->scroller_proportion : scroller_default_proportion;
|
||||||
c->isnoborder = r->isnoborder;
|
c->isnoborder = r->isnoborder > 0 ? r->isnoborder : c->isnoborder;
|
||||||
newtags |= r->tags;
|
newtags = r->tags > 0 ? r->tags|newtags : newtags;
|
||||||
i = 0;
|
i = 0;
|
||||||
wl_list_for_each(m, &mons, link) if (r->monitor == i++) mon = m;
|
wl_list_for_each(m, &mons, link) if (r->monitor == i++) mon = m;
|
||||||
|
|
||||||
if (c->isfloating && r->width != 0 && r->height != 0) {
|
if (c->isfloating) {
|
||||||
c->geom.width = r->width;
|
c->geom.width = r->width > 0 ? r->width : c->geom.width;
|
||||||
c->geom.height = r->height;
|
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);
|
c->geom = setclient_coordinate_center(c->geom);
|
||||||
}
|
}
|
||||||
if (r->isfullscreen) {
|
if (r->isfullscreen && r->isfullscreen > 0) {
|
||||||
c->isfullscreen = 1;
|
c->isfullscreen = 1;
|
||||||
c->ignore_clear_fullscreen = 1;
|
c->ignore_clear_fullscreen = 1;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,8 @@ typedef struct {
|
||||||
const char *animation_type;
|
const char *animation_type;
|
||||||
int isnoborder;
|
int isnoborder;
|
||||||
int monitor;
|
int monitor;
|
||||||
unsigned int width;
|
int width;
|
||||||
unsigned int height;
|
int height;
|
||||||
} ConfigWinRule;
|
} ConfigWinRule;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
@ -506,6 +506,19 @@ void parse_config_line(Config *config, const char *line) {
|
||||||
ConfigWinRule *rule = &config->window_rules[config->window_rules_count];
|
ConfigWinRule *rule = &config->window_rules[config->window_rules_count];
|
||||||
memset(rule, 0, sizeof(ConfigWinRule));
|
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, ",");
|
char *token = strtok(value, ",");
|
||||||
while (token != NULL) {
|
while (token != NULL) {
|
||||||
char *colon = strchr(token, ':');
|
char *colon = strchr(token, ':');
|
||||||
|
|
@ -518,6 +531,7 @@ void parse_config_line(Config *config, const char *line) {
|
||||||
rule->isfloating = atoi(val);
|
rule->isfloating = atoi(val);
|
||||||
} else if (strcmp(key, "title") == 0) {
|
} else if (strcmp(key, "title") == 0) {
|
||||||
rule->title = strdup(val);
|
rule->title = strdup(val);
|
||||||
|
logtofile(rule->title);
|
||||||
} else if (strcmp(key, "appid") == 0) {
|
} else if (strcmp(key, "appid") == 0) {
|
||||||
rule->id = strdup(val);
|
rule->id = strdup(val);
|
||||||
} else if (strcmp(key, "animation_type") == 0) {
|
} else if (strcmp(key, "animation_type") == 0) {
|
||||||
|
|
@ -528,8 +542,10 @@ void parse_config_line(Config *config, const char *line) {
|
||||||
rule->monitor = atoi(val);
|
rule->monitor = atoi(val);
|
||||||
} else if (strcmp(key, "width") == 0) {
|
} else if (strcmp(key, "width") == 0) {
|
||||||
rule->width = atoi(val);
|
rule->width = atoi(val);
|
||||||
|
lognumtofile(rule->width);
|
||||||
} else if (strcmp(key, "height") == 0) {
|
} else if (strcmp(key, "height") == 0) {
|
||||||
rule->height = atoi(val);
|
rule->height = atoi(val);
|
||||||
|
lognumtofile(rule->height);
|
||||||
} else if (strcmp(key, "isnoborder") == 0) {
|
} else if (strcmp(key, "isnoborder") == 0) {
|
||||||
rule->isnoborder = atoi(val);
|
rule->isnoborder = atoi(val);
|
||||||
} else if (strcmp(key, "scroller_proportion") == 0) {
|
} else if (strcmp(key, "scroller_proportion") == 0) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue