diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/ecore/src/lib/ecore_evas/ecore_evas_fb.c | 659 |
1 files changed, 659 insertions, 0 deletions
diff --git a/libraries/ecore/src/lib/ecore_evas/ecore_evas_fb.c b/libraries/ecore/src/lib/ecore_evas/ecore_evas_fb.c new file mode 100644 index 0000000..3ee913e --- /dev/null +++ b/libraries/ecore/src/lib/ecore_evas/ecore_evas_fb.c | |||
@@ -0,0 +1,659 @@ | |||
1 | #ifdef HAVE_CONFIG_H | ||
2 | # include <config.h> | ||
3 | #endif | ||
4 | |||
5 | #include <sys/types.h> | ||
6 | #include <dirent.h> | ||
7 | |||
8 | #include <Ecore.h> | ||
9 | #include "ecore_private.h" | ||
10 | #ifdef BUILD_ECORE_EVAS_FB | ||
11 | #include <Ecore_Fb.h> | ||
12 | #include <ecore_fb_private.h> | ||
13 | #endif | ||
14 | |||
15 | #include "ecore_evas_private.h" | ||
16 | #include "Ecore_Evas.h" | ||
17 | |||
18 | #ifdef BUILD_ECORE_EVAS_FB | ||
19 | static int _ecore_evas_init_count = 0; | ||
20 | |||
21 | static char *ecore_evas_default_display = "0"; | ||
22 | static Eina_List *ecore_evas_input_devices = NULL; | ||
23 | static Ecore_Event_Handler *ecore_evas_event_handlers[4] = {NULL, NULL, NULL, NULL}; | ||
24 | |||
25 | static void | ||
26 | _ecore_evas_mouse_move_process_fb(Ecore_Evas *ee, int x, int y) | ||
27 | { | ||
28 | int fbw, fbh; | ||
29 | |||
30 | ee->mouse.x = x; | ||
31 | ee->mouse.y = y; | ||
32 | ecore_fb_size_get(&fbw, &fbh); | ||
33 | if (ee->prop.cursor.object) | ||
34 | { | ||
35 | evas_object_show(ee->prop.cursor.object); | ||
36 | if (ee->rotation == 0) | ||
37 | evas_object_move(ee->prop.cursor.object, | ||
38 | x - ee->prop.cursor.hot.x, | ||
39 | y - ee->prop.cursor.hot.y); | ||
40 | else if (ee->rotation == 90) | ||
41 | evas_object_move(ee->prop.cursor.object, | ||
42 | (fbh - ee->h) + ee->h - y - 1 - ee->prop.cursor.hot.x, | ||
43 | x - ee->prop.cursor.hot.y); | ||
44 | else if (ee->rotation == 180) | ||
45 | evas_object_move(ee->prop.cursor.object, | ||
46 | (fbw - ee->w) + ee->w - x - 1 - ee->prop.cursor.hot.x, | ||
47 | (fbh - ee->h) + ee->h - y - 1 - ee->prop.cursor.hot.y); | ||
48 | else if (ee->rotation == 270) | ||
49 | evas_object_move(ee->prop.cursor.object, | ||
50 | y - ee->prop.cursor.hot.x, | ||
51 | (fbw - ee->w) + ee->w - x - 1 - ee->prop.cursor.hot.y); | ||
52 | } | ||
53 | } | ||
54 | |||
55 | static Ecore_Evas *fb_ee = NULL; | ||
56 | |||
57 | static Ecore_Evas * | ||
58 | _ecore_evas_fb_match(void) | ||
59 | { | ||
60 | return fb_ee; | ||
61 | } | ||
62 | |||
63 | static void | ||
64 | _ecore_evas_fb_lose(void *data __UNUSED__) | ||
65 | { | ||
66 | Eina_List *ll; | ||
67 | Ecore_Fb_Input_Device *dev; | ||
68 | |||
69 | if (fb_ee) fb_ee->visible = 0; | ||
70 | |||
71 | EINA_LIST_FOREACH(ecore_evas_input_devices, ll, dev) | ||
72 | ecore_fb_input_device_listen(dev, 0); | ||
73 | } | ||
74 | |||
75 | static void | ||
76 | _ecore_evas_fb_gain(void *data __UNUSED__) | ||
77 | { | ||
78 | Ecore_Evas *ee; | ||
79 | Eina_List *ll; | ||
80 | Ecore_Fb_Input_Device *dev; | ||
81 | |||
82 | if (fb_ee) | ||
83 | { | ||
84 | ee = fb_ee; | ||
85 | |||
86 | ee->visible = 1; | ||
87 | if ((ee->rotation == 90) || (ee->rotation == 270)) | ||
88 | evas_damage_rectangle_add(ee->evas, 0, 0, ee->h, ee->w); | ||
89 | else | ||
90 | evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); | ||
91 | } | ||
92 | |||
93 | EINA_LIST_FOREACH(ecore_evas_input_devices, ll, dev) | ||
94 | ecore_fb_input_device_listen(dev, 1); | ||
95 | } | ||
96 | |||
97 | static Eina_Bool | ||
98 | _ecore_evas_event_mouse_button_down(void *data __UNUSED__, int type __UNUSED__, void *event) | ||
99 | { | ||
100 | Ecore_Evas *ee; | ||
101 | Ecore_Event_Mouse_Button *e; | ||
102 | |||
103 | e = event; | ||
104 | ee = _ecore_evas_fb_match(); | ||
105 | if (!ee) return ECORE_CALLBACK_PASS_ON; | ||
106 | _ecore_evas_mouse_move_process_fb(ee, e->x, e->y); | ||
107 | return ECORE_CALLBACK_PASS_ON; | ||
108 | } | ||
109 | |||
110 | static Eina_Bool | ||
111 | _ecore_evas_event_mouse_button_up(void *data __UNUSED__, int type __UNUSED__, void *event) | ||
112 | { | ||
113 | Ecore_Evas *ee; | ||
114 | Ecore_Event_Mouse_Button *e; | ||
115 | |||
116 | e = event; | ||
117 | ee = _ecore_evas_fb_match(); | ||
118 | if (!ee) return ECORE_CALLBACK_PASS_ON; | ||
119 | _ecore_evas_mouse_move_process_fb(ee, e->x, e->y); | ||
120 | return ECORE_CALLBACK_PASS_ON; | ||
121 | } | ||
122 | |||
123 | static Eina_Bool | ||
124 | _ecore_evas_event_mouse_move(void *data __UNUSED__, int type __UNUSED__, void *event) | ||
125 | { | ||
126 | Ecore_Evas *ee; | ||
127 | Ecore_Event_Mouse_Move *e; | ||
128 | |||
129 | e = event; | ||
130 | ee = _ecore_evas_fb_match(); | ||
131 | if (!ee) return ECORE_CALLBACK_PASS_ON; | ||
132 | _ecore_evas_mouse_move_process_fb(ee, e->x, e->y); | ||
133 | return ECORE_CALLBACK_PASS_ON; | ||
134 | } | ||
135 | |||
136 | static Eina_Bool | ||
137 | _ecore_evas_event_mouse_wheel(void *data __UNUSED__, int type __UNUSED__, void *event) | ||
138 | { | ||
139 | Ecore_Evas *ee; | ||
140 | Ecore_Event_Mouse_Wheel *e; | ||
141 | |||
142 | e = event; | ||
143 | ee = _ecore_evas_fb_match(); | ||
144 | if (!ee) return ECORE_CALLBACK_PASS_ON; | ||
145 | _ecore_evas_mouse_move_process_fb(ee, e->x, e->y); | ||
146 | return ECORE_CALLBACK_PASS_ON; | ||
147 | } | ||
148 | |||
149 | static int | ||
150 | _ecore_evas_fb_render(Ecore_Evas *ee) | ||
151 | { | ||
152 | int rend = 0; | ||
153 | |||
154 | if (ee->visible) | ||
155 | { | ||
156 | Eina_List *updates; | ||
157 | |||
158 | Eina_List *ll; | ||
159 | Ecore_Evas *ee2; | ||
160 | if (ee->func.fn_pre_render) ee->func.fn_pre_render(ee); | ||
161 | |||
162 | EINA_LIST_FOREACH(ee->sub_ecore_evas, ll, ee2) | ||
163 | { | ||
164 | if (ee2->func.fn_pre_render) ee2->func.fn_pre_render(ee2); | ||
165 | if (ee2->engine.func->fn_render) | ||
166 | rend |= ee2->engine.func->fn_render(ee2); | ||
167 | if (ee2->func.fn_post_render) ee2->func.fn_post_render(ee2); | ||
168 | } | ||
169 | |||
170 | updates = evas_render_updates(ee->evas); | ||
171 | if (updates) | ||
172 | { | ||
173 | evas_render_updates_free(updates); | ||
174 | _ecore_evas_idle_timeout_update(ee); | ||
175 | rend = 1; | ||
176 | } | ||
177 | if (ee->func.fn_post_render) ee->func.fn_post_render(ee); | ||
178 | } | ||
179 | else | ||
180 | evas_norender(ee->evas); | ||
181 | return rend; | ||
182 | } | ||
183 | |||
184 | static int | ||
185 | _ecore_evas_fb_init(Ecore_Evas *ee, int w, int h) | ||
186 | { | ||
187 | Ecore_Fb_Input_Device *device; | ||
188 | Ecore_Fb_Input_Device_Cap caps; | ||
189 | int mouse_handled = 0; | ||
190 | |||
191 | DIR *input_dir; | ||
192 | struct dirent *input_entry; | ||
193 | |||
194 | _ecore_evas_init_count++; | ||
195 | if (_ecore_evas_init_count > 1) return _ecore_evas_init_count; | ||
196 | |||
197 | ecore_event_evas_init(); | ||
198 | |||
199 | /* register all input devices */ | ||
200 | input_dir = opendir("/dev/input/"); | ||
201 | if (!input_dir) return _ecore_evas_init_count; | ||
202 | |||
203 | while ((input_entry = readdir(input_dir))) | ||
204 | { | ||
205 | char device_path[256]; | ||
206 | |||
207 | if (strncmp(input_entry->d_name, "event", 5) != 0) | ||
208 | continue; | ||
209 | |||
210 | snprintf(device_path, 256, "/dev/input/%s", input_entry->d_name); | ||
211 | if (!(device = ecore_fb_input_device_open(device_path))) | ||
212 | continue; | ||
213 | ecore_fb_input_device_window_set(device, ee); | ||
214 | |||
215 | caps = ecore_fb_input_device_cap_get(device); | ||
216 | |||
217 | /* Mouse */ | ||
218 | #ifdef HAVE_TSLIB | ||
219 | if (caps & ECORE_FB_INPUT_DEVICE_CAP_RELATIVE) | ||
220 | #else | ||
221 | if ((caps & ECORE_FB_INPUT_DEVICE_CAP_RELATIVE) || (caps & ECORE_FB_INPUT_DEVICE_CAP_ABSOLUTE)) | ||
222 | #endif | ||
223 | { | ||
224 | ecore_fb_input_device_axis_size_set(device, w, h); | ||
225 | ecore_fb_input_device_listen(device,1); | ||
226 | ecore_evas_input_devices = eina_list_append(ecore_evas_input_devices, device); | ||
227 | if (!mouse_handled) | ||
228 | { | ||
229 | ecore_evas_event_handlers[0] = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, _ecore_evas_event_mouse_button_down, NULL); | ||
230 | ecore_evas_event_handlers[1] = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP, _ecore_evas_event_mouse_button_up, NULL); | ||
231 | ecore_evas_event_handlers[2] = ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE, _ecore_evas_event_mouse_move, NULL); | ||
232 | ecore_evas_event_handlers[3] = ecore_event_handler_add(ECORE_EVENT_MOUSE_WHEEL, _ecore_evas_event_mouse_wheel, NULL); | ||
233 | mouse_handled = 1; | ||
234 | } | ||
235 | } | ||
236 | /* Keyboard */ | ||
237 | else if ((caps & ECORE_FB_INPUT_DEVICE_CAP_KEYS_OR_BUTTONS) && !(caps & ECORE_FB_INPUT_DEVICE_CAP_ABSOLUTE)) | ||
238 | { | ||
239 | ecore_fb_input_device_listen(device,1); | ||
240 | ecore_evas_input_devices = eina_list_append(ecore_evas_input_devices, device); | ||
241 | } | ||
242 | } | ||
243 | closedir(input_dir); | ||
244 | |||
245 | if (!mouse_handled) | ||
246 | { | ||
247 | if (ecore_fb_ts_init()) | ||
248 | { | ||
249 | ecore_fb_ts_event_window_set(ee); | ||
250 | ecore_evas_event_handlers[0] = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, _ecore_evas_event_mouse_button_down, NULL); | ||
251 | ecore_evas_event_handlers[1] = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP, _ecore_evas_event_mouse_button_up, NULL); | ||
252 | ecore_evas_event_handlers[2] = ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE, _ecore_evas_event_mouse_move, NULL); | ||
253 | mouse_handled = 1; | ||
254 | } | ||
255 | } | ||
256 | return _ecore_evas_init_count; | ||
257 | } | ||
258 | |||
259 | static void | ||
260 | _ecore_evas_fb_free(Ecore_Evas *ee) | ||
261 | { | ||
262 | ecore_evas_input_event_unregister(ee); | ||
263 | if (fb_ee == ee) fb_ee = NULL; | ||
264 | _ecore_evas_fb_shutdown(); | ||
265 | ecore_fb_shutdown(); | ||
266 | } | ||
267 | |||
268 | static void | ||
269 | _ecore_evas_resize(Ecore_Evas *ee, int w, int h) | ||
270 | { | ||
271 | ee->req.w = w; | ||
272 | ee->req.h = h; | ||
273 | if ((w == ee->w) && (h == ee->h)) return; | ||
274 | ee->w = w; | ||
275 | ee->h = h; | ||
276 | if ((ee->rotation == 90) || (ee->rotation == 270)) | ||
277 | { | ||
278 | evas_output_size_set(ee->evas, ee->h, ee->w); | ||
279 | evas_output_viewport_set(ee->evas, 0, 0, ee->h, ee->w); | ||
280 | evas_damage_rectangle_add(ee->evas, 0, 0, ee->h, ee->w); | ||
281 | } | ||
282 | else | ||
283 | { | ||
284 | evas_output_size_set(ee->evas, ee->w, ee->h); | ||
285 | evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h); | ||
286 | evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); | ||
287 | } | ||
288 | if (ee->func.fn_resize) ee->func.fn_resize(ee); | ||
289 | } | ||
290 | |||
291 | static void | ||
292 | _ecore_evas_move_resize(Ecore_Evas *ee, int x __UNUSED__, int y __UNUSED__, int w, int h) | ||
293 | { | ||
294 | ee->req.w = w; | ||
295 | ee->req.h = h; | ||
296 | if ((w == ee->w) && (h == ee->h)) return; | ||
297 | ee->w = w; | ||
298 | ee->h = h; | ||
299 | if ((ee->rotation == 90) || (ee->rotation == 270)) | ||
300 | { | ||
301 | evas_output_size_set(ee->evas, ee->h, ee->w); | ||
302 | evas_output_viewport_set(ee->evas, 0, 0, ee->h, ee->w); | ||
303 | evas_damage_rectangle_add(ee->evas, 0, 0, ee->h, ee->w); | ||
304 | } | ||
305 | else | ||
306 | { | ||
307 | evas_output_size_set(ee->evas, ee->w, ee->h); | ||
308 | evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h); | ||
309 | evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); | ||
310 | } | ||
311 | if (ee->func.fn_resize) ee->func.fn_resize(ee); | ||
312 | } | ||
313 | |||
314 | static void | ||
315 | _ecore_evas_rotation_set(Ecore_Evas *ee, int rotation, int resize __UNUSED__) | ||
316 | { | ||
317 | Evas_Engine_Info_FB *einfo; | ||
318 | int rot_dif; | ||
319 | |||
320 | if (ee->rotation == rotation) return; | ||
321 | einfo = (Evas_Engine_Info_FB *)evas_engine_info_get(ee->evas); | ||
322 | if (!einfo) return; | ||
323 | rot_dif = ee->rotation - rotation; | ||
324 | if (rot_dif < 0) rot_dif = -rot_dif; | ||
325 | if (rot_dif != 180) | ||
326 | { | ||
327 | |||
328 | einfo->info.rotation = rotation; | ||
329 | if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) | ||
330 | { | ||
331 | ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); | ||
332 | } | ||
333 | if (!ee->prop.fullscreen) | ||
334 | { | ||
335 | int tmp; | ||
336 | |||
337 | tmp = ee->w; | ||
338 | ee->w = ee->h; | ||
339 | ee->h = tmp; | ||
340 | ee->req.w = ee->w; | ||
341 | ee->req.h = ee->h; | ||
342 | } | ||
343 | else | ||
344 | { | ||
345 | if ((rotation == 0) || (rotation == 180)) | ||
346 | { | ||
347 | evas_output_size_set(ee->evas, ee->w, ee->h); | ||
348 | evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h); | ||
349 | } | ||
350 | else | ||
351 | { | ||
352 | evas_output_size_set(ee->evas, ee->h, ee->w); | ||
353 | evas_output_viewport_set(ee->evas, 0, 0, ee->h, ee->w); | ||
354 | } | ||
355 | } | ||
356 | ee->rotation = rotation; | ||
357 | } | ||
358 | else | ||
359 | { | ||
360 | einfo->info.rotation = rotation; | ||
361 | if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) | ||
362 | { | ||
363 | ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); | ||
364 | } | ||
365 | ee->rotation = rotation; | ||
366 | } | ||
367 | if ((ee->rotation == 90) || (ee->rotation == 270)) | ||
368 | evas_damage_rectangle_add(ee->evas, 0, 0, ee->h, ee->w); | ||
369 | else | ||
370 | evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); | ||
371 | _ecore_evas_mouse_move_process_fb(ee, ee->mouse.x, ee->mouse.y); | ||
372 | if (ee->func.fn_resize) ee->func.fn_resize(ee); | ||
373 | } | ||
374 | |||
375 | static void | ||
376 | _ecore_evas_show(Ecore_Evas *ee) | ||
377 | { | ||
378 | if (ee->prop.focused) return; | ||
379 | ee->prop.focused = 1; | ||
380 | evas_focus_in(ee->evas); | ||
381 | if (ee->func.fn_focus_in) ee->func.fn_focus_in(ee); | ||
382 | } | ||
383 | |||
384 | static void | ||
385 | _ecore_evas_object_cursor_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) | ||
386 | { | ||
387 | Ecore_Evas *ee; | ||
388 | |||
389 | ee = data; | ||
390 | if (ee) | ||
391 | ee->prop.cursor.object = NULL; | ||
392 | } | ||
393 | |||
394 | static void | ||
395 | _ecore_evas_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y) | ||
396 | { | ||
397 | int x, y; | ||
398 | |||
399 | if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object); | ||
400 | |||
401 | if (!obj) | ||
402 | { | ||
403 | ee->prop.cursor.object = NULL; | ||
404 | ee->prop.cursor.layer = 0; | ||
405 | ee->prop.cursor.hot.x = 0; | ||
406 | ee->prop.cursor.hot.y = 0; | ||
407 | return; | ||
408 | } | ||
409 | |||
410 | ee->prop.cursor.object = obj; | ||
411 | ee->prop.cursor.layer = layer; | ||
412 | ee->prop.cursor.hot.x = hot_x; | ||
413 | ee->prop.cursor.hot.y = hot_y; | ||
414 | evas_pointer_output_xy_get(ee->evas, &x, &y); | ||
415 | evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer); | ||
416 | evas_object_move(ee->prop.cursor.object, | ||
417 | x - ee->prop.cursor.hot.x, | ||
418 | y - ee->prop.cursor.hot.y); | ||
419 | evas_object_pass_events_set(ee->prop.cursor.object, 1); | ||
420 | if (evas_pointer_inside_get(ee->evas)) | ||
421 | evas_object_show(ee->prop.cursor.object); | ||
422 | |||
423 | evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, _ecore_evas_object_cursor_del, ee); | ||
424 | } | ||
425 | |||
426 | static void | ||
427 | _ecore_evas_fullscreen_set(Ecore_Evas *ee, int on) | ||
428 | { | ||
429 | Eina_List *l; | ||
430 | Ecore_Fb_Input_Device *dev; | ||
431 | int resized = 0; | ||
432 | |||
433 | if (((ee->prop.fullscreen) && (on)) || | ||
434 | ((!ee->prop.fullscreen) && (!on))) return; | ||
435 | if (on) | ||
436 | { | ||
437 | int w, h; | ||
438 | |||
439 | ee->engine.fb.real_w = ee->w; | ||
440 | ee->engine.fb.real_h = ee->h; | ||
441 | w = ee->w; | ||
442 | h = ee->h; | ||
443 | ecore_fb_size_get(&w, &h); | ||
444 | if ((w == 0) && (h == 0)) | ||
445 | { | ||
446 | w = ee->w; | ||
447 | h = ee->h; | ||
448 | } | ||
449 | if ((w != ee->w) || (h != ee->h)) resized = 1; | ||
450 | ee->w = w; | ||
451 | ee->h = h; | ||
452 | ee->req.w = ee->w; | ||
453 | ee->req.h = ee->h; | ||
454 | evas_output_size_set(ee->evas, ee->w, ee->h); | ||
455 | evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h); | ||
456 | evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); | ||
457 | } | ||
458 | else | ||
459 | { | ||
460 | if ((ee->engine.fb.real_w != ee->w) || (ee->engine.fb.real_h != ee->h)) resized = 1; | ||
461 | ee->w = ee->engine.fb.real_w; | ||
462 | ee->h = ee->engine.fb.real_h; | ||
463 | ee->req.w = ee->w; | ||
464 | ee->req.h = ee->h; | ||
465 | evas_output_size_set(ee->evas, ee->w, ee->h); | ||
466 | evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h); | ||
467 | evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); | ||
468 | } | ||
469 | ee->prop.fullscreen = on; | ||
470 | EINA_LIST_FOREACH(ecore_evas_input_devices, l, dev) | ||
471 | ecore_fb_input_device_axis_size_set(dev, ee->w, ee->h); | ||
472 | /* rescale the input device area */ | ||
473 | if (resized) | ||
474 | { | ||
475 | if (ee->func.fn_resize) ee->func.fn_resize(ee); | ||
476 | } | ||
477 | } | ||
478 | |||
479 | int | ||
480 | _ecore_evas_fb_shutdown(void) | ||
481 | { | ||
482 | _ecore_evas_init_count--; | ||
483 | if (_ecore_evas_init_count == 0) | ||
484 | { | ||
485 | int i; | ||
486 | |||
487 | for (i = 0; i < 4; i++) | ||
488 | { | ||
489 | if (ecore_evas_event_handlers[i]) | ||
490 | ecore_event_handler_del(ecore_evas_event_handlers[i]); | ||
491 | } | ||
492 | ecore_fb_ts_shutdown(); | ||
493 | ecore_event_evas_shutdown(); | ||
494 | } | ||
495 | if (_ecore_evas_init_count < 0) _ecore_evas_init_count = 0; | ||
496 | return _ecore_evas_init_count; | ||
497 | } | ||
498 | |||
499 | static Ecore_Evas_Engine_Func _ecore_fb_engine_func = | ||
500 | { | ||
501 | _ecore_evas_fb_free, | ||
502 | NULL, | ||
503 | NULL, | ||
504 | NULL, | ||
505 | NULL, | ||
506 | NULL, | ||
507 | NULL, | ||
508 | NULL, | ||
509 | NULL, | ||
510 | NULL, | ||
511 | NULL, | ||
512 | NULL, | ||
513 | NULL, | ||
514 | NULL, | ||
515 | NULL, | ||
516 | NULL, | ||
517 | NULL, | ||
518 | _ecore_evas_resize, | ||
519 | _ecore_evas_move_resize, | ||
520 | _ecore_evas_rotation_set, | ||
521 | NULL, | ||
522 | _ecore_evas_show, | ||
523 | NULL, | ||
524 | NULL, | ||
525 | NULL, | ||
526 | NULL, | ||
527 | NULL, | ||
528 | NULL, | ||
529 | NULL, | ||
530 | NULL, | ||
531 | NULL, | ||
532 | NULL, | ||
533 | _ecore_evas_object_cursor_set, | ||
534 | NULL, | ||
535 | NULL, | ||
536 | NULL, | ||
537 | NULL, | ||
538 | NULL, | ||
539 | NULL, | ||
540 | _ecore_evas_fullscreen_set, | ||
541 | NULL, | ||
542 | NULL, | ||
543 | NULL, | ||
544 | NULL, | ||
545 | NULL, | ||
546 | NULL, //transparent | ||
547 | |||
548 | NULL, // render | ||
549 | NULL // screen_geometry_get | ||
550 | }; | ||
551 | #endif | ||
552 | |||
553 | /** | ||
554 | * To be documented. | ||
555 | * | ||
556 | * FIXME: To be fixed. | ||
557 | */ | ||
558 | #ifdef BUILD_ECORE_EVAS_FB | ||
559 | EAPI Ecore_Evas * | ||
560 | ecore_evas_fb_new(const char *disp_name, int rotation, int w, int h) | ||
561 | { | ||
562 | Evas_Engine_Info_FB *einfo; | ||
563 | Ecore_Evas *ee; | ||
564 | |||
565 | int rmethod; | ||
566 | |||
567 | if (!disp_name) | ||
568 | disp_name = ecore_evas_default_display; | ||
569 | |||
570 | rmethod = evas_render_method_lookup("fb"); | ||
571 | if (!rmethod) return NULL; | ||
572 | |||
573 | if (!ecore_fb_init(disp_name)) return NULL; | ||
574 | ecore_fb_callback_gain_set(_ecore_evas_fb_gain, NULL); | ||
575 | ecore_fb_callback_lose_set(_ecore_evas_fb_lose, NULL); | ||
576 | ee = calloc(1, sizeof(Ecore_Evas)); | ||
577 | if (!ee) return NULL; | ||
578 | |||
579 | ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS); | ||
580 | |||
581 | _ecore_evas_fb_init(ee, w, h); | ||
582 | |||
583 | ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_fb_engine_func; | ||
584 | |||
585 | ee->driver = "fb"; | ||
586 | if (disp_name) ee->name = strdup(disp_name); | ||
587 | |||
588 | if (w < 1) w = 1; | ||
589 | if (h < 1) h = 1; | ||
590 | ee->rotation = rotation; | ||
591 | ee->visible = 1; | ||
592 | ee->w = w; | ||
593 | ee->h = h; | ||
594 | ee->req.w = ee->w; | ||
595 | ee->req.h = ee->h; | ||
596 | |||
597 | ee->prop.max.w = 0; | ||
598 | ee->prop.max.h = 0; | ||
599 | ee->prop.layer = 0; | ||
600 | ee->prop.focused = 1; | ||
601 | ee->prop.borderless = 1; | ||
602 | ee->prop.override = 1; | ||
603 | ee->prop.maximized = 1; | ||
604 | ee->prop.fullscreen = 0; | ||
605 | ee->prop.withdrawn = 0; | ||
606 | ee->prop.sticky = 0; | ||
607 | |||
608 | /* init evas here */ | ||
609 | ee->evas = evas_new(); | ||
610 | evas_data_attach_set(ee->evas, ee); | ||
611 | evas_output_method_set(ee->evas, rmethod); | ||
612 | |||
613 | if ((rotation == 90) || (rotation == 270)) | ||
614 | { | ||
615 | evas_output_size_set(ee->evas, h, w); | ||
616 | evas_output_viewport_set(ee->evas, 0, 0, h, w); | ||
617 | } | ||
618 | else | ||
619 | { | ||
620 | evas_output_size_set(ee->evas, w, h); | ||
621 | evas_output_viewport_set(ee->evas, 0, 0, w, h); | ||
622 | } | ||
623 | |||
624 | einfo = (Evas_Engine_Info_FB *)evas_engine_info_get(ee->evas); | ||
625 | if (einfo) | ||
626 | { | ||
627 | einfo->info.virtual_terminal = 0; | ||
628 | einfo->info.device_number = strtol(disp_name, NULL, 10); | ||
629 | einfo->info.refresh = 0; | ||
630 | einfo->info.rotation = ee->rotation; | ||
631 | if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) | ||
632 | { | ||
633 | ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); | ||
634 | ecore_evas_free(ee); | ||
635 | return NULL; | ||
636 | } | ||
637 | } | ||
638 | else | ||
639 | { | ||
640 | ERR("evas_engine_info_set() init engine '%s' failed.", ee->driver); | ||
641 | ecore_evas_free(ee); | ||
642 | return NULL; | ||
643 | } | ||
644 | |||
645 | ecore_evas_input_event_register(ee); | ||
646 | |||
647 | ee->engine.func->fn_render = _ecore_evas_fb_render; | ||
648 | _ecore_evas_register(ee); | ||
649 | fb_ee = ee; | ||
650 | evas_event_feed_mouse_in(ee->evas, (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff), NULL); | ||
651 | return ee; | ||
652 | } | ||
653 | #else | ||
654 | EAPI Ecore_Evas * | ||
655 | ecore_evas_fb_new(const char *disp_name __UNUSED__, int rotation __UNUSED__, int w __UNUSED__, int h __UNUSED__) | ||
656 | { | ||
657 | return NULL; | ||
658 | } | ||
659 | #endif | ||