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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
|
#include <dlfcn.h>
#include "xenon.h"
#include "window.h"
#include "display.h"
#include "damage.h"
#include "render.h"
#include "draw.h"
#include "util.h"
Status XAllocColor(
Display* display,
Colormap colormap,
XColor* screen_in_out
)
{
printf("alloc color ok\n");
}
int XCloseDisplay(
Display* display
)
{
printf("close display ok\n");
}
GC XCreateGC(
Display* display,
Drawable d,
unsigned long valuemask,
XGCValues* values
)
{
// XXX init hack, remove when the renderer is changed to gallium
extern int inhibit_rendering;
if (inhibit_rendering)
{
void* handle;
handle = dlopen("/usr/lib64/libX11.so.6", RTLD_LAZY);
if (!handle)
handle = dlopen("/usr/lib/libX11.so.6", RTLD_LAZY);
if (!handle)
printf("can't open libX11\n");
typedef GC (* XCreateGCfunc) (Display*, Drawable,unsigned long, XGCValues*);
XCreateGCfunc XCreateGCreal = dlsym(handle, "XCreateGC");
return XCreateGCreal(display, d, valuemask, values);
}
printf("create GC ok\n");
}
Pixmap XCreatePixmap(
Display* display,
Drawable d,
unsigned int width,
unsigned int height,
unsigned int depth
)
{
printf("create pixmap ok\n");
}
Window XCreateSimpleWindow(
Display* display,
Window parent,
int x,
int y,
unsigned int width,
unsigned int height,
unsigned int border_width,
unsigned long border,
unsigned long background
)
{
Window wid = window_create();
window_resize(wid, width, height);
window_move(wid, x, y);
printf("simple window ok\n");
return wid;
}
int XDrawLine(
Display* display,
Drawable d,
GC gc,
int x1,
int y1,
int x2,
int y2
)
{
}
int XDrawPoint(
Display* display,
Drawable d,
GC gc,
int x,
int y
)
{
draw_point(gc, x, y);
}
int XDrawRectangle(
Display* display,
Drawable d,
GC gc,
int x,
int y,
unsigned int width,
unsigned int height
)
{
xenon_rect r = {x,y,width,height};
draw_rectangle(gc, &r);
printf("draw rectangle ok\n");
}
int XDrawString(
Display* display,
Drawable d,
GC gc,
int x,
int y,
_Xconst char* string,
int length
)
{
printf("draw string ok\n");
}
int XFillRectangle(
Display* display,
Drawable d,
GC gc,
int x,
int y,
unsigned int width,
unsigned int height
)
{
printf("fill rectangle ok\n");
}
int XFlush(
Display* display
)
{
render_update(damage_current());
damage_clear();
printf("flush ok\n");
}
void XFlushGC(
Display* display,
GC gc
)
{
XFlush(display);
}
int XMapWindow(
Display* display,
Window w
)
{
printf("map window ok\n");
}
int XNextEvent(
Display* display,
XEvent* event_return
)
{
printf("event requested\n");
event_return->type = KeyPress;
}
Display *XOpenDisplay(
_Xconst char* name /* display_name */
)
{
Display* r = display_find(name);
printf("open display ok\n");
return r;
}
Status XParseColor(
Display* display,
Colormap colormap,
_Xconst char* spec,
XColor* exact_def_return
)
{
unsigned long r,g,b;
if (!spec)
return BadValue;
if (spec[0] == '#')
{
switch(strlen(spec))
{
case 4:
r = hexval(spec[1]) << 12;
g = hexval(spec[2]) << 12;
b = hexval(spec[3]) << 12;
break;
case 7:
r = ( hexval(spec[1]) << 12 ) + ( hexval(spec[2]) << 8 );
g = ( hexval(spec[3]) << 12 ) + ( hexval(spec[4]) << 8 );
b = ( hexval(spec[5]) << 12 ) + ( hexval(spec[6]) << 8 );
break;
case 10:
r = ( hexval(spec[1]) << 12 ) + ( hexval(spec[2]) << 8 ) + ( hexval(spec[3]) << 4 );
g = ( hexval(spec[4]) << 12 ) + ( hexval(spec[5]) << 8 ) + ( hexval(spec[6]) << 4 );
b = ( hexval(spec[7]) << 12 ) + ( hexval(spec[8]) << 8 ) + ( hexval(spec[9]) << 4 );
break;
case 13:
r = ( hexval(spec[1]) << 12 ) + ( hexval(spec[2]) << 8 ) + ( hexval(spec[3]) << 4 ) + hexval(spec[4]);
g = ( hexval(spec[5]) << 12 ) + ( hexval(spec[6]) << 8 ) + ( hexval(spec[7]) << 4 ) + hexval(spec[8]);
b = ( hexval(spec[9]) << 12 ) + ( hexval(spec[10]) << 8 ) + ( hexval(spec[11]) << 4 ) + hexval(spec[12]);
break;
default:
return BadValue;
}
exact_def_return -> red = r;
exact_def_return -> green = g;
exact_def_return -> blue = b;
exact_def_return -> pixel = (r << 32) | (g << 16) | b;
printf("parse color ok %x-%x-%x\n",r>>8,g>>8,b>>8);
}
else
{
return BadValue;
}
}
int XPutImage(
Display* display,
Drawable d,
GC gc,
XImage* image,
int src_x,
int src_y,
int dest_x,
int dest_y,
unsigned int width,
unsigned int height
)
{
// XXX init hack, remove when the renderer is changed to gallium
extern int inhibit_rendering;
if (inhibit_rendering)
{
void* handle;
handle = dlopen("/usr/lib64/libX11.so.6", RTLD_LAZY);
if (!handle)
handle = dlopen("/usr/lib/libX11.so.6", RTLD_LAZY);
if (!handle)
printf("can't open libX11\n");
typedef int (* XPutImagefunc) (Display*, Drawable, GC, XImage*, int, int, int, int, unsigned, unsigned);
XPutImagefunc XPutImagereal = dlsym(handle, "XPutImage");
return XPutImagereal(display, d, gc, image, src_x, src_y, dest_x, dest_y, width, height);
}
xenon_rect r = {src_x,src_y,width,height};
draw_image(gc, image, &r, dest_x, dest_y);
printf("put image ok\n");
}
int XSelectInput(
Display* display,
Window w,
long event_mask
)
{
printf("select input ok\n");
}
int XSetForeground(
Display* display,
GC gc,
unsigned long foreground
)
{
printf("set foreground ok\n");
}
|