feat: add disable option to monitor rule

This commit is contained in:
DreamMaoMao 2026-06-27 16:45:57 +08:00
parent a00c951ae7
commit 51b50450a4
3 changed files with 19 additions and 2 deletions

View file

@ -33,6 +33,7 @@ monitorrule=name:Values,Parameter:Values,Parameter:Values
| `hdr` | integer | 0, 1 | Enable hdr support |
| `rr` | integer | 0-7 | Monitor transform |
| `custom` | integer | 0, 1 | Enable custom mode (not supported on all displays — may cause black screen) |
| `disable` | integer | 0, 1 | Disable the monitor |
### Transform Values

View file

@ -118,6 +118,7 @@ typedef struct {
int32_t vrr; // variable refresh rate
int32_t custom; // enable custom mode
int32_t hdr; // enable hdr mode
int32_t disable; // prefer disable
} ConfigMonitorRule;
// 修改后的宏定义
@ -2059,6 +2060,7 @@ bool parse_option(Config *config, char *key, char *value) {
rule->vrr = 0;
rule->hdr = 0;
rule->custom = 0;
rule->disable = 0;
bool parse_error = false;
char *token = strtok(value, ",");
@ -2098,6 +2100,8 @@ bool parse_option(Config *config, char *key, char *value) {
rule->vrr = CLAMP_INT(atoi(val), 0, 1);
} else if (strcmp(key, "hdr") == 0) {
rule->hdr = CLAMP_INT(atoi(val), 0, 1);
} else if (strcmp(key, "disable") == 0) {
rule->disable = CLAMP_INT(atoi(val), 0, 1);
} else if (strcmp(key, "custom") == 0) {
rule->custom = CLAMP_INT(atoi(val), 0, 1);
} else {
@ -3902,6 +3906,7 @@ void reapply_monitor_rules(void) {
vrr = mr->vrr >= 0 ? mr->vrr : 0;
custom = mr->custom >= 0 ? mr->custom : 0;
m->hdr_enable = mr->hdr >= 0 ? mr->hdr : 0;
m->prefer_disable = mr->disable >= 0 ? mr->disable : 0;
(void)apply_rule_to_state(m, mr, &m->pending, vrr, custom);
wlr_output_layout_add(output_layout, m->wlr_output, mx, my);
@ -3909,7 +3914,11 @@ void reapply_monitor_rules(void) {
}
}
wlr_output_state_set_enabled(&m->pending, true);
if (m->prefer_disable) {
wlr_output_state_set_enabled(&m->pending, false);
} else {
wlr_output_state_set_enabled(&m->pending, true);
}
if (m->hdr_enable) {
output_state_setup_hdr(m, false, &m->pending);

View file

@ -589,6 +589,7 @@ struct Monitor {
bool vrr_global_enable;
bool is_vrr_opening;
bool hdr_enable;
bool prefer_disable;
};
typedef struct {
@ -3388,6 +3389,7 @@ void createmon(struct wl_listener *listener, void *data) {
m->is_vrr_opening = false;
m->hdr_enable = false;
m->prefer_disable = false;
m->wlr_output = wlr_output;
m->wlr_output->data = m;
@ -3427,6 +3429,7 @@ void createmon(struct wl_listener *listener, void *data) {
scale = r->scale;
rr = r->rr;
m->hdr_enable = r->hdr;
m->prefer_disable = r->disable >= 0 ? r->disable : 0;
if (apply_rule_to_state(m, r, &m->pending, vrr, custom)) {
custom_monitor_mode = true;
@ -3445,7 +3448,11 @@ void createmon(struct wl_listener *listener, void *data) {
LISTEN(&wlr_output->events.request_state, &m->request_state,
requestmonstate);
wlr_output_state_set_enabled(&m->pending, 1);
if (m->prefer_disable) {
wlr_output_state_set_enabled(&m->pending, false);
} else {
wlr_output_state_set_enabled(&m->pending, true);
}
if (m->hdr_enable) {
output_state_setup_hdr(m, false, &m->pending);