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
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <dlfcn.h>
#include "wrappedlibs.h"
#include "debug.h"
#include "wrapper32.h"
#include "bridge.h"
#include "librarian/library_private.h"
#include "x64emu.h"
#include "emu/x64emu_private.h"
#include "callback.h"
#include "librarian.h"
#include "box32context.h"
#include "emu/x64emu_private.h"
#ifdef ANDROID
static const char* libxrandrName = "libXrandr.so";
#else
static const char* libxrandrName = "libXrandr.so.2";
#endif
#define LIBNAME libxrandr
#include "libtools/my_x11_conv.h"
#include "generated/wrappedlibxrandrtypes32.h"
#include "wrappercallback32.h"
EXPORT void* my32_XRRGetScreenResources(x64emu_t* emu, void* dpy, XID window)
{
void* ret = my->XRRGetScreenResources(dpy, window);
inplace_XRRScreenResources_shrink(ret);
return ret;
}
EXPORT void* my32_XRRGetScreenResourcesCurrent(x64emu_t* emu, void* dpy, XID window)
{
void* ret = my->XRRGetScreenResourcesCurrent(dpy, window);
inplace_XRRScreenResources_shrink(ret);
return ret;
}
EXPORT int my32_XRRSetCrtcConfig(x64emu_t* emu, void* dpy, void* res, XID crtc, unsigned long timestamp, int x, int y, XID mode, uint16_t rotation, XID_32* outputs, int noutputs)
{
XID outputs_l[noutputs];
if(outputs)
for(int i=0; i<noutputs; ++i)
outputs_l[i] = from_ulong(outputs[i]);
inplace_XRRScreenResources_enlarge(res);
int ret = my->XRRSetCrtcConfig(dpy, res, crtc, timestamp, x, y, mode, rotation, outputs?(&outputs_l):NULL, noutputs);
inplace_XRRScreenResources_shrink(res);
return ret;
}
EXPORT void* my32_XRRGetPanning(x64emu_t* emu, void* dpy, void* res, XID crtc)
{
inplace_XRRScreenResources_enlarge(res);
void* ret = my->XRRGetPanning(dpy, res, crtc);
inplace_XRRScreenResources_shrink(res);
if(ret) {
// shrink XRRPanning: L and 12i
*(ulong_t*)res = to_ulong(*(unsigned long*)res);
memmove(res+4, res+8, 12*4);
}
return ret;
}
EXPORT int my32_XRRSetPanning(x64emu_t* emu, void* dpy, void* res, XID crtc, void* panning)
{
inplace_XRRScreenResources_enlarge(res);
// enlarge panning
{
unsigned long timestamp = from_ulong(*(ulong_t*)panning);
memmove(panning+8, panning+4, 12*4);
*(unsigned long*)panning = timestamp;
}
int ret = my->XRRSetPanning(dpy, res, crtc, panning);
inplace_XRRScreenResources_shrink(res);
{
// shrink XRRPanning: L and 12i
*(ulong_t*)panning = to_ulong(*(unsigned long*)panning);
memmove(panning+4, panning+8, 12*4);
}
return ret;
}
EXPORT void* my32_XRRGetCrtcInfo(x64emu_t* emu, void* dpy, void* res, XID crtc)
{
inplace_XRRScreenResources_enlarge(res);
void* ret = my->XRRGetCrtcInfo(dpy, res, crtc);
inplace_XRRScreenResources_shrink(res);
inplace_XRRCrtcInfo_shrink(ret);
return ret;
}
EXPORT void* my32_XRRGetOutputInfo(x64emu_t* emu, void* dpy, void* res, XID window)
{
inplace_XRRScreenResources_enlarge(res);
void* ret = my->XRRGetOutputInfo(dpy, res, window);
inplace_XRRScreenResources_shrink(res);
inplace_XRROutputInfo_shrink(ret);
return ret;
}
EXPORT void* my32_XRRGetProviderInfo(x64emu_t* emu, void* dpy, void* res, XID provider)
{
inplace_XRRScreenResources_enlarge(res);
void* ret = my->XRRGetProviderInfo(dpy, res, provider);
inplace_XRRScreenResources_shrink(res);
inplace_XRRProviderInfo_shrink(ret);
return ret;
}
EXPORT void my32_XRRFreeProviderInfo(x64emu_t* emu, void* r)
{
inplace_XRRProviderInfo_enlarge(r);
my->XRRFreeProviderInfo(r);
}
EXPORT void* my32_XRRGetProviderResources(x64emu_t* emu, void* dpy, XID window)
{
void* ret = my->XRRGetProviderResources(dpy, window);
inplace_XRRProviderResources_shrink(ret);
return ret;
}
EXPORT void my32_XRRFreeProviderResources(x64emu_t* emu, void* r)
{
inplace_XRRProviderResources_enlarge(r);
my->XRRFreeProviderResources(r);
}
EXPORT void* my32_XRRListOutputProperties(x64emu_t* emu, void* dpy, XID out, int* num)
{
XID* ret = my->XRRListOutputProperties(dpy, out, num);
if(!ret) return NULL;
XID_32* ret_s = (XID_32*)ret;
for(int i=0; i<*num; ++i)
ret_s[i] = to_ulong(ret[i]);
return ret;
}
EXPORT void* my32_XRRQueryOutputProperty(x64emu_t* emu, void* dpy, XID output, XID prop)
{
void* ret = my->XRRQueryOutputProperty(dpy, output, prop);
return inplace_XRRPropertyInfo_shrink(ret);
}
EXPORT int my32_XRRQueryExtension(x64emu_t* emu, void* dpy, int* event_base, int* error_base)
{
int ret = my->XRRQueryExtension(dpy, event_base, error_base);
if(!ret) return ret;
register_XRandR_events(*event_base);
return ret;
}
EXPORT int my32_XRRUpdateConfiguration(x64emu_t* emu, my_XEvent_32_t* evt)
{
my_XEvent_t evt_l = {0};
unconvertXEvent(&evt_l, evt);
return my->XRRUpdateConfiguration(&evt_l);
}
EXPORT void* my32_XRRGetMonitors(x64emu_t* emu, void* dpy, XID window, int get_active, int* nmonitors)
{
void* ret = my->XRRGetMonitors(dpy, window, get_active, nmonitors);
return inplace_XRRMonitorInfo_shrink(ret, *nmonitors);
}
EXPORT void my32_XRRFreeMonitors(x64emu_t* emu, void* monitors)
{
if(!monitors) return;
int n = 0;
while(((my_XRRMonitorInfo_32_t*)monitors)[n].name) ++n;
my->XRRFreeMonitors(inplace_XRRMonitorInfo_enlarge(monitors, n));
}
#ifdef ANDROID
#define NEEDED_LIBS "libX11.so", "libXext.so", "libXrender.so"
#else
#define NEEDED_LIBS "libX11.so.6", "libXext.so.6", "libXrender.so.1"
#endif
#define CUSTOM_FINI \
unregister_XRandR_events();
#include "wrappedlib_init32.h"
|