mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-04-09 08:21:27 -04:00
feat: add custom option to monitorrule
This commit is contained in:
parent
11b4bb03bf
commit
9a17a0279c
2 changed files with 11 additions and 4 deletions
|
|
@ -112,6 +112,7 @@ typedef struct {
|
||||||
int32_t width, height; // Monitor resolution
|
int32_t width, height; // Monitor resolution
|
||||||
float refresh; // Refresh rate
|
float refresh; // Refresh rate
|
||||||
int32_t vrr; // variable refresh rate
|
int32_t vrr; // variable refresh rate
|
||||||
|
int32_t custom; // enable custom mode
|
||||||
} ConfigMonitorRule;
|
} ConfigMonitorRule;
|
||||||
|
|
||||||
// 修改后的宏定义
|
// 修改后的宏定义
|
||||||
|
|
@ -1796,6 +1797,7 @@ bool parse_option(Config *config, char *key, char *value) {
|
||||||
rule->height = -1;
|
rule->height = -1;
|
||||||
rule->refresh = 0.0f;
|
rule->refresh = 0.0f;
|
||||||
rule->vrr = 0;
|
rule->vrr = 0;
|
||||||
|
rule->custom = 0;
|
||||||
|
|
||||||
bool parse_error = false;
|
bool parse_error = false;
|
||||||
char *token = strtok(value, ",");
|
char *token = strtok(value, ",");
|
||||||
|
|
@ -1833,6 +1835,8 @@ bool parse_option(Config *config, char *key, char *value) {
|
||||||
rule->refresh = CLAMP_FLOAT(atof(val), 0.001f, 1000.0f);
|
rule->refresh = CLAMP_FLOAT(atof(val), 0.001f, 1000.0f);
|
||||||
} else if (strcmp(key, "vrr") == 0) {
|
} else if (strcmp(key, "vrr") == 0) {
|
||||||
rule->vrr = CLAMP_INT(atoi(val), 0, 1);
|
rule->vrr = CLAMP_INT(atoi(val), 0, 1);
|
||||||
|
} else if (strcmp(key, "custom") == 0) {
|
||||||
|
rule->custom = CLAMP_INT(atoi(val), 0, 1);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"\033[1m\033[31m[ERROR]:\033[33m Unknown "
|
"\033[1m\033[31m[ERROR]:\033[33m Unknown "
|
||||||
|
|
@ -3555,7 +3559,7 @@ void reset_blur_params(void) {
|
||||||
void reapply_monitor_rules(void) {
|
void reapply_monitor_rules(void) {
|
||||||
ConfigMonitorRule *mr;
|
ConfigMonitorRule *mr;
|
||||||
Monitor *m = NULL;
|
Monitor *m = NULL;
|
||||||
int32_t ji, vrr;
|
int32_t ji, vrr, custom;
|
||||||
int32_t mx, my;
|
int32_t mx, my;
|
||||||
struct wlr_output_state state;
|
struct wlr_output_state state;
|
||||||
struct wlr_output_mode *internal_mode = NULL;
|
struct wlr_output_mode *internal_mode = NULL;
|
||||||
|
|
@ -3609,13 +3613,15 @@ void reapply_monitor_rules(void) {
|
||||||
mx = mr->x == INT32_MAX ? m->m.x : mr->x;
|
mx = mr->x == INT32_MAX ? m->m.x : mr->x;
|
||||||
my = mr->y == INT32_MAX ? m->m.y : mr->y;
|
my = mr->y == INT32_MAX ? m->m.y : mr->y;
|
||||||
vrr = mr->vrr >= 0 ? mr->vrr : 0;
|
vrr = mr->vrr >= 0 ? mr->vrr : 0;
|
||||||
|
custom = mr->custom >= 0 ? mr->custom : 0;
|
||||||
|
|
||||||
if (mr->width > 0 && mr->height > 0 && mr->refresh > 0) {
|
if (mr->width > 0 && mr->height > 0 && mr->refresh > 0) {
|
||||||
internal_mode = get_nearest_output_mode(
|
internal_mode = get_nearest_output_mode(
|
||||||
m->wlr_output, mr->width, mr->height, mr->refresh);
|
m->wlr_output, mr->width, mr->height, mr->refresh);
|
||||||
if (internal_mode) {
|
if (internal_mode) {
|
||||||
wlr_output_state_set_mode(&state, internal_mode);
|
wlr_output_state_set_mode(&state, internal_mode);
|
||||||
} else if (wlr_output_is_headless(m->wlr_output)) {
|
} else if (custom ||
|
||||||
|
wlr_output_is_headless(m->wlr_output)) {
|
||||||
wlr_output_state_set_custom_mode(
|
wlr_output_state_set_custom_mode(
|
||||||
&state, mr->width, mr->height,
|
&state, mr->width, mr->height,
|
||||||
(int32_t)roundf(mr->refresh * 1000));
|
(int32_t)roundf(mr->refresh * 1000));
|
||||||
|
|
|
||||||
|
|
@ -2884,7 +2884,7 @@ void createmon(struct wl_listener *listener, void *data) {
|
||||||
struct wlr_output *wlr_output = data;
|
struct wlr_output *wlr_output = data;
|
||||||
const ConfigMonitorRule *r;
|
const ConfigMonitorRule *r;
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
int32_t ji, vrr;
|
int32_t ji, vrr, custom;
|
||||||
struct wlr_output_state state;
|
struct wlr_output_state state;
|
||||||
Monitor *m = NULL;
|
Monitor *m = NULL;
|
||||||
struct wlr_output_mode *internal_mode = NULL;
|
struct wlr_output_mode *internal_mode = NULL;
|
||||||
|
|
@ -2976,6 +2976,7 @@ void createmon(struct wl_listener *listener, void *data) {
|
||||||
m->m.x = r->x == INT32_MAX ? INT32_MAX : r->x;
|
m->m.x = r->x == INT32_MAX ? INT32_MAX : r->x;
|
||||||
m->m.y = r->y == INT32_MAX ? INT32_MAX : r->y;
|
m->m.y = r->y == INT32_MAX ? INT32_MAX : r->y;
|
||||||
vrr = r->vrr >= 0 ? r->vrr : 0;
|
vrr = r->vrr >= 0 ? r->vrr : 0;
|
||||||
|
custom = r->custom >= 0 ? r->custom : 0;
|
||||||
scale = r->scale;
|
scale = r->scale;
|
||||||
rr = r->rr;
|
rr = r->rr;
|
||||||
|
|
||||||
|
|
@ -2985,7 +2986,7 @@ void createmon(struct wl_listener *listener, void *data) {
|
||||||
if (internal_mode) {
|
if (internal_mode) {
|
||||||
custom_monitor_mode = true;
|
custom_monitor_mode = true;
|
||||||
wlr_output_state_set_mode(&state, internal_mode);
|
wlr_output_state_set_mode(&state, internal_mode);
|
||||||
} else if (wlr_output_is_headless(m->wlr_output)) {
|
} else if (custom || wlr_output_is_headless(m->wlr_output)) {
|
||||||
custom_monitor_mode = true;
|
custom_monitor_mode = true;
|
||||||
wlr_output_state_set_custom_mode(
|
wlr_output_state_set_custom_mode(
|
||||||
&state, r->width, r->height,
|
&state, r->width, r->height,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue