From: Sung-jae Park Date: Fri, 1 May 2015 07:08:28 +0000 (+0900) Subject: Clean up all to get them again from 2.3.1 with history X-Git-Tag: submit/tizen_mobile/20150511.123737~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cd303f09d3b7501a09defda8fcdc9052308ea73c;p=apps%2Fnative%2Fwidget%2Fwidget.git Clean up all to get them again from 2.3.1 with history [model] Redwood,Kiran,B3(Wearable) [binary_type] AP [customer] Docomo/Orange/ATT/Open [issue#] N/A [problem] [cause] [solution] [team] HomeTF [request] [horizontal_expansion] --- diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index b98db69..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,89 +0,0 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -PROJECT(widget C) - -SET(PREFIX ${CMAKE_INSTALL_PREFIX}) -SET(EXEC_PREFIX "\${prefix}") -SET(PROJECT_NAME "${PROJECT_NAME}") -SET(LIBDIR "\${exec_prefix}/lib") -SET(INCLUDEDIR "\${prefix}/include/${PROJECT_NAME}") -SET(VERSION_MAJOR 1) -SET(VERSION "${VERSION_MAJOR}.0.0") - -set(CMAKE_SKIP_BUILD_RPATH true) - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) - -INCLUDE(FindPkgConfig) -pkg_check_modules(pkgs REQUIRED - dlog - widget_service - widget_provider - evas - ecore - elementary -) - -IF (X11_SUPPORT) -pkg_check_modules(pkgs_extra REQUIRED - x11 -) -ADD_DEFINITIONS("-DHAVE_X11") -SET(BUILD_SOURCE - src/virtual_window.c -) -ENDIF (X11_SUPPORT) - -IF (WAYLAND_SUPPORT) -ADD_DEFINITIONS("-DHAVE_WAYLAND") -SET(BUILD_SOURCE - src/virtual_window_wayland.c -) -ENDIF (WAYLAND_SUPPORT) - -FOREACH(flag ${pkgs_CFLAGS}) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") -ENDFOREACH(flag) - -FOREACH(flag ${pkgs_extra_CFLAGS}) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") -ENDFOREACH(flag) - -SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden") - -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -g") - -ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"") -ADD_DEFINITIONS("-DLOG_TAG=\"WIDGET\"") -ADD_DEFINITIONS("-DNDEBUG") -ADD_DEFINITIONS("-D_USE_ECORE_TIME_GET") -ADD_DEFINITIONS("-DMASTER_PKGNAME=\"data-provider-master\"") -ADD_DEFINITIONS("-DSLAVE_PKGNAME=\"com.samsung.data-provider-slave\"") -#ADD_DEFINITIONS("-D_ENABLE_PERF") - -SET (BUILD_SOURCE - ${BUILD_SOURCE} - src/dlist.c - src/util.c - src/binder.c - src/widget.c - src/snapshot_window.c -) - -ADD_LIBRARY(${PROJECT_NAME} SHARED ${BUILD_SOURCE}) -SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${VERSION_MAJOR}) -SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${VERSION}) -TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} ${pkgs_extra_LDFLAGS} "-lpthread") - -INSTALL(TARGETS ${PROJECT_NAME} DESTINATION lib) - -CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY) -SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${PROJECT_NAME}.pc") - -INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION lib/pkgconfig) - -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/widget.h DESTINATION include/${PROJECT_NAME}) -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/widget_internal.h DESTINATION include/${PROJECT_NAME}) - -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE DESTINATION /usr/share/license RENAME "lib${PROJECT_NAME}") - -ADD_SUBDIRECTORY(data) diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 571fe79..0000000 --- a/LICENSE +++ /dev/null @@ -1,206 +0,0 @@ -Flora License - -Version 1.1, April, 2013 - -http://floralicense.org/license/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - -"License" shall mean the terms and conditions for use, reproduction, -and distribution as defined by Sections 1 through 9 of this document. - -"Licensor" shall mean the copyright owner or entity authorized by -the copyright owner that is granting the License. - -"Legal Entity" shall mean the union of the acting entity and -all other entities that control, are controlled by, or are -under common control with that entity. For the purposes of -this definition, "control" means (i) the power, direct or indirect, -to cause the direction or management of such entity, -whether by contract or otherwise, or (ii) ownership of fifty percent (50%) -or more of the outstanding shares, or (iii) beneficial ownership of -such entity. - -"You" (or "Your") shall mean an individual or Legal Entity -exercising permissions granted by this License. - -"Source" form shall mean the preferred form for making modifications, -including but not limited to software source code, documentation source, -and configuration files. - -"Object" form shall mean any form resulting from mechanical -transformation or translation of a Source form, including but -not limited to compiled object code, generated documentation, -and conversions to other media types. - -"Work" shall mean the work of authorship, whether in Source or Object form, -made available under the License, as indicated by a copyright notice -that is included in or attached to the work (an example is provided -in the Appendix below). - -"Derivative Works" shall mean any work, whether in Source or Object form, -that is based on (or derived from) the Work and for which the editorial -revisions, annotations, elaborations, or other modifications represent, -as a whole, an original work of authorship. For the purposes of this License, -Derivative Works shall not include works that remain separable from, -or merely link (or bind by name) to the interfaces of, the Work and -Derivative Works thereof. - -"Contribution" shall mean any work of authorship, including the original -version of the Work and any modifications or additions to that Work or -Derivative Works thereof, that is intentionally submitted to Licensor -for inclusion in the Work by the copyright owner or by an individual or -Legal Entity authorized to submit on behalf of the copyright owner. -For the purposes of this definition, "submitted" means any form of -electronic, verbal, or written communication sent to the Licensor or -its representatives, including but not limited to communication on -electronic mailing lists, source code control systems, and issue -tracking systems that are managed by, or on behalf of, the Licensor -for the purpose of discussing and improving the Work, but excluding -communication that is conspicuously marked or otherwise designated -in writing by the copyright owner as "Not a Contribution." - -"Contributor" shall mean Licensor and any individual or Legal Entity -on behalf of whom a Contribution has been received by Licensor and -subsequently incorporated within the Work. - -"Tizen Certified Platform" shall mean a software platform that complies -with the standards set forth in the Tizen Compliance Specification -and passes the Tizen Compliance Tests as defined from time to time -by the Tizen Technical Steering Group and certified by the Tizen -Association or its designated agent. - -2. Grant of Copyright License. Subject to the terms and conditions of -this License, each Contributor hereby grants to You a perpetual, -worldwide, non-exclusive, no-charge, royalty-free, irrevocable -copyright license to reproduce, prepare Derivative Works of, -publicly display, publicly perform, sublicense, and distribute the -Work and such Derivative Works in Source or Object form. - -3. Grant of Patent License. Subject to the terms and conditions of -this License, each Contributor hereby grants to You a perpetual, -worldwide, non-exclusive, no-charge, royalty-free, irrevocable -(except as stated in this section) patent license to make, have made, -use, offer to sell, sell, import, and otherwise transfer the Work -solely as incorporated into a Tizen Certified Platform, where such -license applies only to those patent claims licensable by such -Contributor that are necessarily infringed by their Contribution(s) -alone or by combination of their Contribution(s) with the Work solely -as incorporated into a Tizen Certified Platform to which such -Contribution(s) was submitted. If You institute patent litigation -against any entity (including a cross-claim or counterclaim -in a lawsuit) alleging that the Work or a Contribution incorporated -within the Work constitutes direct or contributory patent infringement, -then any patent licenses granted to You under this License for that -Work shall terminate as of the date such litigation is filed. - -4. Redistribution. You may reproduce and distribute copies of the -Work or Derivative Works thereof pursuant to the copyright license -above, in any medium, with or without modifications, and in Source or -Object form, provided that You meet the following conditions: - - 1. You must give any other recipients of the Work or Derivative Works - a copy of this License; and - 2. You must cause any modified files to carry prominent notices stating - that You changed the files; and - 3. You must retain, in the Source form of any Derivative Works that - You distribute, all copyright, patent, trademark, and attribution - notices from the Source form of the Work, excluding those notices - that do not pertain to any part of the Derivative Works; and - 4. If the Work includes a "NOTICE" text file as part of its distribution, - then any Derivative Works that You distribute must include a readable - copy of the attribution notices contained within such NOTICE file, - excluding those notices that do not pertain to any part of - the Derivative Works, in at least one of the following places: - within a NOTICE text file distributed as part of the Derivative Works; - within the Source form or documentation, if provided along with the - Derivative Works; or, within a display generated by the Derivative Works, - if and wherever such third-party notices normally appear. - The contents of the NOTICE file are for informational purposes only - and do not modify the License. You may add Your own attribution notices - within Derivative Works that You distribute, alongside or as an addendum - to the NOTICE text from the Work, provided that such additional attribution - notices cannot be construed as modifying the License. You may add Your own - copyright statement to Your modifications and may provide additional or - different license terms and conditions for use, reproduction, or - distribution of Your modifications, or for any such Derivative Works - as a whole, provided Your use, reproduction, and distribution of - the Work otherwise complies with the conditions stated in this License - and your own copyright statement or terms and conditions do not conflict - the conditions stated in the License including section 3. - -5. Submission of Contributions. Unless You explicitly state otherwise, -any Contribution intentionally submitted for inclusion in the Work -by You to the Licensor shall be under the terms and conditions of -this License, without any additional terms or conditions. -Notwithstanding the above, nothing herein shall supersede or modify -the terms of any separate license agreement you may have executed -with Licensor regarding such Contributions. - -6. Trademarks. This License does not grant permission to use the trade -names, trademarks, service marks, or product names of the Licensor, -except as required for reasonable and customary use in describing the -origin of the Work and reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. Unless required by applicable law or -agreed to in writing, Licensor provides the Work (and each -Contributor provides its Contributions) on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -implied, including, without limitation, any warranties or conditions -of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A -PARTICULAR PURPOSE. You are solely responsible for determining the -appropriateness of using or redistributing the Work and assume any -risks associated with Your exercise of permissions under this License. - -8. Limitation of Liability. In no event and under no legal theory, -whether in tort (including negligence), contract, or otherwise, -unless required by applicable law (such as deliberate and grossly -negligent acts) or agreed to in writing, shall any Contributor be -liable to You for damages, including any direct, indirect, special, -incidental, or consequential damages of any character arising as a -result of this License or out of the use or inability to use the -Work (including but not limited to damages for loss of goodwill, -work stoppage, computer failure or malfunction, or any and all -other commercial damages or losses), even if such Contributor -has been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. While redistributing -the Work or Derivative Works thereof, You may choose to offer, -and charge a fee for, acceptance of support, warranty, indemnity, -or other liability obligations and/or rights consistent with this -License. However, in accepting such obligations, You may act only -on Your own behalf and on Your sole responsibility, not on behalf -of any other Contributor, and only if You agree to indemnify, -defend, and hold each Contributor harmless for any liability -incurred by, or claims asserted against, such Contributor by reason -of your accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Flora License to your work - -To apply the Flora License to your work, attach the following -boilerplate notice, with the fields enclosed by brackets "[]" -replaced with your own identifying information. (Don't include -the brackets!) The text should be enclosed in the appropriate -comment syntax for the file format. We also recommend that a -file or class name and description of purpose be included on the -same "printed page" as the copyright notice for easier -identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Flora License, Version 1.1 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://floralicense.org/license/ - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt deleted file mode 100644 index e69de29..0000000 diff --git a/doc/widget_doc.h b/doc/widget_doc.h deleted file mode 100644 index a778b69..0000000 --- a/doc/widget_doc.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright 2013 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#ifndef __WIDGET_DOC_H__ -#define __WIDGET_DOC_H__ - -/** - * @defgroup WIDGET_UTILITY_MODULE widget - * @brief Supports APIs for development of inhouse widget - * @ingroup CAPI_WIDGET_FRAMEWORK - * @section WIDGET_UTILITY_MODULE_HEADER Required Header - * \#include - * @section WIDGET_UTILITY_MODULE_OVERVIEW Overview -

widget Utility functions

- -

1. Script type widget

-If you choose the Script Type widget, you have to use this. - -widget defines its own syntax to share the content between home application and provider application. -It is called "Description Data Syntax" - -To generate it you have to use following functions. - -@code -struct widget_desc *desc_handle; -int idx; - -desc_handle = widget_desc_open(id, 0); -if (!desc_handle) { - // Error -} - -widget_desc_set_size(desc_handle, id, 720, 360); - -// Loads sub-layout object into main layout -idx = widget_desc_add_block(desc_handle, NULL, WIDGET_DESC_TYPE_SCRIPT, "sub,layout", "/usr/apps/com.samsung.my-app/shared/res/widget.edj", "sub,group"); -widget_desc_set_id(desc_handle, idx, "sub,layout"); - -// Set a text for sub-layout object -widget_desc_add_block(desc_handle, "sub,layout", WIDGET_DESC_TYPE_TEXT, "sub,layout,text", "Hello World", NULL); - -// Flushes changes, the content will be changed after close this handle. -widget_desc_close(desc_handle); -desc_handle = NULL; -@endcode - -Only after you close the desc_handle, the provider will send changes to the widget manager service. -And if it needs to propagate events to the home application, the home application will get changes event. - -

2. Window(buffer) type widget

- -@code -Evas_Object *parent; -Evas_Object *win; - -parent = widget_get_evas_object(id, 0); -if (!parent) { - // Error -} - -win = elm_win_add(parent, "widget Window", ELM_WIN_DYNAMIC_BOX); -evas_object_del(parent); -if (!win) { - // Error -} -@endcode - -To create a window for widget, -You have to get the parent object using widget_get_evas(). -And after creating a window for widget, you have to delete it. -Its attributes will be passed to the newly created window. So you don't need keep the parent object anymore. - -After creating a window, you can do what you want like an application. -Creatig any core-control such as button, list, etc, .... - -

3. Image type widget

-This kind of widget should create an image file using given Id. -The Id's syntax is "file://ABS_PATH_OF_OUTPUT_FILE", so you should create an image file using this URI. -The Id will be assigned to every widget instances. -And those are unique. - -If you create an image file, you should notify it to the viewer using widget_provider_app_widget_updated() -it is provided by libwidget_provider_app package. - -

4. Text type widget (Experimental)

-In case of text type, you may have no window or script file. -The text type widget only needs to generate content data using widget_desc_XXXX series APIs. -Of course, after you prepare the desc file, you have to call widget_provider_app_widget_updated() function too. -Then the viewer will get your updated contents and try to parse it to locate content of widget to its screen. -But, unfortunately, this type of widget is not fully supported yet. -Because it very highly depends on the viewer implementations. -So if the viewer doesn't support this type of widget, you cannot do anything for user. - -To generate the text data, you can use below API set. - - - widget_desc_open() - - widget_desc_set_category() - - widget_desc_set_size() - - widget_desc_set_id() - - widget_desc_add_block() - - widget_desc_del_block() - - widget_desc_close() - -Here is a sample code for you. -\code -#define FOR_GBAR 1 -#define FOR_WIDGET 0 - -struct widget_desc *handle; -int idx; - -handle = widget_desc_open(handle, FOR_GBAR); // The second parameter will help you choose to target, for glance bar or widget? -idx = widget_desc_add_block(handle, NULL, WIDGET_DESC_TYPE_SCRIPT, "/opt/usr/apps/your.company.application/shared/resource/edje/script.edj", "sample", NULL); -widget_desc_set_id(handle, idx, "sample"); -widget_desc_close(handle); -widget_provider_app_widget_updated(widget_id, 0, 0); -\endocde - - */ - -#endif /* __WIDGET_DOC_H__ */ diff --git a/include/binder.h b/include/binder.h deleted file mode 100644 index 8496778..0000000 --- a/include/binder.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2013 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @brief - * Abstracted Data Type of Virtual Window - */ -typedef struct virtual_window_info { - char *id; /**< Identification */ - widget_buffer_h handle; /**< Livebox buffer handle */ - enum win_type { - VWIN_SW_BUF = 0x00, /**< S/W buffer */ - VWIN_GEM = 0x01, /**< GEM buffer */ - VWIN_PIXMAP = 0x02, /**< PIXMAP */ - VWIN_ERROR = 0x03 /**< Unknown */ - } type; - Ecore_Evas *ee; - Evas *e; - int is_gbar; - int deleted; - int w; - int h; - unsigned int *resource_array; - int resource_cnt; - - int pressed; - - int orientation; -} *vwin_info_t; - -extern int binder_widget_send_updated(const char *pkgname, const char *id, widget_buffer_h handle, int idx, int x, int y, int w, int h, int gbar, const char *descfile); -extern int binder_widget_update_extra_info(const char *id, const char *content, const char *title, const char *icon, const char *name); -extern const char *binder_widget_find_pkgname(const char *uri); -extern Ecore_Evas *binder_ecore_evas_new(vwin_info_t info); -extern int binder_widget_auto_align(void); - -#define GL_ENGINE "opengl_x11" - -/* End of a file */ diff --git a/include/debug.h b/include/debug.h deleted file mode 100644 index 1d6ad5e..0000000 --- a/include/debug.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2013 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define DbgPrint(format, arg...) SECURE_LOGD(format, ##arg) -#define ErrPrint(format, arg...) SECURE_LOGE(format, ##arg) -#define WarnPrint(format, arg...) SECURE_LOGW(format, ##arg) - -#if defined(_ENABLE_PERF) -#define PERF_INIT() \ - struct timeval __stv; \ - struct timeval __etv; \ - struct timeval __rtv - -#define PERF_BEGIN() do { \ - if (gettimeofday(&__stv, NULL) < 0) { \ - ErrPrint("gettimeofday: %s\n", strerror(errno)); \ - } \ -} while (0) - -#define PERF_MARK(tag) do { \ - if (gettimeofday(&__etv, NULL) < 0) { \ - ErrPrint("gettimeofday: %s\n", strerror(errno)); \ - } \ - timersub(&__etv, &__stv, &__rtv); \ - DbgPrint("[%s] %u.%06u\n", tag, __rtv.tv_sec, __rtv.tv_usec); \ -} while (0) -#else -#define PERF_INIT() -#define PERF_BEGIN() -#define PERF_MARK(tag) -#endif - -/* End of a file */ diff --git a/include/dlist.h b/include/dlist.h deleted file mode 100644 index 4a4ac3e..0000000 --- a/include/dlist.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2013 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define dlist_remove_data(list, data) do { \ - struct dlist *l; \ - l = dlist_find_data(list, data); \ - list = dlist_remove(list, l); \ -} while (0) - -#define dlist_foreach(list, l, data) \ - for ((l) = (list); ((data) = dlist_data(l)); (l) = dlist_next(l)) - -#define dlist_foreach_safe(list, l, n, data) \ - for ((l) = (list), (n) = dlist_next(l); \ - ((data) = dlist_data(l)); \ - (l) = (n), (n) = dlist_next(l)) - -struct dlist; - -extern struct dlist *dlist_append(struct dlist *list, void *data); -extern struct dlist *dlist_prepend(struct dlist *list, void *data); -extern struct dlist *dlist_remove(struct dlist *list, struct dlist *l); -extern struct dlist *dlist_find_data(struct dlist *list, void *data); -extern void *dlist_data(struct dlist *l); -extern struct dlist *dlist_next(struct dlist *l); -extern struct dlist *dlist_prev(struct dlist *l); -extern int dlist_count(struct dlist *l); -extern struct dlist *dlist_nth(struct dlist *l, int nth); - -/* End of a file */ diff --git a/include/util.h b/include/util.h deleted file mode 100644 index c909e4b..0000000 --- a/include/util.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2013 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define FILE_SCHEMA "file://" - -extern int util_check_extension(const char *filename, const char *check_ptr); -extern double util_timestamp(void); -extern char *util_id_to_uri(const char *id); - -/* End of a file */ diff --git a/include/widget.h b/include/widget.h deleted file mode 100755 index 95c52c7..0000000 --- a/include/widget.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2013 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include - -#ifndef __WIDGET_UILITY_H -#define __WIDGET_UILITY_H - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @file widget.h - * @brief This file declares API of libwidget library - * @since_tizen 2.3.1 - */ - -/** - * @addtogroup CAPI_WIDGET_UTILITY_MODULE - * @{ - */ - -/** - * @brief Creates an Evas to draw widget contents - * @details Creating a new Object using widget frame buffer. - * @since_tizen 2.3.1 - * @param[in] widget_intance_id widget instance id - * @return instance of Evas - * @retval Valid pointer of Evas instance on success, - * @retval @c NULL failed to create, get_last_result() will returns reason of failure - */ -extern Evas *widget_get_evas(const char *widget_intance_id); - -/** - * @brief Requests to schedule the update operation to a provider. - * @detail Inserts a update event to event queue and it will be handled by update callback function defined by provider - * @since_tizen 2.3.1 - * @param[in] widget_intance_id A instance id of the widget to be updated - * @return 0 on success, otherwise a negative error value - * @retval #WIDGET_ERROR_NONE Successfully triggered - * @retval #WIDGET_ERROR_INVALID_PARAMETER Invalid argument - * @retval #WIDGET_ERROR_OUT_OF_MEMORY Not enough memory - * @retval #WIDGET_ERROR_NOT_EXIST Given id instance is not exist - * @retval #WIDGET_ERROR_PERMISSION_DENIED Permission denied - * @retval #WIDGET_ERROR_DISABLED in case of direct request for updating is disabled - */ -extern int widget_request_update(const char *widget_intance_id); - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif -/* End of a file */ diff --git a/include/widget_internal.h b/include/widget_internal.h deleted file mode 100755 index 64ddbdc..0000000 --- a/include/widget_internal.h +++ /dev/null @@ -1,749 +0,0 @@ -/* - * Copyright 2013 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Export by widget_service - */ -#include -#include - -#ifndef __WIDGET_UILITY_INTERNAL_H -#define __WIDGET_UILITY_INTERNAL_H - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @file widget_internal.h - * @brief This file declares API of libwidget library - * @since_tizen 2.3.1 - */ - -/** - * @addtogroup CAPI_WIDGET_UTILITY_MODULE - * @{ - */ - -/** - * @internal - * @brief Definition for COLOR BLOCK. - * @since_tizen 2.3.1 - */ -#define WIDGET_DESC_TYPE_COLOR "color" - -/** - * @internal - * @brief Definition for TEXT BLOCK. - * @since_tizen 2.3.1 - */ -#define WIDGET_DESC_TYPE_TEXT "text" - -/** - * @internal - * @brief Definition for IMAGE BLOCK. - * @since_tizen 2.3.1 - */ -#define WIDGET_DESC_TYPE_IMAGE "image" - -/** - * @internal - * @brief Definition for SIGNAL BLOCK. - * @since_tizen 2.3.1 - */ -#define WIDGET_DESC_TYPE_SIGNAL "signal" - -/** - * @internal - * @brief Definition for INFO BLOCK. - * @since_tizen 2.3.1 - */ -#define WIDGET_DESC_TYPE_INFO "info" - -/** - * @internal - * @brief Definition for DRAG BLOCK. - * @since_tizen 2.3.1 - */ -#define WIDGET_DESC_TYPE_DRAG "drag" - -/** - * @internal - * @brief Definition for SCRIPT SCRIPT. - * @since_tizen 2.3.1 - */ -#define WIDGET_DESC_TYPE_SCRIPT "script" - -/** - * @internal - * @brief Definition for ACCESSIBILITY INFORMATION BLOCK. - * @since_tizen 2.3.1 - */ -#define WIDGET_DESC_TYPE_ACCESS "access" - -/** - * @internal - * @brief Definition for accessibility operation. - * @since_tizen 2.3.1 - */ -#define WIDGET_DESC_TYPE_ACCESS_OPERATION "access,operation" - -/** - * @internal - * @brief Definition for set highlight on specified part. - * @since_tizen 2.3.1 - */ -#define WIDGET_DESC_DATA_ACCESS_OPERATION_HL_SET "set,hl" - -/** - * @internal - * @brief Definition for remove highlight from specified part. - * @since_tizen 2.3.1 - */ -#define WIDGET_DESC_DATA_ACCESS_OPERATION_HL_UNSET "unset,hl" - -/** - * @internal - * @brief Definition for move the highlight to next part. - * @since_tizen 2.3.1 - */ -#define WIDGET_DESC_DATA_ACCESS_OPERATION_HL_NEXT "next,hl" - -/** - * @internal - * @brief Definition for move the highlight to previous part. - * @since_tizen 2.3.1 - */ -#define WIDGET_DESC_DATA_ACCESS_OPERATION_HL_PREV "prev,hl" - -/** - * @internal - * @brief Definition for reset the chain of accessibility highlight list. - * @since_tizen 2.3.1 - */ -#define WIDGET_DESC_DATA_ACCESS_OPERATION_RESET "reset,focus" - -/** - * @internal - * @brief Definition for specify the highlight move option. - * @details If the highlight list reaches to the last object, move back to the first object. - * @since_tizen 2.3.1 - */ -#define WIDGET_DESC_OPTION_ACCESS_HL_LOOP "cycle" - -/** - * @internal - * @brief Definition for specify the highlight move option. - * @details If the highlight list reaches to the last object(or the first object), - * the "prev,hl", "next,hl" will be failed. - * @since_tizen 2.3.1 - */ -#define WIDGET_DESC_OPTION_ACCESS_HL_NOLOOP "no,cycle" - -/** - * @internal - * @brief Return values of widget programming interfaces for the plug-in type widgets - * @since_tizen 2.3.1 - */ -typedef enum widget_api_result { - WIDGET_DONE = 0x00, /**< Operation is successfully done. */ - WIDGET_OUTPUT_UPDATED = 0x01, /**< Contents are updated. */ - WIDGET_NEED_TO_SCHEDULE = 0x02, /**< Need to call the widget_need_to_update and widget_update_content. */ - WIDGET_NEED_TO_CREATE = 0x04, /**< Need to create a new instance. */ - WIDGET_NEED_TO_DESTROY = 0x08, /**< Need to destroy this instance. */ - WIDGET_FORCE_TO_SCHEDULE = 0x10, /**< Need to do force update. */ -} widget_api_result_e; - -/** - * @internal - * @brief System event type for the plug-in type widgets - * @since_tizen 2.3.1 - */ -typedef enum widget_system_event { - WIDGET_SYS_EVENT_FONT_CHANGED = 0x01, /**< System font is changed. */ - WIDGET_SYS_EVENT_LANG_CHANGED = 0x02, /**< System language is changed. */ - WIDGET_SYS_EVENT_TIME_CHANGED = 0x04, /**< System time is changed. */ - WIDGET_SYS_EVENT_REGION_CHANGED = 0x08, /**< Region changed. */ - WIDGET_SYS_EVENT_TTS_CHANGED = 0x10, /**< Accessibility mode changed. */ - WIDGET_SYS_EVENT_PAUSED = 0x0100, /**< widget is paused. */ - WIDGET_SYS_EVENT_RESUMED = 0x0200, /**< widget is resumed. */ - WIDGET_SYS_EVENT_MMC_STATUS_CHANGED = 0x0400, /**< MMC Status change event. */ - WIDGET_SYS_EVENT_DELETED = 0x0800, /**< widget instance is removed from a viewer. */ - WIDGET_SYS_EVENT_ORIENTATION_CHANGED = 0x01000, /**< Orientation is changed */ -} widget_system_event_e; - -/** - * @internal - * @brief widget description data handle. - * @since_tizen 2.3.1 - */ -typedef struct widget_desc *widget_desc_h; - -/** - * @internal - * @brief Flush Callback for snapshot window - * @since_tizen 2.3.1 - */ -typedef void (*widget_flush_cb)(void *snapshot_window, const char *id, int status, void *data); - -/** - * @internal - * @brief Updates a description file. - * @since_tizen 2.3.1 - * @remarks Must be used only by Inhouse widget. - * @param[in] id widget Instance Id - * @param[in] gbar 1 for Glance Bar or 0 - * @privlevel public - * @return Handle of desc instance - * @retval @c NULL Failed to create a desc instance, get_last_result() will returns reason of failure - * @pre Should be loaded by data-provider-slave. - * @post Should be destroyed(flushed) using widget_desc_close() API. - * @see widget_desc_close() - */ -extern widget_desc_h widget_desc_open(const char *id, int gbar); - -/** - * @internal - * @brief Completes the description file update. - * @details Only if this API is called, the description data will be applied to the content of widget (or GBar). - * @since_tizen 2.3.1 - * @remarks Must be used only by Inhouse widget. - * @param[in] handle Handle which is created by widget_desc_open() function - * @privlevel public - * @return 0 on success, otherwise a negative error value - * @retval #WIDGET_ERROR_NONE If the flushing description data is successfully done - * @retval #WIDGET_ERROR_INVALID_PARAMETER If the given handle is not valid - * @retval #WIDGET_ERROR_PERMISSION_DENIED Permission denied - * @pre Handle must be created by widget_desc_open() - * @post Handle must not be used after return from this function. - * @see widget_desc_open() - */ -extern int widget_desc_close(widget_desc_h handle); - -/** - * @internal - * @brief Sets the category information of current description data. - * @details Creates a new description block for updating category information of layout object. - * @since_tizen 2.3.1 - * @param[in] handle Handle which is created by widget_desc_open() function - * @param[in] id Id string of target object - * @param[in] category Category string that will be used by layout object - * @return 0 on success, otherwise a negative error value - * @retval #WIDGET_ERROR_INVALID_PARAMETER Invalid handle - * @retval #WIDGET_ERROR_OUT_OF_MEMORY Memory is not enough to add this block - * @retval index Index(>=0) of added block, which can be used by widget_desc_set_id() - * @pre Must be called after create a handle using widget_desc_open() - * @see widget_desc_set_id() - */ -extern int widget_desc_set_category(widget_desc_h handle, const char *id, const char *category); - -/** - * @internal - * @brief Sets the content size. - * @details Sets the content size of layout. - * @since_tizen 2.3.1 - * @param[in] handle Handle which is created by widget_desc_open() function - * @param[in] id Id string of target object - * @param[in] w Width in pixel - * @param[in] h Height in pixel - * @return 0 on success, otherwise a negative error value - * @retval #WIDGET_ERROR_INVALID_PARAMETER Invalid argument - * @retval #WIDGET_ERROR_OUT_OF_MEMORY Not enough memory to add a new block - * @retval index Index(>=0) of added block Successfully added - * @see widget_desc_open() - * @see widget_desc_set_id() - */ -extern int widget_desc_set_size(widget_desc_h handle, const char *id, int w, int h); - -/** - * @internal - * @brief Sets the target id of the given block. - * @details Only available for the script block. - * @since_tizen 2.3.1 - * @param[in] handle Handle which is created by widget_desc_open() function - * @param[in] idx Index of target block - * @param[in] id Id String which will be used by other widget_desc_XXX functions - * @return 0 on success, otherwise a negative error value - * @retval #WIDGET_ERROR_NONE Id is successfully updated for given idx of desc block - * @retval #WIDGET_ERROR_INVALID_PARAMETER Invalid argument - * @retval #WIDGET_ERROR_NOT_EXIST Given index of desc block is not exists - * @pre Desc block should be exists which has given index "idx". - * @post Specified Id string("id") can be used by other widget_desc_XXXX functions. - * @see widget_desc_open() - * @see widget_desc_set_id() - */ -extern int widget_desc_set_id(widget_desc_h handle, int idx, const char *id); - -/** - * @internal - * @brief Adds a new block. - * @since_tizen 2.3.1 - * @param[in] handle Handle which is created by the widget_desc_open() function - * @param[in] id ID of source script object - * @param[in] type Type (image|text|script|signal|.. etc) - * @param[in] part Target part to update with given content(data) - * @param[in] data Content for specified part - * @param[in] option Option for the block. (script: group, image: option, ...) - * @return Index of current description block - * @retval #WIDGET_ERROR_INVALID_PARAMETER Invalid argument - * @retval #WIDGET_ERROR_OUT_OF_MEMORY Not enough memory to add a new desc block - * @retval index Index(>=0) of added desc block - * @pre Handle must be created using widget_desc_open. - * @see widget_desc_set_id() - * @see widget_desc_del_block() - */ -extern int widget_desc_add_block(widget_desc_h handle, const char *id, const char *type, const char *part, const char *data, const char *option); - -/** - * @internal - * @brief Deletes an added block. - * @since_tizen 2.3.1 - * @details If you discard the added desc block, use this API and the index of the created desc block. - * @param[in] handle Handle which is created by widget_desc_open() function - * @param[in] idx Index of added block, returned from widget_desc_add_block(), widget_desc_set_size(), widget_desc_set_category(), etc - * @return 0 on success, otherwise a negative error value - * @retval #WIDGET_ERROR_NONE Successfully deleted - * @retval #WIDGET_ERROR_NOT_EXIST Given index of desc block is not exists - * @pre Index must be exists. - * @see widget_desc_add_block() - * @see widget_desc_open() - */ -extern int widget_desc_del_block(widget_desc_h handle, int idx); - -/** - * @internal - * @brief Structure for a widget buffer defined by a provider. - * @since_tizen 2.3.1 - */ -typedef struct widget_buffer *widget_buffer_h; - -/** - * @internal - * @brief Return values of widget programming interfaces: Using network. - * @since_tizen 2.3.1 - */ -extern const int WIDGET_USE_NET; - -/** - * @internal - * @brief Notifies the updated content to the provider. - * @details Forcedly notifies the updated contents. - * This function can be used from async callback function to notify the updated content. - * @since_tizen 2.3.1 - * @param[in] id Instance Id which is passed to you via the first parameter of every widget_XXXX interface functions - * @param[in] gbar 1 for updating content of Glance Bar or 0(for content of widget) - * @return 0 on success, otherwise a negative error value - * @retval #WIDGET_ERROR_OUT_OF_MEMORY Not enough memory - * @retval #WIDGET_ERROR_INVALID_PARAMETER Invalid argument - * @retval #WIDGET_ERROR_IO_ERROR I/O failed, Cannot access given resource file(id) - * @retval #WIDGET_ERROR_NONE Successfully notified - * @pre This API only can be used after loaded into the data-provider-slave process. - */ -extern int widget_content_is_updated(const char *id, int gbar); - -/** - * @internal - * @brief Acquires a buffer for GBar or widget, currently only the GBar is supported. - * @since_tizen 2.3.1 - * @param[in] id Instance Id which is passed to you via the first parameter of every widget_XXXX interface functions - * @param[in] gbar 1 for Glance Bar or 0 for widget - * @param[in] width Width in pixel - * @param[in] height Height in pixel - * @param[in] pixels Size of a pixel in bytes - * @param[in] handler Event handling callback - * @param[in] data User data for event handling callback - * @privlevel public - * @return Buffer handle - * @retval @c NULL Failed to acquire buffer, get_last_result() will returns reason of failure. - * @retval handler Handle object - * @pre Given instance must be specify its type as buffer. or this API will be fail. - * @post Allocated buffer object must be released via widget_release_buffer(). - * @see widget_release_buffer() - */ -extern widget_buffer_h widget_create_buffer(const char *id, int gbar, int auto_align, int (*handler)(widget_buffer_h, widget_buffer_event_data_t, void *), void *data); - -/** - * @internal - * @brief Acquire a buffer for GBar or widget. - * @since_tizen 2.3.1 - * @param[in] handle Buffer handle - * @param[in] idx Index of a buffer, WIDGET_PRIMARY_BUFFER is used for accessing primary buffer - * @param[in] width Width of a buffer - * @param[in] height Height of a buffer - * @param[in] pixels Pixel size in byte - * @privlevel public - * @return 0 on success, otherwise a negative error value - * @retval #WIDGET_ERROR_NONE Successfully allocated - * @retval #WIDGET_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #WIDGET_ERROR_FAULT Unrecoverable error occurred - * @retval #WIDGET_ERROR_PERMISSION_DENIED Permission denied - * @pre widget_create_buffer() must be called - * @see widget_create_buffer() - * @see widget_release_buffer() - */ -extern int widget_viewer_acquire_buffer(widget_buffer_h handle, int idx, int width, int height, int pixels); - -/** - * @internal - * @brief Acquires the Id of Resource (window system). - * @details Only if the provider uses Resource for providing render buffer. - * @since_tizen 2.3.1 - * @remarks Pixmap Id can be destroyed if you call the widget_release_buffer(). Then this Resource Id is not guaranteed to use. - * @param[in] handle Buffer handle - * @param[in] idx Index of a buffer, #c WIDGET_PRIMARY_BUFFER is used for accessing the primary buffer - * @return unsigned int Resource Id - * @retval >0 Resource Id - * @retval 0 Failed to get Resource Id - * @pre The system must be set to use the Resource Id method for content sharing. - * @see widget_acquire_buffer() - */ -extern unsigned int widget_viewer_get_resource_id(widget_buffer_h handle, int idx); - -/** - * @internal - * @brief Releases the buffer of widget. - * @since_tizen 2.3.1 - * @param[in] handle Buffer handle - * @param[in] idx Index of a buffer, #c WIDGET_PRIMARY_BUFFER is used for accessing the primary buffer - * @privlevel public - * @return 0 on success, otherwise a negative error value - * @retval #WIDGET_ERROR_INVALID_PARAMETER Invalid argument - * @retval #WIDGET_ERROR_NONE Successfully released - * @retval #WIDGET_ERROR_PERMISSION_DENIED Permission denied - * @pre Handle must be created using widget_acquire_buffer(). - * @see widget_acquire_buffer() - */ -extern int widget_viewer_release_buffer(widget_buffer_h handle, int idx); - -/** - * @internal - * @brief Destroy a buffer of widget - * @since_tizen 2.3.1 - * @param[in] handle buffer handle - * @privlevel public - * @return 0 on success, otherwise a negative error value - * @retval #WIDGET_ERROR_INVALID_PARAMTER Invalid argument - * @retval #WIDGET_ERROR_PERMISSION_DENIED Permission denied - * @retval #WIDGET_ERROR_NONE Successfully destroyed - * @see widget_create_buffer() - */ -extern int widget_destroy_buffer(widget_buffer_h handle); - -/** - * @internal - * @brief Gets the address of buffer for S/W rendering. - * @details If you try to use this, after widget_create_hw_buffer(), you will get @c NULL. - * This API only be used for primary buffer. you cannot access the extra buffer - * @since_tizen 2.3.1 - * @param[in] handle Buffer handle - * @privlevel public - * @retval @c NULL If it falis to get buffer address, get_last_result() will returns reason of failure. - * @retval address If it succeed to get the buffer address - * @see widget_unref_buffer() - */ -extern void *widget_ref_buffer(widget_buffer_h handle); - -/** - * @internal - * @brief Releases the S/W render buffer. - * @since_tizen 2.3.1 - * @param[in] buffer Address of render buffer - * @privlevel public - * @return 0 on success, otherwise a negative error value - * @retval #WIDGET_ERROR_INVALID_PARAMETER Invalid handle - * @retval #WIDGET_ERROR_PERMISSION_DENIED Permission denied - * @retval #WIDGET_ERROR_NONE Successfully unreference - * @pre widget_ref_buffer() must be called. - * @see widget_ref_buffer() - */ -extern int widget_unref_buffer(void *buffer); - -/** - * @internal - * @brief Synchronizes the updated buffer. - * @details This is only needed for non-H/W accelerated buffer. - * This API is only supported for primary buffer (#c WIDGET_PRIMARY_BUFFER) - * @since_tizen 2.3.1 - * @param[in] handle Buffer handle - * @privlevel public - * @return 0 on success, otherwise a negative error value - * @retval #WIDGET_ERROR_NONE Successfully sync'd - * @retval #WIDGET_ERROR_PERMISSION_DENIED Permission denied - * @retval #WIDGET_ERROR_INVALID_PARAMETER Invalid argument - * @see widget_acquire_buffer() - */ -extern int widget_viewer_sync_buffer(widget_buffer_h handle); - -/** - * @internal - * @brief Checks whether the widget supports H/W acceleration or not. - * This API is only supported for primary buffer (#c WIDGET_PRIMARY_BUFFER) - * @since_tizen 2.3.1 - * @param[in] handle Buffer handle - * @return int type - * @retval 1 If the buffer handle support the H/W acceleration buffer - * @retval 0 If it doesn not supported - * @see widget_acquire_buffer() - */ -extern int widget_support_hw_buffer(widget_buffer_h handle); - -/** - * @internal - * @brief Creates the H/W accelerated buffer. - * This API is only supported for primary buffer (#c WIDGET_PRIMARY_BUFFER) - * @since_tizen 2.3.1 - * @param[in] handle Buffer handle - * @privlevel public - * @return 0 on success, otherwise a negative error value - * @retval #WIDGET_ERROR_ALREADY_EXIST H/W buffer is already created - * @retval #WIDGET_ERROR_INVALID_PARAMETER Invalid argument - * @retval #WIDGET_ERROR_PERMISSION_DENIED Permission denied - * @retval #WIDGET_ERROR_NONE Successfully created - * @pre Must be checked whether the H/W buffer is supported or not. - * @post Must be destroyed if it is not necessary. - * @see widget_support_hw_buffer() - */ -extern int widget_create_hw_buffer(widget_buffer_h handle); - -/** - * @internal - * @brief Destroys the H/W accelerated buffer. - * This API is only supported for primary buffer (#c WIDGET_PRIMARY_BUFFER) - * @since_tizen 2.3.1 - * @param[in] handle Buffer handle - * @privlevel public - * @return 0 on success, otherwise a negative error value - * @retval #WIDGET_ERROR_NONE Successfully destroyed - * @retval #WIDGET_ERROR_PERMISSION_DENIED Permission denied - * @retval #WIDGET_ERROR_INVALID_PARAMETER Invalid argument - * @pre Must be created h/w buffer using widget_create_hw_buffer. - * @see widget_create_hw_buffer() - */ -extern int widget_destroy_hw_buffer(widget_buffer_h handle); - -/** - * @internal - * @brief Gets the address of the accelerated H/W buffer. - * This API is only supported for primary buffer (#c WIDGET_PRIMARY_BUFFER) - * @since_tizen 2.3.1 - * @param[in] handle Buffer handle - * @privlevel public - * @retval @c NULL Failed to get H/W accelerated buffer address, get_last_result() will returns reason of failure. - * @retval addr H/W accelerated buffer address - * @see widget_create_hw_buffer() - */ -extern void *widget_buffer_hw_buffer(widget_buffer_h handle); - -/** - * @internal - * @brief Get the stride information from the buffer info - * This API is only supported for primary buffer (#c WIDGET_PRIMARY_BUFFER) - * @since_tizen 2.3.1 - * @param[in] handle Buffer handle - * @return int stride size - * @retval positive_value length of stride - * @retval #WIDGET_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #WIDGET_ERROR_FAULT Unrecoverable error - * @see widget_create_hw_buffer() - */ -extern int widget_buffer_stride(widget_buffer_h handle); - -/** - * @internal - * @brief Pre-processes for rendering content. - * @details This is only needed for accessing H/W accelerated buffer. - * @since_tizen 2.3.1 - * @param[in] handle Buffer handle - * @privlevel public - * @return 0 on success, otherwise a negative error value - * @retval #WIDGET_ERROR_INVALID_PARAMETER Invalid handle - * @retval #WIDGET_ERROR_PERMISSION_DENIED Permission denied - * @retval #WIDGET_ERROR_NONE Successfully done - * @post widget_buffer_post_render must be called after the rendering (accessing buffer) is completed. - * @see widget_support_hw_buffer() - * @see widget_buffer_post_render() - */ -extern int widget_buffer_pre_render(widget_buffer_h handle); - -/** - * @internal - * @brief Post-processes for rendering content. - * @since_tizen 2.3.1 - * @param[in] handle Buffer handle - * @privlevel public - * @return 0 on success, otherwise a negative error value - * @retval #WIDGET_ERROR_NONE If succeed - * @retval #WIDGET_ERROR_PERMISSION_DENIED Permission denied - * @retval #WIDGET_ERROR_INVALID_PARAMETER Invalid argument - * @pre widget_buffer_pre_render must be called. - * @see widget_support_hw_buffer() - * @see widget_buffer_pre_render() - */ -extern int widget_buffer_post_render(widget_buffer_h handle); - -/** - * @internal - * @brief Sends a request to the viewer (homescreen) to close the GBar. - * @details Even though you call this function. the homescreen can ignore it. - * @since_tizen 2.3.1 - * @param[in] widgetid widget Package Id - * @param[in] id Instance Id which is passed to you via the first parameter of every widget_XXXX interface functions - * @param[in] reason #WIDGET_ERROR_NONE(0) - * @privlevel public - * @return 0 on success, otherwise a negative error value - * @retval #WIDGET_ERROR_PERMISSION_DENIED Permission denied - * @retval #WIDGET_ERROR_INVALID_PARAMETER Invalid parameters - * @retval #WIDGET_ERROR_OUT_OF_MEMORY Out of memory - * @retval #WIDGET_ERROR_FAULT Failed to send a request - * @retval #WIDGET_ERROR_NONE Successfully requested - */ -extern int widget_request_close_glance_bar(const char *widgetid, const char *id, int reason); - -/** - * @internal - * @brief Create a snapshot window - * @details - * If you want create a snapshot image of contents, create this snapshot window - * But it will not renders object asynchronously, - * So you have to render the objects immediately, the delayed rendering object will not be on the canvas - * After flush it to a file. - * @since_tizen 2.3.1 - * @param[in] id - * @param[in] size_type - * @retval @c NULL failed to create a snapshot window, get_last_result() will returns reason of failure. - * @retval Object window object (ex, elementary window) - * @see widget_snapshot_window_flush() - */ -extern void *widget_snapshot_window_add(const char *id, int size_type); - -/** - * @internal - * @brief Flush to a file for snapshot window - * @since_tizen 2.3.1 - * @param[in] snapshot_win Snapshot window - * @param[in] timeout After this, the image file will be created - * @param[in] flush_cb Right after flush an image file, this callback will be called - * @param[in] data Callback data for flush_cb - * @return 0 on success, otherwise a negative error value - * @retval #WIDGET_ERROR_NONE Successfully flushed (flush timer added) - * @retval #WIDGET_ERROR_INVALID_PARAMETER Invalid paramter - * @retval #WIDGET_ERROR_FAULT Failed to create a flush timer - * @see widget_snapshot_window_add() - */ -extern int widget_snapshot_window_flush(void *snapshot_win, double timeout, widget_flush_cb flush_cb, void *data); - -/** - * @internal - * @brief Sending the updated event to the viewer - * @since_tizen 2.3.1 - * @param[in] handle widget Buffer Handle - * @param[in] idx Index of a buffer - * @privlevel public - * @return 0 on success, otherwise a negative error value - * @retval #WIDGET_ERROR_NONE Successfully sent - */ -extern int widget_send_updated_by_idx(widget_buffer_h handle, int idx); - -/** - * @internal - * @brief Set extra information for updated content. - * @details - * If the provider should give some hints to the viewer, - * such as title, icon and name, this function can set them. - * provider will send those information to the viewer when the - * content is updated. - * @since_tizen 2.3.1 - * * @remarks This function only works with the buffer type inhouse provider. - * @param[in] id widget Instance Id - * @param[in] content Content string that will pass to a widget via widget_create interface when it is re-created. - * @param[in] title Human readable text for accessibility, summarized text for representing the content of a box. - * @param[in] icon Path of icon image file - alternative image content - * @param[in] name Name of a box - alternative text content - * @return 0 on success, otherwise a negative error value - * @retval #WIDGET_ERROR_OUT_OF_MEMORY Out of memory - * @retval #WIDGET_ERROR_INVALID_PARAMETER Invalid parameters - * @retval #WIDGET_ERROR_FAULT Unrecoverable error - * @retval #WIDGET_ERROR_NONE Successfully sent - * TODO: plug-in type - */ -extern int widget_set_extra_info(const char *id, const char *content, const char *title, const char *icon, const char *name); - -/** - * @internal - * @brief Send a freeze request to the viewer (homescreen) - * @details - * The viewer will get this request via event callback. - * Then it should freeze its scroller or stop moving the widget. - * @since_tizen 2.3.1 - * @remarks If the viewer doesn't care this request, this will has no effect. - * @param[in] widgetid widget Package Id - * @param[in] id Instance Id which is passed to you via the first parameter of every widget_XXXX interface functions - * @privlevel public - * @return 0 on success, otherwise a negative error value - * @retval #WIDGET_ERROR_INVALID_PARAMETER Invalid parameters - * @retval #WIDGET_ERROR_OUT_OF_MEMORY Out of memory - * @retval #WIDGET_ERROR_PERMISSION_DENIED Permission denied - * @retval #WIDGET_ERROR_FAULT Failed to send requet - * @retval #WIDGET_ERROR_NONE Successfully requested - * @see widget_release_scroller() - * TODO: plug-in type - */ -extern int widget_freeze_scroller(const char *widgetid, const char *id); - -/** - * @inernal - * @brief Send a release request to the viewer (homescreen) - * @details - * The viewer will get this request via event callback. - * Then it should release its scroller or continue moving the widget. - * @since_tizen 2.3.1 - * @remarks If the viewer doesn't care this request, this will has no effect. - * @param[in] widgetid widget Package Id - * @param[in] id Instance Id which is passed to you via the first parameter of every widget_XXXX interface functions - * @privlevel public - * @return 0 on success, otherwise a negative error value - * @retval #WIDGET_ERROR_PERMISSION_DENIED Permission denied - * @retval #WIDGET_ERROR_INVALID_PARAMETER Invalid parameters - * @retval #WIDGET_ERROR_OUT_OF_MEMORY Out of memory - * @retval #WIDGET_ERROR_FAULT Failed to send requet - * @retval #WIDGET_ERROR_NONE Successfully requested - * @see widget_freeze_scroller() - * TODO: plug-in type - */ -extern int widget_thaw_scroller(const char *widgetid, const char *id); - -/** - */ -extern int widget_del_pre_callback(widget_pre_callback_e type, widget_pre_callback_t cb, void *data); - -/** - */ -extern int widget_add_pre_callback(widget_pre_callback_e type, widget_pre_callback_t cb, void *data); - -/** - */ -extern int widget_get_orientation(const char *id); - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif -/* End of a file */ diff --git a/packaging/libwidget.manifest b/packaging/libwidget.manifest deleted file mode 100644 index a76fdba..0000000 --- a/packaging/libwidget.manifest +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/packaging/libwidget.spec b/packaging/libwidget.spec deleted file mode 100644 index ade1ed6..0000000 --- a/packaging/libwidget.spec +++ /dev/null @@ -1,89 +0,0 @@ -%bcond_with wayland - -Name: libwidget -Summary: widget development library -Version: 1.1.2 -Release: 1 -Group: HomeTF/widget -License: Flora -Source0: %{name}-%{version}.tar.gz -Source1001: %{name}.manifest -BuildRequires: cmake, gettext-tools, coreutils -BuildRequires: pkgconfig(dlog) -BuildRequires: pkgconfig(widget_service) -BuildRequires: pkgconfig(widget_provider) -BuildRequires: pkgconfig(ecore) -BuildRequires: pkgconfig(evas) -BuildRequires: pkgconfig(elementary) -BuildRequires: model-build-features - -%if %{with wayland} -%else -BuildRequires: pkgconfig(x11) -%endif - -%if "%{model_build_feature_widget}" == "0" -ExclusiveArch: -%endif - -%description -Library for the development of a widget - -%package devel -Summary: widget development library (dev) -Group: Development/Libraries -Requires: %{name} = %{version}-%{release} - -%description devel -Header & Package configuration files for widget development - -%prep -%setup -q -cp %{SOURCE1001} . - -%build -%if 0%{?sec_build_binary_debug_enable} -export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE" -export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE" -export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE" -%endif - -%if 0%{?tizen_build_binary_release_type_eng} -export CFLAGS="${CFLAGS} -DTIZEN_ENGINEER_MODE" -export CXXFLAGS="${CXXFLAGS} -DTIZEN_ENGINEER_MODE" -export FFLAGS="${FFLAGS} -DTIZEN_ENGINEER_MODE" -%endif - -%if %{with wayland} -export WAYLAND_SUPPORT=On -export X11_SUPPORT=Off -%else -export WAYLAND_SUPPORT=Off -export X11_SUPPORT=On -%endif - -%cmake . -DWAYLAND_SUPPORT=${WAYLAND_SUPPORT} -DX11_SUPPORT=${X11_SUPPORT} -make %{?jobs:-j%jobs} - -%install -rm -rf %{buildroot} -%make_install -mkdir -p %{buildroot}/%{_datarootdir}/license - -%post -n %{name} -p /sbin/ldconfig -%postun -n %{name} -p /sbin/ldconfig - -%files -n %{name} -%defattr(-,root,root,-) -%manifest %{name}.manifest -%{_libdir}/libwidget.so* -%{_datarootdir}/license/libwidget - -%files devel -%defattr(-,root,root,-) -%manifest %{name}.manifest -%{_includedir}/widget/widget.h -%{_includedir}/widget/widget_internal.h -%{_libdir}/pkgconfig/widget.pc - -# End of a file diff --git a/patch/pixmap_ee.patch b/patch/pixmap_ee.patch deleted file mode 100644 index e144c5c..0000000 --- a/patch/pixmap_ee.patch +++ /dev/null @@ -1,128 +0,0 @@ -diff --git a/src/virtual_window.c b/src/virtual_window.c -index 1c42a7c..7a487ff 100644 ---- a/src/virtual_window.c -+++ b/src/virtual_window.c -@@ -40,9 +40,14 @@ - static struct static_info { - Ecore_Evas *(*alloc_canvas)(int w, int h, void *(*a)(void *data, int size), void (*f)(void *data, void *ptr), void *data); - Ecore_Evas *(*alloc_canvas_with_stride)(int w, int h, void *(*a)(void *data, int size, int *stride, int *bpp), void (*f)(void *data, void *ptr), void *data); -+ Ecore_Evas *(*alloc_canvas_with_pixmap)(const char *disp_name, Ecore_X_Window parent, -+ int x, int y, int w, int h, -+ Ecore_X_Pixmap (*alloc_cb)(void *data, Ecore_X_Window parent, int w, int h, int *depth), -+ void (*free_cb)(void *data, Ecore_X_Pixmap pixmap), void *data); - } s_info = { - .alloc_canvas = NULL, - .alloc_canvas_with_stride = NULL, -+ .alloc_canvas_with_pixmap = NULL, - }; - - /*! -@@ -639,12 +644,70 @@ static void ecore_evas_free_cb(Ecore_Evas *ee) - info->ee = NULL; - } - -+/** -+ * @note -+ * This callback can be called twice (or more) to get a several pixmaps -+ * Acquired pixmaps are used for double/tripple buffering for canvas -+ */ -+static Ecore_X_Pixmap alloc_pixmap_cb(void *data, Ecore_X_Window parent, int w, int h, int *depth) -+{ -+ struct info *info = data; -+ -+ if (info->ee) { -+ ecore_evas_geometry_get(info->ee, NULL, NULL, &info->w, &info->h); -+ DbgPrint("Size of ee is updated: %dx%d (info: %p)\n", info->w, info->h, info); -+ } -+ -+ /*! -+ * Acquire a buffer for canvas. -+ */ -+ info->handle = widget_acquire_buffer(info->id, info->is_gbar, -+ info->w, info->h, sizeof(int), 0, -+ event_handler_cb, info); -+ if (!info->handle) { -+ ErrPrint("Failed to get the buffer\n"); -+ return 0u; -+ } -+ -+ info->is_hw = 0; -+ return (Ecore_X_Pixmap)widget_resource_id(info->handle); -+} -+ -+static void free_pixmap_cb(void *data, Ecore_X_Pixmap pixmap) -+{ -+ struct info *info = data; -+ -+ if (!info->handle) { -+ return; -+ } -+ -+ if (info->is_hw) { -+ ErrPrint("Impossible\n"); -+ } -+ -+ widget_release_buffer(info->handle); -+ info->handle = NULL; -+ -+ if (info->deleted) { -+ free(info->id); -+ info->id = NULL; -+ -+ free(info); -+ } -+} -+ - PUBLIC Evas_Object *widget_get_evas_object(const char *id, int is_pd) - { - struct info *info; - Evas_Object *rect; -+ const char *engine; -+ -+ if (!s_info.alloc_canvas && !s_info.alloc_canvas_with_stride && !s_info.alloc_canvas_with_pixmap) { -+ s_info.alloc_canvas_with_pixmap = dlsym(RTLD_DEFAULT, "ecore_evas_gl_x11_pixmap_allocfunc_new"); -+ if (!s_info.alloc_canvas_with_pixmap) { -+ DbgPrint("pixmap_allocfunc_new is not found\n"); -+ } - -- if (!s_info.alloc_canvas && !s_info.alloc_canvas_with_stride) { - s_info.alloc_canvas_with_stride = dlsym(RTLD_DEFAULT, "ecore_evas_buffer_allocfunc_with_stride_new"); - if (!s_info.alloc_canvas_with_stride) { - DbgPrint("allocfunc_with_stirde_new is not found\n"); -@@ -655,7 +718,7 @@ PUBLIC Evas_Object *widget_get_evas_object(const char *id, int is_pd) - ErrPrint("allocfunc_new is not found\n"); - } - -- if (!s_info.alloc_canvas_with_stride && !s_info.alloc_canvas) { -+ if (!s_info.alloc_canvas_with_stride && !s_info.alloc_canvas && !s_info.alloc_canvas_with_pixmap) { - ErrPrint("No way to allocate canvas\n"); - return NULL; - } -@@ -687,10 +750,23 @@ PUBLIC Evas_Object *widget_get_evas_object(const char *id, int is_pd) - info->w = 1; - info->h = 1; - -- if (!widget_conf_auto_align() && s_info.alloc_canvas_with_stride) { -- info->ee = s_info.alloc_canvas_with_stride(1, 1, alloc_stride_fb, free_fb, info); -- } else { -- info->ee = s_info.alloc_canvas(1, 1, alloc_fb, free_fb, info); -+ engine = elm_config_preferred_engine_get(); -+ DbgPrint("Preferred engine: %s\n", engine); -+ if (engine && !strcmp(engine, "opengl_x11")) { -+ if (s_info.alloc_canvas_with_pixmap) { -+ info->ee = s_info.alloc_canvas_with_pixmap(NULL, 0u, 0, 0, 1, 1, alloc_pixmap_cb, free_pixmap_cb, info); -+ } -+ } -+ -+ if (!info->ee) { -+ /** -+ * Fallback to buffer backend -+ */ -+ if (!widget_conf_auto_align() && s_info.alloc_canvas_with_stride) { -+ info->ee = s_info.alloc_canvas_with_stride(1, 1, alloc_stride_fb, free_fb, info); -+ } else { -+ info->ee = s_info.alloc_canvas(1, 1, alloc_fb, free_fb, info); -+ } - } - - if (!info->ee) { diff --git a/patch/pixmap_ee_widget.patch b/patch/pixmap_ee_widget.patch deleted file mode 100644 index 0bdb73e..0000000 --- a/patch/pixmap_ee_widget.patch +++ /dev/null @@ -1,125 +0,0 @@ -diff --git a/src/virtual_window.c b/src/virtual_window.c -index 4f482ff..0e39eda 100644 ---- a/src/virtual_window.c -+++ b/src/virtual_window.c -@@ -41,9 +41,11 @@ - static struct static_info { - Ecore_Evas *(*alloc_canvas)(int w, int h, void *(*a)(void *data, int size), void (*f)(void *data, void *ptr), void *data); - Ecore_Evas *(*alloc_canvas_with_stride)(int w, int h, void *(*a)(void *data, int size, int *stride, int *bpp), void (*f)(void *data, void *ptr), void *data); -+ Ecore_Evas *(*alloc_canvas_with_pixmap)(const char *disp_name, Ecore_X_Window parent, int x, int y, int w, int h, Ecore_X_Pixmap (*alloc_cb)(void *data, Ecore_X_Window parent, int w, int h, int *depth), void (*free_cb)(void *data, Ecore_X_Pixmap pixmap), void *data); - } s_info = { - .alloc_canvas = NULL, - .alloc_canvas_with_stride = NULL, -+ .alloc_canvas_with_pixmap = NULL, - }; - - /** -@@ -486,6 +488,58 @@ static int event_handler_cb(struct widget_buffer *handler, struct widget - return ret; - } - -+/** -+ * @note -+ * This callback can be called twice (or more) to get a several pixmaps -+ * Acquired pixmaps are used for double/tripple buffering for canvas -+ */ -+static Ecore_X_Pixmap alloc_pixmap_cb(void *data, Ecore_X_Window parent, int w, int h, int *depth) -+{ -+ struct info *info = data; -+ -+ if (info->ee) { -+ ecore_evas_geometry_get(info->ee, NULL, NULL, &info->w, &info->h); -+ DbgPrint("Size of ee is updated: %dx%d (info: %p)\n", info->w, info->h, info); -+ } -+ -+ /*! -+ * Acquire a buffer for canvas. -+ */ -+ info->handle = widget_acquire_buffer(info->id, info->is_gbar, -+ info->w, info->h, sizeof(int), 0, -+ event_handler_cb, info); -+ if (!info->handle) { -+ ErrPrint("Failed to get the buffer\n"); -+ return 0u; -+ } -+ -+ info->is_hw = 0; -+ return (Ecore_X_Pixmap)widget_resource_id(info->handle); -+} -+ -+static void free_pixmap_cb(void *data, Ecore_X_Pixmap pixmap) -+{ -+ struct info *info = data; -+ -+ if (!info->handle) { -+ return; -+ } -+ -+ if (info->is_hw) { -+ ErrPrint("Impossible\n"); -+ } -+ -+ widget_release_buffer(info->handle); -+ info->handle = NULL; -+ -+ if (info->deleted) { -+ free(info->id); -+ info->id = NULL; -+ -+ free(info); -+ } -+} -+ - static void *alloc_fb(void *data, int size) - { - struct info *info = data; -@@ -654,8 +708,14 @@ PUBLIC void *widget_get_evas_object(const char *id, int is_gbar) - { - struct info *info; - Evas_Object *rect; -+ const char *engine; -+ -+ if (!s_info.alloc_canvas && !s_info.alloc_canvas_with_stride && !s_info.alloc_canvas_with_pixmap) { -+ s_info.alloc_canvas_with_pixmap = dlsym(RTLD_DEFAULT, "ecore_evas_gl_x11_pixmap_allocfunc_new"); -+ if (!s_info.alloc_canvas_with_pixmap) { -+ DbgPrint("pixmap_allocfunc_new is not found\n"); -+ } - -- if (!s_info.alloc_canvas && !s_info.alloc_canvas_with_stride) { - s_info.alloc_canvas_with_stride = dlsym(RTLD_DEFAULT, "ecore_evas_buffer_allocfunc_with_stride_new"); - if (!s_info.alloc_canvas_with_stride) { - DbgPrint("allocfunc_with_stirde_new is not found\n"); -@@ -666,7 +726,7 @@ PUBLIC void *widget_get_evas_object(const char *id, int is_gbar) - ErrPrint("allocfunc_new is not found\n"); - } - -- if (!s_info.alloc_canvas_with_stride && !s_info.alloc_canvas) { -+ if (!s_info.alloc_canvas_with_stride && !s_info.alloc_canvas && !s_info.alloc_canvas_with_pixmap) { - ErrPrint("No way to allocate canvas\n"); - return NULL; - } -@@ -698,10 +758,20 @@ PUBLIC void *widget_get_evas_object(const char *id, int is_gbar) - info->w = 1; - info->h = 1; - -- if (!widget_conf_auto_align() && s_info.alloc_canvas_with_stride) { -- info->ee = s_info.alloc_canvas_with_stride(1, 1, alloc_stride_fb, free_fb, info); -- } else if (s_info.alloc_canvas) { -- info->ee = s_info.alloc_canvas(1, 1, alloc_fb, free_fb, info); -+ engine = elm_config_preferred_engine_get(); -+ DbgPrint("Preferred engine: %s\n", engine); -+ if (engine && !strcmp(engine, "opengl_x11")) { -+ if (s_info.alloc_canvas_with_pixmap) { -+ info->ee = s_info.alloc_canvas_with_pixmap(NULL, 0u, 0, 0, 1, 1, alloc_pixmap_cb, free_pixmap_cb, info); -+ } -+ } -+ -+ if (!info->ee) { -+ if (!widget_conf_auto_align() && s_info.alloc_canvas_with_stride) { -+ info->ee = s_info.alloc_canvas_with_stride(1, 1, alloc_stride_fb, free_fb, info); -+ } else if (s_info.alloc_canvas) { -+ info->ee = s_info.alloc_canvas(1, 1, alloc_fb, free_fb, info); -+ } - } - - if (!info->ee) { diff --git a/src/binder.c b/src/binder.c deleted file mode 100644 index 09fac0e..0000000 --- a/src/binder.c +++ /dev/null @@ -1,536 +0,0 @@ -#include -#include -#define __USE_GNU -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -#include "widget.h" -#include "widget_internal.h" -#include "binder.h" -#include "debug.h" -#include "util.h" - -#define PUBLIC __attribute__((visibility("default"))) - -/** - * @brief These functions are defined in the data-provider-slave - */ -static struct info { - const char *(*find_pkgname)(const char *filename); - int (*request_update_by_id)(const char *uri); - int (*trigger_update_monitor)(const char *id, int is_gbar); - int (*update_extra_info)(const char *id, const char *content, const char *title, const char *icon, const char *name); - int (*add_pre_callback)(widget_pre_callback_e type, widget_pre_callback_t cb, void *data); - int (*del_pre_callback)(widget_pre_callback_e type, widget_pre_callback_t cb, void *data); - int (*orientation)(const char *id); - Ecore_Evas *(*alloc_canvas)(int w, int h, void *(*a)(void *data, int size), void (*f)(void *data, void *ptr), void *data); - Ecore_Evas *(*alloc_canvas_with_stride)(int w, int h, void *(*a)(void *data, int size, int *stride, int *bpp), void (*f)(void *data, void *ptr), void *data); - Ecore_Evas *(*alloc_canvas_with_pixmap)(const char *disp_name, Ecore_X_Window parent, int x, int y, int w, int h, Ecore_X_Pixmap (*alloc_cb)(void *data, Ecore_X_Window parent, int w, int h, int depth), void (*free_cb)(void *data, Ecore_X_Pixmap pixmap), void *data); - - enum load_type { - LOAD_TYPE_UNKNOWN = -1, - LOAD_TYPE_SLAVE = 0, - LOAD_TYPE_APP = 1 - } type; - - union _updated { - struct _slave { - int (*send)(const char *pkgname, const char *id, widget_buffer_h handle, int idx, int x, int y, int w, int h, int gbar, const char *descfile); - } slave; - - struct _app { - int (*send)(widget_buffer_h handle, int idx, int x, int y, int w, int h, int gbar); - } app; - } binder; -} s_info = { - .find_pkgname = NULL, - .request_update_by_id = NULL, - .trigger_update_monitor = NULL, - .update_extra_info = NULL, - .add_pre_callback = NULL, - .del_pre_callback = NULL, - .orientation = NULL, - .alloc_canvas = NULL, - .alloc_canvas_with_stride = NULL, - .alloc_canvas_with_pixmap = NULL, - .type = LOAD_TYPE_UNKNOWN, /* Not initialized */ - .binder = { - .slave = { - .send = NULL, - }, - .app = { - .send = NULL, - }, - }, -}; - -#define FUNC_PREFIX "widget_" -#define FUNC_WIDGET_SEND_UPDATED FUNC_PREFIX "send_buffer_updated" -#define FUNC_WIDGET_FIND_PKGNAME FUNC_PREFIX "find_pkgname" -#define FUNC_WIDGET_REQUEST_UPDATE_BY_ID FUNC_PREFIX "request_update_by_id" -#define FUNC_WIDGET_TRIGGER_UPDATE_MONITOR FUNC_PREFIX "trigger_update_monitor" -#define FUNC_WIDGET_UPDATE_EXTRA_INFO FUNC_PREFIX "update_extra_info" - -#define FUNC_WIDGET_PROVIDER_APP_UPDATED FUNC_PREFIX "provider_app_buffer_updated" - -#define FUNC_WIDGET_PROVIDER_APP_ADD_PRE_CALLBACK FUNC_PREFIX "provider_app_add_pre_callback" -#define FUNC_WIDGET_PROVIDER_APP_DEL_PRE_CALLBACK FUNC_PREFIX "provider_app_del_pre_callback" -#define FUNC_WIDGET_PROVIDER_APP_ORIENTATION FUNC_PREFIX "provider_app_get_orientation" - -static inline void load_ecore_evas_function(void) -{ - if (!s_info.alloc_canvas && !s_info.alloc_canvas_with_stride && !s_info.alloc_canvas_with_pixmap) { - s_info.alloc_canvas_with_pixmap = dlsym(RTLD_DEFAULT, "ecore_evas_gl_x11_pixmap_allocfunc_new"); - if (!s_info.alloc_canvas_with_pixmap) { - DbgPrint("pixmap_allocfunc_new is not found\n"); - } - - s_info.alloc_canvas_with_stride = dlsym(RTLD_DEFAULT, "ecore_evas_buffer_allocfunc_with_stride_new"); - if (!s_info.alloc_canvas_with_stride) { - DbgPrint("allocfunc_with_stirde_new is not found\n"); - } - - s_info.alloc_canvas = dlsym(RTLD_DEFAULT, "ecore_evas_buffer_allocfunc_new"); - if (!s_info.alloc_canvas) { - ErrPrint("allocfunc_new is not found\n"); - } - - if (!s_info.alloc_canvas_with_stride && !s_info.alloc_canvas && !s_info.alloc_canvas_with_pixmap) { - ErrPrint("No way to allocate canvas\n"); - } - } -} - -static inline void load_update_function(void) -{ - /* Must to be checked the slave function first. */ - s_info.binder.slave.send = dlsym(RTLD_DEFAULT, FUNC_WIDGET_SEND_UPDATED); - if (s_info.binder.slave.send) { - s_info.type = LOAD_TYPE_SLAVE; - DbgPrint("Slave detected\n"); - } else { - s_info.binder.app.send = dlsym(RTLD_DEFAULT, FUNC_WIDGET_PROVIDER_APP_UPDATED); - if (s_info.binder.app.send) { - s_info.type = LOAD_TYPE_APP; - DbgPrint("App detected\n"); - } - } -} - -PUBLIC int widget_get_orientation(const char *id) -{ - if (!s_info.orientation) { - s_info.orientation = dlsym(RTLD_DEFAULT, FUNC_WIDGET_PROVIDER_APP_ORIENTATION); - if (!s_info.orientation) { - return WIDGET_ERROR_NOT_SUPPORTED; - } - } - - return s_info.orientation(id); -} - -PUBLIC int widget_add_pre_callback(widget_pre_callback_e type, widget_pre_callback_t cb, void *data) -{ - if (!s_info.add_pre_callback) { - s_info.add_pre_callback = dlsym(RTLD_DEFAULT, FUNC_WIDGET_PROVIDER_APP_ADD_PRE_CALLBACK); - if (!s_info.add_pre_callback) { - return WIDGET_ERROR_NOT_SUPPORTED; - } - } - - return s_info.add_pre_callback(type, cb, data); -} - -PUBLIC int widget_del_pre_callback(widget_pre_callback_e type, widget_pre_callback_t cb, void *data) -{ - if (!s_info.del_pre_callback) { - s_info.del_pre_callback = dlsym(RTLD_DEFAULT, FUNC_WIDGET_PROVIDER_APP_DEL_PRE_CALLBACK); - if (!s_info.del_pre_callback) { - return WIDGET_ERROR_NOT_SUPPORTED; - } - } - - return s_info.del_pre_callback(type, cb, data); -} - -int binder_widget_send_updated(const char *pkgname, const char *id, widget_buffer_h handle, int idx, int x, int y, int w, int h, int gbar, const char *descfile) -{ - int ret = WIDGET_ERROR_INVALID_PARAMETER; - - if (s_info.type == LOAD_TYPE_UNKNOWN) { - load_update_function(); - } - - if (s_info.type == LOAD_TYPE_APP) { - ret = s_info.binder.app.send(handle, idx, x, y, w, h, gbar); - } else if (s_info.type == LOAD_TYPE_SLAVE) { - /** - * pkgname, id are used for finding handle of direct connection. - */ - ret = s_info.binder.slave.send(pkgname, id, handle, idx, x, y, w, h, gbar, descfile); - } else { - widget_damage_region_s region = { - .x = x, - .y = y, - .w = w, - .h = h, - }; - ret = widget_provider_send_buffer_updated(handle, idx, ®ion, gbar, descfile); - } - - return ret; -} - -PUBLIC int widget_content_is_updated(const char *filename, int is_gbar) -{ - if (!s_info.trigger_update_monitor) { - s_info.trigger_update_monitor = dlsym(RTLD_DEFAULT, FUNC_WIDGET_TRIGGER_UPDATE_MONITOR); - if (!s_info.trigger_update_monitor) { - ErrPrint("Trigger update monitor function is not exists\n"); - return WIDGET_ERROR_FAULT; - } - } - - return s_info.trigger_update_monitor(filename, is_gbar); -} - -const char *binder_widget_find_pkgname(const char *uri) -{ - const char *pkgname; - - if (!s_info.find_pkgname) { - s_info.find_pkgname = dlsym(RTLD_DEFAULT, FUNC_WIDGET_FIND_PKGNAME); - if (!s_info.find_pkgname) { - ErrPrint("Failed to find a \"widget_find_pkgname\"\n"); - return NULL; - } - } - - pkgname = s_info.find_pkgname(uri); - if (!pkgname) { - ErrPrint("Failed to find a package (%s)\n", uri); - return NULL; - } - - return pkgname; -} - -PUBLIC int widget_request_update(const char *filename) -{ - char *uri; - int ret; - - if (!filename) { - ErrPrint("Invalid argument\n"); - return WIDGET_ERROR_INVALID_PARAMETER; - } - - uri = util_id_to_uri(filename); - if (!uri) { - ErrPrint("Heap: %d\n", errno); - return WIDGET_ERROR_OUT_OF_MEMORY; - } - - if (!s_info.request_update_by_id) { - s_info.request_update_by_id = dlsym(RTLD_DEFAULT, FUNC_WIDGET_REQUEST_UPDATE_BY_ID); - if (!s_info.request_update_by_id) { - ErrPrint("\"widget_request_update_by_id\" is not exists\n"); - free(uri); - return WIDGET_ERROR_FAULT; - } - } - - ret = s_info.request_update_by_id(uri); - free(uri); - return ret; -} - -int binder_widget_update_extra_info(const char *id, const char *content, const char *title, const char *icon, const char *name) -{ - if (!s_info.update_extra_info) { - s_info.update_extra_info = dlsym(RTLD_DEFAULT, FUNC_WIDGET_UPDATE_EXTRA_INFO); - if (!s_info.update_extra_info) { - ErrPrint("Failed to find a \"widget_update_extra_info\"\n"); - return WIDGET_ERROR_INVALID_PARAMETER; - } - } - - return s_info.update_extra_info(id, content, title, icon, name); -} - -/** - * @note - * This callback can be called twice (or more) to get a several pixmaps - * Acquired pixmaps are used for double/tripple buffering for canvas - */ -static Ecore_X_Pixmap alloc_pixmap_cb(void *data, Ecore_X_Window parent, int w, int h, int depth) -{ - vwin_info_t info = data; - Ecore_X_Pixmap pixmap; - - if (!info->handle) { - ErrPrint("Invalid handle\n"); - return 0u; - } - - info->w = w; - info->h = h; - DbgPrint("Size of ee is updated: %dx%d - %d (info: %p)\n", info->w, info->h, depth, info); - depth >>= 3; - - if (widget_viewer_get_resource_id(info->handle, WIDGET_PRIMARY_BUFFER) == 0u) { - /** - * @note - * Need to allocate a primary buffer - */ - widget_viewer_acquire_buffer(info->handle, WIDGET_PRIMARY_BUFFER, info->w, info->h, depth); - if (!info->handle) { - ErrPrint("Failed to get the buffer\n"); - return 0u; - } - - pixmap = (Ecore_X_Pixmap)widget_viewer_get_resource_id(info->handle, WIDGET_PRIMARY_BUFFER); - } else if (WIDGET_CONF_EXTRA_BUFFER_COUNT > 0) { - int idx; - - if (!info->resource_array) { - info->resource_array = calloc(WIDGET_CONF_EXTRA_BUFFER_COUNT, sizeof(*info->resource_array)); - if (!info->resource_array) { - ErrPrint("Out of memory: %d\n", errno); - return 0u; - } - - idx = 0; - } else { - for (idx = 0; idx < WIDGET_CONF_EXTRA_BUFFER_COUNT; idx++) { - if (info->resource_array[idx] == 0u) { - break; - } - } - - if (idx == WIDGET_CONF_EXTRA_BUFFER_COUNT) { - ErrPrint("Out of index: %d\n", idx); - return 0u; - } - } - - if (widget_viewer_acquire_buffer(info->handle, idx, info->w, info->h, depth) < 0) { - ErrPrint("Failed to acquire a buffer for %d\n", idx); - return 0u; - } - - info->resource_array[idx] = widget_viewer_get_resource_id(info->handle, idx); - if (info->resource_array[idx] == 0u) { - ErrPrint("Failed to allocate pixmap\n"); - } - - DbgPrint("Allocated index: %d/%d - %u\n", idx, WIDGET_CONF_EXTRA_BUFFER_COUNT, info->resource_array[idx]); - pixmap = info->resource_array[idx]; - } else { - ErrPrint("Unable to allocate pixmap\n"); - pixmap = 0u; - } - - /** - * Acquire a buffer for canvas. - */ - info->type = VWIN_PIXMAP; - info->resource_cnt += !!(unsigned int)pixmap; - return pixmap; -} - -static void free_pixmap_cb(void *data, Ecore_X_Pixmap pixmap) -{ - vwin_info_t info = data; - - if (!info->handle) { - return; - } - - if (info->type != VWIN_PIXMAP) { - ErrPrint("Impossible\n"); - } - - if (widget_viewer_get_resource_id(info->handle, WIDGET_PRIMARY_BUFFER) == pixmap) { - if (widget_viewer_release_buffer(info->handle, WIDGET_PRIMARY_BUFFER) < 0) { - DbgPrint("Failed to release buffer\n"); - } - info->resource_cnt--; - } else { - int idx; - - for (idx = 0; idx < WIDGET_CONF_EXTRA_BUFFER_COUNT; idx++) { - /** - * @note - * Find a index to release it - */ - if (info->resource_array[idx] == pixmap) { - if (widget_viewer_release_buffer(info->handle, idx) < 0) { - DbgPrint("Failed to release buffer\n"); - } - info->resource_array[idx] = 0u; - info->resource_cnt--; - break; - } - } - } - - if (info->deleted && info->resource_cnt == 0) { - DbgPrint("Destroy buffer handle\n"); - - widget_destroy_buffer(info->handle); - free(info->resource_array); - free(info->id); - free(info); - } -} - -static void *alloc_fb(void *data, int size) -{ - vwin_info_t info = data; - void *buffer; - - if (info->ee) { - ecore_evas_geometry_get(info->ee, NULL, NULL, &info->w, &info->h); - DbgPrint("Size of ee is updated: %dx%d (info: %p)\n", info->w, info->h, info); - } - - if (!info->handle) { - ErrPrint("Failed to create a buffer\n"); - return NULL; - } - - if (widget_viewer_acquire_buffer(info->handle, WIDGET_PRIMARY_BUFFER, info->w, info->h, sizeof(int)) < 0) { - ErrPrint("Failed to acquire buffer\n"); - return NULL; - } - - /** - * If it supports the H/W accelerated buffer, - * Use it. - */ - if (widget_support_hw_buffer(info->handle)) { - if (widget_create_hw_buffer(info->handle) == 0) { - buffer = widget_buffer_hw_buffer(info->handle); - if (buffer) { - DbgPrint("HW Accelerated buffer is created %p, (%dx%d)\n", info, info->w, info->h); - info->type = VWIN_GEM; - return buffer; - } - } - - ErrPrint("Failed to allocate HW Accelerated buffer\n"); - } - - /** - * Or use the buffer of a S/W backend. - */ - buffer = widget_ref_buffer(info->handle); - DbgPrint("SW buffer is created (%dx%d)\n", info->w, info->h); - info->type = VWIN_SW_BUF; - return buffer; -} - -static void *alloc_stride_fb(void *data, int size, int *stride, int *bpp) -{ - void *buffer; - - buffer = alloc_fb(data, size); - if (buffer) { - vwin_info_t info = data; - int _stride; - - *bpp = sizeof(int); - _stride = widget_buffer_stride(info->handle); - if (_stride < 0) { - _stride = info->w * *bpp; - } - - *stride = _stride; - *bpp <<= 3; - DbgPrint("bpp: %d, stride: %d\n", *bpp, *stride); - } - - return buffer; -} - -static void free_fb(void *data, void *ptr) -{ - vwin_info_t info = data; - - if (!info->handle) { - return; - } - - if (info->type == VWIN_GEM) { - if (widget_destroy_hw_buffer(info->handle) == 0) { - DbgPrint("HW Accelerated buffer is destroyed\n"); - } - } else if (info->type == VWIN_SW_BUF) { - DbgPrint("SW buffer is destroyed, %p\n", info); - widget_unref_buffer(ptr); - } else if (info->type == VWIN_PIXMAP) { - ErrPrint("Unable to reach to here\n"); - } - - if (widget_viewer_release_buffer(info->handle, WIDGET_PRIMARY_BUFFER) < 0) { - ErrPrint("Failed to release buffer\n"); - } - - if (info->deleted) { - widget_destroy_buffer(info->handle); - free(info->resource_array); - free(info->id); - free(info); - } -} - -Ecore_Evas *binder_ecore_evas_new(vwin_info_t info) -{ - const char *engine; - Ecore_Evas *ee = NULL; - - load_ecore_evas_function(); - - engine = elm_config_preferred_engine_get(); - - DbgPrint("Preferred engine: %s (%s)\n", engine, GL_ENGINE); - if (engine && !strcmp(engine, GL_ENGINE)) { - if (s_info.alloc_canvas_with_pixmap) { - ee = s_info.alloc_canvas_with_pixmap(NULL, 0u, 0, 0, info->w, info->h, alloc_pixmap_cb, free_pixmap_cb, info); - if (!ee) { - ErrPrint("Unable to create a ee for pixmap\n"); - } - } - } - - if (!ee) { - if (!widget_conf_auto_align() && s_info.alloc_canvas_with_stride) { - ee = s_info.alloc_canvas_with_stride(info->w, info->h, alloc_stride_fb, free_fb, info); - } else if (s_info.alloc_canvas) { - ee = s_info.alloc_canvas(info->w, info->h, alloc_fb, free_fb, info); - } - } - - return ee; -} - -int binder_widget_auto_align(void) -{ - load_ecore_evas_function(); - - return widget_conf_auto_align() || !s_info.alloc_canvas_with_stride; -} - -/* End of a file */ diff --git a/src/dlist.c b/src/dlist.c deleted file mode 100644 index b545904..0000000 --- a/src/dlist.c +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright 2013 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include - -#include "dlist.h" - -struct dlist { - struct dlist *next; - struct dlist *prev; - void *data; -}; - -struct dlist *dlist_append(struct dlist *list, void *data) -{ - struct dlist *item; - - item = malloc(sizeof(*item)); - if (!item) { - return NULL; - } - - item->next = NULL; - item->data = data; - - if (!list) { - item->prev = item; - - list = item; - } else { - item->prev = list->prev; - item->prev->next = item; - - list->prev = item; - } - - assert(!list->prev->next && "item NEXT"); - - return list; -} - -struct dlist *dlist_prepend(struct dlist *list, void *data) -{ - struct dlist *item; - - item = malloc(sizeof(*item)); - if (!item) { - return NULL; - } - - if (!list) { - item->prev = item; - item->next = NULL; - } else { - item->prev = list->prev; - list->prev = item; - item->next = list; - } - - return item; -} - -struct dlist *dlist_remove(struct dlist *list, struct dlist *l) -{ - if (!list || !l) { - return NULL; - } - - if (l == list) { - l->prev = list->prev; - list = l->next; - } else { - l->prev->next = l->next; - } - - if (l->next) { - l->next->prev = l->prev; - } - - free(l); - return list; -} - -struct dlist *dlist_find_data(struct dlist *list, void *data) -{ - struct dlist *l; - void *_data; - - dlist_foreach(list, l, _data) { - if (data == _data) { - return l; - } - } - - return NULL; -} - -void *dlist_data(struct dlist *l) -{ - return l ? l->data : NULL; -} - -struct dlist *dlist_next(struct dlist *l) -{ - return l ? l->next : NULL; -} - -struct dlist *dlist_prev(struct dlist *l) -{ - return l ? l->prev : NULL; -} - -int dlist_count(struct dlist *l) -{ - register int i; - struct dlist *n; - void *data; - - i = 0; - dlist_foreach(l, n, data) { - i++; - } - - return i; -} - -struct dlist *dlist_nth(struct dlist *l, int nth) -{ - register int i; - struct dlist *n; - void *data; - - i = 0; - dlist_foreach(l, n, data) { - if (i == nth) { - return l; - } - - i++; - } - - return NULL; -} - -/* End of a file */ diff --git a/src/snapshot_window.c b/src/snapshot_window.c deleted file mode 100644 index fd96018..0000000 --- a/src/snapshot_window.c +++ /dev/null @@ -1,502 +0,0 @@ -/* - * Copyright 2013 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "widget.h" -#include "widget_internal.h" -#include "debug.h" - -#define QUALITY_N_COMPRESS "quality=100 compress=1" -#define PUBLIC __attribute__((visibility("default"))) - -struct snapshot_info { - char *id; - widget_flush_cb flush_cb; - void *data; - - Ecore_Timer *flush_timer; - - int render_cnt; - double timeout; -}; - -static void post_render_cb(void *data, Evas *e, void *event_info); -static void pre_render_cb(void *data, Evas *e, void *event_info); - -static inline Evas *create_virtual_canvas(int w, int h) -{ - Ecore_Evas *internal_ee; - Evas *internal_e; - - // Create virtual canvas - internal_ee = ecore_evas_buffer_new(w, h); - if (!internal_ee) { - DbgPrint("Failed to create a new canvas buffer\n"); - return NULL; - } - - ecore_evas_alpha_set(internal_ee, EINA_TRUE); - ecore_evas_manual_render_set(internal_ee, EINA_FALSE); - - // Get the "Evas" object from a virtual canvas - internal_e = ecore_evas_get(internal_ee); - if (!internal_e) { - ecore_evas_free(internal_ee); - DbgPrint("Faield to get Evas object\n"); - return NULL; - } - - return internal_e; -} - -static inline int flush_data_to_file(Evas *e, const char *data, const char *filename, int w, int h) -{ - Evas_Object *output; - - output = evas_object_image_add(e); - if (!output) { - DbgPrint("Failed to create an image object\n"); - return WIDGET_ERROR_FAULT; - } - - evas_object_image_data_set(output, NULL); - evas_object_image_colorspace_set(output, EVAS_COLORSPACE_ARGB8888); - evas_object_image_alpha_set(output, EINA_TRUE); - evas_object_image_size_set(output, w, h); - evas_object_image_smooth_scale_set(output, EINA_TRUE); - evas_object_image_data_set(output, (void *)data); - evas_object_image_fill_set(output, 0, 0, w, h); - evas_object_image_data_update_add(output, 0, 0, w, h); - - if (evas_object_image_save(output, filename, NULL, QUALITY_N_COMPRESS) == EINA_FALSE) { - evas_object_del(output); - DbgPrint("Faield to save a captured image (%s)\n", filename); - return WIDGET_ERROR_IO_ERROR; - } - - evas_object_del(output); - - if (access(filename, F_OK) != 0) { - DbgPrint("File %s is not found\n", filename); - return WIDGET_ERROR_IO_ERROR; - } - - DbgPrint("Flush data to a file (%s)\n", filename); - return WIDGET_ERROR_NONE; -} - -static inline int destroy_virtual_canvas(Evas *e) -{ - Ecore_Evas *ee; - - ee = ecore_evas_ecore_evas_get(e); - if (!ee) { - DbgPrint("Failed to ecore evas object\n"); - return WIDGET_ERROR_FAULT; - } - - ecore_evas_free(ee); - return WIDGET_ERROR_NONE; -} - -static inline int flush_to_file(const void *canvas, const char *filename, int w, int h) -{ - int status; - Evas *shot_e; - Ecore_Evas *shot_ee; - - shot_e = create_virtual_canvas(w, h); - if (!shot_e) { - ErrPrint("Unable to create a new virtual window\n"); - return WIDGET_ERROR_FAULT; - } - - shot_ee = ecore_evas_ecore_evas_get(shot_e); - if (!shot_ee) { - ErrPrint("Unable to get Ecore_Evas\n"); - destroy_virtual_canvas(shot_e); - return WIDGET_ERROR_FAULT; - } - - ecore_evas_manual_render_set(shot_ee, EINA_TRUE); - - status = flush_data_to_file(shot_e, canvas, filename, w, h); - destroy_virtual_canvas(shot_e); - - return status; -} - -static Eina_Bool snapshot_cb(void *data) -{ - Evas_Object *snapshot_win = data; - struct snapshot_info *info; - Evas *e; - Ecore_Evas *ee; - void *canvas; - widget_flush_cb flush_cb; - int status = WIDGET_ERROR_NONE; - - info = evas_object_data_get(snapshot_win, "snapshot,info"); - if (!info) { - ErrPrint("Invalid object\n"); - return ECORE_CALLBACK_CANCEL; - } - - if (info->flush_timer) { - info->flush_timer = NULL; - } else { - status = WIDGET_ERROR_CANCELED; - } - - flush_cb = info->flush_cb; - info->flush_cb = NULL; /* To prevent call this from the delete callback */ - - e = evas_object_evas_get(snapshot_win); - if (!e) { - ErrPrint("Invalid object\n"); - if (flush_cb) { - flush_cb(snapshot_win, info->id, WIDGET_ERROR_FAULT, info->data); - } - return ECORE_CALLBACK_CANCEL; - } - - ee = ecore_evas_ecore_evas_get(e); - if (!ee) { - ErrPrint("Invalid object (ee)\n"); - if (flush_cb) { - flush_cb(snapshot_win, info->id, WIDGET_ERROR_FAULT, info->data); - } - return ECORE_CALLBACK_CANCEL; - } - - canvas = (void*)ecore_evas_buffer_pixels_get(ee); - if (!canvas) { - DbgPrint("Failed to get pixel canvas\n"); - if (flush_cb) { - flush_cb(snapshot_win, info->id, WIDGET_ERROR_FAULT, info->data); - } - return ECORE_CALLBACK_CANCEL; - } - - if (flush_cb) { - int w; - int h; - int ret; - - ecore_evas_geometry_get(ee, NULL, NULL, &w, &h); - - DbgPrint("Flush size: %dx%d\n", w, h); - ret = flush_to_file(canvas, info->id, w, h); - if (status == WIDGET_ERROR_NONE) { - status = ret; - } - - flush_cb(snapshot_win, info->id, status, info->data); - /** - * Do not access info after this. - */ - } - - return ECORE_CALLBACK_CANCEL; -} - -static void del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) -{ - struct snapshot_info *info; - - info = evas_object_data_del(obj, "snapshot,info"); - if (!info) { - return; - } - - DbgPrint("Delete object (%s)\n", info->id); - - evas_event_callback_del(e, EVAS_CALLBACK_RENDER_POST, post_render_cb); - evas_event_callback_del(e, EVAS_CALLBACK_RENDER_PRE, pre_render_cb); - - if (info->flush_timer) { - ecore_timer_del(info->flush_timer); - info->flush_timer = NULL; - - (void)snapshot_cb(obj); - DbgPrint("Flush is canceled\n"); - } - - /** - * @note - * Render callback will be deleted. - */ - free(info->id); - free(info); -} - -static Eina_Bool direct_snapshot_cb(void *data) -{ - Evas *e; - Ecore_Evas *ee; - const void *canvas; - int status; - int w; - int h; - widget_flush_cb flush_cb; - Evas_Object *snapshot_win = data; - struct snapshot_info *info; - - info = evas_object_data_get(snapshot_win, "snapshot,info"); - if (!info) { - ErrPrint("Unable to get snapshot info\n"); - return ECORE_CALLBACK_CANCEL; - } - - info->flush_timer = NULL; - flush_cb = info->flush_cb; - info->flush_cb = NULL; /* To prevent call this from the delete callback */ - - e = evas_object_evas_get(snapshot_win); - if (!e) { - ErrPrint("Invalid object, failed to get Evas\n"); - if (flush_cb) { - flush_cb(snapshot_win, info->id, WIDGET_ERROR_FAULT, info->data); - } - return ECORE_CALLBACK_CANCEL; - } - - ee = ecore_evas_ecore_evas_get(e); - if (!ee) { - ErrPrint("Unable to get Ecore_Evas object\n"); - if (flush_cb) { - flush_cb(snapshot_win, info->id, WIDGET_ERROR_FAULT, info->data); - } - return ECORE_CALLBACK_CANCEL; - } - - ecore_evas_geometry_get(ee, NULL, NULL, &w, &h); - ecore_evas_manual_render_set(ee, EINA_TRUE); - - canvas = ecore_evas_buffer_pixels_get(ee); - if (!canvas) { - ErrPrint("Failed to get canvas\n"); - if (flush_cb) { - flush_cb(snapshot_win, info->id, WIDGET_ERROR_FAULT, info->data); - } - return ECORE_CALLBACK_CANCEL; - } - - status = flush_to_file(canvas, info->id, w, h); - if (flush_cb) { - flush_cb(snapshot_win, info->id, status, info->data); - } - return ECORE_CALLBACK_CANCEL; -} - -static void post_render_cb(void *data, Evas *e, void *event_info) -{ - Evas_Object *snapshot_win = data; - struct snapshot_info *info; - - info = evas_object_data_get(snapshot_win, "snapshot,info"); - if (!info) { - ErrPrint("snapshot info is not valid\n"); - return; - } - - info->render_cnt++; - - if (info->flush_timer) { - /** - * @note - * This has not to be happens. - */ - ErrPrint("Flush timer is not cleared\n"); - ecore_timer_del(info->flush_timer); - info->flush_timer = NULL; - } - - if (!info->flush_cb) { - DbgPrint("Flush request is not initiated yet\n"); - return; - } - - /*! - * \NOTE - * Even if tehre is no timer registered, we should capture the content - * from out of this callback. - * Or we can met unexpected problems. - * To avoid it, use the 0.0001f to get timer callback ASAP, not in this function. - */ - DbgPrint("Fire the flush timer %lf (%d)\n", info->timeout, info->render_cnt); - info->flush_timer = ecore_timer_add(info->timeout, snapshot_cb, snapshot_win); - if (!info->flush_timer) { - widget_flush_cb flush_cb; - - ErrPrint("Unalbe to add timer for getting the snapshot\n"); - flush_cb = info->flush_cb; - info->flush_cb = NULL; - - if (flush_cb) { - flush_cb(snapshot_win, info->id, WIDGET_ERROR_FAULT, info->data); - } - /*! - * \note - * Do not access info after from here. - */ - } -} - -static void pre_render_cb(void *data, Evas *e, void *event_info) -{ - Evas_Object *snapshot_win = data; - struct snapshot_info *info; - - info = evas_object_data_get(snapshot_win, "snapshot,info"); - if (!info) { - ErrPrint("snapshot info is not valid\n"); - return; - } - - if (info->flush_timer) { - ecore_timer_del(info->flush_timer); - info->flush_timer = NULL; - DbgPrint("Clear the flush timer\n"); - } - - DbgPrint("Pre-render callback\n"); -} - -PUBLIC void *widget_snapshot_window_add(const char *id, int size_type) -{ - struct snapshot_info *info; - Evas_Object *snapshot_win; - Evas_Object *parent; - Evas *e; - int w; - int h; - - if (widget_service_get_size(size_type, &w, &h) != WIDGET_ERROR_NONE) { - ErrPrint("Invalid size\n"); - return NULL; - } - - info = malloc(sizeof(*info)); - if (!info) { - ErrPrint("Heap: %d\n", errno); - return NULL; - } - - info->id = strdup(id); - if (!info->id) { - ErrPrint("Heap: %d\n", errno); - free(info); - return NULL; - } - - info->flush_cb = NULL; - info->data = NULL; - info->flush_timer = NULL; - info->render_cnt = 0; - - e = create_virtual_canvas(w, h); - if (!e) { - free(info->id); - free(info); - return NULL; - } - - parent = evas_object_rectangle_add(e); - if (!parent) { - destroy_virtual_canvas(e); - free(info->id); - free(info); - return NULL; - } - - snapshot_win = elm_win_add(parent, "widget,Snapshot", ELM_WIN_TIZEN_WIDGET); - evas_object_del(parent); - if (!snapshot_win) { - destroy_virtual_canvas(e); - free(info->id); - free(info); - return NULL; - } - - DbgPrint("Create a new window %dx%d for %s\n", w, h, id); - evas_object_event_callback_add(snapshot_win, EVAS_CALLBACK_DEL, del_cb, NULL); - evas_object_resize(snapshot_win, w, h); - evas_object_show(snapshot_win); - - evas_object_data_set(snapshot_win, "snapshot,info", info); - - evas_event_callback_add(e, EVAS_CALLBACK_RENDER_POST, post_render_cb, snapshot_win); - evas_event_callback_add(e, EVAS_CALLBACK_RENDER_PRE, pre_render_cb, snapshot_win); - - return snapshot_win; -} - -PUBLIC int widget_snapshot_window_flush(void *snapshot_win, double timeout, widget_flush_cb flush_cb, void *data) -{ - struct snapshot_info *info; - - if (!flush_cb || timeout < 0.0f) { - ErrPrint("Invalid argument (%p, %lf)\n", flush_cb, timeout); - return WIDGET_ERROR_INVALID_PARAMETER; - } - - info = evas_object_data_get(snapshot_win, "snapshot,info"); - if (!info) { - ErrPrint("Invalid argument\n"); - return WIDGET_ERROR_INVALID_PARAMETER; - } - - info->timeout = timeout; - - if (timeout == 0.0f) { - /*! - * This timer is just used for guarantees same behavious even if it flushes content directly, - * The callback should be called from next loop. - * or the developer will get confused - */ - info->flush_timer = ecore_timer_add(0.0001f, direct_snapshot_cb, snapshot_win); - if (!info->flush_timer) { - return WIDGET_ERROR_FAULT; - } - } else if (info->render_cnt) { - /*! - * Try to watit pre-render callback. - * If there is rendered contents. - */ - DbgPrint("Rendered %d times already\n", info->render_cnt); - info->flush_timer = ecore_timer_add(info->timeout, snapshot_cb, snapshot_win); - if (!info->flush_timer) { - return WIDGET_ERROR_FAULT; - } - } - - info->flush_cb = flush_cb; - info->data = data; - - return WIDGET_ERROR_NONE; -} - -/* End of a file */ diff --git a/src/util.c b/src/util.c deleted file mode 100644 index 7a0646f..0000000 --- a/src/util.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2013 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include - -#include -#include - -#include "debug.h" -#include "util.h" - -int errno; - -int util_check_extension(const char *filename, const char *check_ptr) -{ - int name_len; - - name_len = strlen(filename); - while (--name_len >= 0 && *check_ptr) { - if (filename[name_len] != *check_ptr) - return -EINVAL; - - check_ptr ++; - } - - return 0; -} - -double util_timestamp(void) -{ -#if defined(_USE_ECORE_TIME_GET) - return ecore_time_get(); -#else - struct timeval tv; - - gettimeofday(&tv, NULL); - - return (double)tv.tv_sec + (double)tv.tv_usec / 1000000.0f; -#endif -} - -char *util_id_to_uri(const char *id) -{ - char *uri; - int uri_len; - - uri_len = strlen(id) + strlen(FILE_SCHEMA) + 1; - - uri = malloc(uri_len); - if (!uri) { - return NULL; - } - - snprintf(uri, uri_len, FILE_SCHEMA "%s", id); - return uri; -} - -/* End of a file */ diff --git a/src/virtual_window.c b/src/virtual_window.c deleted file mode 100644 index 288ef65..0000000 --- a/src/virtual_window.c +++ /dev/null @@ -1,833 +0,0 @@ -/* - * Copyright 2013 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define _GNU_SOURCE - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "widget.h" -#include "widget_internal.h" -#include "debug.h" -#include "binder.h" - -#define IS_GBAR 1 - -#define PUBLIC __attribute__((visibility("default"))) -#define WIDGET_WIN_TAG "dynamic,box,win" - -#define WIDGET_DEFAULT_WIDTH 1 -#define WIDGET_DEFAULT_HEIGHT 1 - -static inline Evas_Object *get_highlighted_object(Evas_Object *obj) -{ - Evas_Object *o, *ho; - - o = evas_object_name_find(evas_object_evas_get(obj), "_elm_access_disp"); - if (!o) return NULL; - - ho = evas_object_data_get(o, "_elm_access_target"); - return ho; -} - -static inline void apply_orientation(int degree, int *x, int *y) -{ - int _x; - int _y; - int _angle; - - switch (degree) { - case 0: - return; - case 90: - _x = *x; - _y = *y; - - *x = -_y; - *y = _x; - return; - case 180: - _x = *x; - _y = *y; - _angle = degree; - - *x = -_x; - *y = -_y; - return; - case 270: - _x = *x; - _y = *y; - _angle = degree; - - *x = _y; - *y = -_x; - return; - default: - _x = *x; - _y = *y; - _angle = degree; - - *x = (double)_x * cos((double)_angle) - (double)_y * sin((double)_angle); - *y = (double)_x * sin((double)_angle) + (double)_y * cos((double)_angle); - return; - } -} - -/** - * @note - * Every user event (mouse) on the buffer will be passed via this event callback - */ -static int event_handler_cb(widget_buffer_h handler, struct widget_buffer_event_data *event_info, void *data) -{ - vwin_info_t info = data; - Elm_Access_Action_Info action_info; - Elm_Access_Action_Type action_type; - int ret = 0; - Evas_Object *parent_elm; - KeySym *key_symbol; - unsigned int flags = 0; - double timestamp; - - if (!info->handle) { - /* Just ignore this event */ - return 0; - } - - if (WIDGET_CONF_USE_GETTIMEOFDAY) { - if (WIDGET_CONF_EVENT_FILTER > 0.0f && (info->pressed == 0 || event_info->type == WIDGET_BUFFER_EVENT_MOVE)) { - struct timeval tv; - - if (gettimeofday(&tv, NULL) < 0) { - ErrPrint("gettimeofday: %d\n", errno); - } else { - timestamp = (double)tv.tv_sec + (double)tv.tv_usec / 1000000.0f; - timestamp -= event_info->timestamp; - - if (timestamp > WIDGET_CONF_EVENT_FILTER) { - DbgPrint("Dropped %lf\n", timestamp); - return 0; - } - } - } - - /** - * If the device doesn't use the clock monotic time, we have to emulate it for EVAS - * Evas only use the monotic time for animating objects - */ - timestamp = ecore_time_get() * 1000.0f; - } else { - if (WIDGET_CONF_EVENT_FILTER > 0.0f && (info->pressed == 0 || event_info->type == WIDGET_BUFFER_EVENT_MOVE)) { - timestamp = ecore_time_get(); - - timestamp -= event_info->timestamp; - if (timestamp > WIDGET_CONF_EVENT_FILTER) { - DbgPrint("Dropped %lf\n", timestamp); - return 0; - } - } - - timestamp = event_info->timestamp * 1000.0f; - } - - /** - * @note - * Feed up events - */ - switch (event_info->type) { - case WIDGET_BUFFER_EVENT_ON_HOLD: - flags = evas_event_default_flags_get(info->e); - flags |= EVAS_EVENT_FLAG_ON_HOLD; - evas_event_default_flags_set(info->e, flags); - ErrPrint("ON_HOLD[%s] %dx%d - %lf\n", info->id, event_info->info.pointer.x, event_info->info.pointer.y, timestamp); - break; - case WIDGET_BUFFER_EVENT_OFF_HOLD: - flags = evas_event_default_flags_get(info->e); - flags &= ~EVAS_EVENT_FLAG_ON_HOLD; - evas_event_default_flags_set(info->e, flags); - break; - case WIDGET_BUFFER_EVENT_ON_SCROLL: - flags = evas_event_default_flags_get(info->e); - flags |= EVAS_EVENT_FLAG_ON_SCROLL; - evas_event_default_flags_set(info->e, flags); - break; - case WIDGET_BUFFER_EVENT_OFF_SCROLL: - flags = evas_event_default_flags_get(info->e); - flags &= ~EVAS_EVENT_FLAG_ON_SCROLL; - evas_event_default_flags_set(info->e, flags); - break; - case WIDGET_BUFFER_EVENT_ENTER: - evas_event_feed_mouse_in(info->e, timestamp, NULL); - break; - case WIDGET_BUFFER_EVENT_LEAVE: - evas_event_feed_mouse_out(info->e, timestamp, NULL); - break; - case WIDGET_BUFFER_EVENT_DOWN: - apply_orientation(info->orientation, &event_info->info.pointer.x, &event_info->info.pointer.y); - - if (info->pressed) { - ErrPrint("MOUSE UP is not called\n"); - ErrPrint("UP[%s] %dx%d - %lf\n", info->id, event_info->info.pointer.x, event_info->info.pointer.y, timestamp); - evas_event_feed_mouse_move(info->e, event_info->info.pointer.x, event_info->info.pointer.y, timestamp, NULL); - evas_event_feed_mouse_up(info->e, 1, EVAS_BUTTON_NONE, timestamp, NULL); - } - - /** - * @note - * Before processing the DOWN event, - * Reset the evas event flags regarding ON_HOLD option. - * It can be re-enabled while processing down-move-up events. - */ - flags = evas_event_default_flags_get(info->e); - flags &= ~EVAS_EVENT_FLAG_ON_SCROLL; - flags &= ~EVAS_EVENT_FLAG_ON_HOLD; - evas_event_default_flags_set(info->e, flags); - /** - * @note - * Calculate the event occurred X & Y on the buffer - */ - evas_event_feed_mouse_move(info->e, event_info->info.pointer.x, event_info->info.pointer.y, timestamp, NULL); - evas_event_feed_mouse_down(info->e, 1, EVAS_BUTTON_NONE, timestamp, NULL); /* + 0.2f just for fake event */ - info->pressed = 1; - ErrPrint("DOWN[%s] %dx%d - %lf\n", info->id, event_info->info.pointer.x, event_info->info.pointer.y, timestamp); - break; - case WIDGET_BUFFER_EVENT_MOVE: - apply_orientation(info->orientation, &event_info->info.pointer.x, &event_info->info.pointer.y); - /** - * @note - * Calculate the event occurred X & Y on the buffer - */ - evas_event_feed_mouse_move(info->e, event_info->info.pointer.x, event_info->info.pointer.y, timestamp, NULL); - break; - case WIDGET_BUFFER_EVENT_UP: - apply_orientation(info->orientation, &event_info->info.pointer.x, &event_info->info.pointer.y); - evas_event_feed_mouse_move(info->e, event_info->info.pointer.x, event_info->info.pointer.y, timestamp, NULL); - evas_event_feed_mouse_up(info->e, 1, EVAS_BUTTON_NONE, timestamp, NULL); - info->pressed = 0; - /** - * @note - * We have to keep the event flags, so we should not clear them from here. - * Sometimes, asynchronously callable Callbacks can refer the evas event flags after up event. - * so if we reset them from here, those kind of callbacks will fails to do their job properly. - */ - ErrPrint("UP[%s] %dx%d - %lf\n", info->id, event_info->info.pointer.x, event_info->info.pointer.y, timestamp); - break; - case WIDGET_BUFFER_EVENT_ACCESS_HIGHLIGHT: - parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); - if (!parent_elm) { - ret = WIDGET_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_HIGHLIGHT; - /** - * @note - * Calculate the event occurred X & Y on the buffer - */ - action_info.x = event_info->info.access.x; - action_info.y = event_info->info.access.y; - ret = elm_access_action(parent_elm, action_type, &action_info); - if (ret == EINA_TRUE) { - if (!get_highlighted_object(parent_elm)) { - ErrPrint("Highlighted object is not found\n"); - ret = WIDGET_ACCESS_STATUS_ERROR; - } else { - DbgPrint("Highlighted object is found\n"); - ret = WIDGET_ACCESS_STATUS_DONE; - } - } else { - ErrPrint("Action error\n"); - ret = WIDGET_ACCESS_STATUS_ERROR; - } - break; - case WIDGET_BUFFER_EVENT_ACCESS_HIGHLIGHT_NEXT: - parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); - if (!parent_elm) { - ret = WIDGET_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_HIGHLIGHT_NEXT; - action_info.highlight_cycle = EINA_FALSE; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_LAST : WIDGET_ACCESS_STATUS_DONE; - break; - case WIDGET_BUFFER_EVENT_ACCESS_HIGHLIGHT_PREV: - parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); - if (!parent_elm) { - ret = WIDGET_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_HIGHLIGHT_PREV; - action_info.highlight_cycle = EINA_FALSE; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_FIRST : WIDGET_ACCESS_STATUS_DONE; - break; - case WIDGET_BUFFER_EVENT_ACCESS_ACTIVATE: - parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); - if (!parent_elm) { - ret = WIDGET_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_ACTIVATE; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE; - break; - case WIDGET_BUFFER_EVENT_ACCESS_ACTION_UP: - parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); - if (!parent_elm) { - ret = WIDGET_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_UP; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE; - break; - case WIDGET_BUFFER_EVENT_ACCESS_ACTION_DOWN: - parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); - if (!parent_elm) { - ret = WIDGET_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_DOWN; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE; - break; - case WIDGET_BUFFER_EVENT_ACCESS_SCROLL_UP: - parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); - if (!parent_elm) { - ret = WIDGET_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_SCROLL; - action_info.x = event_info->info.access.x; - action_info.y = event_info->info.access.y; - action_info.mouse_type = event_info->info.access.mouse_type; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE; - break; - case WIDGET_BUFFER_EVENT_ACCESS_SCROLL_MOVE: - parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); - if (!parent_elm) { - ret = WIDGET_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_SCROLL; - action_info.x = event_info->info.access.x; - action_info.y = event_info->info.access.y; - action_info.mouse_type = event_info->info.access.mouse_type; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE; - break; - case WIDGET_BUFFER_EVENT_ACCESS_SCROLL_DOWN: - parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); - if (!parent_elm) { - ret = WIDGET_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_SCROLL; - action_info.x = event_info->info.access.x; - action_info.y = event_info->info.access.y; - action_info.mouse_type = event_info->info.access.mouse_type; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE; - break; - case WIDGET_BUFFER_EVENT_ACCESS_UNHIGHLIGHT: - parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); - if (!parent_elm) { - ret = WIDGET_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_UNHIGHLIGHT; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE; - break; - case WIDGET_BUFFER_EVENT_ACCESS_VALUE_CHANGE: - parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); - if (!parent_elm) { - ret = WIDGET_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_VALUE_CHANGE; - action_info.x = event_info->info.access.x; - action_info.y = event_info->info.access.y; - action_info.mouse_type = event_info->info.access.mouse_type; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE; - break; - case WIDGET_BUFFER_EVENT_ACCESS_MOUSE: - parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); - if (!parent_elm) { - ret = WIDGET_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_MOUSE; - action_info.x = event_info->info.access.x; - action_info.y = event_info->info.access.y; - action_info.mouse_type = event_info->info.access.mouse_type; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE; - break; - case WIDGET_BUFFER_EVENT_ACCESS_BACK: - parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); - if (!parent_elm) { - ret = WIDGET_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_BACK; - action_info.x = event_info->info.access.x; - action_info.y = event_info->info.access.y; - action_info.mouse_type = event_info->info.access.mouse_type; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE; - break; - case WIDGET_BUFFER_EVENT_ACCESS_OVER: - parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); - if (!parent_elm) { - ret = WIDGET_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_OVER; - action_info.x = event_info->info.access.x; - action_info.y = event_info->info.access.y; - action_info.mouse_type = event_info->info.access.mouse_type; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE; - break; - case WIDGET_BUFFER_EVENT_ACCESS_READ: - parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); - if (!parent_elm) { - ret = WIDGET_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_READ; - action_info.x = event_info->info.access.x; - action_info.y = event_info->info.access.y; - action_info.mouse_type = event_info->info.access.mouse_type; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE; - break; - case WIDGET_BUFFER_EVENT_ACCESS_ENABLE: - parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); - if (!parent_elm) { - ret = WIDGET_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_ENABLE; - action_info.x = event_info->info.access.x; - action_info.y = event_info->info.access.y; - action_info.mouse_type = event_info->info.access.mouse_type; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE; - break; - case WIDGET_BUFFER_EVENT_ACCESS_DISABLE: - parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); - if (!parent_elm) { - ret = WIDGET_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_DISABLE; - action_info.x = event_info->info.access.x; - action_info.y = event_info->info.access.y; - action_info.mouse_type = event_info->info.access.mouse_type; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE; - break; - case WIDGET_BUFFER_EVENT_KEY_DOWN: - parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); - if (!parent_elm) { - ret = WIDGET_ACCESS_STATUS_ERROR; - break; - } - - key_symbol = XGetKeyboardMapping(ecore_x_display_get(), event_info->info.keycode, 1, &ret); - if (key_symbol) { - char *key_name; - char *key_string; - - key_string = XKeysymToString(*key_symbol); - key_name = XKeysymToString(*key_symbol); - DbgPrint("Key symbol: %s, name: %s\n", key_string, key_name); - XFree(key_symbol); - XFree(key_name); - XFree(key_string); - } - ret = WIDGET_KEY_STATUS_ERROR; - break; - case WIDGET_BUFFER_EVENT_KEY_UP: - parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); - if (!parent_elm) { - ret = WIDGET_ACCESS_STATUS_ERROR; - break; - } - - key_symbol = XGetKeyboardMapping(ecore_x_display_get(), event_info->info.keycode, 1, &ret); - if (key_symbol) { - char *key_name; - char *key_string; - - key_string = XKeysymToString(*key_symbol); - key_name = XKeysymToString(*key_symbol); - DbgPrint("Key symbol: %s, name: %s\n", key_string, key_name); - XFree(key_symbol); - XFree(key_name); - XFree(key_string); - } - ret = WIDGET_KEY_STATUS_ERROR; - break; - case WIDGET_BUFFER_EVENT_KEY_FOCUS_IN: - parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); - if (!parent_elm) { - ret = WIDGET_ACCESS_STATUS_ERROR; - break; - } - - key_symbol = XGetKeyboardMapping(ecore_x_display_get(), event_info->info.keycode, 1, &ret); - if (key_symbol) { - char *key_name; - char *key_string; - - key_string = XKeysymToString(*key_symbol); - key_name = XKeysymToString(*key_symbol); - DbgPrint("Key symbol: %s, name: %s\n", key_string, key_name); - XFree(key_symbol); - XFree(key_name); - XFree(key_string); - } - ret = WIDGET_KEY_STATUS_ERROR; - break; - case WIDGET_BUFFER_EVENT_KEY_FOCUS_OUT: - parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); - if (!parent_elm) { - ret = WIDGET_ACCESS_STATUS_ERROR; - break; - } - - key_symbol = XGetKeyboardMapping(ecore_x_display_get(), event_info->info.keycode, 1, &ret); - if (key_symbol) { - char *key_name; - char *key_string; - - key_string = XKeysymToString(*key_symbol); - key_name = XKeysymToString(*key_symbol); - DbgPrint("Key symbol: %s, name: %s\n", key_string, key_name); - XFree(key_symbol); - XFree(key_name); - XFree(key_string); - } - ret = WIDGET_KEY_STATUS_ERROR; - break; - default: - DbgPrint("Unhandled buffer event (%d)\n", event_info->type); - break; - } - - return ret; -} - -static void pre_render_cb(void *data, Evas *e, void *event_info) -{ - vwin_info_t info = data; - - if (!info->handle) { - return; - } - - if (widget_conf_premultiplied_alpha()) { - Evas_Coord w; - Evas_Coord h; - - ecore_evas_geometry_get(info->ee, NULL, NULL, &w, &h); - evas_damage_rectangle_add(e, 0, 0, w, h); - } - - if (info->type == VWIN_GEM) { - widget_buffer_pre_render(info->handle); - } else if (info->type == VWIN_PIXMAP) { - /** - * Only the pixmap type Ecore_Evas uses this variable - */ - } else if (info->type == VWIN_SW_BUF) { - /* Do nothing */ - } -} - -static void post_render_cb(void *data, Evas *e, void *event_info) -{ - vwin_info_t info = data; - - if (!info->handle) { - return; - } - - if (widget_conf_premultiplied_alpha()) { - void *canvas; - int x, y, w, h; - - // Get a pointer of a buffer of the virtual canvas - canvas = (void *)ecore_evas_buffer_pixels_get(info->ee); - if (!canvas) { - ErrPrint("Failed to get pixel canvas\n"); - return; - } - - ecore_evas_geometry_get(info->ee, &x, &y, &w, &h); - evas_data_argb_unpremul(canvas, w * h); - } - - if (info->type == VWIN_GEM) { - widget_buffer_post_render(info->handle); - } else if (info->type == VWIN_PIXMAP) { - int idx; - unsigned int front_resource_id; - - front_resource_id = ecore_evas_gl_x11_pixmap_get(info->ee); - - for (idx = 0; idx < WIDGET_CONF_EXTRA_BUFFER_COUNT; idx++) { - if (front_resource_id == info->resource_array[idx]) { - /** - */ - widget_send_updated_by_idx(info->handle, idx); - break; - } - } - - if (idx == WIDGET_CONF_EXTRA_BUFFER_COUNT) { - /* Send updated event for PRIMARY BUFFER */ - if (front_resource_id == widget_viewer_get_resource_id(info->handle, WIDGET_PRIMARY_BUFFER)) { - widget_send_updated_by_idx(info->handle, WIDGET_PRIMARY_BUFFER); - } else { - DbgPrint("Unable to send updated: %u (%u)\n", front_resource_id, widget_viewer_get_resource_id(info->handle, WIDGET_PRIMARY_BUFFER)); - } - } - } else if (info->type == VWIN_SW_BUF) { - widget_viewer_sync_buffer(info->handle); - } -} - -static int pre_orientation_cb(const char *id, void *data) -{ - vwin_info_t info = data; - const char *path; - int orientation; - - /* Try provider_app first */ - if (!id) { - return WIDGET_ERROR_INVALID_PARAMETER; - } - - path = widget_util_uri_to_path(id); - if (path && strcmp(info->id, path)) { - /* Skip */ - DbgPrint("SKIP: Pre orientation event callback is called [%s], %s\n", id, info->id); - return WIDGET_ERROR_INVALID_PARAMETER; - } - - DbgPrint("Pre orientation event callback is called [%s]\n", id); - orientation = widget_get_orientation(path); - if (orientation < 0) { - ErrPrint("Failed to get orientation: %X\n", orientation); - } else { - info->orientation = orientation; - } - - return WIDGET_ERROR_NONE; -} - -static int pre_destroy_cb(const char *id, void *data) -{ - vwin_info_t info = data; - const char *path = NULL; - - if (id) { - path = widget_util_uri_to_path(id); - - if (path && strcmp(info->id, path)) { - /* Skip */ - DbgPrint("SKIP: Pre destroy event callback is called [%s], %s\n", id, info->id); - return WIDGET_ERROR_INVALID_PARAMETER; - } - } - - DbgPrint("Pre destroy event callback is called [%s]\n", id); - - if (info->ee) { - DbgPrint("Toggle manual render mode to prevent from unwanted rendering"); - ecore_evas_manual_render_set(info->ee, EINA_TRUE); - } - - return WIDGET_ERROR_NONE; -} - -static void ecore_evas_free_cb(Ecore_Evas *ee) -{ - vwin_info_t info; - - info = ecore_evas_data_get(ee, "dynamic,box,info"); - if (!info) { - DbgPrint("Info is not valid\n"); - return; - } - - widget_del_pre_callback(WIDGET_PRE_DESTROY_CALLBACK, pre_destroy_cb, info); - - if (info->e) { - evas_event_callback_del(info->e, EVAS_CALLBACK_RENDER_POST, post_render_cb); - evas_event_callback_del(info->e, EVAS_CALLBACK_RENDER_PRE, pre_render_cb); - } - - info->deleted = 1; - info->ee = NULL; -} - -#ifdef WIDGET_FEATURE_GBAR_SUPPORTED -PUBLIC Evas *widget_get_evas(const char *id, int is_gbar) -#else /* WIDGET_FEATURE_GBAR_SUPPORTED */ -PUBLIC Evas *widget_get_evas(const char *id) -#endif /* WIDGET_FEATURE_GBAR_SUPPORTED */ -{ - vwin_info_t info; - int orientation; - - /** - * @TODO - * If the evas object is already created, - * this function should returns ERROR. - */ - - if (!id) { - ErrPrint("Invalid parameter\n"); - return NULL; - } - - info = calloc(1, sizeof(*info)); - if (!info) { - ErrPrint("Heap: %d\n", errno); - return NULL; - } - - info->id = strdup(id); - if (!info->id) { - ErrPrint("Heap: %d\n", errno); - free(info); - return NULL; - } - -#ifdef WIDGET_FEATURE_GBAR_SUPPORTED - info->is_gbar = is_gbar; -#else - info->is_gbar = 0; -#endif /* WIDGET_FEATURE_GBAR_SUPPORTED */ - - /** - * Acquire a buffer for canvas. - */ - info->handle = widget_create_buffer(info->id, info->is_gbar, - binder_widget_auto_align(), - event_handler_cb, info); - - if (!info->handle) { - ErrPrint("Failed to create a widget buffer\n"); - free(info->id); - free(info); - return NULL; - } - - /** - * Size information must be initialized before call the ecore_evas_buffer_new. - */ - info->w = WIDGET_DEFAULT_WIDTH; - info->h = WIDGET_DEFAULT_HEIGHT; - - info->ee = binder_ecore_evas_new(info); - if (!info->ee) { - ErrPrint("Failed to create ecore_evas (%dx%d)\n", info->w, info->h); - widget_destroy_buffer(info->handle); - free(info->id); - free(info); - return NULL; - } - - ecore_evas_data_set(info->ee, "dynamic,box,info", info); - - /** - * @note - * Free callback must be prepared before use the ecore_evas_free() - */ - ecore_evas_callback_pre_free_set(info->ee, ecore_evas_free_cb); - - info->e = ecore_evas_get(info->ee); - if (!info->e) { - ErrPrint("Failed to get evas\n"); - ecore_evas_free(info->ee); - return NULL; - } - - pre_render_cb(info, NULL, NULL); - ecore_evas_alpha_set(info->ee, EINA_TRUE); - post_render_cb(info, NULL, NULL); - - ecore_evas_manual_render_set(info->ee, EINA_FALSE); - ecore_evas_resize(info->ee, info->w, info->h); - - evas_event_callback_add(info->e, EVAS_CALLBACK_RENDER_POST, post_render_cb, info); - evas_event_callback_add(info->e, EVAS_CALLBACK_RENDER_PRE, pre_render_cb, info); - - widget_add_pre_callback(WIDGET_PRE_DESTROY_CALLBACK, pre_destroy_cb, info); - widget_add_pre_callback(WIDGET_PRE_ORIENTATION_CALLBACK, pre_orientation_cb, info); - - orientation = widget_get_orientation(info->id); - if (orientation < 0) { - ErrPrint("Failed to get orientation[%s]: %X\n", info->id, orientation); - } else { - info->orientation = orientation; - } - - return info->e; -} - -/* End of a file */ diff --git a/src/virtual_window_wayland.c b/src/virtual_window_wayland.c deleted file mode 100644 index 1fab6d3..0000000 --- a/src/virtual_window_wayland.c +++ /dev/null @@ -1,884 +0,0 @@ -/* - * Copyright 2013 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "widget.h" -#include "debug.h" - -#define IS_GBAR 1 - -#define PUBLIC __attribute__((visibility("default"))) -#define WIDGET_WIN_TAG "dynamic,box,win" - -#define WIDGET_DEFAULT_WIDTH 1 -#define WIDGET_DEFAULT_HEIGHT 1 -#define GL_ENGINE "opengl_x11" - -static struct static_info { - Ecore_Evas *(*alloc_canvas)(int w, int h, void *(*a)(void *data, int size), void (*f)(void *data, void *ptr), void *data); - Ecore_Evas *(*alloc_canvas_with_stride)(int w, int h, void *(*a)(void *data, int size, int *stride, int *bpp), void (*f)(void *data, void *ptr), void *data); - Ecore_Evas *(*alloc_canvas_with_pixmap)(const char *disp_name, Ecore_X_Window parent, int x, int y, int w, int h, Ecore_X_Pixmap (*alloc_cb)(void *data, Ecore_X_Window parent, int w, int h, int depth), void (*free_cb)(void *data, Ecore_X_Pixmap pixmap), void *data); -} s_info = { - .alloc_canvas = NULL, - .alloc_canvas_with_stride = NULL, - .alloc_canvas_with_pixmap = NULL, -}; - -/** - * @brief - * Abstracted Data Type of Virtual Window - */ -typedef struct virtual_window_info { - char *id; /**< Identification */ - widget_buffer_h handle; /**< Livebox buffer handle */ - enum win_type { - VWIN_SW_BUF = 0x00, /**< S/W buffer */ - VWIN_GEM = 0x01, /**< GEM buffer */ - VWIN_PIXMAP = 0x02, /**< PIXMAP */ - VWIN_ERROR = 0x03 /**< Unknown */ - } type; - Ecore_Evas *ee; - Evas *e; - int is_gbar; - int deleted; - int w; - int h; - unsigned int *resource_array; - int resource_cnt; - - int pressed; -} *vwin_info_t; - -static inline Evas_Object *get_highlighted_object(Evas_Object *obj) -{ - Evas_Object *o, *ho; - - o = evas_object_name_find(evas_object_evas_get(obj), "_elm_access_disp"); - if (!o) return NULL; - - ho = evas_object_data_get(o, "_elm_access_target"); - return ho; -} - -/*! - * \note - * Every user event (mouse) on the buffer will be passed via this event callback - */ -static int event_handler_cb(struct widget_buffer *handler, struct widget_buffer_event_data *event_info, void *data) -{ - vwin_info_t info = data; - Elm_Access_Action_Info action_info; - Elm_Access_Action_Type action_type; - int ret = 0; - Evas_Object *parent_elm; - unsigned int flags = 0; - double timestamp; - - - if (!info->handle) { - /* Just ignore this event */ - return 0; - } - - if (WIDGET_CONF_USE_GETTIMEOFDAY) { - if (WIDGET_CONF_EVENT_FILTER > 0.0f && (info->pressed == 0 || event_info->type == WIDGET_BUFFER_EVENT_MOVE)) { - struct timeval tv; - - if (gettimeofday(&tv, NULL) < 0) { - ErrPrint("gettimeofday: %s\n", strerror(errno)); - } else { - timestamp = (double)tv.tv_sec + (double)tv.tv_usec / 1000000.0f; - timestamp -= event_info->timestamp; - - if (timestamp > WIDGET_CONF_EVENT_FILTER) { - DbgPrint("Dropped %lf\n", timestamp); - return 0; - } - } - } - - /** - * If the device doesn't use the clock monotic time, we have to emulate it for EVAS - * Evas only use the monotic time for animating objects - */ - timestamp = ecore_time_get() * 1000.0f; - } else { - if (WIDGET_CONF_EVENT_FILTER > 0.0f && (info->pressed == 0 || event_info->type == WIDGET_BUFFER_EVENT_MOVE)) { - timestamp = ecore_time_get(); - - timestamp -= event_info->timestamp; - if (timestamp > WIDGET_CONF_EVENT_FILTER) { - DbgPrint("Dropped %lf\n", timestamp); - return 0; - } - } - - timestamp = event_info->timestamp * 1000.0f; - } - - /*! - * \note - * Feed up events - */ - switch (event_info->type) { - case WIDGET_BUFFER_EVENT_ON_HOLD: - flags = evas_event_default_flags_get(info->e); - flags |= EVAS_EVENT_FLAG_ON_HOLD; - evas_event_default_flags_set(info->e, flags); - ErrPrint("ON_HOLD[%s] %dx%d - %lf\n", info->id, event_info->info.pointer.x, event_info->info.pointer.y, timestamp); - break; - case WIDGET_BUFFER_EVENT_OFF_HOLD: - flags = evas_event_default_flags_get(info->e); - flags &= ~EVAS_EVENT_FLAG_ON_HOLD; - evas_event_default_flags_set(info->e, flags); - break; - case WIDGET_BUFFER_EVENT_ON_SCROLL: - flags = evas_event_default_flags_get(info->e); - flags |= EVAS_EVENT_FLAG_ON_SCROLL; - evas_event_default_flags_set(info->e, flags); - break; - case WIDGET_BUFFER_EVENT_OFF_SCROLL: - flags = evas_event_default_flags_get(info->e); - flags &= ~EVAS_EVENT_FLAG_ON_SCROLL; - evas_event_default_flags_set(info->e, flags); - break; - case WIDGET_BUFFER_EVENT_ENTER: - evas_event_feed_mouse_in(info->e, timestamp, NULL); - break; - case WIDGET_BUFFER_EVENT_LEAVE: - evas_event_feed_mouse_out(info->e, timestamp, NULL); - break; - case WIDGET_BUFFER_EVENT_DOWN: - if (info->pressed) { - ErrPrint("MOUSE UP is not called\n"); - ErrPrint("UP[%s] %dx%d - %lf\n", info->id, event_info->info.pointer.x, event_info->info.pointer.y, timestamp); - evas_event_feed_mouse_move(info->e, event_info->info.pointer.x, event_info->info.pointer.y, timestamp, NULL); - evas_event_feed_mouse_up(info->e, 1, EVAS_BUTTON_NONE, timestamp, NULL); - } - - /** - * @note - * Before processing the DOWN event, - * Reset the evas event flags regarding ON_HOLD option. - * It can be re-enabled while processing down-move-up events. - */ - flags = evas_event_default_flags_get(info->e); - flags &= ~EVAS_EVENT_FLAG_ON_SCROLL; - flags &= ~EVAS_EVENT_FLAG_ON_HOLD; - evas_event_default_flags_set(info->e, flags); - /** - * @note - * Calculate the event occurred X & Y on the buffer - */ - evas_event_feed_mouse_move(info->e, event_info->info.pointer.x, event_info->info.pointer.y, timestamp, NULL); - evas_event_feed_mouse_down(info->e, 1, EVAS_BUTTON_NONE, timestamp, NULL); /* + 0.2f just for fake event */ - info->pressed = 1; - ErrPrint("DOWN[%s] %dx%d - %lf\n", info->id, event_info->info.pointer.x, event_info->info.pointer.y, timestamp); - break; - case WIDGET_BUFFER_EVENT_MOVE: - /** - * @note - * Calculate the event occurred X & Y on the buffer - */ - evas_event_feed_mouse_move(info->e, event_info->info.pointer.x, event_info->info.pointer.y, timestamp, NULL); - break; - case WIDGET_BUFFER_EVENT_UP: - evas_event_feed_mouse_move(info->e, event_info->info.pointer.x, event_info->info.pointer.y, timestamp, NULL); - evas_event_feed_mouse_up(info->e, 1, EVAS_BUTTON_NONE, timestamp, NULL); - info->pressed = 0; - /** - * @note - * We have to keep the event flags, so we should not clear them from here. - * Sometimes, asynchronously callable Callbacks can refer the evas event flags after up event. - * so if we reset them from here, those kind of callbacks will fails to do their job properly. - */ - ErrPrint("UP[%s] %dx%d - %lf\n", info->id, event_info->info.pointer.x, event_info->info.pointer.y, timestamp); - break; - case WIDGET_BUFFER_EVENT_ACCESS_HIGHLIGHT: - parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); - if (!parent_elm) { - ret = WIDGET_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_HIGHLIGHT; - /** - * @note - * Calculate the event occurred X & Y on the buffer - */ - action_info.x = event_info->info.access.x; - action_info.y = event_info->info.access.y; - ret = elm_access_action(parent_elm, action_type, &action_info); - if (ret == EINA_TRUE) { - if (!get_highlighted_object(parent_elm)) { - ErrPrint("Highlighted object is not found\n"); - ret = WIDGET_ACCESS_STATUS_ERROR; - } else { - DbgPrint("Highlighted object is found\n"); - ret = WIDGET_ACCESS_STATUS_DONE; - } - } else { - ErrPrint("Action error\n"); - ret = WIDGET_ACCESS_STATUS_ERROR; - } - break; - case WIDGET_BUFFER_EVENT_ACCESS_HIGHLIGHT_NEXT: - parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); - if (!parent_elm) { - ret = WIDGET_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_HIGHLIGHT_NEXT; - action_info.highlight_cycle = EINA_FALSE; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_LAST : WIDGET_ACCESS_STATUS_DONE; - break; - case WIDGET_BUFFER_EVENT_ACCESS_HIGHLIGHT_PREV: - parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); - if (!parent_elm) { - ret = WIDGET_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_HIGHLIGHT_PREV; - action_info.highlight_cycle = EINA_FALSE; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_FIRST : WIDGET_ACCESS_STATUS_DONE; - break; - case WIDGET_BUFFER_EVENT_ACCESS_ACTIVATE: - parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); - if (!parent_elm) { - ret = WIDGET_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_ACTIVATE; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE; - break; - case WIDGET_BUFFER_EVENT_ACCESS_ACTION_UP: - parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); - if (!parent_elm) { - ret = WIDGET_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_UP; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE; - break; - case WIDGET_BUFFER_EVENT_ACCESS_ACTION_DOWN: - parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); - if (!parent_elm) { - ret = WIDGET_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_DOWN; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE; - break; - case WIDGET_BUFFER_EVENT_ACCESS_SCROLL_UP: - parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); - if (!parent_elm) { - ret = WIDGET_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_SCROLL; - action_info.x = event_info->info.access.x; - action_info.y = event_info->info.access.y; - action_info.mouse_type = event_info->info.access.mouse_type; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE; - break; - case WIDGET_BUFFER_EVENT_ACCESS_SCROLL_MOVE: - parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); - if (!parent_elm) { - ret = WIDGET_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_SCROLL; - action_info.x = event_info->info.access.x; - action_info.y = event_info->info.access.y; - action_info.mouse_type = event_info->info.access.mouse_type; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE; - break; - case WIDGET_BUFFER_EVENT_ACCESS_SCROLL_DOWN: - parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); - if (!parent_elm) { - ret = WIDGET_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_SCROLL; - action_info.x = event_info->info.access.x; - action_info.y = event_info->info.access.y; - action_info.mouse_type = event_info->info.access.mouse_type; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE; - break; - case WIDGET_BUFFER_EVENT_ACCESS_UNHIGHLIGHT: - parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); - if (!parent_elm) { - ret = WIDGET_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_UNHIGHLIGHT; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE; - break; - case WIDGET_BUFFER_EVENT_ACCESS_VALUE_CHANGE: - parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); - if (!parent_elm) { - ret = WIDGET_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_VALUE_CHANGE; - action_info.x = event_info->info.access.x; - action_info.y = event_info->info.access.y; - action_info.mouse_type = event_info->info.access.mouse_type; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE; - break; - case WIDGET_BUFFER_EVENT_ACCESS_MOUSE: - parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); - if (!parent_elm) { - ret = WIDGET_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_MOUSE; - action_info.x = event_info->info.access.x; - action_info.y = event_info->info.access.y; - action_info.mouse_type = event_info->info.access.mouse_type; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE; - break; - case WIDGET_BUFFER_EVENT_ACCESS_BACK: - parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); - if (!parent_elm) { - ret = WIDGET_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_BACK; - action_info.x = event_info->info.access.x; - action_info.y = event_info->info.access.y; - action_info.mouse_type = event_info->info.access.mouse_type; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE; - break; - case WIDGET_BUFFER_EVENT_ACCESS_OVER: - parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); - if (!parent_elm) { - ret = WIDGET_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_OVER; - action_info.x = event_info->info.access.x; - action_info.y = event_info->info.access.y; - action_info.mouse_type = event_info->info.access.mouse_type; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE; - break; - case WIDGET_BUFFER_EVENT_ACCESS_READ: - parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); - if (!parent_elm) { - ret = WIDGET_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_READ; - action_info.x = event_info->info.access.x; - action_info.y = event_info->info.access.y; - action_info.mouse_type = event_info->info.access.mouse_type; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE; - break; - case WIDGET_BUFFER_EVENT_ACCESS_ENABLE: - parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); - if (!parent_elm) { - ret = WIDGET_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_ENABLE; - action_info.x = event_info->info.access.x; - action_info.y = event_info->info.access.y; - action_info.mouse_type = event_info->info.access.mouse_type; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE; - break; - case WIDGET_BUFFER_EVENT_ACCESS_DISABLE: - parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); - if (!parent_elm) { - ret = WIDGET_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_DISABLE; - action_info.x = event_info->info.access.x; - action_info.y = event_info->info.access.y; - action_info.mouse_type = event_info->info.access.mouse_type; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE; - break; - case WIDGET_BUFFER_EVENT_KEY_DOWN: - parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); - if (!parent_elm) { - ret = WIDGET_ACCESS_STATUS_ERROR; - break; - } - - key_symbol = XGetKeyboardMapping(ecore_x_display_get(), event_info->info.keycode, 1, &ret); - if (key_symbol) { - char *key_name; - char *key_string; - - key_string = XKeysymToString(*key_symbol); - key_name = XKeysymToString(*key_symbol); - DbgPrint("Key symbol: %s, name: %s\n", key_string, key_name); - XFree(key_symbol); - XFree(key_name); - XFree(key_string); - } - ret = WIDGET_KEY_STATUS_ERROR; - break; - case WIDGET_BUFFER_EVENT_KEY_UP: - parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); - if (!parent_elm) { - ret = WIDGET_ACCESS_STATUS_ERROR; - break; - } - - key_symbol = XGetKeyboardMapping(ecore_x_display_get(), event_info->info.keycode, 1, &ret); - if (key_symbol) { - char *key_name; - char *key_string; - - key_string = XKeysymToString(*key_symbol); - key_name = XKeysymToString(*key_symbol); - DbgPrint("Key symbol: %s, name: %s\n", key_string, key_name); - XFree(key_symbol); - XFree(key_name); - XFree(key_string); - } - ret = WIDGET_KEY_STATUS_ERROR; - break; - case WIDGET_BUFFER_EVENT_KEY_FOCUS_IN: - parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); - if (!parent_elm) { - ret = WIDGET_ACCESS_STATUS_ERROR; - break; - } - - key_symbol = XGetKeyboardMapping(ecore_x_display_get(), event_info->info.keycode, 1, &ret); - if (key_symbol) { - char *key_name; - char *key_string; - - key_string = XKeysymToString(*key_symbol); - key_name = XKeysymToString(*key_symbol); - DbgPrint("Key symbol: %s, name: %s\n", key_string, key_name); - XFree(key_symbol); - XFree(key_name); - XFree(key_string); - } - ret = WIDGET_KEY_STATUS_ERROR; - break; - case WIDGET_BUFFER_EVENT_KEY_FOCUS_OUT: - parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); - if (!parent_elm) { - ret = WIDGET_ACCESS_STATUS_ERROR; - break; - } - - key_symbol = XGetKeyboardMapping(ecore_x_display_get(), event_info->info.keycode, 1, &ret); - if (key_symbol) { - char *key_name; - char *key_string; - - key_string = XKeysymToString(*key_symbol); - key_name = XKeysymToString(*key_symbol); - DbgPrint("Key symbol: %s, name: %s\n", key_string, key_name); - XFree(key_symbol); - XFree(key_name); - XFree(key_string); - } - ret = WIDGET_KEY_STATUS_ERROR; - break; - default: - DbgPrint("Unhandled buffer event (%d)\n", event_info->type); - break; - } - - return ret; -} - -static void *alloc_fb(void *data, int size) -{ - vwin_info_t info = data; - void *buffer; - - if (info->ee) { - ecore_evas_geometry_get(info->ee, NULL, NULL, &info->w, &info->h); - DbgPrint("Size of ee is updated: %dx%d (info: %p)\n", info->w, info->h, info); - } - - if (!info->handle) { - ErrPrint("Failed to create a buffer\n"); - return NULL; - } - - if (widget_viewer_acquire_buffer(info->handle, WIDGET_PRIMARY_BUFFER, info->w, info->h, sizeof(int)) < 0) { - ErrPrint("Failed to acquire buffer\n"); - return NULL; - } - - /** - * If it supports the H/W accelerated buffer, - * Use it. - */ - if (widget_support_hw_buffer(info->handle)) { - if (widget_create_hw_buffer(info->handle) == 0) { - buffer = widget_buffer_hw_buffer(info->handle); - if (buffer) { - DbgPrint("HW Accelerated buffer is created %p, (%dx%d)\n", info, info->w, info->h); - info->type = VWIN_GEM; - return buffer; - } - } - - ErrPrint("Failed to allocate HW Accelerated buffer\n"); - } - - /** - * Or use the buffer of a S/W backend. - */ - buffer = widget_ref_buffer(info->handle); - DbgPrint("SW buffer is created (%dx%d)\n", info->w, info->h); - info->type = VWIN_SW_BUF; - return buffer; -} - -static void free_fb(void *data, void *ptr) -{ - vwin_info_t info = data; - - if (!info->handle) { - return; - } - - if (info->type == VWIN_GEM) { - if (widget_destroy_hw_buffer(info->handle) == 0) { - DbgPrint("HW Accelerated buffer is destroyed\n"); - } - } else if (info->type == VWIN_SW_BUF) { - DbgPrint("SW buffer is destroyed, %p\n", info); - widget_unref_buffer(ptr); - } else if (info->type == VWIN_PIXMAP) { - ErrPrint("Unable to reach to here\n"); - } - - if (widget_viewer_release_buffer(info->handle, WIDGET_PRIMARY_BUFFER) < 0) { - ErrPrint("Failed to release buffer\n"); - } - - if (info->deleted) { - widget_destroy_buffer(info->handle); - free(info->resource_array); - free(info->id); - free(info); - } -} - -static void pre_render_cb(void *data, Evas *e, void *event_info) -{ - vwin_info_t info = data; - - if (!info->handle) { - return; - } - - if (widget_conf_premultiplied_alpha()) { - Evas_Coord w; - Evas_Coord h; - - ecore_evas_geometry_get(info->ee, NULL, NULL, &w, &h); - evas_damage_rectangle_add(e, 0, 0, w, h); - } - - if (info->type == VWIN_GEM) { - widget_buffer_pre_render(info->handle); - } else if (info->type == VWIN_PIXMAP) { - /** - * Only the pixmap type Ecore_Evas uses this variable - */ - } else if (info->type == VWIN_SW_BUF) { - /* Do nothing */ - } -} - -static void post_render_cb(void *data, Evas *e, void *event_info) -{ - vwin_info_t info = data; - - if (!info->handle) { - return; - } - - if (widget_conf_premultiplied_alpha()) { - void *canvas; - int x, y, w, h; - - // Get a pointer of a buffer of the virtual canvas - canvas = (void *)ecore_evas_buffer_pixels_get(info->ee); - if (!canvas) { - ErrPrint("Failed to get pixel canvas\n"); - return; - } - - ecore_evas_geometry_get(info->ee, &x, &y, &w, &h); - evas_data_argb_unpremul(canvas, w * h); - } - - if (info->type == VWIN_GEM) { - widget_buffer_post_render(info->handle); - } else if (info->type == VWIN_PIXMAP) { - int idx; - unsigned int front_resource_id; - - front_resource_id = ecore_evas_gl_x11_pixmap_get(info->ee); - - for (idx = 0; idx < WIDGET_CONF_EXTRA_BUFFER_COUNT; idx++) { - if (front_resource_id == info->resource_array[idx]) { - /** - */ - widget_send_updated_by_idx(info->handle, idx); - break; - } - } - - if (idx == WIDGET_CONF_EXTRA_BUFFER_COUNT) { - /* Send updated event for PRIMARY BUFFER */ - if (front_resource_id == widget_viewer_get_resource_id(info->handle, WIDGET_PRIMARY_BUFFER)) { - widget_send_updated_by_idx(info->handle, WIDGET_PRIMARY_BUFFER); - } else { - DbgPrint("Unable to send updated: %u (%u)\n", front_resource_id, widget_viewer_get_resource_id(info->handle, WIDGET_PRIMARY_BUFFER)); - } - } - } else if (info->type == VWIN_SW_BUF) { - widget_viewer_sync_buffer(info->handle); - } -} - -static void pre_destroy_cb(const char *id, void *data) -{ - vwin_info_t info = data; - - if (id && strcmp(info->id, widget_util_uri_to_path(id))) { - /* Skip */ - DbgPrint("SKIP: Pre destroy event callback is called [%s], %s\n", id, info->id); - return; - } - - DbgPrint("Pre destroy event callback is called [%s]\n", id); - - if (info->ee) { - DbgPrint("Toggle manual render mode to prevent from unwanted rendering"); - ecore_evas_manual_render_set(info->ee, EINA_TRUE); - } -} - -static void ecore_evas_free_cb(Ecore_Evas *ee) -{ - vwin_info_t info; - - info = ecore_evas_data_get(ee, "dynamic,box,info"); - if (!info) { - DbgPrint("Info is not valid\n"); - return; - } - - widget_del_pre_callback(WIDGET_PRE_DESTROY_CALLBACK, pre_destroy_cb, info); - - if (info->e) { - evas_event_callback_del(info->e, EVAS_CALLBACK_RENDER_POST, post_render_cb); - evas_event_callback_del(info->e, EVAS_CALLBACK_RENDER_PRE, pre_render_cb); - } - - info->deleted = 1; - info->ee = NULL; -} - -#ifdef WIDGET_FEATURE_GBAR_SUPPORTED -PUBLIC Evas *widget_get_evas(const char *id, int is_gbar) -#else /* WIDGET_FEATURE_GBAR_SUPPORTED */ -PUBLIC Evas *widget_get_evas(const char *id) -#endif /* WIDGET_FEATURE_GBAR_SUPPORTED */ -{ - vwin_info_t info; - Evas_Object *rect; - const char *engine; - - /** - * @TODO - * If the evas object is already created, - * this function should returns ERROR. - */ - - if (!s_info.alloc_canvas && !s_info.alloc_canvas_with_stride && !s_info.alloc_canvas_with_pixmap) { - /* - s_info.alloc_canvas_with_pixmap = dlsym(RTLD_DEFAULT, "ecore_evas_gl_x11_pixmap_allocfunc_new"); - if (!s_info.alloc_canvas_with_pixmap) { - DbgPrint("pixmap_allocfunc_new is not found\n"); - } - */ - - s_info.alloc_canvas_with_stride = dlsym(RTLD_DEFAULT, "ecore_evas_buffer_allocfunc_with_stride_new"); - if (!s_info.alloc_canvas_with_stride) { - DbgPrint("allocfunc_with_stirde_new is not found\n"); - } - - s_info.alloc_canvas = dlsym(RTLD_DEFAULT, "ecore_evas_buffer_allocfunc_new"); - if (!s_info.alloc_canvas) { - ErrPrint("allocfunc_new is not found\n"); - } - - if (!s_info.alloc_canvas_with_stride && !s_info.alloc_canvas && !s_info.alloc_canvas_with_pixmap) { - ErrPrint("No way to allocate canvas\n"); - return NULL; - } - } - - if (!id) { - ErrPrint("Invalid parameter\n"); - return NULL; - } - - info = calloc(1, sizeof(*info)); - if (!info) { - ErrPrint("Heap: %d\n", errno); - return NULL; - } - - info->id = strdup(id); - if (!info->id) { - ErrPrint("Heap: %d\n", errno); - free(info); - return NULL; - } - -#ifdef WIDGET_FEATURE_GBAR_SUPPORTED - info->is_gbar = is_gbar; -#else - info->is_gbar = 0; -#endif /* WIDGET_FEATURE_GBAR_SUPPORTED */ - - /** - * Acquire a buffer for canvas. - */ - info->handle = widget_create_buffer(info->id, info->is_gbar, - (widget_conf_auto_align() || !s_info.alloc_canvas_with_stride), - event_handler_cb, info); - - if (!info->handle) { - ErrPrint("Failed to create a widget buffer\n"); - free(info->id); - free(info); - return NULL; - } - - /** - * Size information must be initialized before call the ecore_evas_buffer_new. - */ - info->w = WIDGET_DEFAULT_WIDTH; - info->h = WIDGET_DEFAULT_HEIGHT; - - engine = elm_config_preferred_engine_get(); - DbgPrint("Preferred engine: %s (%s)\n", engine, GL_ENGINE); - if (engine && !strcmp(engine, GL_ENGINE)) { - if (s_info.alloc_canvas_with_pixmap) { - info->ee = s_info.alloc_canvas_with_pixmap(NULL, 0u, 0, 0, info->w, info->h, alloc_pixmap_cb, free_pixmap_cb, info); - if (!info->ee) { - ErrPrint("Unable to create a ee for pixmap\n"); - } - } - } - - if (!info->ee) { - if (!widget_conf_auto_align() && s_info.alloc_canvas_with_stride) { - info->ee = s_info.alloc_canvas_with_stride(info->w, info->h, alloc_stride_fb, free_fb, info); - } else if (s_info.alloc_canvas) { - info->ee = s_info.alloc_canvas(info->w, info->h, alloc_fb, free_fb, info); - } - } - - if (!info->ee) { - ErrPrint("Failed to create ecore_evas (%dx%d)\n", info->w, info->h); - widget_destroy_buffer(info->handle); - free(info->id); - free(info); - return NULL; - } - - ecore_evas_data_set(info->ee, "dynamic,box,info", info); - - /** - * @note - * Free callback must be prepared before use the ecore_evas_free() - */ - ecore_evas_callback_pre_free_set(info->ee, ecore_evas_free_cb); - - info->e = ecore_evas_get(info->ee); - if (!info->e) { - ErrPrint("Failed to get evas\n"); - ecore_evas_free(info->ee); - return NULL; - } - - pre_render_cb(info, NULL, NULL); - ecore_evas_alpha_set(info->ee, EINA_TRUE); - post_render_cb(info, NULL, NULL); - - ecore_evas_manual_render_set(info->ee, EINA_FALSE); - ecore_evas_resize(info->ee, info->w, info->h); - - evas_event_callback_add(info->e, EVAS_CALLBACK_RENDER_POST, post_render_cb, info); - evas_event_callback_add(info->e, EVAS_CALLBACK_RENDER_PRE, pre_render_cb, info); - - widget_add_pre_callback(WIDGET_PRE_DESTROY_CALLBACK, pre_destroy_cb, info); - - return info->e; -} - -/* End of a file */ diff --git a/src/widget.c b/src/widget.c deleted file mode 100644 index 2db1ea1..0000000 --- a/src/widget.c +++ /dev/null @@ -1,1185 +0,0 @@ -/* - * Copyright 2013 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include /* malloc */ -#include /* strdup */ -#include -#include /* access */ - -#include /* binder.h */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "debug.h" -#include "dlist.h" -#include "util.h" -#include "widget.h" -#include "widget_internal.h" -#include "binder.h" - -#define PUBLIC __attribute__((visibility("default"))) - -/** - * @note - * This value is configurable value. - */ -#define FRAME_WAIT_INTERVAL (1.0f/6.0f) - -struct block { - unsigned int idx; - - char *type; - char *part; - char *data; - char *option; - char *id; - char *file; - char *target_id; -}; - -struct widget_desc { - FILE *fp; - int for_pd; - - unsigned int last_idx; - - struct dlist *block_list; -}; - -struct widget_buffer_data { - int is_gbar; - int accelerated; - - /* for Buffer event wrapper */ - int (*handler)(widget_buffer_h , widget_buffer_event_data_t, void *); - void *cbdata; - - char *content; - char *title; - char *icon; - char *name; - - Ecore_Timer *frame_wait_timer; -}; - -static inline int event_handler_wrapper(widget_buffer_h buffer, widget_buffer_event_data_t event_info, void *data) -{ - const char *pkgname; - const char *id; - struct widget_buffer_data *cbdata = data; - int ret; - - pkgname = widget_provider_buffer_pkgname(buffer); - if (!pkgname) { - ErrPrint("pkgname is not valid\n"); - return WIDGET_ERROR_INVALID_PARAMETER; - } - - id = widget_provider_buffer_id(buffer); - if (!id) { - ErrPrint("id is not valid[%s]\n", pkgname); - return WIDGET_ERROR_INVALID_PARAMETER; - } - - if (cbdata->handler) { - ret = cbdata->handler(buffer, event_info, cbdata->cbdata); - } else { - ret = WIDGET_ERROR_FAULT; - } - - switch (event_info->type) { - case WIDGET_BUFFER_EVENT_ACCESS_HIGHLIGHT: - case WIDGET_BUFFER_EVENT_ACCESS_HIGHLIGHT_NEXT: - case WIDGET_BUFFER_EVENT_ACCESS_HIGHLIGHT_PREV: - case WIDGET_BUFFER_EVENT_ACCESS_ACTIVATE: - case WIDGET_BUFFER_EVENT_ACCESS_ACTION_UP: - case WIDGET_BUFFER_EVENT_ACCESS_ACTION_DOWN: - case WIDGET_BUFFER_EVENT_ACCESS_SCROLL_UP: - case WIDGET_BUFFER_EVENT_ACCESS_SCROLL_MOVE: - case WIDGET_BUFFER_EVENT_ACCESS_SCROLL_DOWN: - case WIDGET_BUFFER_EVENT_ACCESS_UNHIGHLIGHT: - case WIDGET_BUFFER_EVENT_ACCESS_VALUE_CHANGE: - case WIDGET_BUFFER_EVENT_ACCESS_MOUSE: - case WIDGET_BUFFER_EVENT_ACCESS_BACK: - case WIDGET_BUFFER_EVENT_ACCESS_OVER: - case WIDGET_BUFFER_EVENT_ACCESS_READ: - case WIDGET_BUFFER_EVENT_ACCESS_ENABLE: - case WIDGET_BUFFER_EVENT_ACCESS_DISABLE: - DbgPrint("Accessibility event: %d\n", event_info->type); - if (ret < 0) { - (void)widget_provider_send_access_status(pkgname, id, WIDGET_ACCESS_STATUS_ERROR); - } else { - (void)widget_provider_send_access_status(pkgname, id, ret); - } - break; - case WIDGET_BUFFER_EVENT_KEY_UP: - case WIDGET_BUFFER_EVENT_KEY_DOWN: - case WIDGET_BUFFER_EVENT_KEY_FOCUS_IN: - case WIDGET_BUFFER_EVENT_KEY_FOCUS_OUT: - DbgPrint("Key event: %d\n", event_info->type); - if (ret < 0) { - (void)widget_provider_send_key_status(pkgname, id, WIDGET_KEY_STATUS_ERROR); - } else { - (void)widget_provider_send_key_status(pkgname, id, ret); - } - break; - default: - break; - } - - return ret; -} - -static inline int default_event_handler(widget_buffer_h buffer, widget_buffer_event_data_t event_info, void *data) -{ - /* NOP */ - return 0; -} - -PUBLIC struct widget_desc *widget_desc_open(const char *filename, int for_pd) -{ - struct widget_desc *handle; - char *new_fname; - - handle = calloc(1, sizeof(*handle)); - if (!handle) { - ErrPrint("Error: %d\n", errno); - return NULL; - } - - if (for_pd) { - int len; - len = strlen(filename) + strlen(".desc") + 1; - new_fname = malloc(len); - if (!new_fname) { - ErrPrint("Error: %d\n", errno); - free(handle); - return NULL; - } - snprintf(new_fname, len, "%s.desc", filename); - } else { - new_fname = strdup(filename); - if (!new_fname) { - ErrPrint("Error: %d\n", errno); - free(handle); - return NULL; - } - } - - DbgPrint("Open a file %s with merge mode %s\n", - new_fname, - access(new_fname, F_OK) == 0 ? "enabled" : "disabled"); - - handle->fp = fopen(new_fname, "at"); - free(new_fname); - if (!handle->fp) { - ErrPrint("Failed to open a file: %d\n", errno); - free(handle); - return NULL; - } - - return handle; -} - -PUBLIC int widget_desc_close(struct widget_desc *handle) -{ - struct dlist *l; - struct dlist *n; - struct block *block; - - if (!handle) { - return WIDGET_ERROR_INVALID_PARAMETER; - } - - dlist_foreach_safe(handle->block_list, l, n, block) { - handle->block_list = dlist_remove(handle->block_list, l); - - fprintf(handle->fp, "{\n"); - if (block->type) { - fprintf(handle->fp, "type=%s\n", block->type); - } - - if (block->part) { - fprintf(handle->fp, "part=%s\n", block->part); - } - - if (block->data) { - fprintf(handle->fp, "data=%s\n", block->data); - } - - if (block->option) { - fprintf(handle->fp, "option=%s\n", block->option); - } - - if (block->id) { - fprintf(handle->fp, "id=%s\n", block->id); - } - - if (block->target_id) { - fprintf(handle->fp, "target=%s\n", block->target_id); - } - fprintf(handle->fp, "}\n"); - - free(block->type); - free(block->part); - free(block->data); - free(block->option); - free(block->id); - free(block->target_id); - free(block); - } - - if (fclose(handle->fp) != 0) { - ErrPrint("fclose: %d\n", errno); - } - free(handle); - return WIDGET_ERROR_NONE; -} - -PUBLIC int widget_desc_set_category(struct widget_desc *handle, const char *id, const char *category) -{ - struct block *block; - - if (!handle || !category) { - return WIDGET_ERROR_INVALID_PARAMETER; - } - - block = calloc(1, sizeof(*block)); - if (!block) { - return WIDGET_ERROR_OUT_OF_MEMORY; - } - - block->type = strdup(WIDGET_DESC_TYPE_INFO); - if (!block->type) { - free(block); - return WIDGET_ERROR_OUT_OF_MEMORY; - } - - block->part = strdup("category"); - if (!block->part) { - free(block->type); - free(block); - return WIDGET_ERROR_OUT_OF_MEMORY; - } - - block->data = strdup(category); - if (!block->data) { - free(block->type); - free(block->part); - free(block); - return WIDGET_ERROR_OUT_OF_MEMORY; - } - - if (id) { - block->id = strdup(id); - if (!block->id) { - free(block->data); - free(block->type); - free(block->part); - free(block); - return WIDGET_ERROR_OUT_OF_MEMORY; - } - } - - block->idx = handle->last_idx++; - handle->block_list = dlist_append(handle->block_list, block); - return block->idx; -} - -PUBLIC int widget_desc_set_size(struct widget_desc *handle, const char *id, int w, int h) -{ - struct block *block; - char buffer[BUFSIZ]; - - if (!handle) { - return WIDGET_ERROR_INVALID_PARAMETER; - } - - block = calloc(1, sizeof(*block)); - if (!block) { - return WIDGET_ERROR_OUT_OF_MEMORY; - } - - block->type = strdup(WIDGET_DESC_TYPE_INFO); - if (!block->type) { - free(block); - return WIDGET_ERROR_OUT_OF_MEMORY; - } - - block->part = strdup("size"); - if (!block->part) { - free(block->type); - free(block); - return WIDGET_ERROR_OUT_OF_MEMORY; - } - - if (id) { - block->id = strdup(id); - if (!block->id) { - free(block->part); - free(block->type); - free(block); - return WIDGET_ERROR_OUT_OF_MEMORY; - } - } - - snprintf(buffer, sizeof(buffer), "%dx%d", w, h); - block->data = strdup(buffer); - if (!block->data) { - free(block->id); - free(block->part); - free(block->type); - free(block); - return WIDGET_ERROR_OUT_OF_MEMORY; - } - - block->idx = handle->last_idx++; - handle->block_list = dlist_append(handle->block_list, block); - return block->idx; -} - -PUBLIC int widget_desc_set_id(struct widget_desc *handle, int idx, const char *id) -{ - struct dlist *l; - struct block *block; - - dlist_foreach(handle->block_list, l, block) { - if (block->idx == idx) { - if (strcasecmp(block->type, WIDGET_DESC_TYPE_SCRIPT)) { - ErrPrint("Invalid block is used\n"); - return WIDGET_ERROR_INVALID_PARAMETER; - } - - free(block->target_id); - block->target_id = NULL; - - if (!id || !strlen(id)) { - return WIDGET_ERROR_NONE; - } - - block->target_id = strdup(id); - if (!block->target_id) { - ErrPrint("Heap: %d\n", errno); - return WIDGET_ERROR_OUT_OF_MEMORY; - } - - return WIDGET_ERROR_NONE; - } - } - - return WIDGET_ERROR_NOT_EXIST; -} - -/*! - * \return idx - */ -PUBLIC int widget_desc_add_block(struct widget_desc *handle, const char *id, const char *type, const char *part, const char *data, const char *option) -{ - struct block *block; - - if (!handle || !type) { - return WIDGET_ERROR_INVALID_PARAMETER; - } - - if (!part) { - part = ""; - } - - if (!data) { - data = ""; - } - - block = calloc(1, sizeof(*block)); - if (!block) { - ErrPrint("Heap: %d\n", errno); - return WIDGET_ERROR_OUT_OF_MEMORY; - } - - block->type = strdup(type); - if (!block->type) { - ErrPrint("Heap: %d\n", errno); - free(block); - return WIDGET_ERROR_OUT_OF_MEMORY; - } - - block->part = strdup(part); - if (!block->part) { - ErrPrint("Heap: %d\n", errno); - free(block->type); - free(block); - return WIDGET_ERROR_OUT_OF_MEMORY; - } - - block->data = strdup(data); - if (!block->data) { - ErrPrint("Heap: %d\n", errno); - free(block->type); - free(block->part); - free(block); - return WIDGET_ERROR_OUT_OF_MEMORY; - } - - if (option) { - block->option = strdup(option); - if (!block->option) { - ErrPrint("Heap: %d\n", errno); - free(block->data); - free(block->type); - free(block->part); - free(block); - return WIDGET_ERROR_OUT_OF_MEMORY; - } - } - - if (id) { - block->id = strdup(id); - if (!block->id) { - ErrPrint("Heap: %d\n", errno); - free(block->option); - free(block->data); - free(block->type); - free(block->part); - free(block); - return WIDGET_ERROR_OUT_OF_MEMORY; - } - } - - block->idx = handle->last_idx++; - handle->block_list = dlist_append(handle->block_list, block); - return block->idx; -} - -PUBLIC int widget_desc_del_block(struct widget_desc *handle, int idx) -{ - struct dlist *l; - struct block *block; - - if (!handle || idx < 0) { - return WIDGET_ERROR_INVALID_PARAMETER; - } - - dlist_foreach(handle->block_list, l, block) { - if (block->idx == idx) { - handle->block_list = dlist_remove(handle->block_list, l); - free(block->type); - free(block->part); - free(block->data); - free(block->option); - free(block->id); - free(block->target_id); - free(block); - return WIDGET_ERROR_NONE; - } - } - - return WIDGET_ERROR_NOT_EXIST; -} - -PUBLIC int widget_viewer_acquire_buffer(widget_buffer_h handle, int idx, int width, int height, int pixel_size) -{ - int ret; - - if (!handle || width <= 0 || height <= 0 || pixel_size <= 0 || idx > WIDGET_CONF_EXTRA_BUFFER_COUNT) { - return WIDGET_ERROR_INVALID_PARAMETER; - } - - if (idx >= 0) { - int _width = 0; - int _height = 0; - int _pixel_size = 0; - /* To validate the buffer */ - if (widget_provider_buffer_get_size(handle, &_width, &_height, &_pixel_size) < 0) { - ErrPrint("Failed to get buffer size\n"); - } - - if (_width != width || _height != height || pixel_size != _pixel_size) { - DbgPrint("Extra buffer's geometry is not matched with primary one\n"); - } - - ret = widget_provider_buffer_extra_acquire(handle, idx, width, height, pixel_size); - } else { - ret = widget_provider_buffer_acquire(handle, width, height, pixel_size); - } - - return ret; -} - -PUBLIC widget_buffer_h widget_create_buffer(const char *filename, int is_gbar, int auto_align, int (*handler)(widget_buffer_h , widget_buffer_event_data_t, void *), void *data) -{ - struct widget_buffer_data *user_data; - const char *pkgname; - widget_buffer_h handle; - char *uri; - - if (!filename) { - ErrPrint("Invalid argument: %p(%dx%d)\n", filename); - return NULL; - } - - user_data = calloc(1, sizeof(*user_data)); - if (!user_data) { - ErrPrint("Heap: %d\n", errno); - return NULL; - } - - user_data->is_gbar = is_gbar; - user_data->handler = handler ? handler : default_event_handler; - user_data->cbdata = data; - - uri = util_id_to_uri(filename); - if (!uri) { - ErrPrint("Heap: %d\n", errno); - free(user_data); - return NULL; - } - - pkgname = binder_widget_find_pkgname(uri); - if (!pkgname) { - ErrPrint("Invalid Request\n"); - free(user_data); - free(uri); - return NULL; - } - - handle = widget_provider_buffer_create((!!is_gbar) ? WIDGET_TYPE_GBAR : WIDGET_TYPE_WIDGET, pkgname, uri, auto_align, event_handler_wrapper, user_data); - free(uri); - if (!handle) { - free(user_data); - return NULL; - } - - (void)widget_provider_buffer_set_user_data(handle, user_data); - return handle; -} - -PUBLIC unsigned int widget_viewer_get_resource_id(widget_buffer_h handle, int idx) -{ - int ret; - - if (!handle || idx > WIDGET_CONF_EXTRA_BUFFER_COUNT) { - return WIDGET_ERROR_INVALID_PARAMETER; - } - - if (idx >= 0) { - ret = widget_provider_buffer_extra_resource_id(handle, idx); - } else { - ret = widget_provider_buffer_resource_id(handle); - } - - return ret; -} - -PUBLIC int widget_viewer_release_buffer(widget_buffer_h handle, int idx) -{ - int ret; - - if (!handle || idx > WIDGET_CONF_EXTRA_BUFFER_COUNT) { - return WIDGET_ERROR_INVALID_PARAMETER; - } - - if (idx >= 0) { - ret = widget_provider_buffer_extra_release(handle, idx); - } else { - ret = widget_provider_buffer_release(handle); - } - - DbgPrint("Release buffer: %d (%d)\n", idx, ret); - return ret; -} - -PUBLIC int widget_destroy_buffer(widget_buffer_h handle) -{ - struct widget_buffer_data *user_data; - - if (!handle) { - return WIDGET_ERROR_INVALID_PARAMETER; - } - - user_data = widget_provider_buffer_user_data(handle); - if (user_data) { - if (user_data->frame_wait_timer) { - ecore_timer_del(user_data->frame_wait_timer); - user_data->frame_wait_timer = NULL; - } - free(user_data->content); - free(user_data->title); - free(user_data->icon); - free(user_data->name); - free(user_data); - widget_provider_buffer_set_user_data(handle, NULL); - } - - DbgPrint("Destroy buffer\n"); - return widget_provider_buffer_destroy(handle); -} - -PUBLIC void *widget_ref_buffer(widget_buffer_h handle) -{ - struct widget_buffer_data *user_data; - void *data; - int w, h, size; - int ret; - - if (!handle) { - return NULL; - } - - user_data = widget_provider_buffer_user_data(handle); - if (!user_data) { - return NULL; - } - - if (user_data->accelerated) { - DbgPrint("H/W accelerated buffer is allocated\n"); - return NULL; - } - - ret = widget_provider_buffer_get_size(handle, &w, &h, &size); - - data = widget_provider_buffer_ref(handle); - if (data && !ret && w > 0 && h > 0 && size > 0) { - memset(data, 0, w * h * size); - (void)widget_provider_buffer_sync(handle); - } - - DbgPrint("Ref buffer %ds%d(%d)\n", w, h, size); - return data; -} - -PUBLIC int widget_unref_buffer(void *buffer) -{ - if (!buffer) { - return WIDGET_ERROR_INVALID_PARAMETER; - } - - DbgPrint("Unref buffer\n"); - return widget_provider_buffer_unref(buffer); -} - -PUBLIC int widget_viewer_sync_buffer(widget_buffer_h handle) -{ - struct widget_buffer_data *user_data; - const char *pkgname; - const char *id; - int w; - int h; - int pixel_size; - int ret; - - if (!handle) { - return WIDGET_ERROR_INVALID_PARAMETER; - } - - user_data = widget_provider_buffer_user_data(handle); - if (!user_data) { - ErrPrint("Invalid buffer\n"); - return WIDGET_ERROR_INVALID_PARAMETER; - } - - if (user_data->accelerated) { - DbgPrint("H/W Buffer allocated. skip the sync buffer\n"); - return WIDGET_ERROR_NONE; - } - - pkgname = widget_provider_buffer_pkgname(handle); - if (!pkgname) { - ErrPrint("Invalid buffer handler\n"); - return WIDGET_ERROR_INVALID_PARAMETER; - } - - id = widget_provider_buffer_id(handle); - if (!id) { - ErrPrint("Invalid buffer handler\n"); - return WIDGET_ERROR_INVALID_PARAMETER; - } - - (void)widget_provider_buffer_sync(handle); - - if (widget_provider_buffer_get_size(handle, &w, &h, &pixel_size) < 0) { - ErrPrint("Failed to get size (%s)\n", id); - } - - /** - * @todo - * manipulate the damaged region, so send update event only for the damaged region. - * to make more efficient updates - */ - ret = binder_widget_send_updated(pkgname, id, handle, WIDGET_PRIMARY_BUFFER, 0, 0, w, h, user_data->is_gbar, NULL); - if (ret < 0) { - ErrPrint("Failed to send%supdated (%s)\n", user_data->is_gbar ? " GBAR " : " ", id); - } - - return ret; -} - -PUBLIC int widget_send_updated_by_idx(widget_buffer_h handle, int idx) -{ - struct widget_buffer_data *user_data; - const char *pkgname; - const char *id; - int w; - int h; - int pixel_size; - int ret; - - user_data = widget_provider_buffer_user_data(handle); - if (!user_data) { - ErrPrint("Invalid buffer\n"); - return WIDGET_ERROR_INVALID_PARAMETER; - } - - pkgname = widget_provider_buffer_pkgname(handle); - if (!pkgname) { - ErrPrint("Invalid buffer handler\n"); - return WIDGET_ERROR_INVALID_PARAMETER; - } - - id = widget_provider_buffer_id(handle); - if (!id) { - ErrPrint("Invalid buffer handler\n"); - return WIDGET_ERROR_INVALID_PARAMETER; - } - - if (widget_provider_buffer_get_size(handle, &w, &h, &pixel_size) < 0) { - ErrPrint("Failed to get size (%s)\n", id); - } - - ret = binder_widget_send_updated(pkgname, id, handle, idx, 0, 0, w, h, user_data->is_gbar, NULL); - if (ret < 0) { - ErrPrint("Failed to send%supdated (%s) %d\n", user_data->is_gbar ? " GBAR " : " ", id, idx); - } - - return ret; -} - -PUBLIC int widget_support_hw_buffer(widget_buffer_h handle) -{ - if (!handle) { - return WIDGET_ERROR_INVALID_PARAMETER; - } - - return widget_provider_buffer_is_support_hw(handle); -} - -PUBLIC int widget_create_hw_buffer(widget_buffer_h handle) -{ - struct widget_buffer_data *user_data; - int ret; - - if (!handle) { - return WIDGET_ERROR_INVALID_PARAMETER; - } - - user_data = widget_provider_buffer_user_data(handle); - if (!user_data) { - return WIDGET_ERROR_INVALID_PARAMETER; - } - - if (user_data->accelerated) { - return WIDGET_ERROR_ALREADY_EXIST; - } - - ret = widget_provider_buffer_create_hw(handle); - user_data->accelerated = (ret == 0); - return ret; -} - -PUBLIC int widget_destroy_hw_buffer(widget_buffer_h handle) -{ - struct widget_buffer_data *user_data; - - if (!handle) { - LOGD("handle is NULL\n"); - return WIDGET_ERROR_INVALID_PARAMETER; - } - - user_data = widget_provider_buffer_user_data(handle); - if (!user_data || !user_data->accelerated) { - LOGD("user_data is NULL\n"); - return WIDGET_ERROR_INVALID_PARAMETER; - } - - user_data->accelerated = 0; - - return widget_provider_buffer_destroy_hw(handle); -} - -PUBLIC void *widget_buffer_hw_buffer(widget_buffer_h handle) -{ - struct widget_buffer_data *user_data; - - if (!handle) { - return NULL; - } - - user_data = widget_provider_buffer_user_data(handle); - if (!user_data || !user_data->accelerated) { - return NULL; - } - - return widget_provider_buffer_hw_addr(handle); -} - -PUBLIC int widget_buffer_pre_render(widget_buffer_h handle) -{ - struct widget_buffer_data *user_data; - - if (!handle) { - return WIDGET_ERROR_INVALID_PARAMETER; - } - - user_data = widget_provider_buffer_user_data(handle); - if (!user_data) { - return WIDGET_ERROR_INVALID_PARAMETER; - } - - if (!user_data->accelerated) { - return WIDGET_ERROR_NONE; - } - - /*! - * \note - * Do preprocessing for accessing the H/W render buffer - */ - return widget_provider_buffer_pre_render(handle); -} - -static Eina_Bool frame_wait_cb(void *data) -{ - widget_buffer_h handle = data; - struct widget_buffer_data *user_data; - const char *pkgname; - const char *id; - int pixel_size; - int ret; - int w; - int h; - - user_data = widget_provider_buffer_user_data(handle); - if (!user_data) { - ErrPrint("Failed to get a user data\n"); - return ECORE_CALLBACK_CANCEL; - } - - pkgname = widget_provider_buffer_pkgname(handle); - id = widget_provider_buffer_id(handle); - - if (!pkgname || !id) { - ErrPrint("Failed to get instance information (%s), (%s)\n", pkgname, id); - user_data->frame_wait_timer = NULL; - return ECORE_CALLBACK_CANCEL; - } - - if (widget_provider_buffer_get_size(handle, &w, &h, &pixel_size) < 0) { - ErrPrint("Failed to get size (%s)\n", id); - w = 0; - h = 0; - pixel_size = sizeof(int); - } - - DbgPrint("Frame skip waiting timer is fired (%s)\n", id); - - /** - * @todo - * manipulate the damaged region, so send update event only for the damaged region. - * to make more efficient updates - */ - ret = binder_widget_send_updated(pkgname, id, handle, WIDGET_PRIMARY_BUFFER, 0, 0, w, h, user_data->is_gbar, NULL); - if (ret < 0) { - ErrPrint("Failed to send%supdated (%s)\n", user_data->is_gbar ? " GBAR " : " ", id); - } - - (void)widget_provider_buffer_clear_frame_skip(handle); - - user_data->frame_wait_timer = NULL; - return ECORE_CALLBACK_CANCEL; -} - -PUBLIC int widget_buffer_post_render(widget_buffer_h handle) -{ - int ret; - const char *pkgname; - const char *id; - struct widget_buffer_data *user_data; - int w; - int h; - int pixel_size; - PERF_INIT(); - PERF_BEGIN(); - - if (!handle) { - PERF_MARK("post_render"); - return WIDGET_ERROR_INVALID_PARAMETER; - } - - user_data = widget_provider_buffer_user_data(handle); - if (!user_data) { - PERF_MARK("post_render"); - return WIDGET_ERROR_INVALID_PARAMETER; - } - - if (!user_data->accelerated) { - PERF_MARK("post_render"); - return WIDGET_ERROR_NONE; - } - - pkgname = widget_provider_buffer_pkgname(handle); - if (!pkgname) { - ErrPrint("Invalid buffer handle\n"); - PERF_MARK("post_render"); - return WIDGET_ERROR_INVALID_PARAMETER; - } - - id = widget_provider_buffer_id(handle); - if (!id) { - ErrPrint("Invalid buffer handler\n"); - PERF_MARK("post_render"); - return WIDGET_ERROR_INVALID_PARAMETER; - } - - ret = widget_provider_buffer_post_render(handle); - if (ret < 0) { - ErrPrint("Failed to post render processing\n"); - PERF_MARK("post_render"); - return ret; - } - - if (widget_provider_buffer_frame_skip(handle) == 0) { - if (widget_provider_buffer_get_size(handle, &w, &h, &pixel_size) < 0) { - ErrPrint("Failed to get size (%s)\n", id); - } - - /** - * @todo - * manipulate the damaged region, so send update event only for the damaged region. - * to make more efficient updates - */ - ret = binder_widget_send_updated(pkgname, id, handle, WIDGET_PRIMARY_BUFFER, 0, 0, w, h, user_data->is_gbar, NULL); - if (ret < 0) { - ErrPrint("Failed to send%supdated (%s)\n", user_data->is_gbar ? " GBAR " : " ", id); - } - - if (user_data->frame_wait_timer) { - ecore_timer_del(user_data->frame_wait_timer); - user_data->frame_wait_timer = NULL; - } - } else { - if (user_data->frame_wait_timer) { - ecore_timer_reset(user_data->frame_wait_timer); - } else { - user_data->frame_wait_timer = ecore_timer_add(FRAME_WAIT_INTERVAL, frame_wait_cb, handle); - if (!user_data->frame_wait_timer) { - ErrPrint("Failed to add waiting timer for next frame\n"); - } - } - } - - PERF_MARK("post_render"); - return ret; -} - -PUBLIC int widget_buffer_stride(widget_buffer_h handle) -{ - if (!handle) { - return WIDGET_ERROR_INVALID_PARAMETER; - } - - return widget_provider_buffer_stride(handle); -} - -PUBLIC int widget_request_close_glance_bar(const char *pkgname, const char *id, int reason) -{ - char *uri; - int schema_len = strlen(FILE_SCHEMA); - int ret; - - if (!pkgname || !id) { - ErrPrint("Invalid parameters (%s) (%s)\n", pkgname, id); - return WIDGET_ERROR_INVALID_PARAMETER; - } - - if (strncmp(id, FILE_SCHEMA, schema_len)) { - uri = util_id_to_uri(id); - if (!uri) { - ErrPrint("Heap: %d\n", errno); - return WIDGET_ERROR_OUT_OF_MEMORY; - } - } else { - uri = strdup(id); - if (!uri) { - ErrPrint("Heap: %d\n", errno); - return WIDGET_ERROR_OUT_OF_MEMORY; - } - } - - ret = widget_provider_send_request_close_gbar(pkgname, uri, reason); - free(uri); - return ret; -} - -PUBLIC int widget_freeze_scroller(const char *pkgname, const char *id) -{ - char *uri; - int ret; - - if (!pkgname || !id) { - return WIDGET_ERROR_INVALID_PARAMETER; - } - - uri = util_id_to_uri(id); - if (!uri) { - ErrPrint("Heap: %d\n", errno); - return WIDGET_ERROR_OUT_OF_MEMORY; - } - - ret = widget_provider_send_hold_scroll(pkgname, uri, 1); - free(uri); - return ret; -} - -PUBLIC int widget_thaw_scroller(const char *pkgname, const char *id) -{ - char *uri; - int ret; - - if (!pkgname || !id) { - return WIDGET_ERROR_INVALID_PARAMETER; - } - - uri = util_id_to_uri(id); - if (!uri) { - ErrPrint("Heap: %d\n", errno); - return WIDGET_ERROR_OUT_OF_MEMORY; - } - - ret = widget_provider_send_hold_scroll(pkgname, uri, 0); - free(uri); - return ret; -} - -PUBLIC int widget_set_extra_info(const char *id, const char *content, const char *title, const char *icon, const char *name) -{ - widget_buffer_h handle; - const char *pkgname; - char *uri; - - uri = util_id_to_uri(id); - if (!uri) { - ErrPrint("Heap: %d\n", errno); - return WIDGET_ERROR_OUT_OF_MEMORY; - } - - pkgname = binder_widget_find_pkgname(uri); - if (!pkgname) { - ErrPrint("Failed to find a package (%s)\n", uri); - free(uri); - return WIDGET_ERROR_INVALID_PARAMETER; - } - - handle = widget_provider_buffer_find_buffer(WIDGET_TYPE_WIDGET, pkgname, uri); - if (handle) { - struct widget_buffer_data *user_data; - - user_data = widget_provider_buffer_user_data(handle); - if (!user_data) { - ErrPrint("User data is not available\n"); - free(uri); - return WIDGET_ERROR_FAULT; - } - - if (content && strlen(content)) { - char *_content; - - _content = strdup(content); - if (_content) { - if (user_data->content) { - free(user_data->content); - } - - user_data->content = _content; - } else { - ErrPrint("Heap: %d\n", errno); - } - } - - if (title && strlen(title)) { - char *_title; - - _title = strdup(title); - if (_title) { - if (user_data->title) { - free(user_data->title); - } - - user_data->title = _title; - } else { - ErrPrint("Heap: %d\n", errno); - } - } - - if (icon && strlen(icon)) { - char *_icon; - - _icon = strdup(icon); - if (_icon) { - if (user_data->icon) { - free(user_data->icon); - } - - user_data->icon = _icon; - } else { - ErrPrint("Heap: %d\n", errno); - } - } - - if (name && strlen(name)) { - char *_name; - - _name = strdup(name); - if (_name) { - if (user_data->name) { - free(user_data->name); - } - - user_data->name = _name; - } else { - ErrPrint("Heap: %d\n", errno); - } - } - - if (widget_provider_send_extra_info(pkgname, uri, -1.0f, user_data->content, user_data->title, user_data->icon, user_data->name) < 0) { - ErrPrint("Failed to send extra info (%s)\n", id); - } - - free(uri); - return WIDGET_ERROR_NONE; - } - free(uri); - - return binder_widget_update_extra_info(id, content, title, icon, name); -} - -/* End of a file */ diff --git a/widget.pc.in b/widget.pc.in deleted file mode 100644 index c2c8256..0000000 --- a/widget.pc.in +++ /dev/null @@ -1,12 +0,0 @@ -prefix=@PREFIX@ -exec_prefix=@EXEC_PREFIX@ -libdir=@LIBDIR@ -includedir=@INCLUDEDIR@ - -Name: widget -Description: widget supporting library -Version: @VERSION@ -Requires.private: widget_service >= 1.0.0 widget_provider >= 1.0.0 -Libs: -L${libdir} -lwidget -Cflags: -I${includedir} -cppflags: -I${includedir}