feat: winrule option no_force_center

This commit is contained in:
DreamMaoMao 2025-06-01 21:41:14 +08:00
parent b167fe3c93
commit ea03ba6c49
2 changed files with 17 additions and 3 deletions

View file

@ -37,6 +37,7 @@ typedef struct {
int width;
int height;
int nofadein;
int no_force_center;
int isterm;
int noswallow;
int scratchpad_width;
@ -1101,6 +1102,7 @@ void parse_config_line(Config *config, const char *line) {
rule->offsetx = 0;
rule->offsety = 0;
rule->nofadein = 0;
rule->no_force_center = 0;
rule->scratchpad_width = 0;
rule->scratchpad_height = 0;
rule->width = 0;
@ -1144,7 +1146,9 @@ void parse_config_line(Config *config, const char *line) {
rule->offsety = atoi(val);
} else if (strcmp(key, "nofadein") == 0) {
rule->nofadein = atoi(val);
} else if (strcmp(key, "scratchpad_width") == 0) {
} else if (strcmp(key, "no_force_center") == 0) {
rule->no_force_center = atoi(val);
} else if (strcmp(key, "scratchpad_width") == 0) {
rule->scratchpad_width = atoi(val);
} else if (strcmp(key, "scratchpad_height") == 0) {
rule->scratchpad_height = atoi(val);

View file

@ -277,6 +277,7 @@ struct Client {
bool drag_to_tile;
bool fake_no_border;
int nofadein;
int no_force_center;
};
typedef struct {
@ -1742,8 +1743,14 @@ setclient_coordinate_center(Client *c, struct wlr_box geom, int offsetx,
unsigned int cbw = check_hit_no_border(c) ? c->bw : 0;
tempbox.x = selmon->w.x + (selmon->w.width - geom.width) / 2;
tempbox.y = selmon->w.y + (selmon->w.height - geom.height) / 2;
if(!c->no_force_center) {
tempbox.x = selmon->w.x + (selmon->w.width - geom.width) / 2;
tempbox.y = selmon->w.y + (selmon->w.height - geom.height) / 2;
} else {
tempbox.x = geom.x;
tempbox.y = geom.y;
}
tempbox.width = geom.width;
tempbox.height = geom.height;
@ -1843,6 +1850,8 @@ applyrules(Client *c) {
c->isterm = r->isterm > 0 ? r->isterm : c->isterm;
c->noswallow = r->noswallow > 0 ? r->noswallow : c->noswallow;
c->nofadein = r->nofadein > 0 ? r->nofadein : c->nofadein;
c->no_force_center = r->no_force_center > 0 ? r->no_force_center
: c->no_force_center;
c->scratchpad_geom.width = r->scratchpad_width > 0
? r->scratchpad_width
: c->scratchpad_geom.width;
@ -4491,6 +4500,7 @@ mapnotify(struct wl_listener *listener, void *data) {
c->drag_to_tile = false;
c->fake_no_border = false;
c->nofadein = 0;
c->no_force_center = 0;
if (new_is_master && selmon &&
strcmp(selmon->pertag->ltidxs[selmon->pertag->curtag]->name,