From 2dc368d81bf781eb3b2c78fc9e4e37220da891c2 Mon Sep 17 00:00:00 2001 From: Kyuho Jo Date: Tue, 31 Mar 2015 21:02:30 +0900 Subject: [PATCH 01/16] Set @since_tizen tag. Change-Id: I1b6451f1aeeec8d13f1787dee6b5e326a2eaab6e Signed-off-by: Kyuho Jo --- include/widget.h | 6 +-- include/widget_internal.h | 106 +++++++++++++++++++++++----------------------- 2 files changed, 56 insertions(+), 56 deletions(-) diff --git a/include/widget.h b/include/widget.h index f49ce22..d67918f 100755 --- a/include/widget.h +++ b/include/widget.h @@ -28,7 +28,7 @@ extern "C" { /** * @file widget.h * @brief This file declares API of libwidget library - * @since_tizen 2.4 + * @since_tizen 2.3.1 */ /** @@ -39,7 +39,7 @@ extern "C" { /** * @brief Creates an Evas to draw widget contents * @details Creating a new Object using widget frame buffer. - * @since_tizen 2.4 + * @since_tizen 2.3.1 * @param[in] widget_intance_id widget instance id from widget from widget_provider_event_callback_s functions * @privlevel public * @privilege %http://tizen.org/privilege/widget.provider @@ -53,7 +53,7 @@ extern Evas *widget_get_evas(const char *widget_intance_id); /** * @brief Requests to schedule the update operation to a provider. * @detail Insert a update event to event queue and it will be handled by update callback function. - * @since_tizen 2.4 + * @since_tizen 2.3.1 * @param[in] widget_intance_id A instance id of the widget to be updated * @feature http://tizen.org/feature/shell.appwidget * @return If succes returns 0 or return less than 0 diff --git a/include/widget_internal.h b/include/widget_internal.h index c3cf60a..8c98f58 100755 --- a/include/widget_internal.h +++ b/include/widget_internal.h @@ -30,7 +30,7 @@ extern "C" { /** * @file widget_internal.h * @brief This file declares API of libwidget library - * @since_tizen 2.3 + * @since_tizen 2.3.1 */ /** @@ -41,98 +41,98 @@ extern "C" { /** * @internal * @brief Definition for COLOR BLOCK. - * @since_tizen 2.3 + * @since_tizen 2.3.1 */ #define WIDGET_DESC_TYPE_COLOR "color" /** * @internal * @brief Definition for TEXT BLOCK. - * @since_tizen 2.3 + * @since_tizen 2.3.1 */ #define WIDGET_DESC_TYPE_TEXT "text" /** * @internal * @brief Definition for IMAGE BLOCK. - * @since_tizen 2.3 + * @since_tizen 2.3.1 */ #define WIDGET_DESC_TYPE_IMAGE "image" /** * @internal * @brief Definition for SIGNAL BLOCK. - * @since_tizen 2.3 + * @since_tizen 2.3.1 */ #define WIDGET_DESC_TYPE_SIGNAL "signal" /** * @internal * @brief Definition for INFO BLOCK. - * @since_tizen 2.3 + * @since_tizen 2.3.1 */ #define WIDGET_DESC_TYPE_INFO "info" /** * @internal * @brief Definition for DRAG BLOCK. - * @since_tizen 2.3 + * @since_tizen 2.3.1 */ #define WIDGET_DESC_TYPE_DRAG "drag" /** * @internal * @brief Definition for SCRIPT SCRIPT. - * @since_tizen 2.3 + * @since_tizen 2.3.1 */ #define WIDGET_DESC_TYPE_SCRIPT "script" /** * @internal * @brief Definition for ACCESSIBILITY INFORMATION BLOCK. - * @since_tizen 2.3 + * @since_tizen 2.3.1 */ #define WIDGET_DESC_TYPE_ACCESS "access" /** * @internal * @brief Definition for accessibility operation. - * @since_tizen 2.3 + * @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 + * @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 + * @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 + * @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 + * @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 + * @since_tizen 2.3.1 */ #define WIDGET_DESC_DATA_ACCESS_OPERATION_RESET "reset,focus" @@ -140,7 +140,7 @@ extern "C" { * @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 + * @since_tizen 2.3.1 */ #define WIDGET_DESC_OPTION_ACCESS_HL_LOOP "cycle" @@ -149,14 +149,14 @@ extern "C" { * @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 + * @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.4 + * @since_tizen 2.3.1 * @feature http://tizen.org/feature/shell.appwidget */ typedef enum widget_api_result { @@ -171,7 +171,7 @@ typedef enum widget_api_result { /** * @internal * @brief System event type for the plug-in type widgets - * @since_tizen 2.4 + * @since_tizen 2.3.1 * @feature http://tizen.org/feature/shell.appwidget */ typedef enum widget_system_event { @@ -189,21 +189,21 @@ typedef enum widget_system_event { /** * @internal * @brief widget description data handle. - * @since_tizen 2.3 + * @since_tizen 2.3.1 */ typedef struct widget_desc *widget_desc_h; /** * @internal * @brief Flush Callback for snapshot window - * @since_tizen 2.3 + * @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 + * @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 @@ -222,7 +222,7 @@ 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 + * @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 @@ -243,7 +243,7 @@ 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 + * @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 @@ -261,7 +261,7 @@ extern int widget_desc_set_category(widget_desc_h handle, const char *id, const * @internal * @brief Sets the content size. * @details Sets the content size of layout. - * @since_tizen 2.3 + * @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 @@ -280,7 +280,7 @@ extern int widget_desc_set_size(widget_desc_h handle, const char *id, int w, int * @internal * @brief Sets the target id of the given block. * @details Only available for the script block. - * @since_tizen 2.3 + * @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 @@ -299,7 +299,7 @@ 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 + * @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) @@ -319,7 +319,7 @@ extern int widget_desc_add_block(widget_desc_h handle, const char *id, const cha /** * @internal * @brief Deletes an added block. - * @since_tizen 2.3 + * @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 @@ -336,14 +336,14 @@ 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 + * @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 + * @since_tizen 2.3.1 */ extern const int WIDGET_USE_NET; @@ -352,7 +352,7 @@ extern const int WIDGET_USE_NET; * @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 + * @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 #WIDGET_ERROR_NONE on success, @@ -368,7 +368,7 @@ 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 + * @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 @@ -391,7 +391,7 @@ extern widget_buffer_h widget_create_buffer(const char *id, int gbar, int auto_a /** * @internal * @brief Acquire a buffer for GBar or widget. - * @since_tizen 2.3 + * @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 @@ -415,7 +415,7 @@ extern int widget_viewer_acquire_buffer(widget_buffer_h handle, int idx, int wid * @internal * @brief Acquires the Id of Resource (window system). * @details Only if the provider uses Resource for providing render buffer. - * @since_tizen 2.3 + * @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 @@ -430,7 +430,7 @@ extern unsigned int widget_viewer_get_resource_id(widget_buffer_h handle, int id /** * @internal * @brief Releases the buffer of widget. - * @since_tizen 2.3 + * @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 @@ -448,7 +448,7 @@ extern int widget_viewer_release_buffer(widget_buffer_h handle, int idx); /** * @internal * @brief Destroy a buffer of widget - * @since_tizen 2.3 + * @since_tizen 2.3.1 * @param[in] handle buffer handle * @privlevel public * @privilege %http://tizen.org/privilege/widget.provider @@ -466,7 +466,7 @@ extern int widget_destroy_buffer(widget_buffer_h handle); * @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 + * @since_tizen 2.3.1 * @param[in] handle Buffer handle * @privlevel public * @privilege %http://tizen.org/privilege/widget.provider @@ -481,7 +481,7 @@ extern void *widget_ref_buffer(widget_buffer_h handle); /** * @internal * @brief Releases the S/W render buffer. - * @since_tizen 2.3 + * @since_tizen 2.3.1 * @param[in] buffer Address of render buffer * @privlevel public * @privilege %http://tizen.org/privilege/widget.provider @@ -501,7 +501,7 @@ extern int widget_unref_buffer(void *buffer); * @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 + * @since_tizen 2.3.1 * @param[in] handle Buffer handle * @privlevel public * @privilege %http://tizen.org/privilege/widget.provider @@ -519,7 +519,7 @@ 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 + * @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 @@ -532,7 +532,7 @@ 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 + * @since_tizen 2.3.1 * @param[in] handle Buffer handle * @privlevel public * @privilege %http://tizen.org/privilege/widget.provider @@ -553,7 +553,7 @@ 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 + * @since_tizen 2.3.1 * @param[in] handle Buffer handle * @privlevel public * @privilege %http://tizen.org/privilege/widget.provider @@ -572,7 +572,7 @@ 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 + * @since_tizen 2.3.1 * @param[in] handle Buffer handle * @privlevel public * @privilege %http://tizen.org/privilege/widget.provider @@ -588,7 +588,7 @@ 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 + * @since_tizen 2.3.1 * @param[in] handle Buffer handle * @return int stride size * @retval positive_value length of stride @@ -602,7 +602,7 @@ 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 + * @since_tizen 2.3.1 * @param[in] handle Buffer handle * @privlevel public * @privilege %http://tizen.org/privilege/widget.provider @@ -621,7 +621,7 @@ extern int widget_buffer_pre_render(widget_buffer_h handle); /** * @internal * @brief Post-processes for rendering content. - * @since_tizen 2.3 + * @since_tizen 2.3.1 * @param[in] handle Buffer handle * @privlevel public * @privilege %http://tizen.org/privilege/widget.provider @@ -640,7 +640,7 @@ 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 + * @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) @@ -665,7 +665,7 @@ extern int widget_request_close_glance_bar(const char *widgetid, const char *id, * 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 + * @since_tizen 2.3.1 * @param[in] id * @param[in] size_type * @return void* window @@ -678,7 +678,7 @@ 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 + * @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 @@ -694,7 +694,7 @@ extern int widget_snapshot_window_flush(void *snapshot_win, double timeout, widg /** * @internal * @brief Sending the updated event to the viewer - * @since_tizen 2.3 + * @since_tizen 2.3.1 * @param[in] handle widget Buffer Handle * @param[in] idx Index of a buffer * @privlevel public @@ -713,7 +713,7 @@ extern int widget_send_updated_by_idx(widget_buffer_h handle, int idx); * 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.4 + * @since_tizen 2.3.1 * @privlevel N/P * @feature http://tizen.org/feature/shell.appwidget * @remarks This function only works with the buffer type inhouse provider. @@ -738,7 +738,7 @@ extern int widget_set_extra_info(const char *id, const char *content, const char * @details * The viewer will get this request via event callback. * Then it should freeze its scroller or stop moving the widget. - * @since_tizen 2.4 + * @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 @@ -763,7 +763,7 @@ extern int widget_freeze_scroller(const char *widgetid, const char *id); * @details * The viewer will get this request via event callback. * Then it should release its scroller or continue moving the widget. - * @since_tizen 2.4 + * @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 -- 2.7.4 From 75592f3caa019b98a4ae3722694e52a5bcb7bf75 Mon Sep 17 00:00:00 2001 From: Sung-jae Park Date: Thu, 2 Apr 2015 13:20:33 +0900 Subject: [PATCH 02/16] change file permission (755 -> 644) [model] Redwood,Kiran,B3(Wearable) [binary_type] AP [customer] Docomo/Orange/ATT/Open [issue#] N/A [problem] [cause] [solution] [team] HomeTF [request] [horizontal_expansion] --- CMakeLists.txt | 0 doc/widget_doc.h | 0 include/widget.h | 0 include/widget_internal.h | 0 patch/pixmap_ee.patch | 0 patch/pixmap_ee_widget.patch | 0 src/snapshot_window.c | 0 src/virtual_window.c | 0 src/virtual_window_wayland.c | 0 src/widget.c | 0 widget.pc.in | 0 11 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 CMakeLists.txt mode change 100755 => 100644 doc/widget_doc.h mode change 100755 => 100644 include/widget.h mode change 100755 => 100644 include/widget_internal.h mode change 100755 => 100644 patch/pixmap_ee.patch mode change 100755 => 100644 patch/pixmap_ee_widget.patch mode change 100755 => 100644 src/snapshot_window.c mode change 100755 => 100644 src/virtual_window.c mode change 100755 => 100644 src/virtual_window_wayland.c mode change 100755 => 100644 src/widget.c mode change 100755 => 100644 widget.pc.in diff --git a/CMakeLists.txt b/CMakeLists.txt old mode 100755 new mode 100644 diff --git a/doc/widget_doc.h b/doc/widget_doc.h old mode 100755 new mode 100644 diff --git a/include/widget.h b/include/widget.h old mode 100755 new mode 100644 diff --git a/include/widget_internal.h b/include/widget_internal.h old mode 100755 new mode 100644 diff --git a/patch/pixmap_ee.patch b/patch/pixmap_ee.patch old mode 100755 new mode 100644 diff --git a/patch/pixmap_ee_widget.patch b/patch/pixmap_ee_widget.patch old mode 100755 new mode 100644 diff --git a/src/snapshot_window.c b/src/snapshot_window.c old mode 100755 new mode 100644 diff --git a/src/virtual_window.c b/src/virtual_window.c old mode 100755 new mode 100644 diff --git a/src/virtual_window_wayland.c b/src/virtual_window_wayland.c old mode 100755 new mode 100644 diff --git a/src/widget.c b/src/widget.c old mode 100755 new mode 100644 diff --git a/widget.pc.in b/widget.pc.in old mode 100755 new mode 100644 -- 2.7.4 From 18c34b2f3a6e6cf139d1e71196914e6e45fcad28 Mon Sep 17 00:00:00 2001 From: Sung-jae Park Date: Thu, 9 Apr 2015 19:05:04 +0900 Subject: [PATCH 03/16] Set manual render mode while destroying instances. [model] Redwood,Kiran,B3(Wearable) [binary_type] AP [customer] Docomo/Orange/ATT/Open [issue#] N/A [problem] [cause] [solution] [team] HomeTF [request] [horizontal_expansion] Change-Id: Id6fdda560653dfe09f66fb418282b766eee14bfb --- src/virtual_window.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/virtual_window.c b/src/virtual_window.c index f302cad..74d1b05 100644 --- a/src/virtual_window.c +++ b/src/virtual_window.c @@ -32,6 +32,7 @@ #include #include #include +#include #include "widget.h" #include "widget_internal.h" @@ -861,6 +862,22 @@ static void post_render_cb(void *data, Evas *e, void *event_info) } } +static void pre_destroy_cb(widget_pre_callback_e type, const char *pkgname, const char *id, void *data) +{ + vwin_info_t info = data; + if (strcmp(info->id, id)) { + /* Skip */ + DbgPrint("SKIP: Pre destroy event callback is called [%s]\n", 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; @@ -871,6 +888,8 @@ static void ecore_evas_free_cb(Ecore_Evas *ee) return; } + widget_provider_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); @@ -890,6 +909,12 @@ PUBLIC Evas *widget_get_evas(const char *id) 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) { @@ -1008,6 +1033,8 @@ PUBLIC Evas *widget_get_evas(const char *id) 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_provider_add_pre_callback(WIDGET_PRE_DESTROY_CALLBACK, pre_destroy_cb, info); + return info->e; } -- 2.7.4 From c93bce29f6ed69f950b0b3affb498b7c42bbf890 Mon Sep 17 00:00:00 2001 From: Sung-jae Park Date: Thu, 9 Apr 2015 20:05:38 +0900 Subject: [PATCH 04/16] Compare the id after util_uri_to_path. [model] Redwood,Kiran,B3(Wearable) [binary_type] AP [customer] Docomo/Orange/ATT/Open [issue#] N/A [problem] [cause] [solution] [team] HomeTF [request] [horizontal_expansion] Change-Id: I968daad94dd376cc64c5c5c221e7b63d54a3ac2e --- src/virtual_window.c | 7 +++++-- src/widget.c | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/virtual_window.c b/src/virtual_window.c index 74d1b05..d2f3e23 100644 --- a/src/virtual_window.c +++ b/src/virtual_window.c @@ -33,6 +33,7 @@ #include #include #include +#include #include "widget.h" #include "widget_internal.h" @@ -865,11 +866,13 @@ static void post_render_cb(void *data, Evas *e, void *event_info) static void pre_destroy_cb(widget_pre_callback_e type, const char *pkgname, const char *id, void *data) { vwin_info_t info = data; - if (strcmp(info->id, id)) { + + if (id && strcmp(info->id, widget_util_uri_to_path(id))) { /* Skip */ - DbgPrint("SKIP: Pre destroy event callback is called [%s]\n", id); + 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) { diff --git a/src/widget.c b/src/widget.c index c521977..2b29f12 100644 --- a/src/widget.c +++ b/src/widget.c @@ -31,6 +31,7 @@ #include #include #include +#include #include "debug.h" #include "dlist.h" -- 2.7.4 From 4ed50cf72922df8e87f2a60c2d9e52da51f91b91 Mon Sep 17 00:00:00 2001 From: Sung-jae Park Date: Fri, 10 Apr 2015 10:33:17 +0900 Subject: [PATCH 05/16] Add pre callback only for the provider-app [model] Redwood,Kiran,B3(Wearable) [binary_type] AP [customer] Docomo/Orange/ATT/Open [issue#] N/A [problem] [cause] [solution] [team] HomeTF [request] [horizontal_expansion] Change-Id: Idb323c7ca1efc20c865a2c4ec6aa6827a24d5ab3 --- include/widget_internal.h | 9 ++++++++ src/virtual_window.c | 6 ++--- src/widget.c | 58 +++++++++++++++++++++++++++++++++++++++++------ 3 files changed, 63 insertions(+), 10 deletions(-) diff --git a/include/widget_internal.h b/include/widget_internal.h index 8c98f58..1daaac5 100644 --- a/include/widget_internal.h +++ b/include/widget_internal.h @@ -781,6 +781,15 @@ extern int widget_freeze_scroller(const char *widgetid, const char *id); * 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); + /** * @} */ diff --git a/src/virtual_window.c b/src/virtual_window.c index d2f3e23..37a7280 100644 --- a/src/virtual_window.c +++ b/src/virtual_window.c @@ -863,7 +863,7 @@ static void post_render_cb(void *data, Evas *e, void *event_info) } } -static void pre_destroy_cb(widget_pre_callback_e type, const char *pkgname, const char *id, void *data) +static void pre_destroy_cb(const char *id, void *data) { vwin_info_t info = data; @@ -891,7 +891,7 @@ static void ecore_evas_free_cb(Ecore_Evas *ee) return; } - widget_provider_del_pre_callback(WIDGET_PRE_DESTROY_CALLBACK, pre_destroy_cb, info); + 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); @@ -1036,7 +1036,7 @@ PUBLIC Evas *widget_get_evas(const char *id) 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_provider_add_pre_callback(WIDGET_PRE_DESTROY_CALLBACK, pre_destroy_cb, info); + widget_add_pre_callback(WIDGET_PRE_DESTROY_CALLBACK, pre_destroy_cb, info); return info->e; } diff --git a/src/widget.c b/src/widget.c index 2b29f12..9948de9 100644 --- a/src/widget.c +++ b/src/widget.c @@ -108,14 +108,26 @@ static struct info { struct _app { int (*send)(widget_buffer_h handle, int idx, int x, int y, int w, int h, int gbar); + 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); } app; - } updated; + } binder; } s_info = { .find_pkgname = NULL, .request_update_by_id = NULL, .trigger_update_monitor = NULL, .update_extra_info = NULL, .type = LOAD_TYPE_UNKNOWN, /* Not initialized */ + .binder = { + .slave = { + .send = NULL, + }, + .app = { + .send = NULL, + .add_pre_callback = NULL, + .del_pre_callback = NULL, + }, + }, }; #define FUNC_PREFIX "widget_" @@ -125,23 +137,55 @@ static struct info { #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_ADD_PRE_CALLBACK FUNC_PREFIX "provider_app_add_pre_callback" +#define FUNC_WIDGET_DEL_PRE_CALLBACK FUNC_PREFIX "provider_app_del_pre_callback" static inline void load_update_function(void) { /* Must to be checked the slave function first. */ - s_info.updated.slave.send = dlsym(RTLD_DEFAULT, FUNC_WIDGET_SEND_UPDATED); - if (s_info.updated.slave.send) { + 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.updated.app.send = dlsym(RTLD_DEFAULT, FUNC_WIDGET_PROVIDER_APP_UPDATED); - if (s_info.updated.app.send) { + 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"); } } } +int widget_add_pre_callback(widget_pre_callback_e type, widget_pre_callback_t cb, void *data) +{ + static int loaded = 0; + if (!loaded && !s_info.binder.app.add_pre_callback) { + s_info.binder.app.add_pre_callback = dlsym(RTLD_DEFAULT, FUNC_WIDGET_ADD_PRE_CALLBACK); + loaded = 1; + } + + if (!s_info.binder.app.add_pre_callback) { + return WIDGET_ERROR_NOT_SUPPORTED; + } + + return s_info.binder.app.add_pre_callback(type, cb, data); +} + +int widget_del_pre_callback(widget_pre_callback_e type, widget_pre_callback_t cb, void *data) +{ + static int loaded = 0; + if (!loaded && !s_info.binder.app.del_pre_callback) { + s_info.binder.app.del_pre_callback = dlsym(RTLD_DEFAULT, FUNC_WIDGET_DEL_PRE_CALLBACK); + loaded = 1; + } + + if (!s_info.binder.app.del_pre_callback) { + return WIDGET_ERROR_NOT_SUPPORTED; + } + + return s_info.binder.app.del_pre_callback(type, cb, data); +} + static int 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; @@ -151,12 +195,12 @@ static int send_updated(const char *pkgname, const char *id, widget_buffer_h han } if (s_info.type == LOAD_TYPE_APP) { - ret = s_info.updated.app.send(handle, idx, x, y, w, h, gbar); + 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.updated.slave.send(pkgname, id, handle, idx, x, y, w, h, gbar, descfile); + ret = s_info.binder.slave.send(pkgname, id, handle, idx, x, y, w, h, gbar, descfile); } else { widget_damage_region_s region = { .x = x, -- 2.7.4 From 8ba1d0856e4c6a2e165b5e70ec81580fc751ef66 Mon Sep 17 00:00:00 2001 From: Sung-jae Park Date: Mon, 20 Apr 2015 14:58:49 +0900 Subject: [PATCH 06/16] Prepare for porting to the wayland [model] Redwood,Kiran,B3(Wearable) [binary_type] AP [customer] Docomo/Orange/ATT/Open [issue#] N/A [problem] [cause] [solution] [team] HomeTF [request] [horizontal_expansion] Change-Id: I1850ee192c0d8e1e787b348c32d2021c8caf04bd --- src/virtual_window_wayland.c | 634 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 539 insertions(+), 95 deletions(-) diff --git a/src/virtual_window_wayland.c b/src/virtual_window_wayland.c index d332aaa..4ae8122 100644 --- a/src/virtual_window_wayland.c +++ b/src/virtual_window_wayland.c @@ -27,22 +27,49 @@ #include "widget.h" #include "debug.h" -#define IS_PD 1 +#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 +/** + * @brief * Abstracted Data Type of Virtual Window */ -struct info { - char *id; /*!< Identification */ - struct widget_buffer *handle; /*!< Livebox buffer handle */ - int is_hw; /*!< 1 if a buffer is created on the H/W accelerated place or 0 */ +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) { @@ -61,11 +88,13 @@ static inline Evas_Object *get_highlighted_object(Evas_Object *obj) */ static int event_handler_cb(struct widget_buffer *handler, struct widget_buffer_event_data *event_info, void *data) { - struct info *info = 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) { @@ -73,66 +102,150 @@ static int event_handler_cb(struct widget_buffer *handler, struct widget_buffer_ 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, event_info->timestamp * 1000, NULL); + evas_event_feed_mouse_in(info->e, timestamp, NULL); break; case WIDGET_BUFFER_EVENT_LEAVE: - evas_event_feed_mouse_out(info->e, event_info->timestamp * 1000, NULL); + evas_event_feed_mouse_out(info->e, timestamp, NULL); break; case WIDGET_BUFFER_EVENT_DOWN: - /*! - * \note + 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, (event_info->timestamp - 0.001f) * 1000, NULL); /* + 0.1f just for fake event */ - evas_event_feed_mouse_down(info->e, 1, EVAS_BUTTON_NONE, event_info->timestamp * 1000, NULL); /* + 0.2f just for fake event */ + 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 + /** + * @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, event_info->timestamp * 1000, NULL); + 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, event_info->timestamp * 1000, NULL); - evas_event_feed_mouse_up(info->e, 1, EVAS_BUTTON_NONE, (event_info->timestamp + 0.001f) * 1000, NULL); + 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, "dynamic,box,win"); + 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 + /** + * @note * Calculate the event occurred X & Y on the buffer */ - action_info.x = event_info->info.pointer.x; - action_info.y = event_info->info.pointer.y; + 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)) { - LOGE("Highlighted object is not found\n"); + ErrPrint("Highlighted object is not found\n"); ret = WIDGET_ACCESS_STATUS_ERROR; } else { - LOGD("Highlighted object is found\n"); + DbgPrint("Highlighted object is found\n"); ret = WIDGET_ACCESS_STATUS_DONE; } } else { - LOGE("Action error\n"); + 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, "dynamic,box,win"); + parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); if (!parent_elm) { ret = WIDGET_ACCESS_STATUS_ERROR; break; @@ -144,7 +257,7 @@ static int event_handler_cb(struct widget_buffer *handler, struct widget_buffer_ 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, "dynamic,box,win"); + parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); if (!parent_elm) { ret = WIDGET_ACCESS_STATUS_ERROR; break; @@ -156,7 +269,7 @@ static int event_handler_cb(struct widget_buffer *handler, struct widget_buffer_ 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, "dynamic,box,win"); + parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); if (!parent_elm) { ret = WIDGET_ACCESS_STATUS_ERROR; break; @@ -167,7 +280,7 @@ static int event_handler_cb(struct widget_buffer *handler, struct widget_buffer_ 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, "dynamic,box,win"); + parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); if (!parent_elm) { ret = WIDGET_ACCESS_STATUS_ERROR; break; @@ -178,7 +291,7 @@ static int event_handler_cb(struct widget_buffer *handler, struct widget_buffer_ 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, "dynamic,box,win"); + parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); if (!parent_elm) { ret = WIDGET_ACCESS_STATUS_ERROR; break; @@ -189,49 +302,49 @@ static int event_handler_cb(struct widget_buffer *handler, struct widget_buffer_ 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, "dynamic,box,win"); + 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.pointer.x; - action_info.y = event_info->info.pointer.y; - action_info.mouse_type = 2; + 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, "dynamic,box,win"); + 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.pointer.x; - action_info.y = event_info->info.pointer.y; - action_info.mouse_type = 1; + 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, "dynamic,box,win"); + 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.pointer.x; - action_info.y = event_info->info.pointer.y; - action_info.mouse_type = 0; + 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, "dynamic,box,win"); + parent_elm = ecore_evas_data_get(info->ee, WIDGET_WIN_TAG); if (!parent_elm) { ret = WIDGET_ACCESS_STATUS_ERROR; break; @@ -241,44 +354,190 @@ static int event_handler_cb(struct widget_buffer *handler, struct widget_buffer_ 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, "dynamic,box,win"); + 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, "dynamic,box,win"); + 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, "dynamic,box,win"); + 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, "dynamic,box,win"); + 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: - LOGD("Unhandled buffer event (%d)\n", event_info->type); + DbgPrint("Unhandled buffer event (%d)\n", event_info->type); break; } @@ -287,26 +546,25 @@ static int event_handler_cb(struct widget_buffer *handler, struct widget_buffer_ static void *alloc_fb(void *data, int size) { - struct info *info = data; + vwin_info_t info = data; void *buffer; - int width = 0; - int height = 0; - if (info->ee == NULL) { - width = 1; - height = 1; - } else { - ecore_evas_geometry_get(info->ee, NULL, NULL, &width, &height); + 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_viewer_acquire_buffer(info->id, info->is_gbar, - width, height, - event_handler_cb, 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. */ @@ -314,78 +572,213 @@ static void *alloc_fb(void *data, int size) if (widget_create_hw_buffer(info->handle) == 0) { buffer = widget_buffer_hw_buffer(info->handle); if (buffer) { - LOGD("HW Accelerated buffer is created\n"); - info->is_hw = 1; + DbgPrint("HW Accelerated buffer is created %p, (%dx%d)\n", info, info->w, info->h); + info->type = VWIN_GEM; return buffer; } } - LOGE("Failed to allocate HW Accelerated buffer\n"); + ErrPrint("Failed to allocate HW Accelerated buffer\n"); } - /*! + /** * Or use the buffer of a S/W backend. */ buffer = widget_ref_buffer(info->handle); - LOGD("SW buffer is created\n"); - info->is_hw = 0; + 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) { - struct info *info = data; + vwin_info_t info = data; if (!info->handle) { return; } - if (info->is_hw) { + if (info->type == VWIN_GEM) { if (widget_destroy_hw_buffer(info->handle) == 0) { - LOGD("HW Accelerated buffer is destroyed\n"); - goto out; + 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"); } - widget_unref_buffer(ptr); - LOGD("SW buffer is destroyed\n"); -out: - widget_viewer_release_buffer(info->handle); - info->handle = NULL; + 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) { - struct info *info = data; + vwin_info_t info = data; if (!info->handle) { return; } - if (info->is_hw) { + 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) { - struct info *info = data; + vwin_info_t info = data; if (!info->handle) { return; } - if (info->is_hw) { + 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 { + } 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 */ { - struct info *info; + 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"); @@ -405,24 +798,66 @@ PUBLIC Evas *widget_get_evas(const char *id, int is_gbar) return NULL; } +#ifdef WIDGET_FEATURE_GBAR_SUPPORTED info->is_gbar = is_gbar; +#else + info->is_gbar = 0; +#endif /* WIDGET_FEATURE_GBAR_SUPPORTED */ - info->ee = ecore_evas_buffer_allocfunc_new(1, 1, alloc_fb, free_fb, info); - if (!info->ee) { - ErrPrint("Failed to create ecore_evas (%dx%d)\n", 1, 1); + /** + * 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; } - pre_render_cb(info, NULL, NULL); - ecore_evas_alpha_set(info->ee, EINA_TRUE); - post_render_cb(info, NULL, 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); - ecore_evas_manual_render_set(info->ee, EINA_FALSE); - ecore_evas_resize(info->ee, 1, 1); + /** + * @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) { @@ -431,9 +866,18 @@ PUBLIC Evas *widget_get_evas(const char *id, int is_gbar) 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; } -- 2.7.4 From e341268296e4b95877b2c274333e1abe78bd6739 Mon Sep 17 00:00:00 2001 From: Kyuho Jo Date: Thu, 16 Apr 2015 18:04:42 +0900 Subject: [PATCH 07/16] Changes by ACR Change-Id: I1dee226066a261199da6cafebfa95ea0abfbe420 Signed-off-by: Kyuho Jo --- include/widget.h | 8 ++--- include/widget_internal.h | 88 +++++++++++++---------------------------------- 2 files changed, 27 insertions(+), 69 deletions(-) mode change 100644 => 100755 include/widget.h mode change 100644 => 100755 include/widget_internal.h diff --git a/include/widget.h b/include/widget.h old mode 100644 new mode 100755 index d67918f..6fabf9f --- a/include/widget.h +++ b/include/widget.h @@ -40,10 +40,9 @@ extern "C" { * @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 from widget from widget_provider_event_callback_s functions + * @param[in] widget_intance_id widget instance id * @privlevel public * @privilege %http://tizen.org/privilege/widget.provider - * @feature http://tizen.org/feature/shell.appwidget * @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 @@ -52,11 +51,10 @@ extern Evas *widget_get_evas(const char *widget_intance_id); /** * @brief Requests to schedule the update operation to a provider. - * @detail Insert a update event to event queue and it will be handled by update callback function. + * @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 - * @feature http://tizen.org/feature/shell.appwidget - * @return If succes returns 0 or return less than 0 + * @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 diff --git a/include/widget_internal.h b/include/widget_internal.h old mode 100644 new mode 100755 index 1daaac5..a498e70 --- a/include/widget_internal.h +++ b/include/widget_internal.h @@ -157,7 +157,6 @@ extern "C" { * @internal * @brief Return values of widget programming interfaces for the plug-in type widgets * @since_tizen 2.3.1 - * @feature http://tizen.org/feature/shell.appwidget */ typedef enum widget_api_result { WIDGET_DONE = 0x00, /**< Operation is successfully done. */ @@ -172,7 +171,6 @@ typedef enum widget_api_result { * @internal * @brief System event type for the plug-in type widgets * @since_tizen 2.3.1 - * @feature http://tizen.org/feature/shell.appwidget */ typedef enum widget_system_event { WIDGET_SYS_EVENT_FONT_CHANGED = 0x01, /**< System font is changed. */ @@ -209,7 +207,6 @@ typedef void (*widget_flush_cb)(void *snapshot_window, const char *id, int statu * @param[in] gbar 1 for Glance Bar or 0 * @privlevel public * @privilege %http://tizen.org/privilege/widget.provider - * @feature http://tizen.org/feature/shell.appwidget * @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. @@ -227,9 +224,7 @@ extern widget_desc_h widget_desc_open(const char *id, int gbar); * @param[in] handle Handle which is created by widget_desc_open() function * @privlevel public * @privilege %http://tizen.org/privilege/widget.provider - * @feature http://tizen.org/feature/shell.appwidget - * @return #WIDGET_ERROR_NONE on success, - * otherwise an error code (see #WIDGET_ERROR_XXX) on failure + * @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 @@ -247,8 +242,7 @@ extern int widget_desc_close(widget_desc_h handle); * @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 #WIDGET_ERROR_NONE on success, - * otherwise an error code (see #WIDGET_ERROR_XXX) on failure + * @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() @@ -266,8 +260,7 @@ extern int widget_desc_set_category(widget_desc_h handle, const char *id, const * @param[in] id Id string of target object * @param[in] w Width in pixel * @param[in] h Height in pixel - * @return #WIDGET_ERROR_NONE on success, - * otherwise an error code (see #WIDGET_ERROR_XXX) on failure + * @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 @@ -284,8 +277,7 @@ extern int widget_desc_set_size(widget_desc_h handle, const char *id, int w, int * @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 #WIDGET_ERROR_NONE on success, - * otherwise an error code (see #WIDGET_ERROR_XXX) on failure + * @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 @@ -323,8 +315,7 @@ extern int widget_desc_add_block(widget_desc_h handle, const char *id, const cha * @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 #WIDGET_ERROR_NONE on success, - * otherwise an error code (see #WIDGET_ERROR_XXX) on failure + * @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. @@ -355,8 +346,7 @@ extern const int WIDGET_USE_NET; * @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 #WIDGET_ERROR_NONE on success, - * otherwise an error code (see #WIDGET_ERROR_XXX) on failure + * @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) @@ -378,7 +368,6 @@ extern int widget_content_is_updated(const char *id, int gbar); * @param[in] data User data for event handling callback * @privlevel public * @privilege %http://tizen.org/privilege/widget.provider - * @feature http://tizen.org/feature/shell.appwidget * @return Buffer handle * @retval @c NULL Failed to acquire buffer, get_last_result() will returns reason of failure. * @retval handler Handle object @@ -399,8 +388,7 @@ extern widget_buffer_h widget_create_buffer(const char *id, int gbar, int auto_a * @param[in] pixels Pixel size in byte * @privlevel public * @privilege %http://tizen.org/privilege/widget.provider - * @feature http://tizen.org/feature/shell.appwidget - * @return int status + * @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 @@ -435,8 +423,7 @@ extern unsigned int widget_viewer_get_resource_id(widget_buffer_h handle, int id * @param[in] idx Index of a buffer, #c WIDGET_PRIMARY_BUFFER is used for accessing the primary buffer * @privlevel public * @privilege %http://tizen.org/privilege/widget.provider - * @feature http://tizen.org/feature/shell.appwidget - * @return int status + * @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 @@ -452,8 +439,7 @@ extern int widget_viewer_release_buffer(widget_buffer_h handle, int idx); * @param[in] handle buffer handle * @privlevel public * @privilege %http://tizen.org/privilege/widget.provider - * @feature http://tizen.org/feature/shell.appwidget - * @return int status + * @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 @@ -470,8 +456,6 @@ extern int widget_destroy_buffer(widget_buffer_h handle); * @param[in] handle Buffer handle * @privlevel public * @privilege %http://tizen.org/privilege/widget.provider - * @feature http://tizen.org/feature/shell.appwidget - * @return void* address of the render buffer * @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() @@ -485,9 +469,7 @@ extern void *widget_ref_buffer(widget_buffer_h handle); * @param[in] buffer Address of render buffer * @privlevel public * @privilege %http://tizen.org/privilege/widget.provider - * @feature http://tizen.org/feature/shell.appwidget - * @return #WIDGET_ERROR_NONE on success, - * otherwise an error code (see #WIDGET_ERROR_XXX) on failure + * @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 @@ -505,9 +487,7 @@ extern int widget_unref_buffer(void *buffer); * @param[in] handle Buffer handle * @privlevel public * @privilege %http://tizen.org/privilege/widget.provider - * @feature http://tizen.org/feature/shell.appwidget - * @return #WIDGET_ERROR_NONE on success, - * otherwise an error code (see #WIDGET_ERROR_XXX) on failure + * @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 @@ -536,9 +516,7 @@ extern int widget_support_hw_buffer(widget_buffer_h handle); * @param[in] handle Buffer handle * @privlevel public * @privilege %http://tizen.org/privilege/widget.provider - * @feature http://tizen.org/feature/shell.appwidget - * @return #WIDGET_ERROR_NONE on success, - * otherwise an error code (see #WIDGET_ERROR_XXX) on failure + * @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 @@ -557,9 +535,7 @@ extern int widget_create_hw_buffer(widget_buffer_h handle); * @param[in] handle Buffer handle * @privlevel public * @privilege %http://tizen.org/privilege/widget.provider - * @feature http://tizen.org/feature/shell.appwidget - * @return #WIDGET_ERROR_NONE on success, - * otherwise an error code (see #WIDGET_ERROR_XXX) on failure + * @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 @@ -576,8 +552,6 @@ extern int widget_destroy_hw_buffer(widget_buffer_h handle); * @param[in] handle Buffer handle * @privlevel public * @privilege %http://tizen.org/privilege/widget.provider - * @feature http://tizen.org/feature/shell.appwidget - * @return void* type * @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() @@ -592,8 +566,8 @@ extern void *widget_buffer_hw_buffer(widget_buffer_h handle); * @param[in] handle Buffer handle * @return int stride size * @retval positive_value length of stride - * @return #WIDGET_ERROR_INVALID_PARAMETER Invalid parameter - * @return #WIDGET_ERROR_FAULT Unrecoverable error + * @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); @@ -606,9 +580,7 @@ extern int widget_buffer_stride(widget_buffer_h handle); * @param[in] handle Buffer handle * @privlevel public * @privilege %http://tizen.org/privilege/widget.provider - * @feature http://tizen.org/feature/shell.appwidget - * @return #WIDGET_ERROR_NONE on success, - * otherwise an error code (see #WIDGET_ERROR_XXX) on failure + * @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 @@ -625,8 +597,7 @@ extern int widget_buffer_pre_render(widget_buffer_h handle); * @param[in] handle Buffer handle * @privlevel public * @privilege %http://tizen.org/privilege/widget.provider - * @feature http://tizen.org/feature/shell.appwidget - * @return If succes returns 0 or return less than 0 + * @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 @@ -646,9 +617,7 @@ extern int widget_buffer_post_render(widget_buffer_h handle); * @param[in] reason #WIDGET_ERROR_NONE(0) * @privlevel public * @privilege %http://tizen.org/privilege/widget.provider - * @feature http://tizen.org/feature/shell.appwidget - * @return #WIDGET_ERROR_NONE on success, - * otherwise an error code (see #WIDGET_ERROR_XXX) on failure + * @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 @@ -668,7 +637,6 @@ extern int widget_request_close_glance_bar(const char *widgetid, const char *id, * @since_tizen 2.3.1 * @param[in] id * @param[in] size_type - * @return void* window * @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() @@ -683,7 +651,7 @@ extern void *widget_snapshot_window_add(const char *id, int size_type); * @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 int status + * @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 @@ -699,8 +667,7 @@ extern int widget_snapshot_window_flush(void *snapshot_win, double timeout, widg * @param[in] idx Index of a buffer * @privlevel public * @privilege %http://tizen.org/privilege/widget.provider - * @feature http://tizen.org/feature/shell.appwidget - * @return int status + * @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); @@ -714,16 +681,13 @@ extern int widget_send_updated_by_idx(widget_buffer_h handle, int idx); * provider will send those information to the viewer when the * content is updated. * @since_tizen 2.3.1 - * @privlevel N/P - * @feature http://tizen.org/feature/shell.appwidget - * @remarks This function only works with the buffer type inhouse provider. + * * @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 #WIDGET_ERROR_NONE on success, - * otherwise an error code (see #WIDGET_ERROR_XXX) on failure + * @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 @@ -744,9 +708,7 @@ extern int widget_set_extra_info(const char *id, const char *content, const char * @param[in] id Instance Id which is passed to you via the first parameter of every widget_XXXX interface functions * @privlevel public * @privilege %http://tizen.org/privilege/widget.provider - * @feature http://tizen.org/feature/shell.appwidget - * @return #WIDGET_ERROR_NONE on success, - * otherwise an error code (see #WIDGET_ERROR_XXX) on failure + * @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 @@ -769,9 +731,7 @@ extern int widget_freeze_scroller(const char *widgetid, const char *id); * @param[in] id Instance Id which is passed to you via the first parameter of every widget_XXXX interface functions * @privlevel public * @privilege %http://tizen.org/privilege/widget.provider - * @feature http://tizen.org/feature/shell.appwidget - * @return #WIDGET_ERROR_NONE on success, - * otherwise an error code (see #WIDGET_ERROR_XXX) on failure + * @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 -- 2.7.4 From 141521c17442de9c44330d5008d053047cebc5a9 Mon Sep 17 00:00:00 2001 From: Kyuho Jo Date: Mon, 20 Apr 2015 22:19:13 +0900 Subject: [PATCH 08/16] Fix PREVENT issues Change-Id: I51d9bb197693921957facfea885a40114a596aa5 Signed-off-by: Kyuho Jo --- src/snapshot_window.c | 4 ++-- src/virtual_window.c | 21 +++++++++++-------- src/virtual_window_wayland.c | 4 ++-- src/widget.c | 48 ++++++++++++++++++++++---------------------- 4 files changed, 41 insertions(+), 36 deletions(-) diff --git a/src/snapshot_window.c b/src/snapshot_window.c index 648d382..3e4a1db 100644 --- a/src/snapshot_window.c +++ b/src/snapshot_window.c @@ -401,13 +401,13 @@ PUBLIC void *widget_snapshot_window_add(const char *id, int size_type) info = malloc(sizeof(*info)); if (!info) { - ErrPrint("Heap: %s\n", strerror(errno)); + ErrPrint("Heap: %d\n", errno); return NULL; } info->id = strdup(id); if (!info->id) { - ErrPrint("Heap: %s\n", strerror(errno)); + ErrPrint("Heap: %d\n", errno); free(info); return NULL; } diff --git a/src/virtual_window.c b/src/virtual_window.c index 37a7280..6b6e352 100644 --- a/src/virtual_window.c +++ b/src/virtual_window.c @@ -119,7 +119,7 @@ static int event_handler_cb(widget_buffer_h handler, struct widget_buffer_event_ struct timeval tv; if (gettimeofday(&tv, NULL) < 0) { - ErrPrint("gettimeofday: %s\n", strerror(errno)); + ErrPrint("gettimeofday: %d\n", errno); } else { timestamp = (double)tv.tv_sec + (double)tv.tv_usec / 1000000.0f; timestamp -= event_info->timestamp; @@ -594,7 +594,7 @@ static Ecore_X_Pixmap alloc_pixmap_cb(void *data, Ecore_X_Window parent, int w, 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: %s\n", strerror(errno)); + ErrPrint("Out of memory: %d\n", errno); return 0u; } @@ -866,11 +866,16 @@ static void post_render_cb(void *data, Evas *e, void *event_info) static void pre_destroy_cb(const char *id, void *data) { vwin_info_t info = data; + char *path = NULL; - 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; + 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; + } } DbgPrint("Pre destroy event callback is called [%s]\n", id); @@ -947,13 +952,13 @@ PUBLIC Evas *widget_get_evas(const char *id) info = calloc(1, sizeof(*info)); if (!info) { - ErrPrint("Heap: %s\n", strerror(errno)); + ErrPrint("Heap: %d\n", errno); return NULL; } info->id = strdup(id); if (!info->id) { - ErrPrint("Heap: %s\n", strerror(errno)); + ErrPrint("Heap: %d\n", errno); free(info); return NULL; } diff --git a/src/virtual_window_wayland.c b/src/virtual_window_wayland.c index 4ae8122..1fab6d3 100644 --- a/src/virtual_window_wayland.c +++ b/src/virtual_window_wayland.c @@ -787,13 +787,13 @@ PUBLIC Evas *widget_get_evas(const char *id) info = calloc(1, sizeof(*info)); if (!info) { - ErrPrint("Heap: %s\n", strerror(errno)); + ErrPrint("Heap: %d\n", errno); return NULL; } info->id = strdup(id); if (!info->id) { - ErrPrint("Heap: %s\n", strerror(errno)); + ErrPrint("Heap: %d\n", errno); free(info); return NULL; } diff --git a/src/widget.c b/src/widget.c index 9948de9..232232b 100644 --- a/src/widget.c +++ b/src/widget.c @@ -311,7 +311,7 @@ PUBLIC struct widget_desc *widget_desc_open(const char *filename, int for_pd) handle = calloc(1, sizeof(*handle)); if (!handle) { - ErrPrint("Error: %s\n", strerror(errno)); + ErrPrint("Error: %d\n", errno); return NULL; } @@ -320,7 +320,7 @@ PUBLIC struct widget_desc *widget_desc_open(const char *filename, int for_pd) len = strlen(filename) + strlen(".desc") + 1; new_fname = malloc(len); if (!new_fname) { - ErrPrint("Error: %s\n", strerror(errno)); + ErrPrint("Error: %d\n", errno); free(handle); return NULL; } @@ -328,7 +328,7 @@ PUBLIC struct widget_desc *widget_desc_open(const char *filename, int for_pd) } else { new_fname = strdup(filename); if (!new_fname) { - ErrPrint("Error: %s\n", strerror(errno)); + ErrPrint("Error: %d\n", errno); free(handle); return NULL; } @@ -341,7 +341,7 @@ PUBLIC struct widget_desc *widget_desc_open(const char *filename, int for_pd) handle->fp = fopen(new_fname, "at"); free(new_fname); if (!handle->fp) { - ErrPrint("Failed to open a file: %s\n", strerror(errno)); + ErrPrint("Failed to open a file: %d\n", errno); free(handle); return NULL; } @@ -398,7 +398,7 @@ PUBLIC int widget_desc_close(struct widget_desc *handle) } if (fclose(handle->fp) != 0) { - ErrPrint("fclose: %s\n", strerror(errno)); + ErrPrint("fclose: %d\n", errno); } free(handle); return WIDGET_ERROR_NONE; @@ -527,7 +527,7 @@ PUBLIC int widget_desc_set_id(struct widget_desc *handle, int idx, const char *i block->target_id = strdup(id); if (!block->target_id) { - ErrPrint("Heap: %s\n", strerror(errno)); + ErrPrint("Heap: %d\n", errno); return WIDGET_ERROR_OUT_OF_MEMORY; } @@ -559,20 +559,20 @@ PUBLIC int widget_desc_add_block(struct widget_desc *handle, const char *id, con block = calloc(1, sizeof(*block)); if (!block) { - ErrPrint("Heap: %s\n", strerror(errno)); + ErrPrint("Heap: %d\n", errno); return WIDGET_ERROR_OUT_OF_MEMORY; } block->type = strdup(type); if (!block->type) { - ErrPrint("Heap: %s\n", strerror(errno)); + ErrPrint("Heap: %d\n", errno); free(block); return WIDGET_ERROR_OUT_OF_MEMORY; } block->part = strdup(part); if (!block->part) { - ErrPrint("Heap: %s\n", strerror(errno)); + ErrPrint("Heap: %d\n", errno); free(block->type); free(block); return WIDGET_ERROR_OUT_OF_MEMORY; @@ -580,7 +580,7 @@ PUBLIC int widget_desc_add_block(struct widget_desc *handle, const char *id, con block->data = strdup(data); if (!block->data) { - ErrPrint("Heap: %s\n", strerror(errno)); + ErrPrint("Heap: %d\n", errno); free(block->type); free(block->part); free(block); @@ -590,7 +590,7 @@ PUBLIC int widget_desc_add_block(struct widget_desc *handle, const char *id, con if (option) { block->option = strdup(option); if (!block->option) { - ErrPrint("Heap: %s\n", strerror(errno)); + ErrPrint("Heap: %d\n", errno); free(block->data); free(block->type); free(block->part); @@ -602,7 +602,7 @@ PUBLIC int widget_desc_add_block(struct widget_desc *handle, const char *id, con if (id) { block->id = strdup(id); if (!block->id) { - ErrPrint("Heap: %s\n", strerror(errno)); + ErrPrint("Heap: %d\n", errno); free(block->option); free(block->data); free(block->type); @@ -686,7 +686,7 @@ PUBLIC widget_buffer_h widget_create_buffer(const char *filename, int is_gbar, i user_data = calloc(1, sizeof(*user_data)); if (!user_data) { - ErrPrint("Heap: %s\n", strerror(errno)); + ErrPrint("Heap: %d\n", errno); return NULL; } @@ -696,7 +696,7 @@ PUBLIC widget_buffer_h widget_create_buffer(const char *filename, int is_gbar, i uri = id_to_uri(filename); if (!uri) { - ErrPrint("Heap: %s\n", strerror(errno)); + ErrPrint("Heap: %d\n", errno); free(user_data); return NULL; } @@ -742,7 +742,7 @@ PUBLIC int widget_request_update(const char *filename) uri = id_to_uri(filename); if (!uri) { - ErrPrint("Heap: %s\n", strerror(errno)); + ErrPrint("Heap: %d\n", errno); return WIDGET_ERROR_OUT_OF_MEMORY; } @@ -1222,13 +1222,13 @@ PUBLIC int widget_request_close_glance_bar(const char *pkgname, const char *id, if (strncmp(id, FILE_SCHEMA, schema_len)) { uri = id_to_uri(id); if (!uri) { - ErrPrint("Heap: %s\n", strerror(errno)); + ErrPrint("Heap: %d\n", errno); return WIDGET_ERROR_OUT_OF_MEMORY; } } else { uri = strdup(id); if (!uri) { - ErrPrint("Heap: %s\n", strerror(errno)); + ErrPrint("Heap: %d\n", errno); return WIDGET_ERROR_OUT_OF_MEMORY; } } @@ -1249,7 +1249,7 @@ PUBLIC int widget_freeze_scroller(const char *pkgname, const char *id) uri = id_to_uri(id); if (!uri) { - ErrPrint("Heap: %s\n", strerror(errno)); + ErrPrint("Heap: %d\n", errno); return WIDGET_ERROR_OUT_OF_MEMORY; } @@ -1269,7 +1269,7 @@ PUBLIC int widget_thaw_scroller(const char *pkgname, const char *id) uri = id_to_uri(id); if (!uri) { - ErrPrint("Heap: %s\n", strerror(errno)); + ErrPrint("Heap: %d\n", errno); return WIDGET_ERROR_OUT_OF_MEMORY; } @@ -1286,7 +1286,7 @@ PUBLIC int widget_set_extra_info(const char *id, const char *content, const char uri = id_to_uri(id); if (!uri) { - ErrPrint("Heap: %s\n", strerror(errno)); + ErrPrint("Heap: %d\n", errno); return WIDGET_ERROR_OUT_OF_MEMORY; } @@ -1328,7 +1328,7 @@ PUBLIC int widget_set_extra_info(const char *id, const char *content, const char user_data->content = _content; } else { - ErrPrint("Heap: %s\n", strerror(errno)); + ErrPrint("Heap: %d\n", errno); } } @@ -1343,7 +1343,7 @@ PUBLIC int widget_set_extra_info(const char *id, const char *content, const char user_data->title = _title; } else { - ErrPrint("Heap: %s\n", strerror(errno)); + ErrPrint("Heap: %d\n", errno); } } @@ -1358,7 +1358,7 @@ PUBLIC int widget_set_extra_info(const char *id, const char *content, const char user_data->icon = _icon; } else { - ErrPrint("Heap: %s\n", strerror(errno)); + ErrPrint("Heap: %d\n", errno); } } @@ -1373,7 +1373,7 @@ PUBLIC int widget_set_extra_info(const char *id, const char *content, const char user_data->name = _name; } else { - ErrPrint("Heap: %s\n", strerror(errno)); + ErrPrint("Heap: %d\n", errno); } } -- 2.7.4 From 96b6a4a6f40a65c20c9213b98cf33f581e38ceb4 Mon Sep 17 00:00:00 2001 From: Kyuho Jo Date: Tue, 21 Apr 2015 09:29:47 +0900 Subject: [PATCH 09/16] Fix build error caused by using ELM_WIN_DYNAMIC_BOX Change-Id: I259c464ac08f39e4a99f23ae4cf9e11b8691b1ce Signed-off-by: Kyuho Jo --- packaging/libwidget.spec | 2 +- src/snapshot_window.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packaging/libwidget.spec b/packaging/libwidget.spec index a2c225a..ade1ed6 100755 --- a/packaging/libwidget.spec +++ b/packaging/libwidget.spec @@ -2,7 +2,7 @@ Name: libwidget Summary: widget development library -Version: 1.1.1 +Version: 1.1.2 Release: 1 Group: HomeTF/widget License: Flora diff --git a/src/snapshot_window.c b/src/snapshot_window.c index 3e4a1db..fd96018 100644 --- a/src/snapshot_window.c +++ b/src/snapshot_window.c @@ -432,7 +432,7 @@ PUBLIC void *widget_snapshot_window_add(const char *id, int size_type) return NULL; } - snapshot_win = elm_win_add(parent, "widget,Snapshot", ELM_WIN_DYNAMIC_BOX); + snapshot_win = elm_win_add(parent, "widget,Snapshot", ELM_WIN_TIZEN_WIDGET); evas_object_del(parent); if (!snapshot_win) { destroy_virtual_canvas(e); -- 2.7.4 From f7eb4d709a898ac8aae9b52950d942fd5c9884ac Mon Sep 17 00:00:00 2001 From: Sung-jae Park Date: Tue, 21 Apr 2015 22:49:43 +0900 Subject: [PATCH 10/16] Apply orientation. Rotated input event processing. [model] Redwood,Kiran,B3(Wearable) [binary_type] AP [customer] Docomo/Orange/ATT/Open [issue#] N/A [problem] [cause] [solution] [team] HomeTF [request] [horizontal_expansion] Change-Id: I4d50f95ec9472642b8e1b790094099ddf0bda2ad --- include/widget_internal.h | 1 + src/virtual_window.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++ src/widget.c | 71 ++++++++++++++++++++++++++------------------- 3 files changed, 115 insertions(+), 30 deletions(-) diff --git a/include/widget_internal.h b/include/widget_internal.h index a498e70..77a74f8 100755 --- a/include/widget_internal.h +++ b/include/widget_internal.h @@ -182,6 +182,7 @@ typedef enum widget_system_event { 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; /** diff --git a/src/virtual_window.c b/src/virtual_window.c index 6b6e352..bc98aef 100644 --- a/src/virtual_window.c +++ b/src/virtual_window.c @@ -23,6 +23,7 @@ #include #include #include +#include #include @@ -81,6 +82,8 @@ typedef struct virtual_window_info { int resource_cnt; int pressed; + + int orientation; } *vwin_info_t; static inline Evas_Object *get_highlighted_object(Evas_Object *obj) @@ -94,6 +97,49 @@ static inline Evas_Object *get_highlighted_object(Evas_Object *obj) 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 @@ -183,6 +229,8 @@ static int event_handler_cb(widget_buffer_h handler, struct widget_buffer_event_ evas_event_feed_mouse_out(info->e, timestamp, NULL); break; case WIDGET_BUFFER_EVENT_DOWN: + apply_orientation(info->degree, &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); @@ -210,6 +258,7 @@ static int event_handler_cb(widget_buffer_h handler, struct widget_buffer_event_ 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->degree, &event_info->info.pointer.x, &event_info->info.pointer.y); /** * @note * Calculate the event occurred X & Y on the buffer @@ -217,6 +266,7 @@ static int event_handler_cb(widget_buffer_h handler, struct widget_buffer_event_ 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->degree, &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; @@ -863,6 +913,26 @@ static void post_render_cb(void *data, Evas *e, void *event_info) } } +static void pre_orientation_cb(const char *id, void *data) +{ + vwin_info_t info = data; + char *path = NULL; + + /* Try provider_app first */ + if (id) { + 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; + } + + DbgPrint("Pre orientation event callback is called [%s]\n", id); + info->orientation = widget_get_orientation(path); + } +} + static void pre_destroy_cb(const char *id, void *data) { vwin_info_t info = data; @@ -1042,6 +1112,9 @@ PUBLIC Evas *widget_get_evas(const char *id) 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); + + info->orientation = widget_get_orientation(info->id); return info->e; } diff --git a/src/widget.c b/src/widget.c index 232232b..bb36c43 100644 --- a/src/widget.c +++ b/src/widget.c @@ -94,6 +94,9 @@ static struct info { 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); enum load_type { LOAD_TYPE_UNKNOWN = -1, @@ -108,8 +111,6 @@ static struct info { struct _app { int (*send)(widget_buffer_h handle, int idx, int x, int y, int w, int h, int gbar); - 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); } app; } binder; } s_info = { @@ -117,6 +118,9 @@ static struct info { .request_update_by_id = NULL, .trigger_update_monitor = NULL, .update_extra_info = NULL, + .add_pre_callback = NULL, + .del_pre_callback = NULL, + .orientation = NULL, .type = LOAD_TYPE_UNKNOWN, /* Not initialized */ .binder = { .slave = { @@ -124,21 +128,22 @@ static struct info { }, .app = { .send = NULL, - .add_pre_callback = NULL, - .del_pre_callback = NULL, }, }, }; #define FUNC_PREFIX "widget_" -#define FUNC_WIDGET_SEND_UPDATED FUNC_PREFIX "send_buffer_updated" -#define FUNC_WIDGET_PROVIDER_APP_UPDATED FUNC_PREFIX "provider_app_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_ADD_PRE_CALLBACK FUNC_PREFIX "provider_app_add_pre_callback" -#define FUNC_WIDGET_DEL_PRE_CALLBACK FUNC_PREFIX "provider_app_del_pre_callback" +#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_update_function(void) { @@ -156,34 +161,40 @@ static inline void load_update_function(void) } } -int widget_add_pre_callback(widget_pre_callback_e type, widget_pre_callback_t cb, void *data) +PUBLIC int widget_get_orientation(const char *id) { - static int loaded = 0; - if (!loaded && !s_info.binder.app.add_pre_callback) { - s_info.binder.app.add_pre_callback = dlsym(RTLD_DEFAULT, FUNC_WIDGET_ADD_PRE_CALLBACK); - loaded = 1; - } - - if (!s_info.binder.app.add_pre_callback) { - return WIDGET_ERROR_NOT_SUPPORTED; + 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.binder.app.add_pre_callback(type, cb, data); + return s_info.orientation(id); } -int widget_del_pre_callback(widget_pre_callback_e type, widget_pre_callback_t cb, void *data) +PUBLIC int widget_add_pre_callback(widget_pre_callback_e type, widget_pre_callback_t cb, void *data) { - static int loaded = 0; - if (!loaded && !s_info.binder.app.del_pre_callback) { - s_info.binder.app.del_pre_callback = dlsym(RTLD_DEFAULT, FUNC_WIDGET_DEL_PRE_CALLBACK); - loaded = 1; + 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; + } } - if (!s_info.binder.app.del_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.binder.app.del_pre_callback(type, cb, data); + return s_info.del_pre_callback(type, cb, data); } static int 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) -- 2.7.4 From 098db74ed28b2fe9d962c552a529cba63e899d08 Mon Sep 17 00:00:00 2001 From: Sung-jae Park Date: Wed, 22 Apr 2015 14:23:57 +0900 Subject: [PATCH 11/16] Separate binder code from widget.c. (Check the return value.) [model] Redwood,Kiran,B3(Wearable) [binary_type] AP [customer] Docomo/Orange/ATT/Open [issue#] N/A [problem] [cause] [solution] [team] HomeTF [request] [horizontal_expansion] Change-Id: I024cb2d8b81f3b8e59e2fe920414a18b1f399f2a --- CMakeLists.txt | 1 + include/binder.h | 52 +++++ include/util.h | 3 + include/widget_internal.h | 4 + src/binder.c | 536 ++++++++++++++++++++++++++++++++++++++++++++++ src/util.c | 16 ++ src/virtual_window.c | 365 ++++--------------------------- src/widget.c | 258 ++-------------------- 8 files changed, 666 insertions(+), 569 deletions(-) create mode 100644 include/binder.h create mode 100644 src/binder.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 3da12e4..b98db69 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,6 +64,7 @@ SET (BUILD_SOURCE ${BUILD_SOURCE} src/dlist.c src/util.c + src/binder.c src/widget.c src/snapshot_window.c ) diff --git a/include/binder.h b/include/binder.h new file mode 100644 index 0000000..8496778 --- /dev/null +++ b/include/binder.h @@ -0,0 +1,52 @@ +/* + * 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/util.h b/include/util.h index 905974d..c909e4b 100644 --- a/include/util.h +++ b/include/util.h @@ -14,7 +14,10 @@ * 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_internal.h b/include/widget_internal.h index 77a74f8..fd14c0f 100755 --- a/include/widget_internal.h +++ b/include/widget_internal.h @@ -752,6 +752,10 @@ extern int widget_del_pre_callback(widget_pre_callback_e type, widget_pre_callba 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); + +/** * @} */ diff --git a/src/binder.c b/src/binder.c new file mode 100644 index 0000000..09fac0e --- /dev/null +++ b/src/binder.c @@ -0,0 +1,536 @@ +#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/util.c b/src/util.c index 208ee6c..7a0646f 100644 --- a/src/util.c +++ b/src/util.c @@ -55,4 +55,20 @@ double util_timestamp(void) #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 index bc98aef..288ef65 100644 --- a/src/virtual_window.c +++ b/src/virtual_window.c @@ -39,6 +39,7 @@ #include "widget.h" #include "widget_internal.h" #include "debug.h" +#include "binder.h" #define IS_GBAR 1 @@ -47,44 +48,6 @@ #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; - - int orientation; -} *vwin_info_t; static inline Evas_Object *get_highlighted_object(Evas_Object *obj) { @@ -229,7 +192,7 @@ static int event_handler_cb(widget_buffer_h handler, struct widget_buffer_event_ evas_event_feed_mouse_out(info->e, timestamp, NULL); break; case WIDGET_BUFFER_EVENT_DOWN: - apply_orientation(info->degree, &event_info->info.pointer.x, &event_info->info.pointer.y); + apply_orientation(info->orientation, &event_info->info.pointer.x, &event_info->info.pointer.y); if (info->pressed) { ErrPrint("MOUSE UP is not called\n"); @@ -258,7 +221,7 @@ static int event_handler_cb(widget_buffer_h handler, struct widget_buffer_event_ 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->degree, &event_info->info.pointer.x, &event_info->info.pointer.y); + apply_orientation(info->orientation, &event_info->info.pointer.x, &event_info->info.pointer.y); /** * @note * Calculate the event occurred X & Y on the buffer @@ -266,7 +229,7 @@ static int event_handler_cb(widget_buffer_h handler, struct widget_buffer_event_ 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->degree, &event_info->info.pointer.x, &event_info->info.pointer.y); + 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; @@ -606,233 +569,6 @@ static int event_handler_cb(widget_buffer_h handler, struct widget_buffer_event_ 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) -{ - 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); - } -} - static void pre_render_cb(void *data, Evas *e, void *event_info) { vwin_info_t info = data; @@ -913,30 +649,39 @@ static void post_render_cb(void *data, Evas *e, void *event_info) } } -static void pre_orientation_cb(const char *id, void *data) +static int pre_orientation_cb(const char *id, void *data) { vwin_info_t info = data; - char *path = NULL; + const char *path; + int orientation; /* Try provider_app first */ - if (id) { - path = widget_util_uri_to_path(id); + if (!id) { + return WIDGET_ERROR_INVALID_PARAMETER; + } - if (path && strcmp(info->id, path)) { - /* Skip */ - DbgPrint("SKIP: Pre orientation event callback is called [%s], %s\n", id, info->id); - return; - } + 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); - info->orientation = widget_get_orientation(path); + 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 void pre_destroy_cb(const char *id, void *data) +static int pre_destroy_cb(const char *id, void *data) { vwin_info_t info = data; - char *path = NULL; + const char *path = NULL; if (id) { path = widget_util_uri_to_path(id); @@ -944,7 +689,7 @@ static void pre_destroy_cb(const char *id, void *data) if (path && strcmp(info->id, path)) { /* Skip */ DbgPrint("SKIP: Pre destroy event callback is called [%s], %s\n", id, info->id); - return; + return WIDGET_ERROR_INVALID_PARAMETER; } } @@ -954,6 +699,8 @@ static void pre_destroy_cb(const char *id, void *data) 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) @@ -984,8 +731,7 @@ PUBLIC Evas *widget_get_evas(const char *id) #endif /* WIDGET_FEATURE_GBAR_SUPPORTED */ { vwin_info_t info; - Evas_Object *rect; - const char *engine; + int orientation; /** * @TODO @@ -993,28 +739,6 @@ PUBLIC Evas *widget_get_evas(const char *id) * 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; @@ -1043,7 +767,7 @@ PUBLIC Evas *widget_get_evas(const char *id) * 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), + binder_widget_auto_align(), event_handler_cb, info); if (!info->handle) { @@ -1059,25 +783,7 @@ PUBLIC Evas *widget_get_evas(const char *id) 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); - } - } - + 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); @@ -1114,7 +820,12 @@ PUBLIC Evas *widget_get_evas(const char *id) widget_add_pre_callback(WIDGET_PRE_DESTROY_CALLBACK, pre_destroy_cb, info); widget_add_pre_callback(WIDGET_PRE_ORIENTATION_CALLBACK, pre_orientation_cb, info); - info->orientation = widget_get_orientation(info->id); + 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; } diff --git a/src/widget.c b/src/widget.c index bb36c43..2db1ea1 100644 --- a/src/widget.c +++ b/src/widget.c @@ -20,8 +20,8 @@ #include /* strdup */ #include #include /* access */ -#define __USE_GNU -#include + +#include /* binder.h */ #include #include @@ -29,20 +29,19 @@ #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"))) -#define FILE_SCHEMA "file://" - /** * @note * This value is configurable value. @@ -86,161 +85,6 @@ struct widget_buffer_data { Ecore_Timer *frame_wait_timer; }; -/** - * @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); - - 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, - .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_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); -} - -static int 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; -} - -static char *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; -} - static inline int event_handler_wrapper(widget_buffer_h buffer, widget_buffer_event_data_t event_info, void *data) { const char *pkgname; @@ -705,24 +549,14 @@ PUBLIC widget_buffer_h widget_create_buffer(const char *filename, int is_gbar, i user_data->handler = handler ? handler : default_event_handler; user_data->cbdata = data; - uri = id_to_uri(filename); + uri = util_id_to_uri(filename); if (!uri) { ErrPrint("Heap: %d\n", errno); free(user_data); return NULL; } - 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"); - free(user_data); - free(uri); - return NULL; - } - } - - pkgname = s_info.find_pkgname(uri); + pkgname = binder_widget_find_pkgname(uri); if (!pkgname) { ErrPrint("Invalid Request\n"); free(user_data); @@ -741,36 +575,6 @@ PUBLIC widget_buffer_h widget_create_buffer(const char *filename, int is_gbar, i return handle; } -PUBLIC int widget_request_update(const char *filename) -{ - char *uri; - int ret; - - if (!filename) { - ErrPrint("Invalid argument\n"); - return WIDGET_ERROR_INVALID_PARAMETER; - } - - uri = 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; -} - PUBLIC unsigned int widget_viewer_get_resource_id(widget_buffer_h handle, int idx) { int ret; @@ -923,7 +727,7 @@ PUBLIC int widget_viewer_sync_buffer(widget_buffer_h handle) * manipulate the damaged region, so send update event only for the damaged region. * to make more efficient updates */ - ret = send_updated(pkgname, id, handle, WIDGET_PRIMARY_BUFFER, 0, 0, w, h, user_data->is_gbar, NULL); + 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); } @@ -963,7 +767,7 @@ PUBLIC int widget_send_updated_by_idx(widget_buffer_h handle, int idx) ErrPrint("Failed to get size (%s)\n", id); } - ret = send_updated(pkgname, id, handle, idx, 0, 0, w, h, user_data->is_gbar, NULL); + 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); } @@ -1103,7 +907,7 @@ static Eina_Bool frame_wait_cb(void *data) * manipulate the damaged region, so send update event only for the damaged region. * to make more efficient updates */ - ret = send_updated(pkgname, id, handle, WIDGET_PRIMARY_BUFFER, 0, 0, w, h, user_data->is_gbar, NULL); + 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); } @@ -1173,7 +977,7 @@ PUBLIC int widget_buffer_post_render(widget_buffer_h handle) * manipulate the damaged region, so send update event only for the damaged region. * to make more efficient updates */ - ret = send_updated(pkgname, id, handle, WIDGET_PRIMARY_BUFFER, 0, 0, w, h, user_data->is_gbar, NULL); + 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); } @@ -1206,19 +1010,6 @@ PUBLIC int widget_buffer_stride(widget_buffer_h handle) return widget_provider_buffer_stride(handle); } -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); -} - PUBLIC int widget_request_close_glance_bar(const char *pkgname, const char *id, int reason) { char *uri; @@ -1231,7 +1022,7 @@ PUBLIC int widget_request_close_glance_bar(const char *pkgname, const char *id, } if (strncmp(id, FILE_SCHEMA, schema_len)) { - uri = id_to_uri(id); + uri = util_id_to_uri(id); if (!uri) { ErrPrint("Heap: %d\n", errno); return WIDGET_ERROR_OUT_OF_MEMORY; @@ -1258,7 +1049,7 @@ PUBLIC int widget_freeze_scroller(const char *pkgname, const char *id) return WIDGET_ERROR_INVALID_PARAMETER; } - uri = id_to_uri(id); + uri = util_id_to_uri(id); if (!uri) { ErrPrint("Heap: %d\n", errno); return WIDGET_ERROR_OUT_OF_MEMORY; @@ -1278,7 +1069,7 @@ PUBLIC int widget_thaw_scroller(const char *pkgname, const char *id) return WIDGET_ERROR_INVALID_PARAMETER; } - uri = id_to_uri(id); + uri = util_id_to_uri(id); if (!uri) { ErrPrint("Heap: %d\n", errno); return WIDGET_ERROR_OUT_OF_MEMORY; @@ -1295,22 +1086,13 @@ PUBLIC int widget_set_extra_info(const char *id, const char *content, const char const char *pkgname; char *uri; - uri = id_to_uri(id); + uri = util_id_to_uri(id); if (!uri) { ErrPrint("Heap: %d\n", errno); return WIDGET_ERROR_OUT_OF_MEMORY; } - 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"); - free(uri); - return WIDGET_ERROR_FAULT; - } - } - - pkgname = s_info.find_pkgname(uri); + pkgname = binder_widget_find_pkgname(uri); if (!pkgname) { ErrPrint("Failed to find a package (%s)\n", uri); free(uri); @@ -1397,15 +1179,7 @@ PUBLIC int widget_set_extra_info(const char *id, const char *content, const char } free(uri); - 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); + return binder_widget_update_extra_info(id, content, title, icon, name); } /* End of a file */ -- 2.7.4 From 6b8ad594a30eb9929681855dc40f6978918d0e51 Mon Sep 17 00:00:00 2001 From: Kyuho Jo Date: Fri, 1 May 2015 12:05:34 +0900 Subject: [PATCH 12/16] Give detail license information Change-Id: Ia60229ea0cb293eebf7daa4988e8cb0421b1f4af Signed-off-by: Kyuho Jo --- packaging/libwidget.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100755 => 100644 packaging/libwidget.spec diff --git a/packaging/libwidget.spec b/packaging/libwidget.spec old mode 100755 new mode 100644 index ade1ed6..5f10294 --- a/packaging/libwidget.spec +++ b/packaging/libwidget.spec @@ -5,7 +5,7 @@ Summary: widget development library Version: 1.1.2 Release: 1 Group: HomeTF/widget -License: Flora +License: Flora License, Version 1.1 Source0: %{name}-%{version}.tar.gz Source1001: %{name}.manifest BuildRequires: cmake, gettext-tools, coreutils -- 2.7.4 From 743d8913d8e359240faccc57964e3176a0016609 Mon Sep 17 00:00:00 2001 From: Sung-jae Park Date: Wed, 6 May 2015 10:42:07 +0900 Subject: [PATCH 13/16] Sync with tizen_2.4 Licence [model] Redwood,Kiran,B3(Wearable) [binary_type] AP [customer] Docomo/Orange/ATT/Open [issue#] N/A [problem] [cause] [solution] [team] HomeTF [request] [horizontal_expansion] Change-Id: I1ef6f40d9d19c0aaebe2a9b5459243cd477b7cbd --- doc/widget_doc.h | 2 +- packaging/libwidget.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/widget_doc.h b/doc/widget_doc.h index a778b69..a38b41a 100644 --- a/doc/widget_doc.h +++ b/doc/widget_doc.h @@ -72,7 +72,7 @@ if (!parent) { // Error } -win = elm_win_add(parent, "widget Window", ELM_WIN_DYNAMIC_BOX); +win = elm_win_add(parent, "widget Window", ELM_WIN_TIZEN_WIDGET); evas_object_del(parent); if (!win) { // Error diff --git a/packaging/libwidget.spec b/packaging/libwidget.spec index 5f10294..58be75e 100644 --- a/packaging/libwidget.spec +++ b/packaging/libwidget.spec @@ -2,7 +2,7 @@ Name: libwidget Summary: widget development library -Version: 1.1.2 +Version: 1.1.3 Release: 1 Group: HomeTF/widget License: Flora License, Version 1.1 -- 2.7.4 From 6f9352ab5fb97f3cb7fb8a6f314a841340a9971b Mon Sep 17 00:00:00 2001 From: Sung-jae Park Date: Thu, 7 May 2015 15:04:09 +0900 Subject: [PATCH 14/16] Add input event source information Change-Id: If9510b18c2d06a6ab10e30d15454d48a221ac502 --- src/virtual_window.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/virtual_window.c b/src/virtual_window.c index 288ef65..8766611 100644 --- a/src/virtual_window.c +++ b/src/virtual_window.c @@ -60,12 +60,17 @@ static inline Evas_Object *get_highlighted_object(Evas_Object *obj) return ho; } -static inline void apply_orientation(int degree, int *x, int *y) +static inline void apply_orientation(int degree, int *x, int *y, input_event_source_e source) { int _x; int _y; int _angle; + if (source == INPUT_EVENT_SOURCE_VIEWER) { + /* Already rotated */ + return; + } + switch (degree) { case 0: return; @@ -192,7 +197,7 @@ static int event_handler_cb(widget_buffer_h handler, struct widget_buffer_event_ 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); + apply_orientation(info->orientation, &event_info->info.pointer.x, &event_info->info.pointer.y, event_info->info.pointer.source); if (info->pressed) { ErrPrint("MOUSE UP is not called\n"); @@ -221,7 +226,7 @@ static int event_handler_cb(widget_buffer_h handler, struct widget_buffer_event_ 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); + apply_orientation(info->orientation, &event_info->info.pointer.x, &event_info->info.pointer.y, event_info->info.pointer.source); /** * @note * Calculate the event occurred X & Y on the buffer @@ -229,7 +234,7 @@ static int event_handler_cb(widget_buffer_h handler, struct widget_buffer_event_ 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); + apply_orientation(info->orientation, &event_info->info.pointer.x, &event_info->info.pointer.y, event_info->info.pointer.source); 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; -- 2.7.4 From d01ac6f0c5d6d4a7e2ef4185f96308693edc394b Mon Sep 17 00:00:00 2001 From: Sung-jae Park Date: Thu, 7 May 2015 15:17:14 +0900 Subject: [PATCH 15/16] Fix the rotation logic Rotation should be process in the first quadrant. Change-Id: I3f34bc2058288eae6e85e39c02210224a534064f --- src/virtual_window.c | 42 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/src/virtual_window.c b/src/virtual_window.c index 8766611..664690d 100644 --- a/src/virtual_window.c +++ b/src/virtual_window.c @@ -60,7 +60,7 @@ static inline Evas_Object *get_highlighted_object(Evas_Object *obj) return ho; } -static inline void apply_orientation(int degree, int *x, int *y, input_event_source_e source) +static inline void apply_orientation(int degree, int *x, int *y, int width, int height, input_event_source_e source) { int _x; int _y; @@ -71,35 +71,31 @@ static inline void apply_orientation(int degree, int *x, int *y, input_event_sou return; } + _x = *x; + _y = *y; + switch (degree) { case 0: return; case 90: - _x = *x; - _y = *y; - - *x = -_y; - *y = _x; + *x = _y; + *y = width - _x; return; case 180: - _x = *x; - _y = *y; - _angle = degree; - - *x = -_x; - *y = -_y; + *x = width - _x; + *y = height - _y; return; case 270: - _x = *x; - _y = *y; - _angle = degree; - - *x = _y; - *y = -_x; + *x = height - _y; + *y = _x; return; default: - _x = *x; - _y = *y; + /** + * @FIXME + * This rotation formular is not work correctly. + * The pointer should be rotated by other way. + * This is not what we want. + */ _angle = degree; *x = (double)_x * cos((double)_angle) - (double)_y * sin((double)_angle); @@ -197,7 +193,7 @@ static int event_handler_cb(widget_buffer_h handler, struct widget_buffer_event_ 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, event_info->info.pointer.source); + apply_orientation(info->orientation, &event_info->info.pointer.x, &event_info->info.pointer.y, info->w, info->h, event_info->info.pointer.source); if (info->pressed) { ErrPrint("MOUSE UP is not called\n"); @@ -226,7 +222,7 @@ static int event_handler_cb(widget_buffer_h handler, struct widget_buffer_event_ 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, event_info->info.pointer.source); + apply_orientation(info->orientation, &event_info->info.pointer.x, &event_info->info.pointer.y, info->w, info->h, event_info->info.pointer.source); /** * @note * Calculate the event occurred X & Y on the buffer @@ -234,7 +230,7 @@ static int event_handler_cb(widget_buffer_h handler, struct widget_buffer_event_ 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, event_info->info.pointer.source); + apply_orientation(info->orientation, &event_info->info.pointer.x, &event_info->info.pointer.y, info->w, info->h, event_info->info.pointer.source); 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; -- 2.7.4 From 65dfdebd0137c3361d066686c8986f92aa972bd9 Mon Sep 17 00:00:00 2001 From: Sung-jae Park Date: Thu, 7 May 2015 15:27:50 +0900 Subject: [PATCH 16/16] Protect from invalid vwin_info accessing In some weird cases, if anyone tries to access vwin info object, try to check its state first. if the state indicates unknown, stop and return. [model] Redwood,Kiran,B3(Wearable) [binary_type] AP [customer] Docomo/Orange/ATT/Open [issue#] N/A [problem] [cause] [solution] [team] HomeTF [request] [horizontal_expansion] Change-Id: Ibb212ec67f1c9f189c498679d591a3d1310c78dd Signed-off-by: Sung-jae Park --- include/binder.h | 4 + src/binder.c | 2 + src/virtual_window.c | 22 ++- src/virtual_window_wayland.c | 346 ++++++++++++++----------------------------- 4 files changed, 135 insertions(+), 239 deletions(-) diff --git a/include/binder.h b/include/binder.h index 8496778..6683ca5 100644 --- a/include/binder.h +++ b/include/binder.h @@ -19,6 +19,10 @@ * Abstracted Data Type of Virtual Window */ typedef struct virtual_window_info { + enum _state { + VWIN_INFO_CREATED = 0x00beef00, + VWIN_INFO_DESTROYED = 0x00dead00 + } state; char *id; /**< Identification */ widget_buffer_h handle; /**< Livebox buffer handle */ enum win_type { diff --git a/src/binder.c b/src/binder.c index 09fac0e..d586f9f 100644 --- a/src/binder.c +++ b/src/binder.c @@ -389,6 +389,7 @@ static void free_pixmap_cb(void *data, Ecore_X_Pixmap pixmap) if (info->deleted && info->resource_cnt == 0) { DbgPrint("Destroy buffer handle\n"); + info->state = VWIN_INFO_DESTROYED; widget_destroy_buffer(info->handle); free(info->resource_array); free(info->id); @@ -489,6 +490,7 @@ static void free_fb(void *data, void *ptr) } if (info->deleted) { + info->state = VWIN_INFO_DESTROYED; widget_destroy_buffer(info->handle); free(info->resource_array); free(info->id); diff --git a/src/virtual_window.c b/src/virtual_window.c index 664690d..66f42ed 100644 --- a/src/virtual_window.c +++ b/src/virtual_window.c @@ -45,6 +45,7 @@ #define PUBLIC __attribute__((visibility("default"))) #define WIDGET_WIN_TAG "dynamic,box,win" +#define WIN_INFO_TAG "dynamic,box,info" #define WIDGET_DEFAULT_WIDTH 1 #define WIDGET_DEFAULT_HEIGHT 1 @@ -119,7 +120,7 @@ static int event_handler_cb(widget_buffer_h handler, struct widget_buffer_event_ unsigned int flags = 0; double timestamp; - if (!info->handle) { + if (!info || info->state != VWIN_INFO_CREATED || !info->handle) { /* Just ignore this event */ return 0; } @@ -574,7 +575,7 @@ static void pre_render_cb(void *data, Evas *e, void *event_info) { vwin_info_t info = data; - if (!info->handle) { + if (!info || info->state != VWIN_INFO_CREATED || !info->handle) { return; } @@ -601,7 +602,7 @@ static void post_render_cb(void *data, Evas *e, void *event_info) { vwin_info_t info = data; - if (!info->handle) { + if (!info || info->state != VWIN_INFO_CREATED || !info->handle) { return; } @@ -657,7 +658,7 @@ static int pre_orientation_cb(const char *id, void *data) int orientation; /* Try provider_app first */ - if (!id) { + if (!info || info->state != VWIN_INFO_CREATED || !id) { return WIDGET_ERROR_INVALID_PARAMETER; } @@ -684,6 +685,10 @@ static int pre_destroy_cb(const char *id, void *data) vwin_info_t info = data; const char *path = NULL; + if (!info || info->state != VWIN_INFO_CREATED) { + return WIDGET_ERROR_INVALID_PARAMETER; + } + if (id) { path = widget_util_uri_to_path(id); @@ -708,7 +713,7 @@ static void ecore_evas_free_cb(Ecore_Evas *ee) { vwin_info_t info; - info = ecore_evas_data_get(ee, "dynamic,box,info"); + info = ecore_evas_data_get(ee, WIN_INFO_TAG); if (!info) { DbgPrint("Info is not valid\n"); return; @@ -751,9 +756,12 @@ PUBLIC Evas *widget_get_evas(const char *id) return NULL; } + info->state = VWIN_INFO_CREATED; + info->id = strdup(id); if (!info->id) { ErrPrint("Heap: %d\n", errno); + info->state = VWIN_INFO_DESTROYED; free(info); return NULL; } @@ -773,6 +781,7 @@ PUBLIC Evas *widget_get_evas(const char *id) if (!info->handle) { ErrPrint("Failed to create a widget buffer\n"); + info->state = VWIN_INFO_DESTROYED; free(info->id); free(info); return NULL; @@ -788,12 +797,13 @@ PUBLIC Evas *widget_get_evas(const char *id) if (!info->ee) { ErrPrint("Failed to create ecore_evas (%dx%d)\n", info->w, info->h); widget_destroy_buffer(info->handle); + info->state = VWIN_INFO_DESTROYED; free(info->id); free(info); return NULL; } - ecore_evas_data_set(info->ee, "dynamic,box,info", info); + ecore_evas_data_set(info->ee, WIN_INFO_TAG, info); /** * @note diff --git a/src/virtual_window_wayland.c b/src/virtual_window_wayland.c index 1fab6d3..5bd2c80 100644 --- a/src/virtual_window_wayland.c +++ b/src/virtual_window_wayland.c @@ -24,6 +24,7 @@ #include #include +#include "binder.h" #include "widget.h" #include "debug.h" @@ -36,41 +37,6 @@ #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; @@ -82,6 +48,50 @@ static inline Evas_Object *get_highlighted_object(Evas_Object *obj) return ho; } +static inline void apply_orientation(int degree, int *x, int *y, int width, int height, input_event_source_e source) +{ + int _x; + int _y; + int _angle; + + if (source == INPUT_EVENT_SOURCE_VIEWER) { + /* Already rotated */ + return; + } + + _x = *x; + _y = *y; + + switch (degree) { + case 0: + return; + case 90: + *x = _y; + *y = width - _x; + return; + case 180: + *x = width - _x; + *y = height - _y; + return; + case 270: + *x = height - _y; + *y = _x; + return; + default: + /** + * @FIXME + * This rotation formular is not work correctly. + * The pointer should be rotated by other way. + * This is not what we want. + */ + _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 @@ -171,6 +181,7 @@ static int event_handler_cb(struct widget_buffer *handler, struct widget_buffer_ 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, info->w, info->h, event_info->info.pointer.source); 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); @@ -198,6 +209,7 @@ static int event_handler_cb(struct widget_buffer *handler, struct widget_buffer_ 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, info->w, info->h, event_info->info.pointer.source); /** * @note * Calculate the event occurred X & Y on the buffer @@ -205,6 +217,7 @@ static int event_handler_cb(struct widget_buffer *handler, struct widget_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, info->w, info->h, event_info->info.pointer.source); 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; @@ -459,18 +472,6 @@ static int event_handler_cb(struct widget_buffer *handler, struct widget_buffer_ 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: @@ -480,18 +481,6 @@ static int event_handler_cb(struct widget_buffer *handler, struct widget_buffer_ 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: @@ -501,18 +490,6 @@ static int event_handler_cb(struct widget_buffer *handler, struct widget_buffer_ 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: @@ -522,18 +499,6 @@ static int event_handler_cb(struct widget_buffer *handler, struct widget_buffer_ 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: @@ -544,88 +509,11 @@ static int event_handler_cb(struct widget_buffer *handler, struct widget_buffer_ 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) { + if (!info || info->state != VWIN_INFO_CREATED || !info->handle) { return; } @@ -652,7 +540,7 @@ static void post_render_cb(void *data, Evas *e, void *event_info) { vwin_info_t info = data; - if (!info->handle) { + if (!info || info->state != VWIN_INFO_CREATED || !info->handle) { return; } @@ -674,41 +562,61 @@ static void post_render_cb(void *data, Evas *e, void *event_info) if (info->type == VWIN_GEM) { widget_buffer_post_render(info->handle); } else if (info->type == VWIN_PIXMAP) { - int idx; - unsigned int front_resource_id; + /** + * TODO + */ + ErrPrint("NOT SUPPORTED\n"); + } else if (info->type == VWIN_SW_BUF) { + widget_viewer_sync_buffer(info->handle); + } +} - front_resource_id = ecore_evas_gl_x11_pixmap_get(info->ee); +static int pre_orientation_cb(const char *id, void *data) +{ + vwin_info_t info = data; + const char *path; + int orientation; - 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; - } - } + /* Try provider_app first */ + if (!info || info->state != VWIN_INFO_CREATED || !id) { + return WIDGET_ERROR_INVALID_PARAMETER; + } - 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); + 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 void pre_destroy_cb(const char *id, void *data) { vwin_info_t info = data; + const char *path = NULL; - 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; + if (!info || info->state != VWIN_INFO_CREATED) { + return WIDGET_ERROR_INVALID_PARAMETER; + } + + 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); @@ -717,6 +625,8 @@ static void pre_destroy_cb(const char *id, void *data) 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) @@ -747,8 +657,7 @@ PUBLIC Evas *widget_get_evas(const char *id) #endif /* WIDGET_FEATURE_GBAR_SUPPORTED */ { vwin_info_t info; - Evas_Object *rect; - const char *engine; + int orientation; /** * @TODO @@ -756,30 +665,6 @@ PUBLIC Evas *widget_get_evas(const char *id) * 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; @@ -791,9 +676,12 @@ PUBLIC Evas *widget_get_evas(const char *id) return NULL; } + info->state = VWIN_INFO_CREATED; + info->id = strdup(id); if (!info->id) { ErrPrint("Heap: %d\n", errno); + info->state = VWIN_INFO_DESTROYED; free(info); return NULL; } @@ -808,11 +696,12 @@ PUBLIC Evas *widget_get_evas(const char *id) * 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), + widget_conf_auto_align(), event_handler_cb, info); if (!info->handle) { ErrPrint("Failed to create a widget buffer\n"); + info->state = VWIN_INFO_DESTROYED; free(info->id); free(info); return NULL; @@ -824,28 +713,11 @@ PUBLIC Evas *widget_get_evas(const char *id) 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); - } - } - + 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); + info->state = VWIN_INFO_DESTROYED; free(info->id); free(info); return NULL; @@ -877,6 +749,14 @@ PUBLIC Evas *widget_get_evas(const char *id) 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; } -- 2.7.4