This repository has been archived by the owner on Apr 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 147
/
xwayland_for_android.patch
222 lines (209 loc) · 6.9 KB
/
xwayland_for_android.patch
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
diff -Naur ../xserver-1.20.5-orig/hw/xwayland/ashmem.h ./hw/xwayland/ashmem.h
--- ../xserver-1.20.5-orig/hw/xwayland/ashmem.h 1970-01-01 02:00:00.000000000 +0200
+++ ./hw/xwayland/ashmem.h 2019-07-12 15:00:25.712211695 +0300
@@ -0,0 +1,47 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** This header was automatically generated from a Linux kernel header
+ *** of the same name, to make information necessary for userspace to
+ *** call into the kernel available to libc. It contains only constants,
+ *** structures, and macros generated from the original header, and thus,
+ *** contains no copyrightable information.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _LINUX_ASHMEM_H
+#define _LINUX_ASHMEM_H
+
+#include <linux/limits.h>
+#include <linux/ioctl.h>
+#include <stdint.h>
+
+#define ASHMEM_NAME_LEN 256
+
+#define ASHMEM_NAME_DEF "dev/ashmem"
+
+#define ASHMEM_NOT_PURGED 0
+#define ASHMEM_WAS_PURGED 1
+
+#define ASHMEM_IS_UNPINNED 0
+#define ASHMEM_IS_PINNED 1
+
+struct ashmem_pin {
+ uint32_t offset;
+ uint32_t len;
+};
+
+#define __ASHMEMIOC 0x77
+
+#define ASHMEM_SET_NAME _IOW(__ASHMEMIOC, 1, char[ASHMEM_NAME_LEN])
+#define ASHMEM_GET_NAME _IOR(__ASHMEMIOC, 2, char[ASHMEM_NAME_LEN])
+#define ASHMEM_SET_SIZE _IOW(__ASHMEMIOC, 3, size_t)
+#define ASHMEM_GET_SIZE _IO(__ASHMEMIOC, 4)
+#define ASHMEM_SET_PROT_MASK _IOW(__ASHMEMIOC, 5, unsigned long)
+#define ASHMEM_GET_PROT_MASK _IO(__ASHMEMIOC, 6)
+#define ASHMEM_PIN _IOW(__ASHMEMIOC, 7, struct ashmem_pin)
+#define ASHMEM_UNPIN _IOW(__ASHMEMIOC, 8, struct ashmem_pin)
+#define ASHMEM_GET_PIN_STATUS _IO(__ASHMEMIOC, 9)
+#define ASHMEM_PURGE_ALL_CACHES _IO(__ASHMEMIOC, 10)
+
+#endif
diff -Naur ../xserver-1.20.5-orig/hw/xwayland/xwayland-cursor.c ./hw/xwayland/xwayland-cursor.c
--- ../xserver-1.20.5-orig/hw/xwayland/xwayland-cursor.c 2019-07-12 15:14:26.885076932 +0300
+++ ./hw/xwayland/xwayland-cursor.c 2019-07-12 14:57:25.217524468 +0300
@@ -66,7 +66,8 @@
PixmapPtr pixmap;
pixmap = xwl_shm_create_pixmap(screen, cursor->bits->width,
- cursor->bits->height, 32, 0);
+ cursor->bits->height, 32,
+ CREATE_PIXMAP_USAGE_BACKING_PIXMAP);
dixSetPrivate(&cursor->devPrivates, &xwl_cursor_private_key, pixmap);
return TRUE;
diff -Naur ../xserver-1.20.5-orig/hw/xwayland/xwayland-glamor-gbm.c ./hw/xwayland/xwayland-glamor-gbm.c
--- ../xserver-1.20.5-orig/hw/xwayland/xwayland-glamor-gbm.c 2019-07-12 15:14:26.885076932 +0300
+++ ./hw/xwayland/xwayland-glamor-gbm.c 2019-07-12 14:57:38.836704786 +0300
@@ -212,9 +212,9 @@
PixmapPtr pixmap = NULL;
if (width > 0 && height > 0 && depth >= 15 &&
- (hint == 0 ||
- hint == CREATE_PIXMAP_USAGE_BACKING_PIXMAP ||
- hint == CREATE_PIXMAP_USAGE_SHARED)) {
+ (hint == CREATE_PIXMAP_USAGE_BACKING_PIXMAP ||
+ hint == CREATE_PIXMAP_USAGE_SHARED ||
+ (xwl_screen->rootless && hint == 0))) {
uint32_t format = gbm_format_for_depth(depth);
#ifdef GBM_BO_WITH_MODIFIERS
diff -Naur ../xserver-1.20.5-orig/hw/xwayland/xwayland-output.c ./hw/xwayland/xwayland-output.c
--- ../xserver-1.20.5-orig/hw/xwayland/xwayland-output.c 2019-07-12 15:14:26.889075146 +0300
+++ ./hw/xwayland/xwayland-output.c 2019-07-12 14:54:13.242596617 +0300
@@ -171,6 +171,40 @@
return 25.4 / DEFAULT_DPI;
}
+static int
+xwl_set_pixmap_visit_window(WindowPtr window, void *data)
+{
+ ScreenPtr screen = window->drawable.pScreen;
+
+ if (screen->GetWindowPixmap(window) == data) {
+ screen->SetWindowPixmap(window, screen->GetScreenPixmap(screen));
+ return WT_WALKCHILDREN;
+ }
+
+ return WT_DONTWALKCHILDREN;
+}
+
+static void
+update_backing_pixmaps(struct xwl_screen *xwl_screen, int width, int height)
+{
+ ScreenPtr pScreen = xwl_screen->screen;
+ WindowPtr pRoot = pScreen->root;
+ PixmapPtr old_pixmap, new_pixmap;
+
+ old_pixmap = pScreen->GetScreenPixmap(pScreen);
+ new_pixmap = pScreen->CreatePixmap(pScreen, width, height,
+ pScreen->rootDepth,
+ CREATE_PIXMAP_USAGE_BACKING_PIXMAP);
+ pScreen->SetScreenPixmap(new_pixmap);
+
+ if (old_pixmap) {
+ TraverseTree(pRoot, xwl_set_pixmap_visit_window, old_pixmap);
+ pScreen->DestroyPixmap(old_pixmap);
+ }
+
+ pScreen->ResizeWindow(pRoot, 0, 0, width, height, NULL);
+}
+
static void
update_screen_size(struct xwl_output *xwl_output, int width, int height)
{
@@ -180,6 +214,9 @@
if (xwl_screen->root_clip_mode == ROOT_CLIP_FULL)
SetRootClip(xwl_screen->screen, ROOT_CLIP_NONE);
+ if (!xwl_screen->rootless && xwl_screen->screen->root)
+ update_backing_pixmaps (xwl_screen, width, height);
+
xwl_screen->width = width;
xwl_screen->height = height;
xwl_screen->screen->width = width;
diff -Naur ../xserver-1.20.5-orig/hw/xwayland/xwayland-shm.c ./hw/xwayland/xwayland-shm.c
--- ../xserver-1.20.5-orig/hw/xwayland/xwayland-shm.c 2019-07-12 15:14:26.889075146 +0300
+++ ./hw/xwayland/xwayland-shm.c 2019-07-12 15:28:09.124589333 +0300
@@ -40,12 +40,17 @@
#include <string.h>
#include <stdlib.h>
+#ifdef __ANDROID__
+#include "ashmem.h"
+#endif
+
struct xwl_pixmap {
struct wl_buffer *buffer;
void *data;
size_t size;
};
+#ifndef __ANDROID__
#ifndef HAVE_MKOSTEMP
static int
set_cloexec_or_close(int fd)
@@ -172,6 +177,37 @@
return fd;
}
+#else // __ANDROID__
+
+static int
+os_create_anonymous_file(off_t size) {
+ int fd, ret;
+ long flags;
+
+ fd = open("/dev/ashmem", O_RDWR);
+ if (fd < 0)
+ return fd;
+
+ ret = ioctl(fd, ASHMEM_SET_SIZE, size);
+ if (ret < 0)
+ goto err;
+
+ flags = fcntl(fd, F_GETFD);
+ if (flags == -1)
+ goto err;
+
+ if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == -1)
+ goto err;
+
+ return fd;
+
+err:
+ close(fd);
+ return ret;
+}
+
+#endif // __ANDROID__
+
static uint32_t
shm_format_for_depth(int depth)
{
@@ -202,6 +238,7 @@
int fd;
if (hint == CREATE_PIXMAP_USAGE_GLYPH_PICTURE ||
+ (!xwl_screen->rootless && hint != CREATE_PIXMAP_USAGE_BACKING_PIXMAP) ||
(width == 0 && height == 0) || depth < 15)
return fbCreatePixmap(screen, width, height, depth, hint);
--- ./miext/sync/meson.build.orig 2019-07-21 03:56:18.960672711 +0300
+++ ./miext/sync/meson.build 2019-07-21 04:02:55.926796439 +0300
@@ -1,6 +1,7 @@
srcs_miext_sync = [
'misync.c',
'misyncfd.c',
+ 'misyncshm.c',
]
hdrs_miext_sync = [
@@ -10,10 +11,6 @@
'misyncstr.h',
]
-if build_dri3
- srcs_miext_sync += 'misyncshm.c'
-endif
-
libxserver_miext_sync = static_library('libxserver_miext_sync',
srcs_miext_sync,
include_directories: inc,