forked from djpohly/dwl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add additional monitor configuration patch
- Loading branch information
1 parent
2c515d1
commit bced206
Showing
4 changed files
with
142 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
|