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)
100 *x = (double)_x * cos((double)_angle) - (double)_y * sin((double)_angle);
101 *y = (double)_x * sin((double)_angle) + (double)_y * cos((double)_angle);
108 * Every user event (mouse) on the buffer will be passed via this event callback
110 static int event_handler_cb(widget_buffer_h handler, struct widget_buffer_event_data *event_info, void *data)
112 vwin_info_t info = data;
113 Elm_Access_Action_Info action_info;
114 Elm_Access_Action_Type action_type;
116 Evas_Object *parent_elm;
118 unsigned int flags = 0;
122 /* Just ignore this event */
126 if (WIDGET_CONF_USE_GETTIMEOFDAY) {
127 if (WIDGET_CONF_EVENT_FILTER > 0.0f && (info->pressed == 0 || event_info->type == WIDGET_BUFFER_EVENT_MOVE)) {
130 if (gettimeofday(&tv, NULL) < 0) {
131 ErrPrint("gettimeofday: %d\n", errno);
133 timestamp = (double)tv.tv_sec + (double)tv.tv_usec / 1000000.0f;
134 timestamp -= event_info->timestamp;
136 if (timestamp > WIDGET_CONF_EVENT_FILTER) {
137 DbgPrint("Dropped %lf\n", timestamp);
144 * If the device doesn't use the clock monotic time, we have to emulate it for EVAS
145 * Evas only use the monotic time for animating objects
147 timestamp = ecore_time_get() * 1000.0f;
149 if (WIDGET_CONF_EVENT_FILTER > 0.0f && (info->pressed == 0 || event_info->type == WIDGET_BUFFER_EVENT_MOVE)) {
150 timestamp = ecore_time_get();
152 timestamp -= event_info->timestamp;
153 if (timestamp > WIDGET_CONF_EVENT_FILTER) {
154 DbgPrint("Dropped %lf\n", timestamp);
159 timestamp = event_info->timestamp * 1000.0f;
166 switch (event_info->type) {
167 case WIDGET_BUFFER_EVENT_ON_HOLD:
168 flags = evas_event_default_flags_get(info->e);
169 flags |= EVAS_EVENT_FLAG_ON_HOLD;
170 evas_event_default_flags_set(info->e, flags);
171 ErrPrint("ON_HOLD[%s] %dx%d - %lf\n", info->id, event_info->info.pointer.x, event_info->info.pointer.y, timestamp);
173 case WIDGET_BUFFER_EVENT_OFF_HOLD:
174 flags = evas_event_default_flags_get(info->e);
175 flags &= ~EVAS_EVENT_FLAG_ON_HOLD;
176 evas_event_default_flags_set(info->e, flags);
178 case WIDGET_BUFFER_EVENT_ON_SCROLL:
179 flags = evas_event_default_flags_get(info->e);
180 flags |= EVAS_EVENT_FLAG_ON_SCROLL;
181 evas_event_default_flags_set(info->e, flags);
183 case WIDGET_BUFFER_EVENT_OFF_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_ENTER:
189 evas_event_feed_mouse_in(info->e, timestamp, NULL);
191 case WIDGET_BUFFER_EVENT_LEAVE:
192 evas_event_feed_mouse_out(info->e, timestamp, NULL);
194 case WIDGET_BUFFER_EVENT_DOWN:
195 apply_orientation(info->orientation, &event_info->info.pointer.x, &event_info->info.pointer.y);
198 ErrPrint("MOUSE UP is not called\n");
199 ErrPrint("UP[%s] %dx%d - %lf\n", info->id, event_info->info.pointer.x, event_info->info.pointer.y, timestamp);
200 evas_event_feed_mouse_move(info->e, event_info->info.pointer.x, event_info->info.pointer.y, timestamp, NULL);
201 evas_event_feed_mouse_up(info->e, 1, EVAS_BUTTON_NONE, timestamp, NULL);
206 * Before processing the DOWN event,
207 * Reset the evas event flags regarding ON_HOLD option.
208 * It can be re-enabled while processing down-move-up events.
210 flags = evas_event_default_flags_get(info->e);
211 flags &= ~EVAS_EVENT_FLAG_ON_SCROLL;
212 flags &= ~EVAS_EVENT_FLAG_ON_HOLD;
213 evas_event_default_flags_set(info->e, flags);
216 * Calculate the event occurred X & Y on the buffer
218 evas_event_feed_mouse_move(info->e, event_info->info.pointer.x, event_info->info.pointer.y, timestamp, NULL);
219 evas_event_feed_mouse_down(info->e, 1, EVAS_BUTTON_NONE, timestamp, NULL); /* + 0.2f just for fake event */
221 ErrPrint("DOWN[%s] %dx%d - %lf\n", info->id, event_info->info.pointer.x, event_info->info.pointer.y, timestamp);
223 case WIDGET_BUFFER_EVENT_MOVE:
224 apply_orientation(info->orientation, &event_info->info.pointer.x, &event_info->info.pointer.y);
227 * Calculate the event occurred X & Y on the buffer
229 evas_event_feed_mouse_move(info->e, event_info->info.pointer.x, event_info->info.pointer.y, timestamp, NULL);
231 case WIDGET_BUFFER_EVENT_UP:
232 apply_orientation(info->orientation, &event_info->info.pointer.x, &event_info->info.pointer.y);
233 evas_event_feed_mouse_move(info->e, event_info->info.pointer.x, event_info->info.pointer.y, timestamp, NULL);
234 evas_event_feed_mouse_up(info->e, 1, EVAS_BUTTON_NONE, timestamp, NULL);
238 * We have to keep the event flags, so we should not clear them from here.
239 * Sometimes, asynchronously callable Callbacks can refer the evas event flags after up event.
240 * so if we reset them from here, those kind of callbacks will fails to do their job properly.
242 ErrPrint("UP[%s] %dx%d - %lf\n", info->id, event_info->info.pointer.x, event_info->info.pointer.y, timestamp);
244 case WIDGET_BUFFER_EVENT_ACCESS_HIGHLIGHT:
245 parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG);
247 ret = WIDGET_ACCESS_STATUS_ERROR;
250 memset(&action_info, 0, sizeof(action_info));
251 action_type = ELM_ACCESS_ACTION_HIGHLIGHT;
254 * Calculate the event occurred X & Y on the buffer
256 action_info.x = event_info->info.access.x;
257 action_info.y = event_info->info.access.y;
258 ret = elm_access_action(parent_elm, action_type, &action_info);
259 if (ret == EINA_TRUE) {
260 if (!get_highlighted_object(parent_elm)) {
261 ErrPrint("Highlighted object is not found\n");
262 ret = WIDGET_ACCESS_STATUS_ERROR;
264 DbgPrint("Highlighted object is found\n");
265 ret = WIDGET_ACCESS_STATUS_DONE;
268 ErrPrint("Action error\n");
269 ret = WIDGET_ACCESS_STATUS_ERROR;
272 case WIDGET_BUFFER_EVENT_ACCESS_HIGHLIGHT_NEXT:
273 parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG);
275 ret = WIDGET_ACCESS_STATUS_ERROR;
278 memset(&action_info, 0, sizeof(action_info));
279 action_type = ELM_ACCESS_ACTION_HIGHLIGHT_NEXT;
280 action_info.highlight_cycle = EINA_FALSE;
281 ret = elm_access_action(parent_elm, action_type, &action_info);
282 ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_LAST : WIDGET_ACCESS_STATUS_DONE;
284 case WIDGET_BUFFER_EVENT_ACCESS_HIGHLIGHT_PREV:
285 parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG);
287 ret = WIDGET_ACCESS_STATUS_ERROR;
290 memset(&action_info, 0, sizeof(action_info));
291 action_type = ELM_ACCESS_ACTION_HIGHLIGHT_PREV;
292 action_info.highlight_cycle = EINA_FALSE;
293 ret = elm_access_action(parent_elm, action_type, &action_info);
294 ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_FIRST : WIDGET_ACCESS_STATUS_DONE;
296 case WIDGET_BUFFER_EVENT_ACCESS_ACTIVATE:
297 parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG);
299 ret = WIDGET_ACCESS_STATUS_ERROR;
302 memset(&action_info, 0, sizeof(action_info));
303 action_type = ELM_ACCESS_ACTION_ACTIVATE;
304 ret = elm_access_action(parent_elm, action_type, &action_info);
305 ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE;
307 case WIDGET_BUFFER_EVENT_ACCESS_ACTION_UP:
308 parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG);
310 ret = WIDGET_ACCESS_STATUS_ERROR;
313 memset(&action_info, 0, sizeof(action_info));
314 action_type = ELM_ACCESS_ACTION_UP;
315 ret = elm_access_action(parent_elm, action_type, &action_info);
316 ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE;
318 case WIDGET_BUFFER_EVENT_ACCESS_ACTION_DOWN:
319 parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG);
321 ret = WIDGET_ACCESS_STATUS_ERROR;
324 memset(&action_info, 0, sizeof(action_info));
325 action_type = ELM_ACCESS_ACTION_DOWN;
326 ret = elm_access_action(parent_elm, action_type, &action_info);
327 ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE;
329 case WIDGET_BUFFER_EVENT_ACCESS_SCROLL_UP:
330 parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG);
332 ret = WIDGET_ACCESS_STATUS_ERROR;
335 memset(&action_info, 0, sizeof(action_info));
336 action_type = ELM_ACCESS_ACTION_SCROLL;
337 action_info.x = event_info->info.access.x;
338 action_info.y = event_info->info.access.y;
339 action_info.mouse_type = event_info->info.access.mouse_type;
340 ret = elm_access_action(parent_elm, action_type, &action_info);
341 ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE;
343 case WIDGET_BUFFER_EVENT_ACCESS_SCROLL_MOVE:
344 parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG);
346 ret = WIDGET_ACCESS_STATUS_ERROR;
349 memset(&action_info, 0, sizeof(action_info));
350 action_type = ELM_ACCESS_ACTION_SCROLL;
351 action_info.x = event_info->info.access.x;
352 action_info.y = event_info->info.access.y;
353 action_info.mouse_type = event_info->info.access.mouse_type;
354 ret = elm_access_action(parent_elm, action_type, &action_info);
355 ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE;
357 case WIDGET_BUFFER_EVENT_ACCESS_SCROLL_DOWN:
358 parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG);
360 ret = WIDGET_ACCESS_STATUS_ERROR;
363 memset(&action_info, 0, sizeof(action_info));
364 action_type = ELM_ACCESS_ACTION_SCROLL;
365 action_info.x = event_info->info.access.x;
366 action_info.y = event_info->info.access.y;
367 action_info.mouse_type = event_info->info.access.mouse_type;
368 ret = elm_access_action(parent_elm, action_type, &action_info);
369 ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE;
371 case WIDGET_BUFFER_EVENT_ACCESS_UNHIGHLIGHT:
372 parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG);
374 ret = WIDGET_ACCESS_STATUS_ERROR;
377 memset(&action_info, 0, sizeof(action_info));
378 action_type = ELM_ACCESS_ACTION_UNHIGHLIGHT;
379 ret = elm_access_action(parent_elm, action_type, &action_info);
380 ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE;
382 case WIDGET_BUFFER_EVENT_ACCESS_VALUE_CHANGE:
383 parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG);
385 ret = WIDGET_ACCESS_STATUS_ERROR;
388 memset(&action_info, 0, sizeof(action_info));
389 action_type = ELM_ACCESS_ACTION_VALUE_CHANGE;
390 action_info.x = event_info->info.access.x;
391 action_info.y = event_info->info.access.y;
392 action_info.mouse_type = event_info->info.access.mouse_type;
393 ret = elm_access_action(parent_elm, action_type, &action_info);
394 ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE;
396 case WIDGET_BUFFER_EVENT_ACCESS_MOUSE:
397 parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG);
399 ret = WIDGET_ACCESS_STATUS_ERROR;
402 memset(&action_info, 0, sizeof(action_info));
403 action_type = ELM_ACCESS_ACTION_MOUSE;
404 action_info.x = event_info->info.access.x;
405 action_info.y = event_info->info.access.y;
406 action_info.mouse_type = event_info->info.access.mouse_type;
407 ret = elm_access_action(parent_elm, action_type, &action_info);
408 ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE;
410 case WIDGET_BUFFER_EVENT_ACCESS_BACK:
411 parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG);
413 ret = WIDGET_ACCESS_STATUS_ERROR;
416 memset(&action_info, 0, sizeof(action_info));
417 action_type = ELM_ACCESS_ACTION_BACK;
418 action_info.x = event_info->info.access.x;
419 action_info.y = event_info->info.access.y;
420 action_info.mouse_type = event_info->info.access.mouse_type;
421 ret = elm_access_action(parent_elm, action_type, &action_info);
422 ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE;
424 case WIDGET_BUFFER_EVENT_ACCESS_OVER:
425 parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG);
427 ret = WIDGET_ACCESS_STATUS_ERROR;
430 memset(&action_info, 0, sizeof(action_info));
431 action_type = ELM_ACCESS_ACTION_OVER;
432 action_info.x = event_info->info.access.x;
433 action_info.y = event_info->info.access.y;
434 action_info.mouse_type = event_info->info.access.mouse_type;
435 ret = elm_access_action(parent_elm, action_type, &action_info);
436 ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE;
438 case WIDGET_BUFFER_EVENT_ACCESS_READ:
439 parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG);
441 ret = WIDGET_ACCESS_STATUS_ERROR;
444 memset(&action_info, 0, sizeof(action_info));
445 action_type = ELM_ACCESS_ACTION_READ;
446 action_info.x = event_info->info.access.x;
447 action_info.y = event_info->info.access.y;
448 action_info.mouse_type = event_info->info.access.mouse_type;
449 ret = elm_access_action(parent_elm, action_type, &action_info);
450 ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE;
452 case WIDGET_BUFFER_EVENT_ACCESS_ENABLE:
453 parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG);
455 ret = WIDGET_ACCESS_STATUS_ERROR;
458 memset(&action_info, 0, sizeof(action_info));
459 action_type = ELM_ACCESS_ACTION_ENABLE;
460 action_info.x = event_info->info.access.x;
461 action_info.y = event_info->info.access.y;
462 action_info.mouse_type = event_info->info.access.mouse_type;
463 ret = elm_access_action(parent_elm, action_type, &action_info);
464 ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE;
466 case WIDGET_BUFFER_EVENT_ACCESS_DISABLE:
467 parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG);
469 ret = WIDGET_ACCESS_STATUS_ERROR;
472 memset(&action_info, 0, sizeof(action_info));
473 action_type = ELM_ACCESS_ACTION_DISABLE;
474 action_info.x = event_info->info.access.x;
475 action_info.y = event_info->info.access.y;
476 action_info.mouse_type = event_info->info.access.mouse_type;
477 ret = elm_access_action(parent_elm, action_type, &action_info);
478 ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE;
480 case WIDGET_BUFFER_EVENT_KEY_DOWN:
481 parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG);
483 ret = WIDGET_ACCESS_STATUS_ERROR;
487 key_symbol = XGetKeyboardMapping(ecore_x_display_get(), event_info->info.keycode, 1, &ret);
492 key_string = XKeysymToString(*key_symbol);
493 key_name = XKeysymToString(*key_symbol);
494 DbgPrint("Key symbol: %s, name: %s\n", key_string, key_name);
499 ret = WIDGET_KEY_STATUS_ERROR;
501 case WIDGET_BUFFER_EVENT_KEY_UP:
502 parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG);
504 ret = WIDGET_ACCESS_STATUS_ERROR;
508 key_symbol = XGetKeyboardMapping(ecore_x_display_get(), event_info->info.keycode, 1, &ret);
513 key_string = XKeysymToString(*key_symbol);
514 key_name = XKeysymToString(*key_symbol);
515 DbgPrint("Key symbol: %s, name: %s\n", key_string, key_name);
520 ret = WIDGET_KEY_STATUS_ERROR;
522 case WIDGET_BUFFER_EVENT_KEY_FOCUS_IN:
523 parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG);
525 ret = WIDGET_ACCESS_STATUS_ERROR;
529 key_symbol = XGetKeyboardMapping(ecore_x_display_get(), event_info->info.keycode, 1, &ret);
534 key_string = XKeysymToString(*key_symbol);
535 key_name = XKeysymToString(*key_symbol);
536 DbgPrint("Key symbol: %s, name: %s\n", key_string, key_name);
541 ret = WIDGET_KEY_STATUS_ERROR;
543 case WIDGET_BUFFER_EVENT_KEY_FOCUS_OUT:
544 parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG);
546 ret = WIDGET_ACCESS_STATUS_ERROR;
550 key_symbol = XGetKeyboardMapping(ecore_x_display_get(), event_info->info.keycode, 1, &ret);
555 key_string = XKeysymToString(*key_symbol);
556 key_name = XKeysymToString(*key_symbol);
557 DbgPrint("Key symbol: %s, name: %s\n", key_string, key_name);
562 ret = WIDGET_KEY_STATUS_ERROR;
565 DbgPrint("Unhandled buffer event (%d)\n", event_info->type);
572 static void pre_render_cb(void *data, Evas *e, void *event_info)
574 vwin_info_t info = data;
580 if (widget_conf_premultiplied_alpha()) {
584 ecore_evas_geometry_get(info->ee, NULL, NULL, &w, &h);
585 evas_damage_rectangle_add(e, 0, 0, w, h);
588 if (info->type == VWIN_GEM) {
589 widget_buffer_pre_render(info->handle);
590 } else if (info->type == VWIN_PIXMAP) {
592 * Only the pixmap type Ecore_Evas uses this variable
594 } else if (info->type == VWIN_SW_BUF) {
599 static void post_render_cb(void *data, Evas *e, void *event_info)
601 vwin_info_t info = data;
607 if (widget_conf_premultiplied_alpha()) {
611 // Get a pointer of a buffer of the virtual canvas
612 canvas = (void *)ecore_evas_buffer_pixels_get(info->ee);
614 ErrPrint("Failed to get pixel canvas\n");
618 ecore_evas_geometry_get(info->ee, &x, &y, &w, &h);
619 evas_data_argb_unpremul(canvas, w * h);
622 if (info->type == VWIN_GEM) {
623 widget_buffer_post_render(info->handle);
624 } else if (info->type == VWIN_PIXMAP) {
626 unsigned int front_resource_id;
628 front_resource_id = ecore_evas_gl_x11_pixmap_get(info->ee);
630 for (idx = 0; idx < WIDGET_CONF_EXTRA_BUFFER_COUNT; idx++) {
631 if (front_resource_id == info->resource_array[idx]) {
634 widget_send_updated_by_idx(info->handle, idx);
639 if (idx == WIDGET_CONF_EXTRA_BUFFER_COUNT) {
640 /* Send updated event for PRIMARY BUFFER */
641 if (front_resource_id == widget_viewer_get_resource_id(info->handle, WIDGET_PRIMARY_BUFFER)) {
642 widget_send_updated_by_idx(info->handle, WIDGET_PRIMARY_BUFFER);
644 DbgPrint("Unable to send updated: %u (%u)\n", front_resource_id, widget_viewer_get_resource_id(info->handle, WIDGET_PRIMARY_BUFFER));
647 } else if (info->type == VWIN_SW_BUF) {
648 widget_viewer_sync_buffer(info->handle);
652 static int pre_orientation_cb(const char *id, void *data)
654 vwin_info_t info = data;
658 /* Try provider_app first */
660 return WIDGET_ERROR_INVALID_PARAMETER;
663 path = widget_util_uri_to_path(id);
664 if (path && strcmp(info->id, path)) {
666 DbgPrint("SKIP: Pre orientation event callback is called [%s], %s\n", id, info->id);
667 return WIDGET_ERROR_INVALID_PARAMETER;
670 DbgPrint("Pre orientation event callback is called [%s]\n", id);
671 orientation = widget_get_orientation(path);
672 if (orientation < 0) {
673 ErrPrint("Failed to get orientation: %X\n", orientation);
675 info->orientation = orientation;
678 return WIDGET_ERROR_NONE;
681 static int pre_destroy_cb(const char *id, void *data)
683 vwin_info_t info = data;
684 const char *path = NULL;
687 path = widget_util_uri_to_path(id);
689 if (path && strcmp(info->id, path)) {
691 DbgPrint("SKIP: Pre destroy event callback is called [%s], %s\n", id, info->id);
692 return WIDGET_ERROR_INVALID_PARAMETER;
696 DbgPrint("Pre destroy event callback is called [%s]\n", id);
699 DbgPrint("Toggle manual render mode to prevent from unwanted rendering");
700 ecore_evas_manual_render_set(info->ee, EINA_TRUE);
703 return WIDGET_ERROR_NONE;
706 static void ecore_evas_free_cb(Ecore_Evas *ee)
710 info = ecore_evas_data_get(ee, "dynamic,box,info");
712 DbgPrint("Info is not valid\n");
716 widget_del_pre_callback(WIDGET_PRE_DESTROY_CALLBACK, pre_destroy_cb, info);
719 evas_event_callback_del(info->e, EVAS_CALLBACK_RENDER_POST, post_render_cb);
720 evas_event_callback_del(info->e, EVAS_CALLBACK_RENDER_PRE, pre_render_cb);
727 #ifdef WIDGET_FEATURE_GBAR_SUPPORTED
728 PUBLIC Evas *widget_get_evas(const char *id, int is_gbar)
729 #else /* WIDGET_FEATURE_GBAR_SUPPORTED */
730 PUBLIC Evas *widget_get_evas(const char *id)
731 #endif /* WIDGET_FEATURE_GBAR_SUPPORTED */
738 * If the evas object is already created,
739 * this function should returns ERROR.
743 ErrPrint("Invalid parameter\n");
747 info = calloc(1, sizeof(*info));
749 ErrPrint("Heap: %d\n", errno);
753 info->id = strdup(id);
755 ErrPrint("Heap: %d\n", errno);
760 #ifdef WIDGET_FEATURE_GBAR_SUPPORTED
761 info->is_gbar = is_gbar;
764 #endif /* WIDGET_FEATURE_GBAR_SUPPORTED */
767 * Acquire a buffer for canvas.
769 info->handle = widget_create_buffer(info->id, info->is_gbar,
770 binder_widget_auto_align(),
771 event_handler_cb, info);
774 ErrPrint("Failed to create a widget buffer\n");
781 * Size information must be initialized before call the ecore_evas_buffer_new.
783 info->w = WIDGET_DEFAULT_WIDTH;
784 info->h = WIDGET_DEFAULT_HEIGHT;
786 info->ee = binder_ecore_evas_new(info);
788 ErrPrint("Failed to create ecore_evas (%dx%d)\n", info->w, info->h);
789 widget_destroy_buffer(info->handle);
795 ecore_evas_data_set(info->ee, "dynamic,box,info", info);
799 * Free callback must be prepared before use the ecore_evas_free()
801 ecore_evas_callback_pre_free_set(info->ee, ecore_evas_free_cb);
803 info->e = ecore_evas_get(info->ee);
805 ErrPrint("Failed to get evas\n");
806 ecore_evas_free(info->ee);
810 pre_render_cb(info, NULL, NULL);
811 ecore_evas_alpha_set(info->ee, EINA_TRUE);
812 post_render_cb(info, NULL, NULL);
814 ecore_evas_manual_render_set(info->ee, EINA_FALSE);
815 ecore_evas_resize(info->ee, info->w, info->h);
817 evas_event_callback_add(info->e, EVAS_CALLBACK_RENDER_POST, post_render_cb, info);
818 evas_event_callback_add(info->e, EVAS_CALLBACK_RENDER_PRE, pre_render_cb, info);
820 widget_add_pre_callback(WIDGET_PRE_DESTROY_CALLBACK, pre_destroy_cb, info);
821 widget_add_pre_callback(WIDGET_PRE_ORIENTATION_CALLBACK, pre_orientation_cb, info);
823 orientation = widget_get_orientation(info->id);
824 if (orientation < 0) {
825 ErrPrint("Failed to get orientation[%s]: %X\n", info->id, orientation);
827 info->orientation = orientation;