feat: make force_tiled_state as a option

This commit is contained in:
DreamMaoMao 2026-02-12 11:19:39 +08:00
parent 910bb78dab
commit 0fe3197574
2 changed files with 26 additions and 5 deletions

View file

@ -88,6 +88,7 @@ typedef struct {
int32_t isterm; int32_t isterm;
int32_t allow_csd; int32_t allow_csd;
int32_t force_maximize; int32_t force_maximize;
int32_t force_tiled_state;
int32_t force_tearing; int32_t force_tearing;
int32_t noswallow; int32_t noswallow;
float focused_opacity; float focused_opacity;
@ -1933,6 +1934,7 @@ bool parse_option(Config *config, char *key, char *value) {
rule->isterm = -1; rule->isterm = -1;
rule->allow_csd = -1; rule->allow_csd = -1;
rule->force_maximize = -1; rule->force_maximize = -1;
rule->force_tiled_state = -1;
rule->force_tearing = -1; rule->force_tearing = -1;
rule->noswallow = -1; rule->noswallow = -1;
rule->nofocus = -1; rule->nofocus = -1;
@ -2042,6 +2044,8 @@ bool parse_option(Config *config, char *key, char *value) {
rule->allow_csd = atoi(val); rule->allow_csd = atoi(val);
} else if (strcmp(key, "force_maximize") == 0) { } else if (strcmp(key, "force_maximize") == 0) {
rule->force_maximize = atoi(val); rule->force_maximize = atoi(val);
} else if (strcmp(key, "force_tiled_state") == 0) {
rule->force_tiled_state = atoi(val);
} else if (strcmp(key, "force_tearing") == 0) { } else if (strcmp(key, "force_tearing") == 0) {
rule->force_tearing = atoi(val); rule->force_tearing = atoi(val);
} else if (strcmp(key, "noswallow") == 0) { } else if (strcmp(key, "noswallow") == 0) {

View file

@ -3,6 +3,7 @@
*/ */
#include "wlr-layer-shell-unstable-v1-protocol.h" #include "wlr-layer-shell-unstable-v1-protocol.h"
#include "wlr/util/box.h" #include "wlr/util/box.h"
#include "wlr/util/edges.h"
#include <getopt.h> #include <getopt.h>
#include <libinput.h> #include <libinput.h>
#include <limits.h> #include <limits.h>
@ -390,6 +391,7 @@ struct Client {
int32_t isterm, noswallow; int32_t isterm, noswallow;
int32_t allow_csd; int32_t allow_csd;
int32_t force_maximize; int32_t force_maximize;
int32_t force_tiled_state;
pid_t pid; pid_t pid;
Client *swallowing, *swallowedby; Client *swallowing, *swallowedby;
bool is_clip_to_hide; bool is_clip_to_hide;
@ -1293,6 +1295,7 @@ static void apply_rule_properties(Client *c, const ConfigWinRule *r) {
APPLY_INT_PROP(c, r, isterm); APPLY_INT_PROP(c, r, isterm);
APPLY_INT_PROP(c, r, allow_csd); APPLY_INT_PROP(c, r, allow_csd);
APPLY_INT_PROP(c, r, force_maximize); APPLY_INT_PROP(c, r, force_maximize);
APPLY_INT_PROP(c, r, force_tiled_state);
APPLY_INT_PROP(c, r, force_tearing); APPLY_INT_PROP(c, r, force_tearing);
APPLY_INT_PROP(c, r, noswallow); APPLY_INT_PROP(c, r, noswallow);
APPLY_INT_PROP(c, r, nofocus); APPLY_INT_PROP(c, r, nofocus);
@ -2395,9 +2398,6 @@ void commitnotify(struct wl_listener *listener, void *data) {
setmon(c, NULL, 0, setmon(c, NULL, 0,
true); /* Make sure to reapply rules in mapnotify() */ true); /* Make sure to reapply rules in mapnotify() */
client_set_tiled(c, WLR_EDGE_TOP | WLR_EDGE_BOTTOM | WLR_EDGE_LEFT |
WLR_EDGE_RIGHT);
uint32_t serial = wlr_xdg_surface_schedule_configure(c->surface.xdg); uint32_t serial = wlr_xdg_surface_schedule_configure(c->surface.xdg);
if (serial > 0) { if (serial > 0) {
c->configure_serial = serial; c->configure_serial = serial;
@ -3776,6 +3776,7 @@ void init_client_properties(Client *c) {
c->isterm = 0; c->isterm = 0;
c->allow_csd = 0; c->allow_csd = 0;
c->force_maximize = 0; c->force_maximize = 0;
c->force_tiled_state = 1;
c->force_tearing = 0; c->force_tearing = 0;
c->allow_shortcuts_inhibit = SHORTCUTS_INHIBIT_ENABLE; c->allow_shortcuts_inhibit = SHORTCUTS_INHIBIT_ENABLE;
c->scroller_proportion_single = 0.0f; c->scroller_proportion_single = 0.0f;
@ -3895,8 +3896,10 @@ mapnotify(struct wl_listener *listener, void *data) {
applyrules(c); applyrules(c);
client_set_tiled(c, WLR_EDGE_TOP | WLR_EDGE_BOTTOM | WLR_EDGE_LEFT | if (!c->isfloating || c->force_tiled_state) {
WLR_EDGE_RIGHT); client_set_tiled(c, WLR_EDGE_TOP | WLR_EDGE_BOTTOM | WLR_EDGE_LEFT |
WLR_EDGE_RIGHT);
}
// set border color // set border color
setborder_color(c); setborder_color(c);
@ -4737,6 +4740,13 @@ setfloating(Client *c, int32_t floating) {
if (!c->force_maximize) if (!c->force_maximize)
client_set_maximized(c, false); client_set_maximized(c, false);
if (!c->isfloating || c->force_tiled_state) {
client_set_tiled(c, WLR_EDGE_TOP | WLR_EDGE_BOTTOM | WLR_EDGE_LEFT |
WLR_EDGE_RIGHT);
} else {
client_set_tiled(c, WLR_EDGE_NONE);
}
arrange(c->mon, false, false); arrange(c->mon, false, false);
setborder_color(c); setborder_color(c);
printstatus(); printstatus();
@ -5477,6 +5487,9 @@ void overview_backup(Client *c) {
c->ismaximizescreen = 0; c->ismaximizescreen = 0;
} }
c->bw = c->isnoborder ? 0 : borderpx; c->bw = c->isnoborder ? 0 : borderpx;
client_set_tiled(c, WLR_EDGE_TOP | WLR_EDGE_BOTTOM | WLR_EDGE_LEFT |
WLR_EDGE_RIGHT);
} }
// overview切回到普通视图还原窗口的状态 // overview切回到普通视图还原窗口的状态
@ -5516,6 +5529,10 @@ void overview_restore(Client *c, const Arg *arg) {
!c->isfullscreen) { // 如果是在ov模式中创建的窗口,没有bw记录 !c->isfullscreen) { // 如果是在ov模式中创建的窗口,没有bw记录
c->bw = c->isnoborder ? 0 : borderpx; c->bw = c->isnoborder ? 0 : borderpx;
} }
if (c->isfloating && !c->force_tiled_state) {
client_set_tiled(c, WLR_EDGE_NONE);
}
} }
void handlecursoractivity(void) { void handlecursoractivity(void) {