From 95fc5bc2e3ab275d5627ba0b15d64d7f4f875fb5 Mon Sep 17 00:00:00 2001 From: "Maarten A." Date: Wed, 12 Nov 2025 22:44:54 +0100 Subject: [PATCH] display mode patch for v0.7 --- patches/display_mode/README.md | 11 ++++ patches/display_mode/display_mode.patch | 84 +++++++++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 patches/display_mode/README.md create mode 100644 patches/display_mode/display_mode.patch diff --git a/patches/display_mode/README.md b/patches/display_mode/README.md new file mode 100644 index 0000000..15bb22c --- /dev/null +++ b/patches/display_mode/README.md @@ -0,0 +1,11 @@ +### Description +Add the display mode to the monitor rules. + +The value for the mode can be from a program like [wlr-randr](https://gitlab.freedesktop.org/emersion/wlr-randr), with the first option being 0. + +### Download +- [v0.7](/dwl/dwl-patches/raw/branch/main/patches/display_mode/display_mode.patch) + +### Authors - latest at top +- [Toothpick](https://codeberg.org/Toothpick) + diff --git a/patches/display_mode/display_mode.patch b/patches/display_mode/display_mode.patch new file mode 100644 index 0000000..84332be --- /dev/null +++ b/patches/display_mode/display_mode.patch @@ -0,0 +1,84 @@ +From b8c5891e7643c6d786cd5c8cdd2fef8dfb9ced7b Mon Sep 17 00:00:00 2001 +From: "Maarten A." +Date: Wed, 12 Nov 2025 22:01:19 +0100 +Subject: [PATCH] Add mode_index to display configuration + +--- + config.def.h | 8 +++++--- + dwl.c | 14 +++++++++++++- + 2 files changed, 18 insertions(+), 4 deletions(-) + +diff --git a/config.def.h b/config.def.h +index 22d2171..c942289 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -40,15 +40,17 @@ static const Layout layouts[] = { + /* (x=-1, y=-1) is reserved as an "autoconfigure" monitor position indicator + * WARNING: negative values other than (-1, -1) cause problems with Xwayland clients + * https://gitlab.freedesktop.org/xorg/xserver/-/issues/899 ++ * ++ * mode: 0 based index of the display mode use -1 to use the preferred display mode + */ + /* NOTE: ALWAYS add a fallback rule, even if you are completely sure it won't be used */ + static const MonitorRule monrules[] = { +- /* name mfact nmaster scale layout rotate/reflect x y */ ++ /* name mfact nmaster scale layout rotate/reflect x y mode */ + /* example of a HiDPI laptop monitor: +- { "eDP-1", 0.5f, 1, 2, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 }, ++ { "eDP-1", 0.5f, 1, 2, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1, -1}, + */ + /* defaults */ +- { NULL, 0.55f, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 }, ++ { NULL, 0.55f, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1, -1}, + }; + + /* keyboard */ +diff --git a/dwl.c b/dwl.c +index a2711f6..1f34b94 100644 +--- a/dwl.c ++++ b/dwl.c +@@ -218,6 +218,7 @@ typedef struct { + const Layout *lt; + enum wl_output_transform rr; + int x, y; ++ int mode_index; + } MonitorRule; + + typedef struct { +@@ -978,6 +979,7 @@ createmon(struct wl_listener *listener, void *data) + const MonitorRule *r; + size_t i; + struct wlr_output_state state; ++ struct wlr_output_mode *mode = wlr_output_preferred_mode(wlr_output); + Monitor *m; + + if (!wlr_output_init_render(wlr_output, alloc, drw)) +@@ -1003,6 +1005,16 @@ createmon(struct wl_listener *listener, void *data) + strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, LENGTH(m->ltsymbol)); + wlr_output_state_set_scale(&state, r->scale); + wlr_output_state_set_transform(&state, r->rr); ++ if (r->mode_index >= 0 && !wl_list_empty(&wlr_output->modes)) { ++ int count = 0; ++ struct wlr_output_mode *mode_iter; ++ wl_list_for_each(mode_iter, &wlr_output->modes, link) { ++ if (count == r->mode_index) { ++ mode = mode_iter; ++ break; ++ } count++; ++ } ++ } + break; + } + } +@@ -1011,7 +1023,7 @@ 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)); ++ wlr_output_state_set_mode(&state, mode); + + /* Set up event listeners */ + LISTEN(&wlr_output->events.frame, &m->frame, rendermon); +-- +2.47.3 +