summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac4
-rw-r--r--src/bin/Makefile.am5
-rw-r--r--src/bin/engine_xrender_xcb.c386
-rw-r--r--src/bin/engine_xrender_xcb.h7
-rw-r--r--src/bin/main.c7
-rw-r--r--src/bin/main.h3
6 files changed, 412 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 893743a..a225259 100644
--- a/configure.ac
+++ b/configure.ac
@@ -38,6 +38,9 @@ EXPEDITE_CHECK_ENGINE([opengl-x11], [OpenGL X11], "yes")
38# Software XCB 38# Software XCB
39EXPEDITE_CHECK_ENGINE([software-xcb], [Software XCB], "yes") 39EXPEDITE_CHECK_ENGINE([software-xcb], [Software XCB], "yes")
40 40
41# XRender XCB
42EXPEDITE_CHECK_ENGINE([xrender-xcb], [XRender XCB], "yes")
43
41# DirectDraw 44# DirectDraw
42EXPEDITE_CHECK_ENGINE([software-ddraw], [Software DirectDraw], "yes", [ddraw_libs="-lddraw -ldxguid -lgdi32"]) 45EXPEDITE_CHECK_ENGINE([software-ddraw], [Software DirectDraw], "yes", [ddraw_libs="-lddraw -ldxguid -lgdi32"])
43AC_SUBST(ddraw_libs) 46AC_SUBST(ddraw_libs)
@@ -205,6 +208,7 @@ echo " Software X11.................: ${have_software_x11}"
205echo " X Render X11.................: ${have_xrender_x11}" 208echo " X Render X11.................: ${have_xrender_x11}"
206echo " Open GL X11..................: ${have_opengl_x11}" 209echo " Open GL X11..................: ${have_opengl_x11}"
207echo " Software XCB.................: ${have_software_xcb}" 210echo " Software XCB.................: ${have_software_xcb}"
211echo " X Render XCB.................: ${have_xrender_xcb}"
208echo " Software DirectDraw..........: ${have_software_ddraw}" 212echo " Software DirectDraw..........: ${have_software_ddraw}"
209echo " Direct3D.....................: ${have_direct3d}" 213echo " Direct3D.....................: ${have_direct3d}"
210echo " Open GL Glew.................: ${have_opengl_glew}" 214echo " Open GL Glew.................: ${have_opengl_glew}"
diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am
index 65810f2..daf9a43 100644
--- a/src/bin/Makefile.am
+++ b/src/bin/Makefile.am
@@ -97,6 +97,11 @@ expedite_SOURCES += \
97engine_software_xcb.c engine_software_xcb.h 97engine_software_xcb.c engine_software_xcb.h
98endif 98endif
99 99
100if BUILD_XRENDER_XCB
101expedite_SOURCES += \
102engine_xrender_xcb.c engine_xrender_xcb.h
103endif
104
100if BUILD_SOFTWARE_DDRAW 105if BUILD_SOFTWARE_DDRAW
101expedite_SOURCES += \ 106expedite_SOURCES += \
102engine_software_ddraw.cpp engine_software_ddraw.h 107engine_software_ddraw.cpp engine_software_ddraw.h
diff --git a/src/bin/engine_xrender_xcb.c b/src/bin/engine_xrender_xcb.c
new file mode 100644
index 0000000..6733d30
--- /dev/null
+++ b/src/bin/engine_xrender_xcb.c
@@ -0,0 +1,386 @@
1#include "main.h"
2
3#include <xcb/xcb.h>
4#include <xcb/xcb_keysyms.h>
5#include <Evas_Engine_XRender_Xcb.h>
6
7#define XK_MISCELLANY
8#include <X11/keysymdef.h>
9
10enum {
11 XCB_SIZE_US_POSITION_HINT = 1 << 0,
12 XCB_SIZE_US_SIZE_HINT = 1 << 1,
13 XCB_SIZE_P_POSITION_HINT = 1 << 2,
14 XCB_SIZE_P_SIZE_HINT = 1 << 3,
15 XCB_SIZE_P_MIN_SIZE_HINT = 1 << 4,
16 XCB_SIZE_P_MAX_SIZE_HINT = 1 << 5,
17 XCB_SIZE_P_RESIZE_INC_HINT = 1 << 6,
18 XCB_SIZE_P_ASPECT_HINT = 1 << 7,
19 XCB_SIZE_BASE_SIZE_HINT = 1 << 8,
20 XCB_SIZE_P_WIN_GRAVITY_HINT = 1 << 9
21};
22
23struct xcb_size_hints_t {
24 uint32_t flags;
25 int32_t x, y, width, height;
26 int32_t min_width, min_height;
27 int32_t max_width, max_height;
28 int32_t width_inc, height_inc;
29 int32_t min_aspect_num, min_aspect_den;
30 int32_t max_aspect_num, max_aspect_den;
31 int32_t base_width, base_height;
32 uint32_t win_gravity;
33};
34
35
36static xcb_connection_t *conn = NULL;
37static xcb_screen_t *screen = NULL;
38static xcb_window_t win = 0;
39
40static xcb_visualtype_t *
41_engine_xrender_visual_get(xcb_connection_t *conn, xcb_screen_t *screen)
42{
43 xcb_depth_iterator_t iter_depth;
44
45 iter_depth = xcb_screen_allowed_depths_iterator(screen);
46 for (; iter_depth.rem; xcb_depth_next (&iter_depth))
47 {
48 xcb_visualtype_iterator_t iter_vis;
49
50 iter_vis = xcb_depth_visuals_iterator(iter_depth.data);
51 for (; iter_vis.rem; xcb_visualtype_next (&iter_vis))
52 {
53 if (screen->root_visual == iter_vis.data->visual_id)
54 return iter_vis.data;
55 }
56 }
57}
58
59int
60engine_xrender_xcb_args(int argc, char **argv)
61{
62 struct xcb_size_hints_t hints;
63 uint32_t value_list[6];
64 xcb_screen_iterator_t iter;
65 Evas_Engine_Info_XRender_Xcb *einfo;
66 xcb_intern_atom_reply_t *reply;
67 char *str;
68 xcb_intern_atom_cookie_t cookie1;
69 xcb_intern_atom_cookie_t cookie2;
70 xcb_intern_atom_cookie_t cookie3;
71 xcb_intern_atom_cookie_t cookie4;
72 xcb_intern_atom_cookie_t cookie5;
73 xcb_atom_t string;
74 xcb_atom_t wm_name;
75 xcb_atom_t wm_class;
76 xcb_atom_t wm_normal_hint;
77 xcb_atom_t wm_size_hint;
78 uint32_t value_mask;
79 int s;
80 int s_tmp;
81 int l1;
82 int l2;
83 int i;
84 int ok = 0;
85
86 for (i = 1; i < argc; i++)
87 {
88 if ((!strcmp(argv[i], "-e")) && (i < (argc - 1)))
89 {
90 i++;
91 if (!strcmp(argv[i], "xrxcb")) ok = 1;
92 }
93 }
94 if (!ok) return 0;
95
96 conn = xcb_connect(NULL, &s);
97 if (!conn) return 0;
98
99 s_tmp = s;
100 iter = xcb_setup_roots_iterator(xcb_get_setup(conn));
101 for (; iter.rem; --s_tmp, xcb_screen_next (&iter))
102 if (s_tmp == 0)
103 {
104 screen = iter.data;
105 break;
106 }
107
108 evas_output_method_set(evas, evas_render_method_lookup("xrender_xcb"));
109 einfo = (Evas_Engine_Info_XRender_Xcb *)evas_engine_info_get(evas);
110 if (!einfo)
111 {
112 printf("Evas does not support the XRender XCB Engine\n");
113 return 0;
114 }
115
116 einfo->info.conn = conn;
117 einfo->info.screen = screen;
118 einfo->info.visual = _engine_xrender_visual_get(conn, screen);
119
120 value_mask =
121 XCB_CW_BACK_PIXMAP | XCB_CW_BORDER_PIXEL | XCB_CW_BIT_GRAVITY |
122 XCB_CW_BACKING_STORE | XCB_CW_EVENT_MASK | XCB_CW_COLORMAP;
123
124 value_list[0] = XCB_NONE;
125 value_list[1] = 0;
126 value_list[2] = XCB_GRAVITY_BIT_FORGET;
127 value_list[3] = XCB_BACKING_STORE_NOT_USEFUL;
128 value_list[4] =
129 XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE |
130 XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE |
131 XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW |
132 XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_EXPOSURE |
133 XCB_EVENT_MASK_STRUCTURE_NOTIFY;
134 value_list[5] =screen->default_colormap;
135
136 win = xcb_generate_id(conn);
137 xcb_create_window(conn,
138 screen->root_depth,
139 win, screen->root, 0, 0, win_w, win_h, 0,
140 XCB_WINDOW_CLASS_INPUT_OUTPUT,
141 ((xcb_visualtype_t *)einfo->info.visual)->visual_id,
142 value_mask,
143 value_list);
144 einfo->info.drawable = win;
145
146 xcb_map_window(conn, win);
147
148 evas_engine_info_set(evas, (Evas_Engine_Info *) einfo);
149
150/* XStoreName(disp, win, "Expedite - Evas Test Suite"); */
151
152 cookie1 = xcb_intern_atom_unchecked(conn, 0, strlen("STRING"), "STRING");
153 cookie2 = xcb_intern_atom_unchecked(conn, 0, strlen("WM_NAME"), "WM_NAME");
154 cookie3 = xcb_intern_atom_unchecked(conn, 0, strlen("WM_CLASS"), "WM_CLASS");
155 cookie4 = xcb_intern_atom_unchecked(conn, 0, strlen("WM_NORMAL_HINTS)"), "WM_NORMAL_HINTS)");
156 cookie5 = xcb_intern_atom_unchecked(conn, 0, strlen("WM_SIZE_HINTS)"), "WM_SIZE_HINTS)");
157
158 reply = xcb_intern_atom_reply(conn, cookie1, NULL);
159 string = reply->atom;
160 free(reply);
161 reply = xcb_intern_atom_reply(conn, cookie2, NULL);
162 wm_name = reply->atom;
163 free(reply);
164
165 xcb_change_property(conn, XCB_PROP_MODE_REPLACE, win,
166 wm_name, string, 8,
167 strlen("Expedite - Evas Test Suite"), "Expedite - Evas Test Suite");
168
169/* chint.res_name = "expedite"; */
170/* chint.res_class = "Expedite"; */
171/* XSetClassHint(disp, win, &chint); */
172
173 l1 = strlen("expedite");
174 l2 = strlen("Expedite");
175 str = (char *)malloc(l1 + l2 + 1);
176 memcpy(str, "expedite", l1);
177 str[l1] = '\0';
178 memcpy(str + l1 + 1, "Expedite", l2);
179
180 reply = xcb_intern_atom_reply(conn, cookie3, NULL);
181 wm_class = reply->atom;
182 free(reply);
183
184 xcb_change_property(conn, XCB_PROP_MODE_REPLACE, win,
185 wm_class, string, 8,
186 l1 + l2 + 1, str);
187 free(str);
188
189/* szhints.flags = PMinSize | PMaxSize | PSize | USSize; */
190/* szhints.min_width = szhints.max_width = win_w; */
191/* szhints.min_height = szhints.max_height = win_h; */
192/* XSetWMNormalHints(disp, win, &szhints); */
193
194 memset(&hints, 0, sizeof(hints));
195 hints.flags = XCB_SIZE_US_SIZE_HINT | XCB_SIZE_P_SIZE_HINT | XCB_SIZE_P_MIN_SIZE_HINT | XCB_SIZE_P_MAX_SIZE_HINT;
196 hints.min_width = win_w;
197 hints.max_width = win_w;
198 hints.min_height = win_h;
199 hints.max_height = win_h;
200
201 reply = xcb_intern_atom_reply(conn, cookie4, NULL);
202 wm_normal_hint = reply->atom;
203 free(reply);
204
205 reply = xcb_intern_atom_reply(conn, cookie5, NULL);
206 wm_size_hint = reply->atom;
207 free(reply);
208
209 xcb_change_property(conn, XCB_PROP_MODE_REPLACE, win,
210 wm_normal_hint, wm_size_hint, 32,
211 sizeof(hints) / 4, &hints);
212
213 free(xcb_get_input_focus_reply(conn, xcb_get_input_focus_unchecked(conn), NULL));
214
215 return 1;
216}
217
218void
219engine_xrender_xcb_loop(void)
220{
221 xcb_generic_event_t *ev;
222
223 again:
224 ev = xcb_poll_for_event(conn);
225 if (!ev)
226 return;
227
228 switch (ev->response_type)
229 {
230 case XCB_BUTTON_PRESS:
231 {
232 xcb_button_press_event_t *e;
233
234 e = (xcb_button_press_event_t *)ev;
235
236 evas_event_feed_mouse_move(evas, e->event_x, e->event_y, 0, NULL);
237 evas_event_feed_mouse_down(evas, e->detail, EVAS_BUTTON_NONE, 0, NULL);
238 break;
239 }
240 case XCB_BUTTON_RELEASE:
241 {
242 xcb_button_release_event_t *e;
243
244 e = (xcb_button_release_event_t *)ev;
245
246 evas_event_feed_mouse_move(evas, e->event_x, e->event_y, 0, NULL);
247 evas_event_feed_mouse_up(evas, e->detail, EVAS_BUTTON_NONE, 0, NULL);
248 break;
249 }
250 case XCB_MOTION_NOTIFY:
251 {
252 xcb_motion_notify_event_t *e;
253
254 e = (xcb_motion_notify_event_t *)ev;
255
256 evas_event_feed_mouse_move(evas, e->event_x, e->event_y, 0, NULL);
257 break;
258 }
259 case XCB_EXPOSE:
260 {
261 xcb_expose_event_t *e;
262
263 e = (xcb_expose_event_t *)ev;
264
265 evas_damage_rectangle_add(evas,
266 e->x,
267 e->y,
268 e->width,
269 e->height);
270 break;
271 }
272 case XCB_CONFIGURE_NOTIFY:
273 {
274 xcb_configure_notify_event_t *e;
275
276 e = (xcb_configure_notify_event_t *)ev;
277
278 evas_output_size_set(evas,
279 e->width,
280 e->height);
281 break;
282 }
283 case XCB_ENTER_NOTIFY:
284 evas_event_feed_mouse_in(evas, 0, NULL);
285 break;
286 case XCB_LEAVE_NOTIFY:
287 evas_event_feed_mouse_out(evas, 0, NULL);
288 break;
289 case XCB_KEY_PRESS:
290 {
291 xcb_key_press_event_t *e;
292 xcb_key_symbols_t *kss;
293 xcb_keysym_t ks;
294 char *str;
295
296 e = (xcb_key_press_event_t *)ev;
297
298 kss = xcb_key_symbols_alloc(conn);
299
300 ks = xcb_key_symbols_get_keysym(kss, e->detail, 0);
301
302 if ((ks == XK_Shift_L) || (ks == XK_Shift_R))
303 evas_key_modifier_on(evas, "Shift");
304 else if ((ks == XK_Control_L) || (ks == XK_Control_R))
305 evas_key_modifier_on(evas, "Control");
306 else if ((ks == XK_Alt_L) || (ks == XK_Alt_R))
307 evas_key_modifier_on(evas, "Alt");
308 else if ((ks == XK_Super_L) || (ks == XK_Super_R))
309 evas_key_modifier_on(evas, "Super");
310 else if (ks == XK_Caps_Lock)
311 {
312 if (evas_key_lock_is_set(evas_key_lock_get(evas), "Caps_Lock"))
313 evas_key_lock_off(evas, "Caps_Lock");
314 else
315 evas_key_lock_on(evas, "Caps_Lock");
316 }
317 else if (ks == XK_Scroll_Lock)
318 {
319 if (evas_key_lock_is_set(evas_key_lock_get(evas), "Scroll_Lock"))
320 evas_key_lock_off(evas, "Scroll_Lock");
321 else
322 evas_key_lock_on(evas, "Scroll_Lock");
323 }
324
325 if (ks == XK_Left)
326 str = "Left";
327 if (ks == XK_Right)
328 str = "Right";
329 if (ks == XK_Escape)
330 str = "Escape";
331 if (ks == XK_Return)
332 str = "Return";
333 if (ks == 71)
334 str = "q";
335
336 evas_event_feed_key_down(evas, str, str, NULL, NULL, 0, NULL);
337
338 xcb_key_symbols_free(kss);
339 break;
340 }
341 case XCB_KEY_RELEASE:
342 {
343 xcb_key_release_event_t *e;
344 xcb_key_symbols_t *kss;
345 xcb_keysym_t ks;
346 char *str;
347
348 e = (xcb_key_release_event_t *)ev;
349
350 kss = xcb_key_symbols_alloc(conn);
351
352 ks = xcb_key_symbols_get_keysym(kss, e->detail, 0);
353
354 if ((ks == XK_Shift_L) || (ks == XK_Shift_R))
355 evas_key_modifier_on(evas, "Shift");
356 else if ((ks == XK_Control_L) || (ks == XK_Control_R))
357 evas_key_modifier_on(evas, "Control");
358 else if ((ks == XK_Alt_L) || (ks == XK_Alt_R))
359 evas_key_modifier_on(evas, "Alt");
360 else if ((ks == XK_Super_L) || (ks == XK_Super_R))
361 evas_key_modifier_on(evas, "Super");
362
363 if (ks == XK_Left)
364 str = "Left";
365 if (ks == XK_Right)
366 str = "Right";
367 if (ks == XK_Escape)
368 str = "Escape";
369 if (ks == XK_Return)
370 str = "Return";
371 if (ks == 71)
372 str = "q";
373
374 evas_event_feed_key_up(evas, str, str, NULL, NULL, 0, NULL);
375
376 xcb_key_symbols_free(kss);
377 break;
378 }
379 default:
380 free(ev);
381 return;
382 }
383 free(ev);
384
385 goto again;
386}
diff --git a/src/bin/engine_xrender_xcb.h b/src/bin/engine_xrender_xcb.h
new file mode 100644
index 0000000..867b943
--- /dev/null
+++ b/src/bin/engine_xrender_xcb.h
@@ -0,0 +1,7 @@
1#ifndef ENGINE_XRENDER_XCB_H
2#define ENGINE_XRENDER_XCB_H
3
4int engine_xrender_xcb_args(int argc, char **argv);
5void engine_xrender_xcb_loop(void);
6
7#endif
diff --git a/src/bin/main.c b/src/bin/main.c
index 90eb892..cabcd34 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -1215,6 +1215,10 @@ _engine_args(int argc, char **argv)
1215 if (engine_software_xcb_args(argc, argv)) 1215 if (engine_software_xcb_args(argc, argv))
1216 loop_func = engine_software_xcb_loop; 1216 loop_func = engine_software_xcb_loop;
1217#endif 1217#endif
1218#if HAVE_EVAS_XRENDER_XCB
1219 if (engine_xrender_xcb_args(argc, argv))
1220 loop_func = engine_xrender_xcb_loop;
1221#endif
1218#if HAVE_EVAS_SOFTWARE_DDRAW 1222#if HAVE_EVAS_SOFTWARE_DDRAW
1219 if (engine_software_ddraw_args(argc, argv)) 1223 if (engine_software_ddraw_args(argc, argv))
1220 loop_func = engine_software_ddraw_loop; 1224 loop_func = engine_software_ddraw_loop;
@@ -1282,6 +1286,9 @@ _engine_args(int argc, char **argv)
1282#if HAVE_EVAS_SOFTWARE_XCB 1286#if HAVE_EVAS_SOFTWARE_XCB
1283 " xcb" 1287 " xcb"
1284#endif 1288#endif
1289#if HAVE_EVAS_XRENDER_XCB
1290 " xrxcb"
1291#endif
1285#if HAVE_EVAS_SOFTWARE_DDRAW 1292#if HAVE_EVAS_SOFTWARE_DDRAW
1286 " ddraw" 1293 " ddraw"
1287#endif 1294#endif
diff --git a/src/bin/main.h b/src/bin/main.h
index cf6143e..e0a35c1 100644
--- a/src/bin/main.h
+++ b/src/bin/main.h
@@ -33,6 +33,9 @@
33#if HAVE_EVAS_SOFTWARE_XCB 33#if HAVE_EVAS_SOFTWARE_XCB
34#include "engine_software_xcb.h" 34#include "engine_software_xcb.h"
35#endif 35#endif
36#if HAVE_EVAS_XRENDER_X11
37#include "engine_xrender_xcb.h"
38#endif
36#if HAVE_EVAS_SOFTWARE_DDRAW 39#if HAVE_EVAS_SOFTWARE_DDRAW
37#include "engine_software_ddraw.h" 40#include "engine_software_ddraw.h"
38#endif 41#endif