diff --git a/src/config/parse_config.h b/src/config/parse_config.h index 9dc4932..7d161c5 100644 --- a/src/config/parse_config.h +++ b/src/config/parse_config.h @@ -2452,6 +2452,7 @@ void reapply_monitor_rules(void) { Monitor *m; int ji, jk; struct wlr_output_state state; + struct wlr_output_mode *internal_mode = NULL; wlr_output_state_init(&state); wl_list_for_each(m, &mons, link) { @@ -2480,9 +2481,11 @@ void reapply_monitor_rules(void) { } if (mr->width > 0 && mr->height > 0 && mr->refresh > 0) { - wlr_output_state_set_custom_mode( - &state, mr->width, mr->height, - (int)roundf(mr->refresh * 1000)); + internal_mode = get_output_mode(m->wlr_output, mr->width, + mr->height, mr->refresh); + if (internal_mode) { + wlr_output_state_set_mode(&state, internal_mode); + } } wlr_output_state_set_scale(&state, mr->scale); diff --git a/src/mango.c b/src/mango.c index 0839811..2399972 100644 --- a/src/mango.c +++ b/src/mango.c @@ -622,6 +622,10 @@ static struct wlr_box setclient_coordinate_center(Client *c, int offsetx, int offsety); static unsigned int get_tags_first_tag(unsigned int tags); +static struct wlr_output_mode *get_output_mode(struct wlr_output *output, + int width, int height, + float refresh); + static void client_commit(Client *c); static void layer_commit(LayerSurface *l); static void apply_border(Client *c); @@ -2391,6 +2395,19 @@ void createlocksurface(struct wl_listener *listener, void *data) { client_notify_enter(lock_surface->surface, wlr_seat_get_keyboard(seat)); } +struct wlr_output_mode *get_output_mode(struct wlr_output *output, int width, + int height, float refresh) { + struct wlr_output_mode *mode; + wl_list_for_each(mode, &output->modes, link) { + if (mode->width == width && mode->height == height && + (int)(mode->refresh / 1000) == (int)refresh) { + return mode; + } + } + + return NULL; +} + void createmon(struct wl_listener *listener, void *data) { /* This event is raised by the backend when a new output (aka a display or * monitor) becomes available. */ @@ -2400,6 +2417,7 @@ void createmon(struct wl_listener *listener, void *data) { int ji, jk; struct wlr_output_state state; Monitor *m; + struct wlr_output_mode *internal_mode = NULL; bool custom_monitor_mode = false; if (!wlr_output_init_render(wlr_output, alloc, drw)) @@ -2453,8 +2471,11 @@ void createmon(struct wl_listener *listener, void *data) { if (r->width > 0 && r->height > 0 && r->refresh > 0) { custom_monitor_mode = true; - wlr_output_state_set_custom_mode(&state, r->width, r->height, - r->refresh * 1000); + internal_mode = get_output_mode(m->wlr_output, r->width, + r->height, r->refresh); + if (internal_mode) { + wlr_output_state_set_mode(&state, internal_mode); + } } wlr_output_state_set_scale(&state, r->scale); wlr_output_state_set_transform(&state, r->rr);