mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2025-11-04 13:29:56 -05:00
feat:windowrule allowed to further match the title on the premise of matching the id
This commit is contained in:
parent
2c2c99aa50
commit
5f048c4c4e
2 changed files with 17 additions and 28 deletions
|
|
@ -121,8 +121,7 @@ tags=id:9,layout_name:tile
|
||||||
|
|
||||||
# example
|
# example
|
||||||
# windowrule=isfloating:1,appid:yesplaymusic
|
# windowrule=isfloating:1,appid:yesplaymusic
|
||||||
# windowrule=width:1500,appid:yesplaymusic
|
# windowrule=width:1000,height:900,appid:yesplaymusic,title:Demons
|
||||||
# windowrule=height:900,appid:yesplaymusic
|
|
||||||
# windowrule=isfloating:1,title:qxdrag
|
# windowrule=isfloating:1,title:qxdrag
|
||||||
# windowrule=isfloating:1,appid:Rofi
|
# windowrule=isfloating:1,appid:Rofi
|
||||||
# windowrule=isfloating:1,appid:wofi
|
# windowrule=isfloating:1,appid:wofi
|
||||||
|
|
|
||||||
30
src/maomao.c
30
src/maomao.c
|
|
@ -1572,8 +1572,9 @@ applyrulesgeom(Client *c) {
|
||||||
if (config.window_rules_count < 1)
|
if (config.window_rules_count < 1)
|
||||||
break;
|
break;
|
||||||
r = &config.window_rules[ji];
|
r = &config.window_rules[ji];
|
||||||
if ((r->title && strstr(title, r->title)) ||
|
if ((r->title && strstr(title, r->title) && !r->id) ||
|
||||||
(r->id && strstr(appid, r->id))) {
|
(r->id && strstr(appid, r->id) && !r->title) ||
|
||||||
|
(r->id && strstr(appid, r->id) && r->title && strstr(title, r->title))) {
|
||||||
c->geom.width = r->width > 0 ? r->width : c->geom.width;
|
c->geom.width = r->width > 0 ? r->width : c->geom.width;
|
||||||
c->geom.height = r->height > 0 ? r->height : c->geom.height;
|
c->geom.height = r->height > 0 ? r->height : c->geom.height;
|
||||||
// 重新计算居中的坐标
|
// 重新计算居中的坐标
|
||||||
|
|
@ -1608,8 +1609,9 @@ applyrules(Client *c) {
|
||||||
break;
|
break;
|
||||||
r = &config.window_rules[ji];
|
r = &config.window_rules[ji];
|
||||||
|
|
||||||
if ((r->title && strstr(title, r->title)) ||
|
if ((r->title && strstr(title, r->title) && !r->id) ||
|
||||||
(r->id && strstr(appid, r->id))) {
|
(r->id && strstr(appid, r->id) && !r->title) ||
|
||||||
|
(r->id && strstr(appid, r->id) && r->title && strstr(title, r->title))) {
|
||||||
c->isterm = r->isterm > 0 ? r->isterm : c->isterm;
|
c->isterm = r->isterm > 0 ? r->isterm : c->isterm;
|
||||||
c->noswallow = r->noswallow > 0 ? r->noswallow : c->noswallow;
|
c->noswallow = r->noswallow > 0 ? r->noswallow : c->noswallow;
|
||||||
c->isfloating = r->isfloating > 0 ? r->isfloating : c->isfloating;
|
c->isfloating = r->isfloating > 0 ? r->isfloating : c->isfloating;
|
||||||
|
|
@ -3707,7 +3709,7 @@ bool keypressglobal(struct wlr_surface *last_surface,
|
||||||
int reset = false;
|
int reset = false;
|
||||||
const char *appid = NULL;
|
const char *appid = NULL;
|
||||||
const char *title = NULL;
|
const char *title = NULL;
|
||||||
int appid_len, title_len, ji;
|
int ji;
|
||||||
const ConfigWinRule *r;
|
const ConfigWinRule *r;
|
||||||
|
|
||||||
for (ji = 0; ji < config.window_rules_count; ji++) {
|
for (ji = 0; ji < config.window_rules_count; ji++) {
|
||||||
|
|
@ -3725,21 +3727,10 @@ bool keypressglobal(struct wlr_surface *last_surface,
|
||||||
if (c && c != lastc) {
|
if (c && c != lastc) {
|
||||||
appid = client_get_appid(c);
|
appid = client_get_appid(c);
|
||||||
title = client_get_title(c);
|
title = client_get_title(c);
|
||||||
if (appid && r->id) {
|
|
||||||
appid_len = strlen(appid);
|
|
||||||
if (strncmp(appid, r->id, appid_len) == 0) {
|
|
||||||
reset = true;
|
|
||||||
wlr_seat_keyboard_enter(seat, client_surface(c), keycodes, 0,
|
|
||||||
&keyboard->modifiers);
|
|
||||||
wlr_seat_keyboard_send_key(seat, event->time_msec, event->keycode,
|
|
||||||
event->state);
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (title && r->title) {
|
if ((r->title && strstr(title, r->title) && !r->id) ||
|
||||||
title_len = strlen(title);
|
(r->id && strstr(appid, r->id) && !r->title) ||
|
||||||
if (strncmp(title, r->title, title_len) == 0) {
|
(r->id && strstr(appid, r->id) && r->title && strstr(title, r->title))) {
|
||||||
reset = true;
|
reset = true;
|
||||||
wlr_seat_keyboard_enter(seat, client_surface(c), keycodes, 0,
|
wlr_seat_keyboard_enter(seat, client_surface(c), keycodes, 0,
|
||||||
&keyboard->modifiers);
|
&keyboard->modifiers);
|
||||||
|
|
@ -3751,7 +3742,6 @@ bool keypressglobal(struct wlr_surface *last_surface,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (reset)
|
if (reset)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue