mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-03-07 04:34:24 -05:00
feat: add custom option to monitorrule
This commit is contained in:
parent
dcea22bfda
commit
b1875f4663
2 changed files with 11 additions and 4 deletions
|
|
@ -111,6 +111,7 @@ typedef struct {
|
|||
int32_t width, height; // Monitor resolution
|
||||
float refresh; // Refresh rate
|
||||
int32_t vrr; // variable refresh rate
|
||||
int32_t custom; // enable custom mode
|
||||
} ConfigMonitorRule;
|
||||
|
||||
// 修改后的宏定义
|
||||
|
|
@ -1730,6 +1731,7 @@ bool parse_option(Config *config, char *key, char *value) {
|
|||
rule->height = -1;
|
||||
rule->refresh = 0.0f;
|
||||
rule->vrr = 0;
|
||||
rule->custom = 0;
|
||||
|
||||
bool parse_error = false;
|
||||
char *token = strtok(value, ",");
|
||||
|
|
@ -1767,6 +1769,8 @@ bool parse_option(Config *config, char *key, char *value) {
|
|||
rule->refresh = CLAMP_FLOAT(atof(val), 0.001f, 1000.0f);
|
||||
} else if (strcmp(key, "vrr") == 0) {
|
||||
rule->vrr = CLAMP_INT(atoi(val), 0, 1);
|
||||
} else if (strcmp(key, "custom") == 0) {
|
||||
rule->custom = CLAMP_INT(atoi(val), 0, 1);
|
||||
} else {
|
||||
fprintf(stderr,
|
||||
"\033[1m\033[31m[ERROR]:\033[33m Unknown "
|
||||
|
|
@ -3411,7 +3415,7 @@ bool parse_config(void) {
|
|||
void reapply_monitor_rules(void) {
|
||||
ConfigMonitorRule *mr;
|
||||
Monitor *m = NULL;
|
||||
int32_t ji, vrr;
|
||||
int32_t ji, vrr, custom;
|
||||
int32_t mx, my;
|
||||
struct wlr_output_state state;
|
||||
struct wlr_output_mode *internal_mode = NULL;
|
||||
|
|
@ -3465,13 +3469,15 @@ void reapply_monitor_rules(void) {
|
|||
mx = mr->x == INT32_MAX ? m->m.x : mr->x;
|
||||
my = mr->y == INT32_MAX ? m->m.y : mr->y;
|
||||
vrr = mr->vrr >= 0 ? mr->vrr : 0;
|
||||
custom = mr->custom >= 0 ? mr->custom : 0;
|
||||
|
||||
if (mr->width > 0 && mr->height > 0 && mr->refresh > 0) {
|
||||
internal_mode = get_nearest_output_mode(
|
||||
m->wlr_output, mr->width, mr->height, mr->refresh);
|
||||
if (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(
|
||||
&state, mr->width, mr->height,
|
||||
(int32_t)roundf(mr->refresh * 1000));
|
||||
|
|
|
|||
|
|
@ -2846,7 +2846,7 @@ void createmon(struct wl_listener *listener, void *data) {
|
|||
struct wlr_output *wlr_output = data;
|
||||
const ConfigMonitorRule *r;
|
||||
uint32_t i;
|
||||
int32_t ji, vrr;
|
||||
int32_t ji, vrr, custom;
|
||||
struct wlr_output_state state;
|
||||
Monitor *m = NULL;
|
||||
struct wlr_output_mode *internal_mode = NULL;
|
||||
|
|
@ -2938,6 +2938,7 @@ void createmon(struct wl_listener *listener, void *data) {
|
|||
m->m.x = r->x == INT32_MAX ? INT32_MAX : r->x;
|
||||
m->m.y = r->y == INT32_MAX ? INT32_MAX : r->y;
|
||||
vrr = r->vrr >= 0 ? r->vrr : 0;
|
||||
custom = r->custom >= 0 ? r->custom : 0;
|
||||
scale = r->scale;
|
||||
rr = r->rr;
|
||||
|
||||
|
|
@ -2947,7 +2948,7 @@ void createmon(struct wl_listener *listener, void *data) {
|
|||
if (internal_mode) {
|
||||
custom_monitor_mode = true;
|
||||
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;
|
||||
wlr_output_state_set_custom_mode(
|
||||
&state, r->width, r->height,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue