diff --git a/config.def.h b/config.def.h index 8a6eda0..7c7b565 100644 --- a/config.def.h +++ b/config.def.h @@ -40,10 +40,10 @@ static const Layout layouts[] = { * WARNING: negative values other than (-1, -1) cause problems with Xwayland clients due to * https://gitlab.freedesktop.org/xorg/xserver/-/issues/899 */ static const MonitorRule monrules[] = { - /* name mfact nmaster scale layout rotate/reflect x y + /* name mfact nmaster scale layout rotate/reflect x y width height refresh rate * example of a HiDPI laptop monitor: - { "eDP-1", 0.5f, 1, 2, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 }, */ - { NULL, 0.55f, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 }, + { "eDP-1", 0.5f, 1, 2, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1, 0, 0, 0 0 }, */ + { NULL, 0.55f, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1, 0, 0, 0 }, /* default monitor rule: can be changed but cannot be eliminated; at least one monitor rule must exist */ }; diff --git a/dwl.c b/dwl.c index 44f3ad9..8947d25 100644 --- a/dwl.c +++ b/dwl.c @@ -215,6 +215,7 @@ typedef struct { const Layout *lt; enum wl_output_transform rr; int x, y; + int width, height, refresh_rate; } MonitorRule; typedef struct { @@ -1045,6 +1046,7 @@ createmon(struct wl_listener *listener, void *data) size_t i; struct wlr_output_state state; Monitor *m; + struct wlr_output_mode *mode = NULL; if (!wlr_output_init_render(wlr_output, alloc, drw)) return; @@ -1077,7 +1079,19 @@ createmon(struct wl_listener *listener, void *data) * monitor supports only a specific set of modes. We just pick the * monitor's preferred mode; a more sophisticated compositor would let * the user configure it. */ - wlr_output_state_set_mode(&state, wlr_output_preferred_mode(wlr_output)); + if (r->refresh_rate || r->width || r->height) { + wl_list_for_each(mode, &wlr_output->modes, link) { + if ((r->refresh_rate == 0 || mode->refresh == r->refresh_rate) && (r->width == 0 || mode->width == r->width) && (r->height == 0 || mode->height == r->height)) { + break; + } + } + } + if (mode == NULL) { + printf("Was not able find output mode with (width, height, refresh rate): (%d, %d, %d)\n", r->width, r->height, r->refresh_rate); + mode = wlr_output_preferred_mode(wlr_output); + } + + wlr_output_state_set_mode(&state, mode); /* Set up event listeners */ LISTEN(&wlr_output->events.frame, &m->frame, rendermon);