mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-04-06 07:15:53 -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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue