mirror of
https://codeberg.org/dwl/dwl-patches.git
synced 2025-12-14 00:43:19 +00:00
display mode patch for v0.7
This commit is contained in:
parent
e104ef3495
commit
95fc5bc2e3
11
patches/display_mode/README.md
Normal file
11
patches/display_mode/README.md
Normal file
@ -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)
|
||||
|
||||
84
patches/display_mode/display_mode.patch
Normal file
84
patches/display_mode/display_mode.patch
Normal file
@ -0,0 +1,84 @@
|
||||
From b8c5891e7643c6d786cd5c8cdd2fef8dfb9ced7b Mon Sep 17 00:00:00 2001
|
||||
From: "Maarten A." <maarten410@gmail.com>
|
||||
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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user