Skip to content

Commit

Permalink
Add additional monitor configuration patch
Browse files Browse the repository at this point in the history
  • Loading branch information
Carl-github-acc committed Sep 3, 2023
1 parent 2c515d1 commit bced206
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 26 deletions.
12 changes: 7 additions & 5 deletions config.def.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,16 @@ static const Layout layouts[] = {
{ "[M]", monocle },
};

/* monitors */
/* monitors
* The order in which monitors are defined determines their position.
* Non-configured monitors are always added to the left. */
static const MonitorRule monrules[] = {
/* name mfact nmaster scale layout rotate/reflect x y */
/* example of a HiDPI laptop monitor:
{ "eDP-1", 0.5, 1, 2, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 },
/* name mfact nmaster scale layout rotate/reflect x y resx resy rate adaptive*/
/* example of a HiDPI laptop monitor at 120Hz:
{ "eDP-1", 0.5, 1, 2, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, 0, 0, 0, 0, 120.000, 1},
*/
/* defaults */
{ NULL, 0.55, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 },
{ NULL, 0.55, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, 0, 0, 0, 0, 0, 1},
};

/* keyboard */
Expand Down
20 changes: 12 additions & 8 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ static const char *const autostart[] = {
"fcitx5", NULL,
"nm-applet", NULL,
"dunst", NULL,
"/usr/libexec/polkit-gnome-authentication-agent-1", NULL,
"imwheel", NULL,
"/usr/libexec/polkit-gnome-authentication-agent-1", NULL,
"dropbox", "start", "-i", NULL,
"wljoywake", NULL,
NULL /* terminate */
Expand All @@ -51,16 +52,19 @@ static const Layout layouts[] = {
{ "[M]", monocle },
};

/* monitors */

/* monitors
* The order in which monitors are defined determines their position.
* Non-configured monitors are always added to the left. */
static const MonitorRule monrules[] = {
/* name mfact nmaster scale layout rotate/reflect x y */
/* example of a HiDPI laptop monitor:
{ "eDP-1", 0.5, 1, 2, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 },
/* name mfact nmaster scale layout rotate/reflect x y resx resy rate adaptive*/
/* example of a HiDPI laptop monitor at 120Hz:
{ "eDP-1", 0.5, 1, 2, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, 0, 0, 0, 0, 120.000, 1},
*/
{ "DP-3", 0.5, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, 0, 0 },
{ "DP-4", 0.5, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, 2560, 0 },
{ "DP-3", 0.5, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, 0, 0, 2560, 1440, 165.080002, 1 },
{ "DP-4", 0.5, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, 2560, 0, 2560, 1440, 59.951000, 0 },
/* defaults */
{ NULL, 0.55, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 },
{ NULL, 0.55, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, 0, 0, 0, 0, 0, 1},
};

/* keyboard */
Expand Down
25 changes: 12 additions & 13 deletions dwl.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ typedef struct {
const Layout *lt;
enum wl_output_transform rr;
int x, y;
int resx;
int resy;
float rate;
int adaptive;
} MonitorRule;

typedef struct {
Expand Down Expand Up @@ -993,7 +997,6 @@ createmon(struct wl_listener *listener, void *data)
m->wlr_output = wlr_output;

wl_list_init(&m->dwl_ipc_outputs);
wlr_output_init_render(wlr_output, alloc, drw);

/* Initialize monitor state using configured rules */
for (i = 0; i < LENGTH(m->layers); i++)
Expand All @@ -1012,17 +1015,16 @@ createmon(struct wl_listener *listener, void *data)
wlr_xcursor_manager_load(cursor_mgr, r->scale);
m->lt[0] = m->lt[1] = r->lt;
wlr_output_set_transform(wlr_output, r->rr);
m->m.x = r->x;
m->m.y = r->y;

wlr_output_set_custom_mode(wlr_output, r->resx, r->resy,
r->rate > 0 ? (int)((r->rate * 1000) + 0.5) : 0);

wlr_output_enable_adaptive_sync(wlr_output, r->adaptive);
break;
}
}

/* The mode is a tuple of (width, height, refresh rate), and each
* 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_set_mode(wlr_output, wlr_output_preferred_mode(wlr_output));
wlr_output_init_render(wlr_output, alloc, drw);

/* Set up event listeners */
LISTEN(&wlr_output->events.frame, &m->frame, rendermon);
Expand All @@ -1032,9 +1034,6 @@ createmon(struct wl_listener *listener, void *data)
if (!wlr_output_commit(wlr_output))
return;

/* Try to enable adaptive sync, note that not all monitors support it.
* wlr_output_commit() will deactivate it in case it cannot be enabled */
wlr_output_enable_adaptive_sync(wlr_output, 1);
wlr_output_commit(wlr_output);

wl_list_insert(&mons, &m->link);
Expand All @@ -1059,10 +1058,10 @@ createmon(struct wl_listener *listener, void *data)
* output (such as DPI, scale factor, manufacturer, etc).
*/
m->scene_output = wlr_scene_output_create(scene, wlr_output);
if (m->m.x < 0 || m->m.y < 0)
if (r->x < 0 || r->y < 0)
wlr_output_layout_add_auto(output_layout, wlr_output);
else
wlr_output_layout_add(output_layout, wlr_output, m->m.x, m->m.y);
wlr_output_layout_add(output_layout, wlr_output, r->x, r->y);
strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, LENGTH(m->ltsymbol));
}

Expand Down
111 changes: 111 additions & 0 deletions patches/main...PalanixYT:monfig.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
From cc4a2d5fac4e0a1f4d8a43e4ace7ff819ab3e731 Mon Sep 17 00:00:00 2001
From: Palanix <[email protected]>
Date: Mon, 4 Apr 2022 16:08:29 +0200
Subject: [PATCH] Updated patch now allowing setting x and y
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Leonardo Hernández Hernández <[email protected]
---
config.def.h | 12 +++++++-----
dwl.c | 26 ++++++++++++--------------
2 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/config.def.h b/config.def.h
index 447ba0051..9fe6ac072 100644
--- a/config.def.h
+++ b/config.def.h
@@ -26,14 +26,16 @@ static const Layout layouts[] = {
{ "[M]", monocle },
};

-/* monitors */
+/* monitors
+ * The order in which monitors are defined determines their position.
+ * Non-configured monitors are always added to the left. */
static const MonitorRule monrules[] = {
- /* name mfact nmaster scale layout rotate/reflect x y */
- /* example of a HiDPI laptop monitor:
- { "eDP-1", 0.5, 1, 2, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 },
+ /* name mfact nmaster scale layout rotate/reflect x y resx resy rate adaptive*/
+ /* example of a HiDPI laptop monitor at 120Hz:
+ { "eDP-1", 0.5, 1, 2, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, 0, 0, 0, 0, 120.000, 1},
*/
/* defaults */
- { NULL, 0.55, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 },
+ { NULL, 0.55, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, 0, 0, 0, 0, 0, 1},
};

/* keyboard */
diff --git a/dwl.c b/dwl.c
index 93f66efe6..237a5896e 100644
--- a/dwl.c
+++ b/dwl.c
@@ -201,6 +201,10 @@ typedef struct {
const Layout *lt;
enum wl_output_transform rr;
int x, y;
+ int resx;
+ int resy;
+ float rate;
+ int adaptive;
} MonitorRule;

typedef struct {
@@ -908,8 +912,6 @@ createmon(struct wl_listener *listener, void *data)
Monitor *m = wlr_output->data = ecalloc(1, sizeof(*m));
m->wlr_output = wlr_output;

- wlr_output_init_render(wlr_output, alloc, drw);
-
/* Initialize monitor state using configured rules */
for (i = 0; i < LENGTH(m->layers); i++)
wl_list_init(&m->layers[i]);
@@ -922,17 +924,16 @@ createmon(struct wl_listener *listener, void *data)
wlr_xcursor_manager_load(cursor_mgr, r->scale);
m->lt[0] = m->lt[1] = r->lt;
wlr_output_set_transform(wlr_output, r->rr);
- m->m.x = r->x;
- m->m.y = r->y;
+
+ wlr_output_set_custom_mode(wlr_output, r->resx, r->resy,
+ r->rate > 0 ? (int)((r->rate * 1000) + 0.5) : 0);
+
+ wlr_output_enable_adaptive_sync(wlr_output, r->adaptive);
break;
}
}

- /* The mode is a tuple of (width, height, refresh rate), and each
- * 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_set_mode(wlr_output, wlr_output_preferred_mode(wlr_output));
+ wlr_output_init_render(wlr_output, alloc, drw);

/* Set up event listeners */
LISTEN(&wlr_output->events.frame, &m->frame, rendermon);
@@ -942,9 +943,6 @@ createmon(struct wl_listener *listener, void *data)
if (!wlr_output_commit(wlr_output))
return;

- /* Try to enable adaptive sync, note that not all monitors support it.
- * wlr_output_commit() will deactivate it in case it cannot be enabled */
- wlr_output_enable_adaptive_sync(wlr_output, 1);
wlr_output_commit(wlr_output);

wl_list_insert(&mons, &m->link);
@@ -969,10 +967,10 @@ createmon(struct wl_listener *listener, void *data)
* output (such as DPI, scale factor, manufacturer, etc).
*/
m->scene_output = wlr_scene_output_create(scene, wlr_output);
- if (m->m.x < 0 || m->m.y < 0)
+ if (r->x < 0 || r->y < 0)
wlr_output_layout_add_auto(output_layout, wlr_output);
else
- wlr_output_layout_add(output_layout, wlr_output, m->m.x, m->m.y);
+ wlr_output_layout_add(output_layout, wlr_output, r->x, r->y);
strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, LENGTH(m->ltsymbol));
}

0 comments on commit bced206

Please sign in to comment.