6 #include <Ecore_Input.h>
7 #include <Ecore_Input_Evas.h>
9 #include "ecore_evas_private.h"
10 #include "Ecore_Evas.h"
12 #ifdef BUILD_ECORE_EVAS_PSL1GHT
13 #include <Ecore_Psl1ght.h>
14 #include <Evas_Engine_PSL1GHT.h>
16 static int _ecore_evas_init_count = 0;
18 static Ecore_Evas *psl1ght_ee = NULL;
19 static Ecore_Event_Handler *ecore_evas_event_handlers[5] = {
20 NULL, NULL, NULL, NULL
23 static const char *ecore_evas_psl1ght_default = "EFL PSL1GHT";
24 static int _ecore_evas_fps_debug = 0;
25 static Ecore_Poller *ecore_evas_event;
28 _ecore_evas_time_get()
30 return (unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff;
34 _ecore_evas_psl1ght_match(void)
40 _ecore_evas_psl1ght_event_got_focus(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
44 ee = _ecore_evas_psl1ght_match();
46 if (!ee) return ECORE_CALLBACK_PASS_ON;
49 evas_focus_in(ee->evas);
50 if (ee->func.fn_focus_in) ee->func.fn_focus_in(ee);
52 return ECORE_CALLBACK_PASS_ON;
56 _ecore_evas_psl1ght_event_lost_focus(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
60 ee = _ecore_evas_psl1ght_match();
62 if (!ee) return ECORE_CALLBACK_PASS_ON;
64 evas_focus_out(ee->evas);
66 if (ee->func.fn_focus_out) ee->func.fn_focus_out(ee);
68 return ECORE_CALLBACK_PASS_ON;
72 _ecore_evas_psl1ght_event_video_expose(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
78 ee = _ecore_evas_psl1ght_match();
80 if (!ee) return ECORE_CALLBACK_PASS_ON;
81 evas_output_size_get(ee->evas, &w, &h);
82 evas_damage_rectangle_add(ee->evas, 0, 0, w, h);
84 return ECORE_CALLBACK_PASS_ON;
88 _ecore_evas_psl1ght_event_key_modifiers(void *data __UNUSED__, int type __UNUSED__, void *event)
91 Ecore_Psl1ght_Event_Key_Modifiers *e = event;
93 ee = _ecore_evas_psl1ght_match();
95 if (!ee) return ECORE_CALLBACK_PASS_ON;
96 ecore_event_evas_modifier_lock_update(ee->evas, e->modifiers);
98 return ECORE_CALLBACK_PASS_ON;
102 _ecore_evas_psl1ght_event_quit (void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
106 ee = _ecore_evas_psl1ght_match();
108 if (!ee) return ECORE_CALLBACK_PASS_ON; /* pass on event */
109 if (ee->func.fn_delete_request)
110 ee->func.fn_delete_request(ee);
111 return ECORE_CALLBACK_PASS_ON;
115 _ecore_evas_render(Ecore_Evas *ee)
119 updates = evas_render_updates(ee->evas);
122 evas_render_updates_free(updates);
123 _ecore_evas_idle_timeout_update(ee);
125 return updates ? 1 : 0;
129 _ecore_evas_psl1ght_render(Ecore_Evas *ee)
133 #ifdef BUILD_ECORE_EVAS_SOFTWARE_BUFFER
137 EINA_LIST_FOREACH(ee->sub_ecore_evas, ll, ee2)
139 if (ee2->func.fn_pre_render) ee2->func.fn_pre_render(ee2);
140 rend |= _ecore_evas_buffer_render(ee2);
141 if (ee2->func.fn_post_render) ee2->func.fn_post_render(ee2);
145 if (ee->func.fn_pre_render) ee->func.fn_pre_render(ee);
147 if (ee->prop.avoid_damage) rend = _ecore_evas_render(ee);
148 else if ((ee->visible) ||
149 ((ee->should_be_visible) && (ee->prop.fullscreen)) ||
150 ((ee->should_be_visible) && (ee->prop.override)))
151 rend |= _ecore_evas_render(ee);
153 evas_norender(ee->evas);
155 if (ee->func.fn_post_render) ee->func.fn_post_render(ee);
160 _ecore_evas_psl1ght_event(void *data __UNUSED__)
162 ecore_psl1ght_poll_events();
163 return ECORE_CALLBACK_RENEW;
167 _ecore_evas_psl1ght_init(int w __UNUSED__, int h __UNUSED__)
169 _ecore_evas_init_count++;
170 if (_ecore_evas_init_count > 1) return _ecore_evas_init_count;
172 _ecore_evas_fps_debug = 1;
174 // this is pretty bad: poller? and set poll time? pol time is meant to be
175 // adjustable for things like polling battery state, or amoutn of spare
178 ecore_evas_event = ecore_poller_add(ECORE_POLLER_CORE, 1, _ecore_evas_psl1ght_event, NULL);
179 ecore_poller_poll_interval_set(ECORE_POLLER_CORE, 0.006);
181 if (_ecore_evas_fps_debug)
182 _ecore_evas_fps_debug_init();
184 ecore_event_evas_init();
186 ecore_evas_event_handlers[0] =
187 ecore_event_handler_add(ECORE_PSL1GHT_EVENT_GOT_FOCUS,
188 _ecore_evas_psl1ght_event_got_focus, NULL);
189 ecore_evas_event_handlers[1] =
190 ecore_event_handler_add(ECORE_PSL1GHT_EVENT_LOST_FOCUS,
191 _ecore_evas_psl1ght_event_lost_focus, NULL);
192 ecore_evas_event_handlers[2] =
193 ecore_event_handler_add(ECORE_PSL1GHT_EVENT_EXPOSE,
194 _ecore_evas_psl1ght_event_video_expose, NULL);
195 ecore_evas_event_handlers[3] =
196 ecore_event_handler_add(ECORE_PSL1GHT_EVENT_KEY_MODIFIERS,
197 _ecore_evas_psl1ght_event_key_modifiers, NULL);
198 ecore_evas_event_handlers[4] =
199 ecore_event_handler_add(ECORE_PSL1GHT_EVENT_QUIT,
200 _ecore_evas_psl1ght_event_quit, NULL);
202 return _ecore_evas_init_count;
206 _ecore_evas_psl1ght_shutdown(void)
208 _ecore_evas_init_count--;
209 if (_ecore_evas_init_count == 0)
213 for (i = 0; i < sizeof (ecore_evas_event_handlers) / sizeof (Ecore_Event_Handler *); i++)
214 ecore_event_handler_del(ecore_evas_event_handlers[i]);
215 ecore_event_evas_shutdown();
216 ecore_poller_del(ecore_evas_event);
217 ecore_evas_event = NULL;
218 if (_ecore_evas_fps_debug)
219 _ecore_evas_fps_debug_shutdown();
221 if (_ecore_evas_init_count < 0) _ecore_evas_init_count = 0;
222 return _ecore_evas_init_count;
226 _ecore_evas_psl1ght_free(Ecore_Evas *ee)
228 if (psl1ght_ee == ee) psl1ght_ee = NULL;
230 ecore_event_window_unregister(0);
231 _ecore_evas_psl1ght_shutdown();
232 ecore_psl1ght_shutdown();
236 _ecore_evas_psl1ght_callback_delete_request_set(Ecore_Evas *ee, Ecore_Evas_Event_Cb func)
238 ee->func.fn_delete_request = func;
242 _ecore_evas_screen_resized(Ecore_Evas *ee)
246 /* Do not resize if the window is not fullscreen */
247 if (ee->prop.fullscreen == 0) return;
249 ecore_psl1ght_screen_resolution_get (&w, &h);
251 if (w != ee->w || h != ee->h)
253 ee->req.w = ee->w = w;
254 ee->req.h = ee->h = h;
255 evas_output_size_set(ee->evas, ee->w, ee->h);
256 evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h);
257 ecore_psl1ght_resolution_set (w, h);
258 evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
260 _ecore_evas_mouse_move_process(ee, ee->mouse.x, ee->mouse.y,
261 _ecore_evas_time_get());
262 if (ee->func.fn_resize) ee->func.fn_resize(ee);
267 _ecore_evas_resize(Ecore_Evas *ee, int w, int h)
269 if ((w == ee->w) && (h == ee->h)) return;
273 evas_output_size_set(ee->evas, ee->w, ee->h);
275 evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h);
276 evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
278 ecore_psl1ght_resolution_set (w, h);
280 if (ee->func.fn_resize) ee->func.fn_resize(ee);
282 _ecore_evas_screen_resized (ee);
286 _ecore_evas_move_resize(Ecore_Evas *ee, int x __UNUSED__, int y __UNUSED__, int w, int h)
288 _ecore_evas_resize (ee, w, h);
292 _ecore_evas_show(Ecore_Evas *ee)
294 if (ee->prop.focused) return;
295 ee->prop.focused = 1;
296 evas_focus_in(ee->evas);
297 if (ee->func.fn_focus_in) ee->func.fn_focus_in(ee);
301 _ecore_evas_screen_geometry_get(const Ecore_Evas *ee __UNUSED__, int *x, int *y, int *w, int *h)
305 ecore_psl1ght_screen_resolution_get (w, h);
309 _ecore_evas_object_cursor_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
315 ee->prop.cursor.object = NULL;
319 _ecore_evas_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y)
323 if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
327 ee->prop.cursor.object = NULL;
328 ee->prop.cursor.layer = 0;
329 ee->prop.cursor.hot.x = 0;
330 ee->prop.cursor.hot.y = 0;
334 ee->prop.cursor.object = obj;
335 ee->prop.cursor.layer = layer;
336 ee->prop.cursor.hot.x = hot_x;
337 ee->prop.cursor.hot.y = hot_y;
338 evas_pointer_output_xy_get(ee->evas, &x, &y);
339 evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer);
340 evas_object_move(ee->prop.cursor.object,
341 x - ee->prop.cursor.hot.x,
342 y - ee->prop.cursor.hot.y);
343 evas_object_pass_events_set(ee->prop.cursor.object, 1);
344 if (evas_pointer_inside_get(ee->evas))
345 evas_object_show(ee->prop.cursor.object);
347 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, _ecore_evas_object_cursor_del, ee);
350 static Ecore_Evas_Engine_Func _ecore_psl1ght_engine_func =
352 _ecore_evas_psl1ght_free,
357 _ecore_evas_psl1ght_callback_delete_request_set,
370 _ecore_evas_move_resize,
384 _ecore_evas_object_cursor_set,
398 NULL, // profiles_set
408 _ecore_evas_screen_geometry_get, // screen_geometry_get
409 NULL // screen_dpi_get
413 ecore_evas_psl1ght_new(const char *name, int w, int h)
419 name = ecore_evas_psl1ght_default;
421 ee = calloc(1, sizeof(Ecore_Evas));
422 if (!ee) return NULL;
424 ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS);
426 ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_psl1ght_engine_func;
428 ee->driver = "psl1ght";
429 if (name) ee->name = strdup(name);
440 ee->prop.focused = 1;
441 ee->prop.borderless = 1;
442 ee->prop.override = 1;
443 ee->prop.maximized = 1;
444 ee->prop.fullscreen = 0;
445 ee->prop.withdrawn = 0;
450 ee->evas = evas_new();
451 evas_data_attach_set(ee->evas, ee);
452 evas_output_method_set(ee->evas, evas_render_method_lookup("psl1ght"));
454 evas_output_size_set(ee->evas, w, h);
455 evas_output_viewport_set(ee->evas, 0, 0, w, h);
457 einfo = evas_engine_info_get(ee->evas);
460 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
462 ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
469 ERR("evas_engine_info_set() init engine '%s' failed.", ee->driver);
474 if (!ecore_psl1ght_init(name))
477 if (ee->name) free(ee->name);
481 ecore_psl1ght_resolution_set (w, h);
483 _ecore_evas_psl1ght_init(w, h);
485 ecore_event_window_register(0, ee, ee->evas,
486 (Ecore_Event_Mouse_Move_Cb)_ecore_evas_mouse_move_process,
487 (Ecore_Event_Multi_Move_Cb)_ecore_evas_mouse_multi_move_process,
488 (Ecore_Event_Multi_Down_Cb)_ecore_evas_mouse_multi_down_process,
489 (Ecore_Event_Multi_Up_Cb)_ecore_evas_mouse_multi_up_process);
491 ee->engine.func->fn_render = _ecore_evas_psl1ght_render;
492 _ecore_evas_register(ee);
496 _ecore_evas_screen_resized (ee);
498 if (getenv("ECORE_EVAS_PSL1GHT_CURSOR_PATH"))
499 ecore_evas_cursor_set(ee, getenv("ECORE_EVAS_PSL1GHT_CURSOR_PATH"), EVAS_LAYER_MAX, 0, 0);
501 evas_event_feed_mouse_in(ee->evas, (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff), NULL);
506 #else /* BUILD_ECORE_EVAS_PSL1GHT */
509 ecore_evas_psl1ght_new(const char *name __UNUSED__, int w __UNUSED__, int h __UNUSED__)
515 #endif /* BUILD_ECORE_EVAS_PSL1GHT */