summarylogtreecommitdiffstats
path: root/0003-Fix-size-hints-under-Xwayland-scaling.patch
blob: 457a663e4ac30154f5acae03e41f8415c9ec33eb (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
51
52
53
54
From a10d70f2b1314059835cba48875b1048e6203500 Mon Sep 17 00:00:00 2001
From: Patrick Taibel <git@pmt97.com>
Date: Sat, 12 Aug 2023 16:05:28 +0800
Subject: [PATCH 3/3] Fix size hints under Xwayland scaling

---
 xwayland/xwm.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/xwayland/xwm.c b/xwayland/xwm.c
index 1c8cab70..9e16969e 100644
--- a/xwayland/xwm.c
+++ b/xwayland/xwm.c
@@ -723,17 +723,34 @@ static void read_surface_normal_hints(struct wlr_xwm *xwm,
 		xsurface->size_hints->base_width = -1;
 		xsurface->size_hints->base_height = -1;
 	} else if (!has_base_size_hints) {
-		xsurface->size_hints->base_width = xsurface->size_hints->min_width;
-		xsurface->size_hints->base_height = xsurface->size_hints->min_height;
-	} else if (!has_min_size_hints) {
+		xsurface->size_hints->base_width = unscale(xwm, xsurface->size_hints->min_width);
+		xsurface->size_hints->base_height = unscale(xwm, xsurface->size_hints->min_height); 
 		xsurface->size_hints->min_width = xsurface->size_hints->base_width;
 		xsurface->size_hints->min_height = xsurface->size_hints->base_height;
+	} else if (!has_min_size_hints) {
+		xsurface->size_hints->min_width = unscale(xwm, xsurface->size_hints->base_width);
+		xsurface->size_hints->min_height = unscale(xwm, xsurface->size_hints->base_height);
+		xsurface->size_hints->base_width = xsurface->size_hints->min_width;
+		xsurface->size_hints->base_height = xsurface->size_hints->min_height;
+	} else {
+		xsurface->size_hints->min_width = unscale(xwm, xsurface->size_hints->min_width);
+		xsurface->size_hints->min_height = unscale(xwm, xsurface->size_hints->min_height);
+		xsurface->size_hints->base_width = unscale(xwm, xsurface->size_hints->base_width);
+		xsurface->size_hints->base_height = unscale(xwm, xsurface->size_hints->base_height); 
 	}
 
 	if ((flags & XCB_ICCCM_SIZE_HINT_P_MAX_SIZE) == 0) {
 		xsurface->size_hints->max_width = -1;
 		xsurface->size_hints->max_height = -1;
+	} else {
+		xsurface->size_hints->max_width = unscale(xwm, xsurface->size_hints->max_width);
+		xsurface->size_hints->max_height = unscale(xwm, xsurface->size_hints->max_height);
 	}
+
+	xsurface->size_hints->x = unscale(xwm, xsurface->size_hints->x);
+	xsurface->size_hints->y = unscale(xwm, xsurface->size_hints->y);
+	xsurface->size_hints->width = unscale(xwm, xsurface->size_hints->width);
+	xsurface->size_hints->height = unscale(xwm, xsurface->size_hints->height);
 }
 
 #define MWM_HINTS_FLAGS_FIELD 0
-- 
2.42.0