summaryrefslogtreecommitdiffstats
path: root/dwl-patches/patches/right/right.patch
blob: baf8eeb1c8d362fd33183c87de9728d1dc46c27a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
From 9d4b0ebb95381525351b05aad6a98f1747ae96e2 Mon Sep 17 00:00:00 2001
From: Dima Krasner <dima@dimakrasner.com>
Date: Thu, 21 Jul 2022 21:14:14 +0300
Subject: [PATCH] extend the display to the right

---
 dwl.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/dwl.c b/dwl.c
index d48bf40..fb795e1 100644
--- a/dwl.c
+++ b/dwl.c
@@ -923,7 +923,8 @@ createmon(struct wl_listener *listener, void *data)
 	const MonitorRule *r;
 	size_t i;
 	struct wlr_output_state state;
-	Monitor *m;
+	Monitor *om, *m;
+	int max_x = 0, max_x_y = 0, width, height;
 
 	if (!wlr_output_init_render(wlr_output, alloc, drw))
 		return;
@@ -967,6 +968,14 @@ createmon(struct wl_listener *listener, void *data)
 	wlr_output_commit_state(wlr_output, &state);
 	wlr_output_state_finish(&state);
 
+	wl_list_for_each(om, &mons, link) {
+		wlr_output_effective_resolution(om->wlr_output, &width, &height);
+		if (om->m.x + width > max_x) {
+			max_x = om->m.x + width;
+			max_x_y = om->m.y;
+		}
+	}
+
 	wl_list_insert(&mons, &m->link);
 	printstatus();
 
@@ -990,7 +999,7 @@ createmon(struct wl_listener *listener, void *data)
 	 */
 	m->scene_output = wlr_scene_output_create(scene, wlr_output);
 	if (m->m.x == -1 && m->m.y == -1)
-		wlr_output_layout_add_auto(output_layout, wlr_output);
+		wlr_output_layout_add(output_layout, wlr_output, max_x, max_x_y);
 	else
 		wlr_output_layout_add(output_layout, wlr_output, m->m.x, m->m.y);
 }
-- 
2.43.0