8 #include "ecore_private.h"
9 #ifdef BUILD_ECORE_EVAS_DIRECTFB
10 #include <Ecore_DirectFB.h>
13 #include "ecore_evas_private.h"
14 #include "Ecore_Evas.h"
16 #ifdef BUILD_ECORE_EVAS_DIRECTFB
17 static int _ecore_evas_init_count = 0;
18 static Ecore_Event_Handler *ecore_evas_event_handlers[13];
20 static Eina_Hash *ecore_evases_hash = NULL;
23 _ecore_evas_directfb_render(Ecore_Evas *ee)
25 Eina_List *updates, *ll;
29 #ifdef BUILD_ECORE_EVAS_SOFTWARE_BUFFER
30 EINA_LIST_FOREACH(ee->sub_ecore_evas, ll, ee2)
32 if (ee2->func.fn_pre_render) ee2->func.fn_pre_render(ee2);
33 rend |= _ecore_evas_buffer_render(ee2);
34 if (ee2->func.fn_post_render) ee2->func.fn_post_render(ee2);
37 if (ee->func.fn_pre_render) ee->func.fn_pre_render(ee);
38 updates = evas_render_updates(ee->evas);
41 evas_render_updates_free(updates);
42 _ecore_evas_idle_timeout_update(ee);
44 if (ee->func.fn_post_render) ee->func.fn_post_render(ee);
46 return updates ? 1 : rend;
50 _ecore_evas_directfb_winid_str_get(Ecore_X_Window win)
52 const char *vals = "qWeRtYuIoP5$&<~";
55 val = (unsigned int)win;
56 id[0] = vals[(val >> 28) & 0xf];
57 id[1] = vals[(val >> 24) & 0xf];
58 id[2] = vals[(val >> 20) & 0xf];
59 id[3] = vals[(val >> 16) & 0xf];
60 id[4] = vals[(val >> 12) & 0xf];
61 id[5] = vals[(val >> 8) & 0xf];
62 id[6] = vals[(val >> 4) & 0xf];
63 id[7] = vals[(val ) & 0xf];
69 _ecore_evas_directfb_match(DFBWindowID win)
73 ee = eina_hash_find(ecore_evases_hash, _ecore_evas_directfb_winid_str_get(win));
78 _ecore_evas_directfb_event_key_down(void *data __UNUSED__, int type __UNUSED__, void *event)
81 Ecore_DirectFB_Event_Key_Down *e;
84 ee = _ecore_evas_directfb_match(e->win);
86 if (!ee) return EINA_TRUE; /* pass on event */
87 evas_event_feed_key_down(ee->evas, e->name, e->name, e->string,
88 e->key_compose, e->time, NULL);
93 _ecore_evas_directfb_event_key_up(void *data __UNUSED__, int type __UNUSED__, void *event)
96 Ecore_DirectFB_Event_Key_Up *e;
99 ee = _ecore_evas_directfb_match(e->win);
101 if (!ee) return EINA_TRUE; /* pass on event */
102 evas_event_feed_key_up(ee->evas, e->name, e->name, e->string,
103 e->key_compose, e->time, NULL);
108 _ecore_evas_directfb_event_motion(void *data __UNUSED__, int type __UNUSED__, void *event)
111 Ecore_DirectFB_Event_Motion *e;
114 ee = _ecore_evas_directfb_match(e->win);
116 if (!ee) return EINA_TRUE; /* pass on event */
117 _ecore_evas_mouse_move_process(ee, e->x, e->y, e->time);
122 _ecore_evas_directfb_event_button_down(void *data __UNUSED__, int type __UNUSED__, void *event)
125 Ecore_DirectFB_Event_Button_Down *e;
128 ee = _ecore_evas_directfb_match(e->win);
130 if (!ee) return EINA_TRUE; /* pass on event */
131 // _ecore_evas_mouse_move_process(ee, e->x, e->y, e->time);
132 evas_event_feed_mouse_down(ee->evas, e->button, EVAS_BUTTON_NONE, e->time, NULL);
137 _ecore_evas_directfb_event_button_up(void *data __UNUSED__, int type __UNUSED__, void *event)
140 Ecore_DirectFB_Event_Button_Up *e;
141 Evas_Button_Flags flags = EVAS_BUTTON_NONE;
144 ee = _ecore_evas_directfb_match(e->win);
146 if (!ee) return EINA_TRUE; /* pass on event */
147 //_ecore_evas_mouse_move_process(ee, e->x, e->y, e->time);
148 evas_event_feed_mouse_up(ee->evas, e->button, flags, e->time, NULL);
153 _ecore_evas_directfb_event_enter(void *data __UNUSED__, int type __UNUSED__, void *event)
156 Ecore_DirectFB_Event_Enter *e;
159 ee = _ecore_evas_directfb_match(e->win);
161 if (!ee) return EINA_TRUE; /* pass on event */
162 evas_event_feed_mouse_in(ee->evas, e->time, NULL);
163 //_ecore_evas_mouse_move_process(ee, e->x, e->y, e->time);
168 _ecore_evas_directfb_event_leave(void *data __UNUSED__, int type __UNUSED__, void *event)
171 Ecore_DirectFB_Event_Leave *e;
174 ee = _ecore_evas_directfb_match(e->win);
176 if (!ee) return EINA_TRUE; /* pass on event */
177 evas_event_feed_mouse_out(ee->evas, e->time, NULL);
178 //_ecore_evas_mouse_move_process(ee, e->x, e->y, e->time);
179 if (ee->func.fn_mouse_out) ee->func.fn_mouse_out(ee);
180 if (ee->prop.cursor.object) evas_object_hide(ee->prop.cursor.object);
185 _ecore_evas_directfb_event_wheel(void *data __UNUSED__, int type __UNUSED__, void *event)
188 Ecore_DirectFB_Event_Wheel *e;
191 ee = _ecore_evas_directfb_match(e->win);
193 if (!ee) return EINA_TRUE; /* pass on event */
194 evas_event_feed_mouse_wheel(ee->evas, e->direction, e->z, e->time, NULL);
199 _ecore_evas_directfb_event_got_focus(void *data __UNUSED__, int type __UNUSED__, void *event)
202 Ecore_DirectFB_Event_Got_Focus *e;
205 ee = _ecore_evas_directfb_match(e->win);
207 if (!ee) return EINA_TRUE; /* pass on event */
208 ee->prop.focused = 1;
213 _ecore_evas_directfb_event_lost_focus(void *data __UNUSED__, int type __UNUSED__, void *event)
216 Ecore_DirectFB_Event_Lost_Focus *e;
219 ee = _ecore_evas_directfb_match(e->win);
221 if (!ee) return EINA_TRUE; /* pass on event */
222 ee->prop.focused = 0;
227 _ecore_evas_directfb_shutdown(void)
229 _ecore_evas_init_count--;
230 if (_ecore_evas_init_count == 0)
234 for (i = 0; i < 8; i++)
235 ecore_event_handler_del(ecore_evas_event_handlers[i]);
237 if (_ecore_evas_init_count < 0) _ecore_evas_init_count = 0;
238 return _ecore_evas_init_count;
246 _ecore_evas_directfb_init(void)
248 _ecore_evas_init_count++;
249 if (_ecore_evas_init_count > 1) return _ecore_evas_init_count;
251 ecore_evas_event_handlers[0] = ecore_event_handler_add(ECORE_DIRECTFB_EVENT_KEY_DOWN, _ecore_evas_directfb_event_key_down, NULL);
252 ecore_evas_event_handlers[1] = ecore_event_handler_add(ECORE_DIRECTFB_EVENT_KEY_UP, _ecore_evas_directfb_event_key_up, NULL);
253 ecore_evas_event_handlers[2] = ecore_event_handler_add(ECORE_DIRECTFB_EVENT_BUTTON_DOWN, _ecore_evas_directfb_event_button_down, NULL);
254 ecore_evas_event_handlers[3] = ecore_event_handler_add(ECORE_DIRECTFB_EVENT_BUTTON_UP, _ecore_evas_directfb_event_button_up, NULL);
255 ecore_evas_event_handlers[4] = ecore_event_handler_add(ECORE_DIRECTFB_EVENT_MOTION, _ecore_evas_directfb_event_motion, NULL);
256 ecore_evas_event_handlers[5] = ecore_event_handler_add(ECORE_DIRECTFB_EVENT_ENTER, _ecore_evas_directfb_event_enter, NULL);
257 ecore_evas_event_handlers[6] = ecore_event_handler_add(ECORE_DIRECTFB_EVENT_LEAVE, _ecore_evas_directfb_event_leave, NULL);
258 ecore_evas_event_handlers[7] = ecore_event_handler_add(ECORE_DIRECTFB_EVENT_WHEEL, _ecore_evas_directfb_event_wheel, NULL);
259 ecore_evas_event_handlers[8] = ecore_event_handler_add(ECORE_DIRECTFB_EVENT_GOT_FOCUS, _ecore_evas_directfb_event_got_focus, NULL);
260 ecore_evas_event_handlers[9] = ecore_event_handler_add(ECORE_DIRECTFB_EVENT_LOST_FOCUS, _ecore_evas_directfb_event_lost_focus, NULL);
261 ecore_evas_event_handlers[10] = NULL;
262 ecore_evas_event_handlers[11] = NULL;
263 ecore_evas_event_handlers[12] = NULL;
265 return _ecore_evas_init_count;
268 /* engine functions */
269 /********************/
272 _ecore_evas_directfb_free(Ecore_Evas *ee)
274 eina_hash_del(ecore_evases_hash, _ecore_evas_directfb_winid_str_get(ee->engine.directfb.window->id), ee);
275 ecore_directfb_window_free(ee->engine.directfb.window);
276 _ecore_evas_directfb_shutdown();
277 ecore_directfb_shutdown();
281 _ecore_evas_directfb_move(Ecore_Evas *ee, int x, int y)
283 ecore_directfb_window_move(ee->engine.directfb.window, x, y);
287 _ecore_evas_directfb_resize(Ecore_Evas *ee, int w, int h)
289 if ((w == ee->w) && (h == ee->h)) return;
290 ecore_directfb_window_resize(ee->engine.directfb.window, w, h);
293 if ((ee->rotation == 90) || (ee->rotation == 270))
295 evas_output_size_set(ee->evas, ee->h, ee->w);
296 evas_output_viewport_set(ee->evas, 0, 0, ee->h, ee->w);
300 evas_output_size_set(ee->evas, ee->w, ee->h);
301 evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h);
306 _ecore_evas_directfb_focus_set(Ecore_Evas *ee, int on __UNUSED__)
308 ecore_directfb_window_focus(ee->engine.directfb.window);
312 _ecore_evas_directfb_hide(Ecore_Evas *ee)
314 ecore_directfb_window_hide(ee->engine.directfb.window);
315 ee->should_be_visible = 0;
319 _ecore_evas_directfb_show(Ecore_Evas *ee)
321 ecore_directfb_window_show(ee->engine.directfb.window);
322 ee->should_be_visible = 1;
326 _ecore_evas_directfb_shaped_set(Ecore_Evas *ee, int shaped)
328 if (((ee->shaped) && (shaped)) || ((!ee->shaped) && (!shaped)))
332 ecore_directfb_window_shaped_set(ee->engine.directfb.window, 1);
334 ecore_directfb_window_shaped_set(ee->engine.directfb.window, 0);
339 _ecore_evas_object_cursor_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
345 ee->prop.cursor.object = NULL;
349 _ecore_evas_directfb_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y)
353 if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
357 ee->prop.cursor.object = NULL;
358 ee->prop.cursor.layer = 0;
359 ee->prop.cursor.hot.x = 0;
360 ee->prop.cursor.hot.y = 0;
361 ecore_directfb_window_cursor_show(ee->engine.directfb.window, 1);
366 ee->prop.cursor.object = obj;
367 ee->prop.cursor.layer = layer;
368 ee->prop.cursor.hot.x = hot_x;
369 ee->prop.cursor.hot.y = hot_y;
371 ecore_directfb_window_cursor_show(ee->engine.directfb.window, 0);
373 evas_pointer_output_xy_get(ee->evas, &x, &y);
374 evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer);
375 evas_object_move(ee->prop.cursor.object,x - ee->prop.cursor.hot.x,y - ee->prop.cursor.hot.y);
376 evas_object_pass_events_set(ee->prop.cursor.object, 1);
377 if (evas_pointer_inside_get(ee->evas))
378 evas_object_show(ee->prop.cursor.object);
380 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, _ecore_evas_object_cursor_del, ee);
384 _ecore_evas_directfb_fullscreen_set(Ecore_Evas *ee, int on)
386 Evas_Engine_Info_DirectFB *einfo;
391 if (((ee->prop.fullscreen) && (on)) || ((!ee->prop.fullscreen) && (!on)))
395 ecore_directfb_window_fullscreen_set(ee->engine.directfb.window, 1);
397 ecore_directfb_window_fullscreen_set(ee->engine.directfb.window, 0);
398 /* set the new size of the evas */
399 ecore_directfb_window_size_get(ee->engine.directfb.window, &w, &h);
400 if( (ee->w != w) || (ee->h != h))
405 if ((ee->rotation == 90) || (ee->rotation == 270))
407 evas_output_size_set(ee->evas, ee->h, ee->w);
408 evas_output_viewport_set(ee->evas, 0, 0, ee->h, ee->w);
412 evas_output_size_set(ee->evas, ee->w, ee->h);
413 evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h);
416 einfo = (Evas_Engine_Info_DirectFB *)evas_engine_info_get(ee->evas);
419 einfo->info.surface = ee->engine.directfb.window->surface;
420 evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
422 ee->prop.fullscreen = on;
425 if(ee->func.fn_resize) ee->func.fn_resize(ee);
430 _ecore_evas_directfb_window_get(const Ecore_Evas *ee)
432 return ee->engine.directfb.window;
436 #ifdef BUILD_ECORE_EVAS_DIRECTFB
437 static Ecore_Evas_Engine_Func _ecore_directfb_engine_func =
439 _ecore_evas_directfb_free, /* free an ecore_evas */
440 NULL, /* cb resize */
444 NULL, /* cb delete request */
445 NULL, /* cb destroy */
446 NULL, /* cb focus in */
447 NULL, /* cb focus out */
448 NULL, /* cb sticky */
449 NULL, /* cb unsticky */
450 NULL, /* cb mouse in */
451 NULL, /* cb mouse out */
452 NULL, /* cb pre render */
453 NULL, /* cb post render */
454 _ecore_evas_directfb_move, /* move */
455 NULL, /* managed move */
456 _ecore_evas_directfb_resize, /* resize */
457 NULL, /* move resize */
458 NULL,//_ecore_evas_directfb_rotation_set,/* rotation */
459 _ecore_evas_directfb_shaped_set, /* shaped */
460 _ecore_evas_directfb_show, /* show */
461 _ecore_evas_directfb_hide, /* hide */
465 NULL, /* title set */
466 NULL, /* name class set */
469 NULL, /* size base */
470 NULL, /* size step */
471 _ecore_evas_directfb_object_cursor_set, /* set cursor to an evas object */
472 NULL, /* layer set */
473 _ecore_evas_directfb_focus_set, /* focus */
474 NULL, /* iconified */
475 NULL, /* borderless */
477 NULL, /* maximized */
478 _ecore_evas_directfb_fullscreen_set,/* fullscreen */
479 NULL, /* avoid damage */
480 NULL, /* withdrawn */
482 NULL, /* ignore events */
493 #ifdef BUILD_ECORE_EVAS_DIRECTFB
495 ecore_evas_directfb_new(const char *disp_name, int windowed, int x, int y, int w, int h)
497 Evas_Engine_Info_DirectFB *einfo;
499 Ecore_DirectFB_Window *window;
502 rmethod = evas_render_method_lookup("directfb");
503 if (!rmethod) return NULL;
504 if (!ecore_directfb_init(disp_name)) return NULL;
505 ee = calloc(1, sizeof(Ecore_Evas));
506 if (!ee) return NULL;
508 ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS);
509 _ecore_evas_directfb_init();
510 ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_directfb_engine_func;
512 ee->driver = "directfb";
513 if (disp_name) ee->name = strdup(disp_name);
525 ee->prop.fullscreen = 0;
528 ee->evas = evas_new();
529 evas_data_attach_set(ee->evas, ee);
530 evas_output_method_set(ee->evas, rmethod);
531 evas_output_size_set(ee->evas, w, h);
532 evas_output_viewport_set(ee->evas, 0, 0, w, h);
533 einfo = (Evas_Engine_Info_DirectFB *)evas_engine_info_get(ee->evas);
535 window = ecore_directfb_window_new(x,y,w,h);
536 ee->engine.directfb.window = window;
539 einfo->info.dfb = ecore_directfb_interface_get();
540 einfo->info.surface = window->surface;
541 evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
544 ee->engine.func->fn_render = _ecore_evas_directfb_render;
545 _ecore_evas_register(ee);
547 if (!ecore_evases_hash)
548 ecore_evases_hash = eina_hash_string_superfast_new(NULL);
549 eina_hash_add(ecore_evases_hash, _ecore_evas_directfb_winid_str_get(ee->engine.directfb.window->id), ee);
555 ecore_evas_directfb_new(const char *disp_name __UNUSED__, int windowed __UNUSED__, int x __UNUSED__, int y __UNUSED__, int w __UNUSED__, int h __UNUSED__)
561 #ifdef BUILD_ECORE_EVAS_DIRECTFB
562 EAPI Ecore_DirectFB_Window *
563 ecore_evas_directfb_window_get(const Ecore_Evas *ee)
565 return (Ecore_DirectFB_Window *) _ecore_evas_directfb_window_get(ee);
568 EAPI Ecore_DirectFB_Window *
569 ecore_evas_directfb_window_get(const Ecore_Evas *ee __UNUSED__)