2 * Copyright 2013 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <Elementary.h>
21 #include <Ecore_Evas.h>
31 #include <widget_errno.h>
32 #include <widget_service.h>
33 #include <widget_service_internal.h>
34 #include <widget_conf.h>
35 #include <widget_buffer.h>
36 #include <widget_provider.h>
37 #include <widget_util.h>
40 #include "widget_internal.h"
46 #define PUBLIC __attribute__((visibility("default")))
47 #define WIDGET_WIN_TAG "dynamic,box,win"
49 #define WIDGET_DEFAULT_WIDTH 1
50 #define WIDGET_DEFAULT_HEIGHT 1
52 static inline Evas_Object *get_highlighted_object(Evas_Object *obj)
56 o = evas_object_name_find(evas_object_evas_get(obj), "_elm_access_disp");
59 ho = evas_object_data_get(o, "_elm_access_target");
63 static inline void apply_orientation(int degree, int *x, int *y, input_event_source_e source)
69 if (source == INPUT_EVENT_SOURCE_VIEWER) {
105 *x = (double)_x * cos((double)_angle) - (double)_y * sin((double)_angle);
106 *y = (double)_x * sin((double)_angle) + (double)_y * cos((double)_angle);
113 * Every user event (mouse) on the buffer will be passed via this event callback
115 static int event_handler_cb(widget_buffer_h handler, struct widget_buffer_event_data *event_info, void *data)
117 vwin_info_t info = data;
118 Elm_Access_Action_Info action_info;
119 Elm_Access_Action_Type action_type;
121 Evas_Object *parent_elm;
123 unsigned int flags = 0;
127 /* Just ignore this event */
131 if (WIDGET_CONF_USE_GETTIMEOFDAY) {
132 if (WIDGET_CONF_EVENT_FILTER > 0.0f && (info->pressed == 0 || event_info->type == WIDGET_BUFFER_EVENT_MOVE)) {
135 if (gettimeofday(&tv, NULL) < 0) {
136 ErrPrint("gettimeofday: %d\n", errno);
138 timestamp = (double)tv.tv_sec + (double)tv.tv_usec / 1000000.0f;
139 timestamp -= event_info->timestamp;
141 if (timestamp > WIDGET_CONF_EVENT_FILTER) {
142 DbgPrint("Dropped %lf\n", timestamp);
149 * If the device doesn't use the clock monotic time, we have to emulate it for EVAS
150 * Evas only use the monotic time for animating objects
152 timestamp = ecore_time_get() * 1000.0f;
154 if (WIDGET_CONF_EVENT_FILTER > 0.0f && (info->pressed == 0 || event_info->type == WIDGET_BUFFER_EVENT_MOVE)) {
155 timestamp = ecore_time_get();
157 timestamp -= event_info->timestamp;
158 if (timestamp > WIDGET_CONF_EVENT_FILTER) {
159 DbgPrint("Dropped %lf\n", timestamp);
164 timestamp = event_info->timestamp * 1000.0f;
171 switch (event_info->type) {
172 case WIDGET_BUFFER_EVENT_ON_HOLD:
173 flags = evas_event_default_flags_get(info->e);
174 flags |= EVAS_EVENT_FLAG_ON_HOLD;
175 evas_event_default_flags_set(info->e, flags);
176 ErrPrint("ON_HOLD[%s] %dx%d - %lf\n", info->id, event_info->info.pointer.x, event_info->info.pointer.y, timestamp);
178 case WIDGET_BUFFER_EVENT_OFF_HOLD:
179 flags = evas_event_default_flags_get(info->e);
180 flags &= ~EVAS_EVENT_FLAG_ON_HOLD;
181 evas_event_default_flags_set(info->e, flags);
183 case WIDGET_BUFFER_EVENT_ON_SCROLL:
184 flags = evas_event_default_flags_get(info->e);
185 flags |= EVAS_EVENT_FLAG_ON_SCROLL;
186 evas_event_default_flags_set(info->e, flags);
188 case WIDGET_BUFFER_EVENT_OFF_SCROLL:
189 flags = evas_event_default_flags_get(info->e);
190 flags &= ~EVAS_EVENT_FLAG_ON_SCROLL;
191 evas_event_default_flags_set(info->e, flags);
193 case WIDGET_BUFFER_EVENT_ENTER:
194 evas_event_feed_mouse_in(info->e, timestamp, NULL);
196 case WIDGET_BUFFER_EVENT_LEAVE:
197 evas_event_feed_mouse_out(info->e, timestamp, NULL);
199 case WIDGET_BUFFER_EVENT_DOWN:
200 apply_orientation(info->orientation, &event_info->info.pointer.x, &event_info->info.pointer.y, event_info->info.pointer.source);
203 ErrPrint("MOUSE UP is not called\n");
204 ErrPrint("UP[%s] %dx%d - %lf\n", info->id, event_info->info.pointer.x, event_info->info.pointer.y, timestamp);
205 evas_event_feed_mouse_move(info->e, event_info->info.pointer.x, event_info->info.pointer.y, timestamp, NULL);
206 evas_event_feed_mouse_up(info->e, 1, EVAS_BUTTON_NONE, timestamp, NULL);
211 * Before processing the DOWN event,
212 * Reset the evas event flags regarding ON_HOLD option.
213 * It can be re-enabled while processing down-move-up events.
215 flags = evas_event_default_flags_get(info->e);
216 flags &= ~EVAS_EVENT_FLAG_ON_SCROLL;
217 flags &= ~EVAS_EVENT_FLAG_ON_HOLD;
218 evas_event_default_flags_set(info->e, flags);
221 * Calculate the event occurred X & Y on the buffer
223 evas_event_feed_mouse_move(info->e, event_info->info.pointer.x, event_info->info.pointer.y, timestamp, NULL);
224 evas_event_feed_mouse_down(info->e, 1, EVAS_BUTTON_NONE, timestamp, NULL); /* + 0.2f just for fake event */
226 ErrPrint("DOWN[%s] %dx%d - %lf\n", info->id, event_info->info.pointer.x, event_info->info.pointer.y, timestamp);
228 case WIDGET_BUFFER_EVENT_MOVE:
229 apply_orientation(info->orientation, &event_info->info.pointer.x, &event_info->info.pointer.y, event_info->info.pointer.source);
232 * Calculate the event occurred X & Y on the buffer
234 evas_event_feed_mouse_move(info->e, event_info->info.pointer.x, event_info->info.pointer.y, timestamp, NULL);
236 case WIDGET_BUFFER_EVENT_UP:
237 apply_orientation(info->orientation, &event_info->info.pointer.x, &event_info->info.pointer.y, event_info->info.pointer.source);
238 evas_event_feed_mouse_move(info->e, event_info->info.pointer.x, event_info->info.pointer.y, timestamp, NULL);
239 evas_event_feed_mouse_up(info->e, 1, EVAS_BUTTON_NONE, timestamp, NULL);
243 * We have to keep the event flags, so we should not clear them from here.
244 * Sometimes, asynchronously callable Callbacks can refer the evas event flags after up event.
245 * so if we reset them from here, those kind of callbacks will fails to do their job properly.
247 ErrPrint("UP[%s] %dx%d - %lf\n", info->id, event_info->info.pointer.x, event_info->info.pointer.y, timestamp);
249 case WIDGET_BUFFER_EVENT_ACCESS_HIGHLIGHT:
250 parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG);
252 ret = WIDGET_ACCESS_STATUS_ERROR;
255 memset(&action_info, 0, sizeof(action_info));
256 action_type = ELM_ACCESS_ACTION_HIGHLIGHT;
259 * Calculate the event occurred X & Y on the buffer
261 action_info.x = event_info->info.access.x;
262 action_info.y = event_info->info.access.y;
263 ret = elm_access_action(parent_elm, action_type, &action_info);
264 if (ret == EINA_TRUE) {
265 if (!get_highlighted_object(parent_elm)) {
266 ErrPrint("Highlighted object is not found\n");
267 ret = WIDGET_ACCESS_STATUS_ERROR;
269 DbgPrint("Highlighted object is found\n");
270 ret = WIDGET_ACCESS_STATUS_DONE;
273 ErrPrint("Action error\n");
274 ret = WIDGET_ACCESS_STATUS_ERROR;
277 case WIDGET_BUFFER_EVENT_ACCESS_HIGHLIGHT_NEXT:
278 parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG);
280 ret = WIDGET_ACCESS_STATUS_ERROR;
283 memset(&action_info, 0, sizeof(action_info));
284 action_type = ELM_ACCESS_ACTION_HIGHLIGHT_NEXT;
285 action_info.highlight_cycle = EINA_FALSE;
286 ret = elm_access_action(parent_elm, action_type, &action_info);
287 ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_LAST : WIDGET_ACCESS_STATUS_DONE;
289 case WIDGET_BUFFER_EVENT_ACCESS_HIGHLIGHT_PREV:
290 parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG);
292 ret = WIDGET_ACCESS_STATUS_ERROR;
295 memset(&action_info, 0, sizeof(action_info));
296 action_type = ELM_ACCESS_ACTION_HIGHLIGHT_PREV;
297 action_info.highlight_cycle = EINA_FALSE;
298 ret = elm_access_action(parent_elm, action_type, &action_info);
299 ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_FIRST : WIDGET_ACCESS_STATUS_DONE;
301 case WIDGET_BUFFER_EVENT_ACCESS_ACTIVATE:
302 parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG);
304 ret = WIDGET_ACCESS_STATUS_ERROR;
307 memset(&action_info, 0, sizeof(action_info));
308 action_type = ELM_ACCESS_ACTION_ACTIVATE;
309 ret = elm_access_action(parent_elm, action_type, &action_info);
310 ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE;
312 case WIDGET_BUFFER_EVENT_ACCESS_ACTION_UP:
313 parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG);
315 ret = WIDGET_ACCESS_STATUS_ERROR;
318 memset(&action_info, 0, sizeof(action_info));
319 action_type = ELM_ACCESS_ACTION_UP;
320 ret = elm_access_action(parent_elm, action_type, &action_info);
321 ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE;
323 case WIDGET_BUFFER_EVENT_ACCESS_ACTION_DOWN:
324 parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG);
326 ret = WIDGET_ACCESS_STATUS_ERROR;
329 memset(&action_info, 0, sizeof(action_info));
330 action_type = ELM_ACCESS_ACTION_DOWN;
331 ret = elm_access_action(parent_elm, action_type, &action_info);
332 ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE;
334 case WIDGET_BUFFER_EVENT_ACCESS_SCROLL_UP:
335 parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG);
337 ret = WIDGET_ACCESS_STATUS_ERROR;
340 memset(&action_info, 0, sizeof(action_info));
341 action_type = ELM_ACCESS_ACTION_SCROLL;
342 action_info.x = event_info->info.access.x;
343 action_info.y = event_info->info.access.y;
344 action_info.mouse_type = event_info->info.access.mouse_type;
345 ret = elm_access_action(parent_elm, action_type, &action_info);
346 ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE;
348 case WIDGET_BUFFER_EVENT_ACCESS_SCROLL_MOVE:
349 parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG);
351 ret = WIDGET_ACCESS_STATUS_ERROR;
354 memset(&action_info, 0, sizeof(action_info));
355 action_type = ELM_ACCESS_ACTION_SCROLL;
356 action_info.x = event_info->info.access.x;
357 action_info.y = event_info->info.access.y;
358 action_info.mouse_type = event_info->info.access.mouse_type;
359 ret = elm_access_action(parent_elm, action_type, &action_info);
360 ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE;
362 case WIDGET_BUFFER_EVENT_ACCESS_SCROLL_DOWN:
363 parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG);
365 ret = WIDGET_ACCESS_STATUS_ERROR;
368 memset(&action_info, 0, sizeof(action_info));
369 action_type = ELM_ACCESS_ACTION_SCROLL;
370 action_info.x = event_info->info.access.x;
371 action_info.y = event_info->info.access.y;
372 action_info.mouse_type = event_info->info.access.mouse_type;
373 ret = elm_access_action(parent_elm, action_type, &action_info);
374 ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE;
376 case WIDGET_BUFFER_EVENT_ACCESS_UNHIGHLIGHT:
377 parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG);
379 ret = WIDGET_ACCESS_STATUS_ERROR;
382 memset(&action_info, 0, sizeof(action_info));
383 action_type = ELM_ACCESS_ACTION_UNHIGHLIGHT;
384 ret = elm_access_action(parent_elm, action_type, &action_info);
385 ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE;
387 case WIDGET_BUFFER_EVENT_ACCESS_VALUE_CHANGE:
388 parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG);
390 ret = WIDGET_ACCESS_STATUS_ERROR;
393 memset(&action_info, 0, sizeof(action_info));
394 action_type = ELM_ACCESS_ACTION_VALUE_CHANGE;
395 action_info.x = event_info->info.access.x;
396 action_info.y = event_info->info.access.y;
397 action_info.mouse_type = event_info->info.access.mouse_type;
398 ret = elm_access_action(parent_elm, action_type, &action_info);
399 ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE;
401 case WIDGET_BUFFER_EVENT_ACCESS_MOUSE:
402 parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG);
404 ret = WIDGET_ACCESS_STATUS_ERROR;
407 memset(&action_info, 0, sizeof(action_info));
408 action_type = ELM_ACCESS_ACTION_MOUSE;
409 action_info.x = event_info->info.access.x;
410 action_info.y = event_info->info.access.y;
411 action_info.mouse_type = event_info->info.access.mouse_type;
412 ret = elm_access_action(parent_elm, action_type, &action_info);
413 ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE;
415 case WIDGET_BUFFER_EVENT_ACCESS_BACK:
416 parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG);
418 ret = WIDGET_ACCESS_STATUS_ERROR;
421 memset(&action_info, 0, sizeof(action_info));
422 action_type = ELM_ACCESS_ACTION_BACK;
423 action_info.x = event_info->info.access.x;
424 action_info.y = event_info->info.access.y;
425 action_info.mouse_type = event_info->info.access.mouse_type;
426 ret = elm_access_action(parent_elm, action_type, &action_info);
427 ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE;
429 case WIDGET_BUFFER_EVENT_ACCESS_OVER:
430 parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG);
432 ret = WIDGET_ACCESS_STATUS_ERROR;
435 memset(&action_info, 0, sizeof(action_info));
436 action_type = ELM_ACCESS_ACTION_OVER;
437 action_info.x = event_info->info.access.x;
438 action_info.y = event_info->info.access.y;
439 action_info.mouse_type = event_info->info.access.mouse_type;
440 ret = elm_access_action(parent_elm, action_type, &action_info);
441 ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE;
443 case WIDGET_BUFFER_EVENT_ACCESS_READ:
444 parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG);
446 ret = WIDGET_ACCESS_STATUS_ERROR;
449 memset(&action_info, 0, sizeof(action_info));
450 action_type = ELM_ACCESS_ACTION_READ;
451 action_info.x = event_info->info.access.x;
452 action_info.y = event_info->info.access.y;
453 action_info.mouse_type = event_info->info.access.mouse_type;
454 ret = elm_access_action(parent_elm, action_type, &action_info);
455 ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE;
457 case WIDGET_BUFFER_EVENT_ACCESS_ENABLE:
458 parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG);
460 ret = WIDGET_ACCESS_STATUS_ERROR;
463 memset(&action_info, 0, sizeof(action_info));
464 action_type = ELM_ACCESS_ACTION_ENABLE;
465 action_info.x = event_info->info.access.x;
466 action_info.y = event_info->info.access.y;
467 action_info.mouse_type = event_info->info.access.mouse_type;
468 ret = elm_access_action(parent_elm, action_type, &action_info);
469 ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE;
471 case WIDGET_BUFFER_EVENT_ACCESS_DISABLE:
472 parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG);
474 ret = WIDGET_ACCESS_STATUS_ERROR;
477 memset(&action_info, 0, sizeof(action_info));
478 action_type = ELM_ACCESS_ACTION_DISABLE;
479 action_info.x = event_info->info.access.x;
480 action_info.y = event_info->info.access.y;
481 action_info.mouse_type = event_info->info.access.mouse_type;
482 ret = elm_access_action(parent_elm, action_type, &action_info);
483 ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE;
485 case WIDGET_BUFFER_EVENT_KEY_DOWN:
486 parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG);
488 ret = WIDGET_ACCESS_STATUS_ERROR;
492 key_symbol = XGetKeyboardMapping(ecore_x_display_get(), event_info->info.keycode, 1, &ret);
497 key_string = XKeysymToString(*key_symbol);
498 key_name = XKeysymToString(*key_symbol);
499 DbgPrint("Key symbol: %s, name: %s\n", key_string, key_name);
504 ret = WIDGET_KEY_STATUS_ERROR;
506 case WIDGET_BUFFER_EVENT_KEY_UP:
507 parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG);
509 ret = WIDGET_ACCESS_STATUS_ERROR;
513 key_symbol = XGetKeyboardMapping(ecore_x_display_get(), event_info->info.keycode, 1, &ret);
518 key_string = XKeysymToString(*key_symbol);
519 key_name = XKeysymToString(*key_symbol);
520 DbgPrint("Key symbol: %s, name: %s\n", key_string, key_name);
525 ret = WIDGET_KEY_STATUS_ERROR;
527 case WIDGET_BUFFER_EVENT_KEY_FOCUS_IN:
528 parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG);
530 ret = WIDGET_ACCESS_STATUS_ERROR;
534 key_symbol = XGetKeyboardMapping(ecore_x_display_get(), event_info->info.keycode, 1, &ret);
539 key_string = XKeysymToString(*key_symbol);
540 key_name = XKeysymToString(*key_symbol);
541 DbgPrint("Key symbol: %s, name: %s\n", key_string, key_name);
546 ret = WIDGET_KEY_STATUS_ERROR;
548 case WIDGET_BUFFER_EVENT_KEY_FOCUS_OUT:
549 parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG);
551 ret = WIDGET_ACCESS_STATUS_ERROR;
555 key_symbol = XGetKeyboardMapping(ecore_x_display_get(), event_info->info.keycode, 1, &ret);
560 key_string = XKeysymToString(*key_symbol);
561 key_name = XKeysymToString(*key_symbol);
562 DbgPrint("Key symbol: %s, name: %s\n", key_string, key_name);
567 ret = WIDGET_KEY_STATUS_ERROR;
570 DbgPrint("Unhandled buffer event (%d)\n", event_info->type);
577 static void pre_render_cb(void *data, Evas *e, void *event_info)
579 vwin_info_t info = data;
585 if (widget_conf_premultiplied_alpha()) {
589 ecore_evas_geometry_get(info->ee, NULL, NULL, &w, &h);
590 evas_damage_rectangle_add(e, 0, 0, w, h);
593 if (info->type == VWIN_GEM) {
594 widget_buffer_pre_render(info->handle);
595 } else if (info->type == VWIN_PIXMAP) {
597 * Only the pixmap type Ecore_Evas uses this variable
599 } else if (info->type == VWIN_SW_BUF) {
604 static void post_render_cb(void *data, Evas *e, void *event_info)
606 vwin_info_t info = data;
612 if (widget_conf_premultiplied_alpha()) {
616 // Get a pointer of a buffer of the virtual canvas
617 canvas = (void *)ecore_evas_buffer_pixels_get(info->ee);
619 ErrPrint("Failed to get pixel canvas\n");
623 ecore_evas_geometry_get(info->ee, &x, &y, &w, &h);
624 evas_data_argb_unpremul(canvas, w * h);
627 if (info->type == VWIN_GEM) {
628 widget_buffer_post_render(info->handle);
629 } else if (info->type == VWIN_PIXMAP) {
631 unsigned int front_resource_id;
633 front_resource_id = ecore_evas_gl_x11_pixmap_get(info->ee);
635 for (idx = 0; idx < WIDGET_CONF_EXTRA_BUFFER_COUNT; idx++) {
636 if (front_resource_id == info->resource_array[idx]) {
639 widget_send_updated_by_idx(info->handle, idx);
644 if (idx == WIDGET_CONF_EXTRA_BUFFER_COUNT) {
645 /* Send updated event for PRIMARY BUFFER */
646 if (front_resource_id == widget_viewer_get_resource_id(info->handle, WIDGET_PRIMARY_BUFFER)) {
647 widget_send_updated_by_idx(info->handle, WIDGET_PRIMARY_BUFFER);
649 DbgPrint("Unable to send updated: %u (%u)\n", front_resource_id, widget_viewer_get_resource_id(info->handle, WIDGET_PRIMARY_BUFFER));
652 } else if (info->type == VWIN_SW_BUF) {
653 widget_viewer_sync_buffer(info->handle);
657 static int pre_orientation_cb(const char *id, void *data)
659 vwin_info_t info = data;
663 /* Try provider_app first */
665 return WIDGET_ERROR_INVALID_PARAMETER;
668 path = widget_util_uri_to_path(id);
669 if (path && strcmp(info->id, path)) {
671 DbgPrint("SKIP: Pre orientation event callback is called [%s], %s\n", id, info->id);
672 return WIDGET_ERROR_INVALID_PARAMETER;
675 DbgPrint("Pre orientation event callback is called [%s]\n", id);
676 orientation = widget_get_orientation(path);
677 if (orientation < 0) {
678 ErrPrint("Failed to get orientation: %X\n", orientation);
680 info->orientation = orientation;
683 return WIDGET_ERROR_NONE;
686 static int pre_destroy_cb(const char *id, void *data)
688 vwin_info_t info = data;
689 const char *path = NULL;
692 path = widget_util_uri_to_path(id);
694 if (path && strcmp(info->id, path)) {
696 DbgPrint("SKIP: Pre destroy event callback is called [%s], %s\n", id, info->id);
697 return WIDGET_ERROR_INVALID_PARAMETER;
701 DbgPrint("Pre destroy event callback is called [%s]\n", id);
704 DbgPrint("Toggle manual render mode to prevent from unwanted rendering");
705 ecore_evas_manual_render_set(info->ee, EINA_TRUE);
708 return WIDGET_ERROR_NONE;
711 static void ecore_evas_free_cb(Ecore_Evas *ee)
715 info = ecore_evas_data_get(ee, "dynamic,box,info");
717 DbgPrint("Info is not valid\n");
721 widget_del_pre_callback(WIDGET_PRE_DESTROY_CALLBACK, pre_destroy_cb, info);
724 evas_event_callback_del(info->e, EVAS_CALLBACK_RENDER_POST, post_render_cb);
725 evas_event_callback_del(info->e, EVAS_CALLBACK_RENDER_PRE, pre_render_cb);
732 #ifdef WIDGET_FEATURE_GBAR_SUPPORTED
733 PUBLIC Evas *widget_get_evas(const char *id, int is_gbar)
734 #else /* WIDGET_FEATURE_GBAR_SUPPORTED */
735 PUBLIC Evas *widget_get_evas(const char *id)
736 #endif /* WIDGET_FEATURE_GBAR_SUPPORTED */
743 * If the evas object is already created,
744 * this function should returns ERROR.
748 ErrPrint("Invalid parameter\n");
752 info = calloc(1, sizeof(*info));
754 ErrPrint("Heap: %d\n", errno);
758 info->id = strdup(id);
760 ErrPrint("Heap: %d\n", errno);
765 #ifdef WIDGET_FEATURE_GBAR_SUPPORTED
766 info->is_gbar = is_gbar;
769 #endif /* WIDGET_FEATURE_GBAR_SUPPORTED */
772 * Acquire a buffer for canvas.
774 info->handle = widget_create_buffer(info->id, info->is_gbar,
775 binder_widget_auto_align(),
776 event_handler_cb, info);
779 ErrPrint("Failed to create a widget buffer\n");
786 * Size information must be initialized before call the ecore_evas_buffer_new.
788 info->w = WIDGET_DEFAULT_WIDTH;
789 info->h = WIDGET_DEFAULT_HEIGHT;
791 info->ee = binder_ecore_evas_new(info);
793 ErrPrint("Failed to create ecore_evas (%dx%d)\n", info->w, info->h);
794 widget_destroy_buffer(info->handle);
800 ecore_evas_data_set(info->ee, "dynamic,box,info", info);
804 * Free callback must be prepared before use the ecore_evas_free()
806 ecore_evas_callback_pre_free_set(info->ee, ecore_evas_free_cb);
808 info->e = ecore_evas_get(info->ee);
810 ErrPrint("Failed to get evas\n");
811 ecore_evas_free(info->ee);
815 pre_render_cb(info, NULL, NULL);
816 ecore_evas_alpha_set(info->ee, EINA_TRUE);
817 post_render_cb(info, NULL, NULL);
819 ecore_evas_manual_render_set(info->ee, EINA_FALSE);
820 ecore_evas_resize(info->ee, info->w, info->h);
822 evas_event_callback_add(info->e, EVAS_CALLBACK_RENDER_POST, post_render_cb, info);
823 evas_event_callback_add(info->e, EVAS_CALLBACK_RENDER_PRE, pre_render_cb, info);
825 widget_add_pre_callback(WIDGET_PRE_DESTROY_CALLBACK, pre_destroy_cb, info);
826 widget_add_pre_callback(WIDGET_PRE_ORIENTATION_CALLBACK, pre_orientation_cb, info);
828 orientation = widget_get_orientation(info->id);
829 if (orientation < 0) {
830 ErrPrint("Failed to get orientation[%s]: %X\n", info->id, orientation);
832 info->orientation = orientation;