summaryrefslogtreecommitdiffstats
path: root/bsp/meta-synopsys/recipes-graphics/wayland/weston/1010-xwm-dump_property-to-use-FILE-internally.patch
blob: e9e4600258f11346f403a787aa804ec6812c94f6 (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
From 0a3ef9902a210ab1fa0e4ed317ad7782f0399b51 Mon Sep 17 00:00:00 2001
From: Pekka Paalanen <pq@iki.fi>
Date: Thu, 12 Oct 2017 13:18:12 +0200
Subject: [PATCH 10/46] xwm: dump_property() to use FILE internally

Write the output of dump_property() out in one log call. When multiple
processes (weston and Xwayland) are writing to the same file, this will
keep the property dump uninterrupted by Xwayland debug prints.

This is also preparation for more development in the same direction.

Signed-off-by: Pekka Paalanen <pq@iki.fi>
Signed-off-by: Maniraj Devadoss <Maniraj.Devadoss@in.bosch.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
---
 xwayland/window-manager.c | 58 ++++++++++++++++++++++++-----------------------
 1 file changed, 30 insertions(+), 28 deletions(-)

diff --git a/xwayland/window-manager.c b/xwayland/window-manager.c
index 2b3defb7..3bf323a4 100644
--- a/xwayland/window-manager.c
+++ b/xwayland/window-manager.c
@@ -410,20 +410,14 @@ dump_cardinal_array_elem(FILE *fp, unsigned format,
 }
 
 static void
-dump_cardinal_array(xcb_get_property_reply_t *reply)
+dump_cardinal_array(FILE *fp, xcb_get_property_reply_t *reply)
 {
 	unsigned i = 0;
-	FILE *fp;
 	void *arr;
 	char *str = NULL;
-	size_t size = 0;
 
 	assert(reply->type == XCB_ATOM_CARDINAL);
 
-	fp = open_memstream(&str, &size);
-	if (!fp)
-		return;
-
 	arr = xcb_get_property_value(reply);
 
 	fprintf(fp, "[");
@@ -432,10 +426,6 @@ dump_cardinal_array(xcb_get_property_reply_t *reply)
 					     arr, reply->value_len, i);
 	fprintf(fp, "]");
 
-	if (fclose(fp) != 0)
-		return;
-
-	wm_log_continue("%s\n", str);
 	free(str);
 }
 
@@ -449,22 +439,29 @@ dump_property(struct weston_wm *wm,
 	xcb_window_t *window_value;
 	int width, len;
 	uint32_t i;
+	FILE *fp;
+	char *logstr;
+	size_t logsize;
 
-	width = wm_log_continue("%s: ", get_atom_name(wm->conn, property));
-	if (reply == NULL) {
-		wm_log_continue("(no reply)\n");
+	fp = open_memstream(&logstr, &logsize);
+	if (!fp)
 		return;
+
+	width = fprintf(fp, "%s: ", get_atom_name(wm->conn, property));
+	if (reply == NULL) {
+		fprintf(fp, "(no reply)\n");
+		goto out;
 	}
 
-	width += wm_log_continue("%s/%d, length %d (value_len %d): ",
-				 get_atom_name(wm->conn, reply->type),
-				 reply->format,
-				 xcb_get_property_value_length(reply),
-				 reply->value_len);
+	width += fprintf(fp, "%s/%d, length %d (value_len %d): ",
+			 get_atom_name(wm->conn, reply->type),
+			 reply->format,
+			 xcb_get_property_value_length(reply),
+			 reply->value_len);
 
 	if (reply->type == wm->atom.incr) {
 		incr_value = xcb_get_property_value(reply);
-		wm_log_continue("%d\n", *incr_value);
+		fprintf(fp, "%d\n", *incr_value);
 	} else if (reply->type == wm->atom.utf8_string ||
 	           reply->type == wm->atom.string) {
 		text_value = xcb_get_property_value(reply);
@@ -472,29 +469,34 @@ dump_property(struct weston_wm *wm,
 			len = 40;
 		else
 			len = reply->value_len;
-		wm_log_continue("\"%.*s\"\n", len, text_value);
+		fprintf(fp, "\"%.*s\"\n", len, text_value);
 	} else if (reply->type == XCB_ATOM_ATOM) {
 		atom_value = xcb_get_property_value(reply);
 		for (i = 0; i < reply->value_len; i++) {
 			name = get_atom_name(wm->conn, atom_value[i]);
 			if (width + strlen(name) + 2 > 78) {
-				wm_log_continue("\n    ");
+				fprintf(fp, "\n    ");
 				width = 4;
 			} else if (i > 0) {
-				width +=  wm_log_continue(", ");
+				width +=  fprintf(fp, ", ");
 			}
 
-			width +=  wm_log_continue("%s", name);
+			width +=  fprintf(fp, "%s", name);
 		}
-		wm_log_continue("\n");
+		fprintf(fp, "\n");
 	} else if (reply->type == XCB_ATOM_CARDINAL) {
-		dump_cardinal_array(reply);
+		dump_cardinal_array(fp, reply);
 	} else if (reply->type == XCB_ATOM_WINDOW && reply->format == 32) {
 		window_value = xcb_get_property_value(reply);
-		wm_log_continue("win %u\n", *window_value);
+		fprintf(fp, "win %u\n", *window_value);
 	} else {
-		wm_log_continue("huh?\n");
+		fprintf(fp, "huh?\n");
 	}
+
+out:
+	if (fclose(fp) == 0)
+		wm_log_continue("%s", logstr);
+	free(logstr);
 }
 
 static void
-- 
2.16.2