window screen mode support 30/40530/3
authorGwanglim Lee <gl77.lee@samsung.com>
Fri, 5 Jun 2015 03:50:10 +0000 (12:50 +0900)
committerGwanglim Lee <gl77.lee@samsung.com>
Sat, 6 Jun 2015 13:43:49 +0000 (22:43 +0900)
Change-Id: Ib8b0844462768d630313ec1ce6727a64a41fbcc6

AUTHORS
CMakeLists.txt
doc/ui_efl_util_input_doc.h [new file with mode: 0644]
doc/ui_efl_util_screenshot_doc.h [new file with mode: 0644]
include/efl_util.h
packaging/capi-ui-efl-util.spec
src/efl_util.c

diff --git a/AUTHORS b/AUTHORS
index 0e57832..03e695c 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,3 +1,4 @@
 Doyoun Kang <doyoun.kang@samsung.com>
 Gwanglim Lee <gl77.lee@samsung.com>
+Gwan-gyeong Mun <kk.moon@samsung.com>
 Kyuhun Jung <kyuhun.jung@samsung.com>
index 8d7ef86..04a46ac 100644 (file)
@@ -11,11 +11,11 @@ SET(INC_DIR include)
 INCLUDE_DIRECTORIES(${INC_DIR})
 
 # required dependencies
-SET(dependents "dlog elementary capi-base-common")
+SET(dependents "dlog elementary capi-base-common libdrm libtbm")
 
 IF (WITH_X11)
     ADD_DEFINITIONS("-DX11")
-    SET(dependents "${dependents} ecore-x utilX")
+    SET(dependents "${dependents} ecore-x utilX x11 xv libdri2 xext xdamage xtst")
 ENDIF (WITH_X11)
 
 IF (WITH_WAYLAND)
@@ -77,10 +77,10 @@ IF(UNIX)
 
 ADD_CUSTOM_TARGET (distclean @echo cleaning for source distribution)
 ADD_CUSTOM_COMMAND(
-        DEPENDS clean 
+        DEPENDS clean
         COMMENT "distribution clean"
         COMMAND find
-        ARGS    . 
+        ARGS    .
         -not -name config.cmake -and \(
         -name tester.c -or
         -name Testing -or
diff --git a/doc/ui_efl_util_input_doc.h b/doc/ui_efl_util_input_doc.h
new file mode 100644 (file)
index 0000000..fd133ef
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2011-2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __TIZEN_UI_EFL_UTIL_INPUT_DOC_H__
+#define __TIZEN_UI_EFL_UTIL_INPUT_DOC_H__
+
+/**
+ * @ingroup CAPI_EFL_UTIL_MODULE
+ * @defgroup CAPI_EFL_UTIL_INPUT_MODULE EFL UTIL INPUT
+ * @brief Generate touch and key events
+ *
+ * @section CAPI_EFL_UTIL_INPUT_MODULE_HEADER Required Header
+ *   \#include <efl_util.h>
+ *
+ * @section CAPI_EFL_UTIL_INPUT_MODULE_OVERVIEW Overview
+ * The EFL UTIL API provides functions to initialize/deinitialize input devices
+ * and to generation touch / key events.
+ *
+ */
+
+#endif /* __TIZEN_UI_EFL_UTIL_INPUT_DOC_H__ */
diff --git a/doc/ui_efl_util_screenshot_doc.h b/doc/ui_efl_util_screenshot_doc.h
new file mode 100644 (file)
index 0000000..3b51d02
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2011-2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __TIZEN_UI_EFL_UTIL_SCREENSHOT_DOC_H__
+#define __TIZEN_UI_EFL_UTIL_SCREENSHOT_DOC_H__
+
+/**
+ * @ingroup CAPI_EFL_UTIL_MODULE
+ * @defgroup CAPI_EFL_UTIL_SCREENSHOT_MODULE EFL UTIL SCREENSHOT
+ * @brief Provides functions to capture screen shot
+ *
+ * @section CAPI_EFL_UTIL_SCREENSHOT_MODULE_HEADER Required Header
+ *   \#include <efl_util.h>
+ *
+ * @section CAPI_EFL_UTIL_SCREENSHOT_MODULE_OVERVIEW Overview
+ * The EFL UTIL SCREENSHOT API provides functions to capture screenshot.
+ * Client can get screenshot image by efl_util_screenshot_take_tbm_surface
+ * API with tbm_surface handler.
+ *
+ */
+
+#endif /* __TIZEN_UI_EFL_UTIL_SCREENSHOT_DOC_H__ */
index 4934ffa..ee94bf0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2011-2015 Samsung Electronics Co., Ltd All Rights Reserved
  *
  * Licensed under the Apache License, Version 2.0 (the License);
  * you may not use this file except in compliance with the License.
@@ -11,7 +11,7 @@
  * 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. 
+ * limitations under the License.
  */
 
 #ifndef __TIZEN_UI_EFL_UTIL_H__
 
 #include <tizen.h>
 #include <Evas.h>
+#include <tbm_surface.h>
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
+#ifdef __GNUC__
+# if __GNUC__ >= 4
+#  ifndef API
+#   define API __attribute__ ((visibility("default")))
+#  endif
+# endif
+#endif
+
 /**
  * @file efl_util.h
  */
@@ -35,7 +44,7 @@ extern "C" {
 
 /**
  * @brief Enumeration for EFL UTIL ERROR.
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  */
 typedef enum
 {
@@ -43,12 +52,17 @@ typedef enum
    EFL_UTIL_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
    EFL_UTIL_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
    EFL_UTIL_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permisson denied */
-   EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE = TIZEN_ERROR_EFL_UTIL | 0x01 /**< Window type not supported */
+   EFL_UTIL_ERROR_NO_SUCH_DEVICE = TIZEN_ERROR_NO_SUCH_DEVICE, /**< @platform No such device or address (@b Since: 2.4) */
+   EFL_UTIL_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< @platform Function not implemented (@b Since: 2.4) */
+   EFL_UTIL_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< @platform Not supported (@b Since: 2.4) */
+   EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE = TIZEN_ERROR_EFL_UTIL | 0x01, /**< Window type not supported */
+   EFL_UTIL_ERROR_SCREENSHOT_INIT_FAIL = TIZEN_ERROR_EFL_UTIL | 0x02,  /**< @platform Screenshot initialization fail (@b Since: 2.4) */
+   EFL_UTIL_ERROR_SCREENSHOT_EXECUTION_FAIL = TIZEN_ERROR_EFL_UTIL | 0x03  /**< @platform Screenshot execution fail (@b Since: 2.4) */
 } efl_util_error_e;
 
 /**
  * @brief Enumeration of notification window's priority level.
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  */
 typedef enum
 {
@@ -60,11 +74,21 @@ typedef enum
    EFL_UTIL_NOTIFICATION_LEVEL_MEDIUM  = 20, /**< Higher notification level than default. (@b Since: 2.4) */
    EFL_UTIL_NOTIFICATION_LEVEL_HIGH    = 30, /**< Higher notification level than medium. (@b Since: 2.4) */
    EFL_UTIL_NOTIFICATION_LEVEL_TOP     = 40  /**< The highest notification level. (@b Since: 2.4) */
-} efl_util_notification_level_e; 
+} efl_util_notification_level_e;
+
+/**
+ * @brief Enumeration of screen mode.
+ * @since_tizen 2.4
+ */
+typedef enum
+{
+   EFL_UTIL_SCREEN_MODE_DEFAULT, /**< The mode which turns the screen off after a timeout. */
+   EFL_UTIL_SCREEN_MODE_ALWAYS_ON, /**< The mode which keeps the screen turned on. */
+} efl_util_screen_mode_e;
 
 /**
  * @brief Sets the priority level for the specified notification window, asynchronously.
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  * @privlevel public
  * @privilege %http://tizen.org/privilege/window.priority.set
  * @remarks This API can be used for a notification type window only.
@@ -75,12 +99,11 @@ typedef enum
  * @retval #EFL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE Window type not supported
  */
-int efl_util_set_notification_window_level(Evas_Object *window, efl_util_notification_level_e level);
-
+API int efl_util_set_notification_window_level(Evas_Object *window, efl_util_notification_level_e level);
 
 /**
  * @brief Gets the priority level for the specified notification window, asynchronously.
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  *
  * @remarks This API can be used for a notification type window only.
  * @param[in] window The EFL window
@@ -90,14 +113,14 @@ int efl_util_set_notification_window_level(Evas_Object *window, efl_util_notific
  * @retval #EFL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE Window type not supported
  */
-int efl_util_get_notification_window_level(Evas_Object *window, efl_util_notification_level_e *level);
+API int efl_util_get_notification_window_level(Evas_Object *window, efl_util_notification_level_e *level);
 
 /**
  * @brief Called when an error occurs for setting notification window level
- * @since_tizen 2.3
- * @param[in] window     The EFL window
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in] window The EFL window
  * @param[in] error_code The error code (#EFL_UTIL_ERROR_PERMISSION_DENIED)
- * @param[in] user_data  The user data passed from the callback registration function
+ * @param[in] user_data The user data passed from the callback registration function
  * @see efl_util_set_notification_window_level_error_cb()
  * @see efl_util_unset_notification_window_level_error_cb()
  */
@@ -105,9 +128,9 @@ typedef void (*efl_util_notification_window_level_error_cb)(Evas_Object *window,
 
 /**
  * @brief Registers a callback function to be invoked when an error which set the notification level occurs.
- * @since_tizen 2.3
- * @param[in] window    The EFL window
- * @param[in] callback  The callback function to register
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in] window The EFL window
+ * @param[in] callback The callback function to register
  * @param[in] user_data The user data to be passed to the callback function
  * @return @c 0 on success, otherwise a negative error value
  * @retval #EFL_UTIL_ERROR_NONE Successful
@@ -117,18 +140,263 @@ typedef void (*efl_util_notification_window_level_error_cb)(Evas_Object *window,
  * @see efl_util_unset_notification_window_level_error_cb()
  * @see efl_util_notification_window_level_error_cb()
  */
-int efl_util_set_notification_window_level_error_cb(Evas_Object *window, efl_util_notification_window_level_error_cb callback, void *user_data);
+API int efl_util_set_notification_window_level_error_cb(Evas_Object *window, efl_util_notification_window_level_error_cb callback, void *user_data);
 
 /**
  * @brief Unregisters the callback function.
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  * @param[in] window The EFL window
  * @return @c 0 on success, otherwise a negative error value
  * @retval #EFL_UTIL_ERROR_NONE Successful
  * @retval #EFL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
  * @see efl_util_set_notification_window_level_error_cb()
  */
-int efl_util_unset_notification_window_level_error_cb(Evas_Object *window);
+API int efl_util_unset_notification_window_level_error_cb(Evas_Object *window);
+
+/**
+ * @brief Sets the alpha window's visual state to opaque state
+ * @details This API sets the alpha window's visual state to opaque state.
+ *          If the alpha window sets the visual state to the opaque,
+ *          then the window manager could handle it as the opaque window while calculating visibility.
+ *          This API will have no effect when used by a non-alpha window.
+ * @since_tizen 2.4
+ * @param[in] window The EFL window
+ * @param[in] opaque The value that indicates whether the window has set a visual state to opaque (0: unset, 1: set)
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #EFL_UTIL_ERROR_NONE Successful
+ * @retval #EFL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+API int efl_util_set_window_opaque_state(Evas_Object *window, int opaque);
+
+/**
+ * @brief Sets the window's screen mode.
+ * @details This API is useful when the application need to keep the display turned on.
+ *          If the application set the mode to #EFL_UTIL_SCREEN_MODE_ALWAYS_ON to its window and the window is shown wholly or partially,
+ *          the window manager requests the display system to keep the display on as long as the window is shown.
+ *          If the window is no longer shown, then the window manger request the display system to go back to normal operation.
+ *          Default screen mode of window is #EFL_UTIL_SCREEN_MODE_DEFAULT.
+ * @since_tizen 2.4
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/display
+ * @remarks This API needs the privilege.
+ *          If the application which is not get the privilege use this API, the window manager generates the permission deny error.
+ *          The application can notice this error if it set the callback function using the efl_util_set_window_screen_mode_error_cb().
+ * @param[in] window The EFL window
+ * @param[in] mode The screen mode
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #EFL_UTIL_ERROR_NONE Successful
+ * @retval #EFL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+API int efl_util_set_window_screen_mode(Evas_Object *window, efl_util_screen_mode_e mode);
+
+/**
+ * @brief Gets the screen mode of the specified window.
+ * @since_tizen 2.4
+ * @param[in] window The EFL window
+ * @param[out] mode The screen mode
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #EFL_UTIL_ERROR_NONE Successful
+ * @retval #EFL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+API int efl_util_get_window_screen_mode(Evas_Object *window, efl_util_screen_mode_e *mode);
+
+/**
+ * @brief Called when an error occurs for setting window's screen mode
+ * @since_tizen 2.4
+ * @param[in] window The EFL window
+ * @param[in] error_code The error code (#EFL_UTIL_ERROR_PERMISSION_DENIED)
+ * @param[in] user_data The user data passed from the callback registration function
+ * @see efl_util_set_window_screen_mode_error_cb()
+ * @see efl_util_unset_window_screen_mode_error_cb()
+ */
+typedef void (*efl_util_window_screen_mode_error_cb)(Evas_Object *window, int error_code, void *user_data);
+
+/**
+ * @brief Registers a callback function to be invoked when an error which set the screen mode.
+ * @since_tizen 2.4
+ * @param[in] window The EFL window
+ * @param[in] callback The callback function to register
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #EFL_UTIL_ERROR_NONE Successful
+ * @retval #EFL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #EFL_UTIL_ERROR_OUT_OF_MEMORY Out of memory
+ * @post  efl_util_window_screen_mode_error_cb() will be invoked.
+ * @see efl_util_unset_window_screen_mode_error_cb()
+ * @see efl_util_window_screen_mode_error_cb()
+ */
+API int efl_util_set_window_screen_mode_error_cb(Evas_Object *window, efl_util_window_screen_mode_error_cb callback, void *user_data);
+
+/**
+ * @brief Unregisters the callback function.
+ * @since_tizen 2.4
+ * @param[in] window The EFL window
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #EFL_UTIL_ERROR_NONE Successful
+ * @retval #EFL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see efl_util_set_window_screen_mode_error_cb()
+ */
+API int efl_util_unset_window_screen_mode_error_cb(Evas_Object *window);
+
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup CAPI_EFL_UTIL_INPUT_MODULE
+ * @{
+ */
+
+/**
+ * @platform
+ * @brief Enumeration of device type generated events.
+ * @since_tizen 2.4
+ */
+typedef enum
+{
+   EFL_UTIL_INPUT_DEVTYPE_NONE,
+   EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN, /**< Touch Screen device */
+   EFL_UTIL_INPUT_DEVTYPE_KEYBOARD, /**< Keyboard device */
+   EFL_UTIL_INPUT_DEVTYPE_ALL, /**< Both of touch screen and keyboard device */
+   EFL_UTIL_INPUT_DEVTYPE_MAX
+} efl_util_input_device_type_e;
+
+/**
+ * @platform
+ * @brief Enumeration of touch event types.
+ * @since_tizen 2.4
+ */
+typedef enum
+{
+   EFL_UTIL_INPUT_TOUCH_NONE,
+   EFL_UTIL_INPUT_TOUCH_BEGIN, /**< Finger press. It is same a behavior put your finger on touch screen */
+   EFL_UTIL_INPUT_TOUCH_UPDATE, /**< Finger move. It is same a behavior move your finger on touch screen */
+   EFL_UTIL_INPUT_TOUCH_END, /**< Finger release. It is same a behavior release your finger on touch screen */
+   EFL_UTIL_INPUT_TOUCH_MAX
+} efl_util_input_touch_type_e;
+
+/**
+ * @platform
+ * @brief Initializes system and check input generate functions are supported, open devices generated events.
+ * @since_tizen 2.4
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/inputgenerator
+ * @param[in] dev_type The device type want to generate events (ex> EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN, EFL_UTIL_INPUT_DEVTYPE_KEYBOARD, EFL_UTIL_INPUT_DEVTYPE_ALL)
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #EFL_UTIL_ERROR_NONE Successful
+ * @retval #EFL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #EFL_UTIL_ERROR_NO_SUCH_DEVICE No such device or address
+ * @retval #EFL_UTIL_ERROR_INVALID_OPERATION Function not implemented
+ * @see efl_util_input_generate_deinit()
+ */
+API int efl_util_input_initialize_generator(efl_util_input_device_type_e dev_type);
+
+/**
+ * @platform
+ * @brief Deinitializes system and close opened devices.
+ * @since_tizen 2.4
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/inputgenerator
+ * @see efl_util_input_generate_init()
+ */
+API void efl_util_input_deinitialize_generator(void);
+
+/**
+ * @platform
+ * @brief Generates all of key events using a opened device.
+ * @since_tizen 2.4
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/inputgenerator
+ * @param[in] key_name The key name want to generate
+ * @param[in] pressed The value that select key press or release (0: release, 1: press)
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #EFL_UTIL_ERROR_NONE Successful
+ * @retval #EFL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+API int efl_util_input_generate_key(const char *key_name, int pressed);
+
+/**
+ * @platform
+ * @brief Generates a touch event using a opened device.
+ * @since_tizen 2.4
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/inputgenerator
+ * @param[in] idx The index of touched finger
+ * @param[in] efl_util_input_touch_type_e The touch type (ex> EFL_UTIL_INPUT_TOUCH_BEGIN, EFL_UTIL_INPUT_TOUCH_UPDATE, EFL_UTIL_INPUT_TOUCH_END)
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #EFL_UTIL_ERROR_NONE Successful
+ * @retval #EFL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+API int efl_util_input_generate_touch(int idx, efl_util_input_touch_type_e touch_type, int x, int y);
+
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup CAPI_EFL_UTIL_SCREENSHOT_MODULE
+ * @{
+ */
+
+/**
+ * @platform
+ * @brief Definition for the screenshot handle.
+ * @since_tizen 2.4
+ */
+typedef struct _efl_util_screenshot_h * efl_util_screenshot_h;
+
+/**
+ * @platform
+ * @brief Initializes the screenshot.
+ * @since_tizen 2.4
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/screenshot
+ * @remarks The specific error code can be obtained using the get_last_result()
+ * method. Error codes are dedescribed in Exception section.
+ * @param[in] width width of the screenshot surface
+ * @param[in] height height of the screenshot surface
+ * @return #efl_util_screenshot_h on success, otherwise @c NULL
+ * @retval #efl_util_screenshot_h  The screenshot handle
+ * @exception #EFL_UTIL_ERROR_NONE Successful
+ * @exception #EFL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @exception #EFL_UTIL_ERROR_OUT_OF_MEMORY Memory allocation failure
+ * @exception #EFL_UTIL_ERROR_SCREENSHOT_INIT_FAIL Initialization failure
+ * @see efl_util_screenshot_deinitialize()
+ */
+API efl_util_screenshot_h efl_util_screenshot_initialize(int width, int height);
+
+/**
+ * @platform
+ * @brief Takes a screenshot and get a tbm_surface handle.
+ * @since_tizen 2.4
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/screenshot
+ * @remarks The specific error code can be obtained using the get_last_result()
+ *          The tbm_surface_h must be free by caller
+ * @param[in] screenshot efl_util_screenshot_h handle
+ * @return #tbm_surface_h on success, otherwise @c NULL
+ * @retval #tbm_surface_h The TBM surface handle
+ * @exception #EFL_UTIL_ERROR_NONE Successful
+ * @exception #EFL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @exception #EFL_UTIL_ERROR_SCREENSHOT_EXECUTION_FAIL Execution failure
+ * @see efl_util_screenshot_initialize()
+ * @see efl_util_screenshot_deinitialize()
+ */
+API tbm_surface_h efl_util_screenshot_take_tbm_surface(efl_util_screenshot_h screenshot);
+
+/**
+ * @platform
+ * @brief Deinitializes the screenshot.
+ * @since_tizen 2.4
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/screenshot
+ * @param[in]  screenshot  efl_util_screenshot_h handle
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #EFL_UTIL_ERROR_NONE Successful
+ * @retval #EFL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see efl_util_screenshot_initialize()
+ */
+API int efl_util_screenshot_deinitialize(efl_util_screenshot_h screenshot);
 
 /**
  * @}
index 7fb0ae3..b5b8b0a 100644 (file)
@@ -2,7 +2,7 @@
 %bcond_with wayland
 
 Name:       capi-ui-efl-util
-Summary:    An EFL utility library in SLP C API
+Summary:    An EFL utility library in Tizen C API
 Version:    0.1.2
 Release:    1
 Group:      Graphics & UI Framework/API
@@ -15,16 +15,28 @@ BuildRequires:  pkgconfig(dlog)
 BuildRequires:  pkgconfig(x11)
 BuildRequires:  pkgconfig(utilX)
 BuildRequires:  pkgconfig(ecore-x)
+BuildRequires:  pkgconfig(xtst)
+BuildRequires:  pkgconfig(libdri2)
+BuildRequires:  pkgconfig(dri2proto)
+BuildRequires:  pkgconfig(xext)
+BuildRequires:  pkgconfig(xv)
+BuildRequires:  pkgconfig(xdamage)
+%endif
+%if %{with wayland}
+BuildRequires:  pkgconfig(wayland-client)
+BuildRequires:  pkgconfig(ecore-wayland)
 %endif
 BuildRequires:  pkgconfig(elementary)
 BuildRequires:  pkgconfig(capi-base-common)
+BuildRequires:  pkgconfig(libdrm)
+BuildRequires:  pkgconfig(libtbm)
 
 %description
 An EFL utility library in SLP C API.
 
 
 %package devel
-Summary:  An EFL utility library in SLP C API (Development)
+Summary:  An EFL utility library in Tizen C API (Development)
 Requires: %{name} = %{version}-%{release}
 
 %description devel
index 0a77054..69cbe5e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2011-2015 Samsung Electronics Co., Ltd All Rights Reserved
  *
  * Licensed under the Apache License, Version 2.0 (the License);
  * you may not use this file except in compliance with the License.
  * 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. 
+ * limitations under the License.
  */
 
-
 #define LOG_TAG "TIZEN_N_EFL_UTIL"
 
 #include <efl_util.h>
 #include <stdlib.h>
 #include <string.h>
 #include <Elementary.h>
+#include <Ecore_Evas.h>
 
 #if X11
 #include <Ecore_X.h>
 #include <utilX.h>
-#endif
+#endif /* end of X11 */
 
 #if WAYLAND
 #include <Ecore_Wayland.h>
 #include <wayland-client.h>
 #include "tizen_notification-client-protocol.h"
-#endif
-
-typedef struct _notification_error_cb_info
-{
-   Evas_Object *window;
-   efl_util_notification_window_level_error_cb err_cb;
-   void *user_data;
-} notification_error_cb_info;
+#endif /* end of WAYLAND */
 
-Eina_List *_g_notification_error_cb_info_list;
-static Ecore_Event_Handler* _noti_level_access_result_handler = NULL;
-static int _noti_handler_count = 0;
+/* callback handler index */
+#define CBH_NOTI_LEV 0
+#define CBH_SCR_MODE 1
+#define CBH_MAX      2
 
-static notification_error_cb_info *_notification_error_cb_info_find(Evas_Object *window);
-static Eina_Bool _efl_util_notification_info_add(Evas_Object *window, efl_util_notification_window_level_error_cb callback, void *user_data);
-static Eina_Bool _efl_util_notification_info_del(Evas_Object *window);
+typedef void (*Efl_Util_Cb)(Evas_Object *, int, void *);
 
-#if X11
-static unsigned int _noti_level_access_result_atom = 0;
+typedef struct _Efl_Util_Callback_Info
+{
+   Evas_Object *win;
+   Efl_Util_Cb cb;
+   void *data;
+} Efl_Util_Callback_Info;
 
-static Eina_Bool _efl_util_client_message(void *data, int type, void *event);
-static notification_error_cb_info *_notification_error_cb_info_find_by_xwin(unsigned int xwin);
-#endif
+typedef struct _Efl_Util_Wl_Surface_Lv_Info
+{
+   void *surface; /* wl_surface */
+   int level;
+   Eina_Bool wait_for_done;
+} Efl_Util_Wl_Surface_Lv_Info;
 
-#if WAYLAND
-typedef struct _Surface_Level
+typedef struct _Efl_Util_Data
 {
-   struct wl_surface *surface;
-   int32_t level;
-   Eina_Bool wait_set_level_done;
-} Surface_Level;
+   Ecore_Event_Handler *handler; /* x11 client message handler */
+   struct
+   {
+      Eina_List *info_list; /* list of callback info */
+      unsigned int atom; /* x11 atom */
+   } cb_handler[CBH_MAX];
+
+   /* wayland related stuffs */
+   struct
+   {
+      Eina_Bool init;
+      #if WAYLAND
+      struct wl_display *dpy;
+      struct
+      {
+         struct tizen_notification *proto;
+         Eina_Hash *hash;
+      } noti_lv;
+      #endif /* end of WAYLAND */
+   } wl;
+} Efl_Util_Data;
+
+static Efl_Util_Data _eflutil =
+{
+   NULL,
+   {
+      { NULL, 0 }, /* handler for notification level */
+      { NULL, 0 }  /* handler for screen mode */
+   },
+   {
+      EINA_FALSE,
+      #if WAYLAND
+      NULL,
+      { NULL, NULL } /* tizen_notification protocol */
+      #endif /* end of WAYLAND */
+   }
+};
 
-static void _cb_handle_registry_global(void *data, struct wl_registry *registry, unsigned int name, const char *interface, unsigned int version);
-static void _cb_handle_registry_global_remove(void *data, struct wl_registry *registry, unsigned int name);
-static void _notification_set_level_done(void *data, struct tizen_notification *tizen_notification, struct wl_surface *surface, int32_t level, uint32_t error_state);
-static notification_error_cb_info *_notification_error_cb_info_find_by_wl_surface(struct wl_surface *surface);
+static Eina_Bool               _cb_info_add(Evas_Object *win, Efl_Util_Cb cb, void *data, int idx);
+static Eina_Bool               _cb_info_del_by_win(Evas_Object *win, int idx);
+static Eina_List              *_cb_info_list_get(int idx);
+static Efl_Util_Callback_Info *_cb_info_find_by_win(Evas_Object *win, int idx);
+#if X11
+static Efl_Util_Callback_Info *_cb_info_find_by_xwin(unsigned int xwin);
+static Eina_Bool               _cb_x11_client_msg(void *data, int type, void *event);
+#endif /* end of X11 */
+#if WAYLAND
+static Eina_Bool               _wl_init(void);
+static void                    _cb_wl_reg_global(void *data, struct wl_registry *reg, unsigned int name, const char *interface, unsigned int version);
+static void                    _cb_wl_reg_global_remove(void *data, struct wl_registry *reg, unsigned int name);
+static Efl_Util_Callback_Info *_cb_info_find_by_wlsurf(void *wlsurf, int idx);
+static void                    _cb_wl_tz_noti_lv_done(void *data, struct tizen_notification *proto, struct wl_surface *surface, int32_t level, uint32_t state);
 
-static const struct wl_registry_listener _registry_listener =
+static const struct wl_registry_listener _wl_reg_listener =
 {
-   _cb_handle_registry_global,
-   _cb_handle_registry_global_remove
+   _cb_wl_reg_global,
+   _cb_wl_reg_global_remove
 };
 
-struct tizen_notification_listener _tizen_notification_listener =
+struct tizen_notification_listener _wl_tz_noti_lv_listener =
 {
-   _notification_set_level_done,
+   _cb_wl_tz_noti_lv_done
 };
+#endif /* end of WAYLAND */
 
-static struct tizen_notification *_tizen_notification = NULL;
-static Eina_Bool _efl_util_init_done = EINA_FALSE;
-static Eina_Hash *hash_surface_levels = NULL;
+static Eina_Bool
+_cb_info_add(Evas_Object *win,
+             Efl_Util_Cb cb,
+             void *data,
+             int idx)
+{
+   Efl_Util_Callback_Info *info;
 
-static void
-_cb_handle_registry_global(void *data, struct wl_registry *registry, unsigned int name, const char *interface, unsigned int version)
+   info = _cb_info_find_by_win(win, idx);
+   if (info)
+     {
+        _eflutil.cb_handler[idx].info_list
+           = eina_list_remove(_eflutil.cb_handler[idx].info_list,
+                              info);
+        free(info);
+     }
+
+   info = (Efl_Util_Callback_Info *)calloc(1, sizeof(Efl_Util_Callback_Info));
+   if (!info) return EINA_FALSE;
+
+   info->win = win;
+   info->cb = cb;
+   info->data = data;
+
+   _eflutil.cb_handler[idx].info_list
+      = eina_list_append(_eflutil.cb_handler[idx].info_list,
+                         info);
+
+#if X11
+   if (!_eflutil.handler)
+     _eflutil.handler = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE,
+                                                _cb_x11_client_msg,
+                                                NULL);
+#endif /* end of X11 */
+
+   return EINA_TRUE;
+}
+
+static Eina_Bool
+_cb_info_del_by_win(Evas_Object *win,
+                    int idx)
 {
-   if (!strcmp(interface, "tizen_notification"))
+   Efl_Util_Callback_Info *info;
+   unsigned int count;
+
+   info = _cb_info_find_by_win(win, idx);
+   if (!info) return EINA_FALSE;
+
+   _eflutil.cb_handler[idx].info_list
+      = eina_list_remove(_eflutil.cb_handler[idx].info_list,
+                         info);
+   free(info);
+
+   count = eina_list_count(_eflutil.cb_handler[idx].info_list);
+   if ((count == 0) && (_eflutil.handler))
      {
-        _tizen_notification = wl_registry_bind(registry, name, &tizen_notification_interface, 1);
-        if (!_tizen_notification) return;
-        tizen_notification_add_listener(_tizen_notification, &_tizen_notification_listener, NULL);
-        _efl_util_init_done = EINA_TRUE;
-        hash_surface_levels = eina_hash_pointer_new(free);
+        ecore_event_handler_del(_eflutil.handler);
+        _eflutil.handler = NULL;
      }
+
+   return EINA_TRUE;
 }
 
-# define _FREE_FUNC(_h, _fn) do { if (_h) { _fn((void*)_h); _h = NULL; } } while (0)
-static void
-_cb_handle_registry_global_remove(void *data, struct wl_registry *registry, unsigned int name)
+static Eina_List *
+_cb_info_list_get(int idx)
 {
-   _tizen_notification = NULL;
-   _efl_util_init_done = EINA_FALSE;
-   _FREE_FUNC(hash_surface_levels, eina_hash_free);
-   /* no-op */
+   return _eflutil.cb_handler[idx].info_list;
 }
 
-static void
-_notification_set_level_done(void *data,
-                             struct tizen_notification *tizen_notification,
-                             struct wl_surface *surface,
-                             int32_t level,
-                             uint32_t error_state)
+static Efl_Util_Callback_Info *
+_cb_info_find_by_win(Evas_Object *win,
+                     int idx)
+{
+   Eina_List *l, *ll;
+   Efl_Util_Callback_Info *info;
+
+   l = _cb_info_list_get(idx);
+   EINA_LIST_FOREACH(l, ll, info)
+     {
+        if (info->win == win) return info;
+     }
+
+   return NULL;
+}
+
+#if X11
+static Efl_Util_Callback_Info *
+_cb_info_find_by_xwin(unsigned int xwin,
+                      int idx)
 {
-   Surface_Level *sl;
-   notification_error_cb_info *cb_info = NULL;
-   efl_util_error_e error_cb_state = EFL_UTIL_ERROR_NONE;
+   Eina_List *l, *ll;
+   Efl_Util_Callback_Info *info;
+   unsigned int xwin2;
 
-   if (hash_surface_levels)
+   l = _cb_info_list_get(idx);
+   EINA_LIST_FOREACH(l, ll, info)
      {
-        sl = eina_hash_find(hash_surface_levels, &surface);
-        if (sl)
+        xwin2 = elm_win_xwindow_get(info->win);
+        if (xwin == xwin2) return info;
+     }
+
+   return NULL;
+}
+
+static Eina_Bool
+_cb_x11_client_msg(void *data,
+                   int type,
+                   void *event)
+{
+   Ecore_X_Event_Client_Message *ev;
+   Ecore_X_Window xwin;
+   Efl_Util_Callback_Info *info;
+
+   ev = event;
+   if (!ev) return ECORE_CALLBACK_PASS_ON;
+
+   xwin = ev->win;
+   if (xwin == 0) return ECORE_CALLBACK_PASS_ON;
+
+   if (ev->message_type == _eflutil.atom.noti_lv)
+     {
+        info = _cb_info_find_by_xwin(xwin, CBH_NOTI_LEV);
+
+        /* permission denied */
+        if ((ev->data.l[1] == 0) &&
+            (info) &&
+            (info->cb))
           {
-             sl->level = level;
-             sl->wait_set_level_done = EINA_FALSE;
+             info->cb(info->win,
+                      EFL_UTIL_ERROR_PERMISSION_DENIED,
+                      info->data);
           }
      }
-
-   cb_info = _notification_error_cb_info_find_by_wl_surface(surface);
-   if (cb_info)
+   else if (ev->message_type == _eflutil.atom.scr_mode)
      {
-        switch (error_state)
+        info = _cb_info_find_by_xwin(xwin, CBH_SCR_MODE);
+
+        /* permission denied */
+        if ((ev->data.l[1] == 0) &&
+            (info) &&
+            (info->cb))
           {
-             case TIZEN_NOTIFICATION_ERROR_STATE_NONE:
-                error_cb_state = EFL_UTIL_ERROR_NONE;
-                break;
-             case TIZEN_NOTIFICATION_ERROR_STATE_PERMISSION_DENIED:
-             default:
-                error_cb_state = EFL_UTIL_ERROR_PERMISSION_DENIED;
-                break;
+             info->cb(info->win,
+                      EFL_UTIL_ERROR_PERMISSION_DENIED,
+                      info->data);
           }
-        if (cb_info->err_cb)
-          cb_info->err_cb(cb_info->window, error_cb_state , cb_info->user_data);
      }
+   return ECORE_CALLBACK_PASS_ON;
+}
+#endif /* end of X11 */
+
+#if WAYLAND
+static Eina_Bool
+_wl_init(void)
+{
+   struct wl_registry *reg;
+
+   if (_eflutil.wl.init) return EINA_TRUE;
+
+   _eflutil.wl.dpy = ecore_wl_display_get();
+   EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.dpy, EINA_FALSE);
+
+   reg = wl_display_get_registry(_eflutil.wl.dpy);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(reg, EINA_FALSE);
+
+   wl_registry_add_listener(reg, &_wl_reg_listener, NULL);
+
+   _eflutil.wl.init = EINA_TRUE;
+
+   return EINA_TRUE;
 }
 
 static void
-_efl_util_wl_init(void)
+_cb_wl_reg_global(void *data,
+                  struct wl_registry *reg,
+                  unsigned int name,
+                  const char *interface,
+                  unsigned int version)
 {
-   static Eina_Bool init = EINA_FALSE;
-   if (!init)
+   if (!strcmp(interface, "tizen_notification"))
+     {
+        struct tizen_notification *proto;
+        proto = wl_registry_bind(reg,
+                                 name,
+                                 &tizen_notification_interface,
+                                 1);
+        if (!proto) return;
+
+        tizen_notification_add_listener(proto,
+                                        &_wl_tz_noti_lv_listener,
+                                        NULL);
+
+        _eflutil.wl.noti_lv.hash = eina_hash_pointer_new(free);
+        _eflutil.wl.noti_lv.proto = proto;
+     }
+}
+
+static void
+_cb_wl_reg_global_remove(void *data,
+                         struct wl_registry *reg,
+                         unsigned int name)
+{
+   _eflutil.wl.noti_lv.proto = NULL;
+   eina_hash_free(_eflutil.wl.noti_lv.hash);
+}
+
+static Efl_Util_Callback_Info *
+_cb_info_find_by_wlsurf(void *wlsurf,
+                        int idx)
+{
+   Eina_List *l, *ll;
+   Efl_Util_Callback_Info *info;
+   Ecore_Wl_Window *wlwin2 = NULL;
+   void *wlsurf2 = NULL;
+
+   l = _cb_info_list_get(idx);
+   EINA_LIST_FOREACH(l, ll, info)
+     {
+        wlwin2 = elm_win_wl_window_get(info->win);
+        wlsurf2 = ecore_wl_window_surface_get(wlwin2);
+        if (wlsurf== wlsurf2) return info;
+     }
+
+   return NULL;
+}
+
+static void
+_cb_wl_tz_noti_lv_done(void *data,
+                       struct tizen_notification *proto,
+                       struct wl_surface *surface,
+                       int32_t level,
+                       uint32_t state)
+{
+   Efl_Util_Wl_Surface_Lv_Info *lv_info;
+   Efl_Util_Callback_Info *cb_info;
+
+   lv_info = eina_hash_find(_eflutil.wl.noti_lv.hash, &surface);
+   if (lv_info)
      {
-        wl_registry_add_listener(wl_display_get_registry(ecore_wl_display_get()),
-                                 &_registry_listener, NULL);
-        init = EINA_TRUE;
+        lv_info->level = level;
+        lv_info->wait_for_done = EINA_FALSE;
      }
-   while (!_efl_util_init_done)
-     wl_display_dispatch(ecore_wl_display_get());
+
+   if (state != TIZEN_NOTIFICATION_ERROR_STATE_PERMISSION_DENIED) return;
+
+   cb_info = _cb_info_find_by_wlsurf((void *)surface, CBH_NOTI_LEV);
+   if (!cb_info) return;
+   if (!cb_info->cb) return;
+
+   cb_info->cb(cb_info->win,
+               EFL_UTIL_ERROR_PERMISSION_DENIED,
+               cb_info->data);
 }
-#endif
+#endif /* end of WAYLAND */
 
-int
-efl_util_set_notification_window_level(Evas_Object *window, efl_util_notification_level_e level)
+API int
+efl_util_set_notification_window_level(Evas_Object *window,
+                                       efl_util_notification_level_e level)
 {
    EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
    EINA_SAFETY_ON_FALSE_RETURN_VAL((level >= EFL_UTIL_NOTIFICATION_LEVEL_1) &&
@@ -174,10 +391,10 @@ efl_util_set_notification_window_level(Evas_Object *window, efl_util_notificatio
    if (xwin)
      {
         Ecore_X_Window_Type window_type;
-        if(ecore_x_netwm_window_type_get(xwin, &window_type) == EINA_TRUE)
+        if (ecore_x_netwm_window_type_get(xwin, &window_type) == EINA_TRUE)
           {
              // success to get window type
-             if(window_type != ECORE_X_WINDOW_TYPE_NOTIFICATION)
+             if (window_type != ECORE_X_WINDOW_TYPE_NOTIFICATION)
                {
                   // given EFL window's type is not notification type.
                   return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
@@ -186,55 +403,68 @@ efl_util_set_notification_window_level(Evas_Object *window, efl_util_notificatio
         else
           return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
 
-        utilx_set_system_notification_level(ecore_x_display_get(), xwin,
-                                            level);
+        utilx_set_system_notification_level(ecore_x_display_get(), xwin, level);
         return EFL_UTIL_ERROR_NONE;
      }
-#endif
+#endif /* end of X11 */
 
 #if WAYLAND
-   Ecore_Wl_Window *wl_win = elm_win_wl_window_get(window);
-   if (wl_win)
+   Elm_Win_Type type;
+   Ecore_Wl_Window *wlwin;
+   struct wl_surface *surface;
+   Efl_Util_Wl_Surface_Lv_Info *lv_info;
+
+   type = elm_win_type_get(window);
+   EINA_SAFETY_ON_FALSE_RETURN_VAL((type == ELM_WIN_NOTIFICATION),
+                                   EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
+
+   wlwin = elm_win_wl_window_get(window);
+   if (wlwin)
      {
-        _efl_util_wl_init();
+        _wl_init();
+
+        while (!_eflutil.wl.noti_lv.proto)
+          wl_display_dispatch(_eflutil.wl.dpy);
+
+        surface = ecore_wl_window_surface_get(wlwin);
+        EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
+                                       EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
 
-        if (hash_surface_levels)
+        lv_info = eina_hash_find(_eflutil.wl.noti_lv.hash, &surface);
+        if (!lv_info)
           {
-             Surface_Level *sl;
-             struct wl_surface *surface = ecore_wl_window_surface_get(wl_win);
-             sl = eina_hash_find(hash_surface_levels, &surface);
-             if (!sl)
-               {
-                  sl = calloc(1, sizeof(Surface_Level));
-                  if (sl)
-                    {
-                       sl->surface = surface;
-                       sl->level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
-                       sl->wait_set_level_done = EINA_TRUE;
-                       eina_hash_add(hash_surface_levels, &surface, sl);
-                    }
-               }
-             else
-               {
-                  sl->wait_set_level_done = EINA_TRUE;
-               }
+             lv_info = calloc(1, sizeof(Efl_Util_Wl_Surface_Lv_Info));
+             EINA_SAFETY_ON_NULL_RETURN_VAL(lv_info, EFL_UTIL_ERROR_OUT_OF_MEMORY);
+
+             lv_info->surface = surface;
+             lv_info->level = (int)level;
+             lv_info->wait_for_done = EINA_TRUE;
+
+             eina_hash_add(_eflutil.wl.noti_lv.hash,
+                           &surface,
+                           lv_info);
+          }
+        else
+          {
+             lv_info->level = (int)level;
+             lv_info->wait_for_done = EINA_TRUE;
           }
 
-        //Add notification window type check
-        tizen_notification_set_level(_tizen_notification,
-                                     ecore_wl_window_surface_get(wl_win),
-                                     level);
+        tizen_notification_set_level(_eflutil.wl.noti_lv.proto,
+                                     surface,
+                                     (int)level);
+
         return EFL_UTIL_ERROR_NONE;
      }
-#endif
+#endif /* end of WAYLAND */
 
    return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
 }
 
-int
-efl_util_get_notification_window_level(Evas_Object *window, efl_util_notification_level_e *level)
+API int
+efl_util_get_notification_window_level(Evas_Object *window,
+                                       efl_util_notification_level_e *level)
 {
-
    EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
    EINA_SAFETY_ON_NULL_RETURN_VAL(level, EFL_UTIL_ERROR_INVALID_PARAMETER);
 
@@ -244,64 +474,66 @@ efl_util_get_notification_window_level(Evas_Object *window, efl_util_notificatio
    Ecore_X_Window xwin = elm_win_xwindow_get(window);
    if (xwin)
      {
-        if(ecore_x_netwm_window_type_get(xwin, &window_type) == EINA_TRUE)
+        if (ecore_x_netwm_window_type_get(xwin, &window_type) == EINA_TRUE)
           {
              // success to get window type
-             if(window_type != ECORE_X_WINDOW_TYPE_NOTIFICATION)
+             if (window_type != ECORE_X_WINDOW_TYPE_NOTIFICATION)
                {
                   // given EFL window's type is not notification type.
                   return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
                }
 
-             utilx_level = utilx_get_system_notification_level (ecore_x_display_get(), xwin);
-
-             if(utilx_level == UTILX_NOTIFICATION_LEVEL_LOW)
-               {
-                  *level = EFL_UTIL_NOTIFICATION_LEVEL_1;
-               }
+             utilx_level = utilx_get_system_notification_level(ecore_x_display_get(), xwin);
+             if (utilx_level == UTILX_NOTIFICATION_LEVEL_LOW)
+               *level = EFL_UTIL_NOTIFICATION_LEVEL_1;
              else if(utilx_level == UTILX_NOTIFICATION_LEVEL_NORMAL)
-               {
-                  *level = EFL_UTIL_NOTIFICATION_LEVEL_2;
-               }
+               *level = EFL_UTIL_NOTIFICATION_LEVEL_2;
              else if(utilx_level == UTILX_NOTIFICATION_LEVEL_HIGH)
-               {
-                  *level = EFL_UTIL_NOTIFICATION_LEVEL_3;
-               }
+               *level = EFL_UTIL_NOTIFICATION_LEVEL_3;
              else
-               {
-                  return EFL_UTIL_ERROR_INVALID_PARAMETER;
-               }
-
+               return EFL_UTIL_ERROR_INVALID_PARAMETER;
           }
         else
-          {
-             // fail to get window type
-             return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
-          }
+          return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
 
         return EFL_UTIL_ERROR_NONE;
      }
-#endif
+#endif /* end of X11 */
 
 #if WAYLAND
-   Ecore_Wl_Window *wl_win = elm_win_wl_window_get(window);
-   if (wl_win)
+   Elm_Win_Type type;
+   Ecore_Wl_Window *wlwin;
+   struct wl_surface *surface;
+   Efl_Util_Wl_Surface_Lv_Info *lv_info;
+
+   type = elm_win_type_get(window);
+   EINA_SAFETY_ON_FALSE_RETURN_VAL((type == ELM_WIN_NOTIFICATION),
+                                   EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
+
+   wlwin = elm_win_wl_window_get(window);
+   if (wlwin)
      {
-        Surface_Level *sl;
-        struct wl_surface *surface = ecore_wl_window_surface_get(wl_win);
+        _wl_init();
+
+        while (!_eflutil.wl.noti_lv.proto)
+          wl_display_dispatch(_eflutil.wl.dpy);
 
-        sl = eina_hash_find(hash_surface_levels, &surface);
-        if (sl)
+        surface = ecore_wl_window_surface_get(wlwin);
+        EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
+                                       EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
+
+        lv_info = eina_hash_find(_eflutil.wl.noti_lv.hash, &surface);
+        if (lv_info)
           {
-            if (sl->wait_set_level_done)
-              {
-                  if (ecore_wl_window_shell_surface_get(wl_win) ||
-                      ecore_wl_window_xdg_surface_get(wl_win))
+             if (lv_info->wait_for_done)
+               {
+                  if (ecore_wl_window_shell_surface_get(wlwin) ||
+                      ecore_wl_window_xdg_surface_get(wlwin))
                     {
-                       while (sl->wait_set_level_done)
+                       while (lv_info->wait_for_done)
                          {
                             ecore_wl_flush();
-                            wl_display_dispatch(ecore_wl_display_get());
+                            wl_display_dispatch(_eflutil.wl.dpy);
                          }
                     }
                   else
@@ -309,236 +541,274 @@ efl_util_get_notification_window_level(Evas_Object *window, efl_util_notificatio
                        *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
                        return EFL_UTIL_ERROR_INVALID_PARAMETER;
                     }
-              }
+               }
 
-            switch (sl->level)
+            switch (lv_info->level)
               {
-                 case TIZEN_NOTIFICATION_LEVEL_1:
-                   *level = EFL_UTIL_NOTIFICATION_LEVEL_1;
-                   break;
-                 case TIZEN_NOTIFICATION_LEVEL_2:
-                   *level = EFL_UTIL_NOTIFICATION_LEVEL_2;
-                   break;
-                 case TIZEN_NOTIFICATION_LEVEL_3:
-                   *level = EFL_UTIL_NOTIFICATION_LEVEL_3;
-                   break;
-                 case TIZEN_NOTIFICATION_LEVEL_NONE:
-                   *level = EFL_UTIL_NOTIFICATION_LEVEL_NONE;
-                   break;
-                 case TIZEN_NOTIFICATION_LEVEL_DEFAULT:
-                   *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
-                   break;
-                 case TIZEN_NOTIFICATION_LEVEL_MEDIUM:
-                   *level = EFL_UTIL_NOTIFICATION_LEVEL_MEDIUM;
-                   break;
-                 case TIZEN_NOTIFICATION_LEVEL_HIGH:
-                   *level = EFL_UTIL_NOTIFICATION_LEVEL_HIGH;
-                   break;
-                 case TIZEN_NOTIFICATION_LEVEL_TOP:
-                   *level = EFL_UTIL_NOTIFICATION_LEVEL_TOP;
-                   break;
-                 default:
-                   *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
+                 case TIZEN_NOTIFICATION_LEVEL_1:       *level = EFL_UTIL_NOTIFICATION_LEVEL_1;       break;
+                 case TIZEN_NOTIFICATION_LEVEL_2:       *level = EFL_UTIL_NOTIFICATION_LEVEL_2;       break;
+                 case TIZEN_NOTIFICATION_LEVEL_3:       *level = EFL_UTIL_NOTIFICATION_LEVEL_3;       break;
+                 case TIZEN_NOTIFICATION_LEVEL_NONE:    *level = EFL_UTIL_NOTIFICATION_LEVEL_NONE;    break;
+                 case TIZEN_NOTIFICATION_LEVEL_DEFAULT: *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT; break;
+                 case TIZEN_NOTIFICATION_LEVEL_MEDIUM:  *level = EFL_UTIL_NOTIFICATION_LEVEL_MEDIUM;  break;
+                 case TIZEN_NOTIFICATION_LEVEL_HIGH:    *level = EFL_UTIL_NOTIFICATION_LEVEL_HIGH;    break;
+                 case TIZEN_NOTIFICATION_LEVEL_TOP:     *level = EFL_UTIL_NOTIFICATION_LEVEL_TOP;     break;
+                 default:                               *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
                    return EFL_UTIL_ERROR_INVALID_PARAMETER;
               }
             return EFL_UTIL_ERROR_NONE;
           }
         else
-          {
-             *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
-          }
+          *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
+
+        return EFL_UTIL_ERROR_NONE;
      }
-#endif
+#endif /* end of WAYLAND */
    return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
 }
 
-int
-efl_util_set_notification_window_level_error_cb(Evas_Object *window, efl_util_notification_window_level_error_cb callback, void *user_data)
+API int
+efl_util_set_notification_window_level_error_cb(Evas_Object *window,
+                                                efl_util_notification_window_level_error_cb callback,
+                                                void *user_data)
 {
    Eina_Bool ret = EINA_FALSE;
 
    EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
    EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EFL_UTIL_ERROR_INVALID_PARAMETER);
 
-   ret = _efl_util_notification_info_add(window, callback, user_data);
-   if (ret)
-     {
-#if X11
-        if (!_noti_level_access_result_atom)
-          _noti_level_access_result_atom = ecore_x_atom_get("_E_NOTIFICATION_LEVEL_ACCESS_RESULT");
-
-        if (!_noti_level_access_result_handler)
-          _noti_level_access_result_handler = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, _efl_util_client_message, NULL);
-        _noti_handler_count++;
+   ret = _cb_info_add(window,
+                      (Efl_Util_Cb)callback,
+                      user_data,
+                      CBH_NOTI_LEV);
+   if (!ret) return EFL_UTIL_ERROR_OUT_OF_MEMORY;
 
-        return EFL_UTIL_ERROR_NONE;
-#endif
+#if X11
+   if (!_eflutil.atom.noti_lv)
+     _eflutil.atom.noti_lv = ecore_x_atom_get("_E_NOTIFICATION_LEVEL_ACCESS_RESULT");
+#endif /* end of X11 */
 
-#if WAYLAND
-        return EFL_UTIL_ERROR_NONE;
-#endif
-     }
-   return EFL_UTIL_ERROR_OUT_OF_MEMORY;
+   return EFL_UTIL_ERROR_NONE;
 }
 
-int
+API int
 efl_util_unset_notification_window_level_error_cb(Evas_Object *window)
 {
    Eina_Bool ret = EINA_FALSE;
 
    EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
 
-   ret = _efl_util_notification_info_del(window);
-   if (ret)
-     {
-        _noti_handler_count--;
-        if (_noti_handler_count == 0)
-          {
-             if (_noti_level_access_result_handler)
-               {
-                  ecore_event_handler_del(_noti_level_access_result_handler);
-                  _noti_level_access_result_handler = NULL;
-               }
-          }
-        return EFL_UTIL_ERROR_NONE;
-     }
+   ret = _cb_info_del_by_win(window, CBH_NOTI_LEV);
+   if (!ret) return EFL_UTIL_ERROR_OUT_OF_MEMORY;
 
-   return EFL_UTIL_ERROR_INVALID_PARAMETER;
+   return EFL_UTIL_ERROR_NONE;
 }
 
-#if X11
-static Eina_Bool
-_efl_util_client_message(void *data, int type, void *event)
+API int
+efl_util_set_window_opaque_state(Evas_Object *window,
+                                 int opaque)
 {
-   Ecore_X_Event_Client_Message *ev;
+   EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
+   EINA_SAFETY_ON_FALSE_RETURN_VAL(((opaque >= 0) && (opaque <= 1)),
+                                   EFL_UTIL_ERROR_INVALID_PARAMETER);
 
-   ev = event;
-   if (!ev) return ECORE_CALLBACK_PASS_ON;
+#if X11
+   Ecore_X_Window xwin = elm_win_xwindow_get(window);
+   Ecore_X_Display *xdpy = ecore_x_display_get();
+   Utilx_Opaque_State state;
+   int ret;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(xwin, EFL_UTIL_ERROR_INVALID_PARAMETER);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(xdpy, EFL_UTIL_ERROR_INVALID_PARAMETER);
+
+   if (opaque)
+     state = UTILX_OPAQUE_STATE_ON;
+   else
+     state = UTILX_OPAQUE_STATE_OFF;
+
+   ret = utilx_set_window_opaque_state(xdpy, xwin, state);
 
-   if (ev->message_type == _noti_level_access_result_atom)
+   if (!ret)
+     return EFL_UTIL_ERROR_INVALID_PARAMETER;
+   else
+     return EFL_UTIL_ERROR_NONE;
+#endif /* end of X11 */
+
+#if WAYLAND
+   Ecore_Wl_Window *wlwin;
+   int x, y, w, h;
+
+   wlwin = elm_win_wl_window_get(window);
+   if (wlwin)
      {
-        Ecore_X_Window xwin;
-        xwin = ev->win;
+        _wl_init();
 
-        notification_error_cb_info *cb_info = NULL;
-        cb_info = _notification_error_cb_info_find_by_xwin(xwin);
-        if (cb_info)
-          {
-             int access = ev->data.l[1];
-             if (access == 0) // permission denied
-               {
-                  if (cb_info->err_cb)
-                    {
-                       cb_info->err_cb(cb_info->window, EFL_UTIL_ERROR_PERMISSION_DENIED, cb_info->user_data);
-                    }
-               }
-          }
+        evas_object_geometry_get(window, &x, &y, &w, &h);
+
+        if (opaque)
+          ecore_wl_window_opaque_region_set(wlwin, x, y, w, h);
+        else
+          ecore_wl_window_opaque_region_set(wlwin, 0, 0, 0, 0);
+
+        return EFL_UTIL_ERROR_NONE;
      }
 
-   return ECORE_CALLBACK_PASS_ON;
+   return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
+#endif /* end of WAYLAND */
 }
 
-static notification_error_cb_info *
-_notification_error_cb_info_find_by_xwin(unsigned int xwin)
+API int
+efl_util_set_window_screen_mode(Evas_Object *window,
+                                efl_util_screen_mode_e mode)
 {
-   Eina_List *l;
-   notification_error_cb_info* temp;
-   unsigned int temp_xwin;
+   Evas *e;
+   Ecore_Evas *ee;
+   int id;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
+   EINA_SAFETY_ON_FALSE_RETURN_VAL(((mode >= EFL_UTIL_SCREEN_MODE_DEFAULT) &&
+                                    (mode <= EFL_UTIL_SCREEN_MODE_ALWAYS_ON)),
+                                   EFL_UTIL_ERROR_INVALID_PARAMETER);
+
+   e = evas_object_evas_get(window);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(e, EFL_UTIL_ERROR_INVALID_PARAMETER);
 
-   EINA_LIST_FOREACH(_g_notification_error_cb_info_list, l, temp)
+   ee = ecore_evas_ecore_evas_get(e);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(ee, EFL_UTIL_ERROR_INVALID_PARAMETER);
+
+   id = ecore_evas_aux_hint_id_get(ee, "wm.policy.win.lcd.lock");
+   if (mode == EFL_UTIL_SCREEN_MODE_ALWAYS_ON)
      {
-        if (temp->window)
-          {
-             temp_xwin = elm_win_xwindow_get(temp->window);
-             if (xwin == temp_xwin)
-               {
-                  return temp;
-               }
-          }
+        if (id == -1)
+          ecore_evas_aux_hint_add(ee, "wm.policy.win.lcd.lock", "1");
+        else
+          ecore_evas_aux_hint_val_set(ee, id, "1");
+     }
+   else if (mode == EFL_UTIL_SCREEN_MODE_DEFAULT)
+     {
+        if (id == -1)
+          ecore_evas_aux_hint_add(ee, "wm.policy.win.lcd.lock", "0");
+        else
+          ecore_evas_aux_hint_val_set(ee, id, "0");
      }
+   else
+     return EFL_UTIL_ERROR_INVALID_PARAMETER;
 
-   return NULL;
+   return EFL_UTIL_ERROR_NONE;
 }
-#endif
 
-#if WAYLAND
-static notification_error_cb_info *
-_notification_error_cb_info_find_by_wl_surface(struct wl_surface *surface)
+API int
+efl_util_get_window_screen_mode(Evas_Object *window,
+                                efl_util_screen_mode_e *mode)
 {
-   Eina_List *l;
-   notification_error_cb_info* temp;
-   struct wl_surface *temp_surface;
+   Evas *e;
+   Ecore_Evas *ee;
+   const char *str;
+   int id;
 
-   EINA_LIST_FOREACH(_g_notification_error_cb_info_list, l, temp)
-     {
-        if (temp->window)
-          {
-             temp_surface = ecore_wl_window_surface_get(elm_win_wl_window_get(temp->window));
-             if (surface == temp_surface)
-               {
-                  return temp;
-               }
-          }
-     }
+   EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(mode, EFL_UTIL_ERROR_INVALID_PARAMETER);
 
-   return NULL;
+   e = evas_object_evas_get(window);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(e, EFL_UTIL_ERROR_INVALID_PARAMETER);
+
+   ee = ecore_evas_ecore_evas_get(e);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(ee, EFL_UTIL_ERROR_INVALID_PARAMETER);
+
+   id = ecore_evas_aux_hint_id_get(ee, "wm.policy.win.lcd.lock");
+   EINA_SAFETY_ON_TRUE_RETURN_VAL((id == -1), EFL_UTIL_ERROR_INVALID_PARAMETER);
+
+   str = ecore_evas_aux_hint_val_get(ee, id);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(str, EFL_UTIL_ERROR_INVALID_PARAMETER);
+
+   if (strncmp(str, "1", strlen("1")) == 0)
+     *mode = EFL_UTIL_SCREEN_MODE_ALWAYS_ON;
+   else
+     *mode = EFL_UTIL_SCREEN_MODE_DEFAULT;
+
+   return EFL_UTIL_ERROR_NONE;
 }
-#endif
 
-static notification_error_cb_info *
-_notification_error_cb_info_find(Evas_Object *window)
+API int
+efl_util_set_window_screen_mode_error_cb(Evas_Object *window,
+                                         efl_util_window_screen_mode_error_cb callback,
+                                         void *user_data)
 {
-   Eina_List *l;
-   notification_error_cb_info* temp;
+   Eina_Bool ret = EINA_FALSE;
 
-   EINA_LIST_FOREACH(_g_notification_error_cb_info_list, l, temp)
-     {
-        if (temp->window == window)
-          {
-             return temp;
-          }
-     }
+   EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EFL_UTIL_ERROR_INVALID_PARAMETER);
 
-   return NULL;
+   ret = _cb_info_add(window,
+                      (Efl_Util_Cb)callback,
+                      user_data,
+                      CBH_SCR_MODE);
+   if (!ret) return EFL_UTIL_ERROR_OUT_OF_MEMORY;
+
+#if X11
+   if (!_eflutil.atom.scr_mode)
+     _eflutil.atom.scr_mode = ecore_x_atom_get("_E_SCREEN_MODE_ACCESS_RESULT");
+#endif /* end of X11 */
+
+   return EFL_UTIL_ERROR_NONE;
 }
 
-static Eina_Bool
-_efl_util_notification_info_add(Evas_Object *window, efl_util_notification_window_level_error_cb callback, void *user_data)
+API int
+efl_util_unset_window_screen_mode_error_cb(Evas_Object *window)
 {
-   notification_error_cb_info* _err_info = _notification_error_cb_info_find(window);
+   Eina_Bool ret = EINA_FALSE;
 
-   if (_err_info)
-     {
-        _g_notification_error_cb_info_list = eina_list_remove(_g_notification_error_cb_info_list, _err_info);
-        free(_err_info);
-        _err_info = NULL;
-     }
+   EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
 
-   _err_info = (notification_error_cb_info*)calloc(1, sizeof(notification_error_cb_info));
-   if (!_err_info)
-     {
-        return EINA_FALSE;
-     }
-   _err_info->window = window;
-   _err_info->err_cb = callback;
-   _err_info->user_data = user_data;
+   ret = _cb_info_del_by_win(window, CBH_SCR_MODE);
+   if (!ret) return EFL_UTIL_ERROR_OUT_OF_MEMORY;
 
-   _g_notification_error_cb_info_list = eina_list_append(_g_notification_error_cb_info_list, _err_info);
+   return EFL_UTIL_ERROR_NONE;
+}
 
-   return EINA_TRUE;
+API int
+efl_util_input_initialize_generator(efl_util_input_device_type_e dev_type)
+{
+   return EFL_UTIL_ERROR_NONE;
 }
 
-static Eina_Bool
-_efl_util_notification_info_del(Evas_Object *window)
+API void
+efl_util_input_deinitialize_generator(void)
 {
-   notification_error_cb_info* _err_info = _notification_error_cb_info_find(window);
-   if (!_err_info)
-     {
-        return EINA_FALSE;
-     }
+   return;
+}
+
+API int
+efl_util_input_generate_key(const char *key_name,
+                            int pressed)
+{
+   return EFL_UTIL_ERROR_NONE;
+}
 
-   _g_notification_error_cb_info_list = eina_list_remove(_g_notification_error_cb_info_list, _err_info);
-   free(_err_info);
+API int
+efl_util_input_generate_touch(int idx,
+                              efl_util_input_touch_type_e touch_type,
+                              int x,
+                              int y)
+{
+   return EFL_UTIL_ERROR_NONE;
+}
 
-   return EINA_TRUE;
+API efl_util_screenshot_h
+efl_util_screenshot_initialize(int width,
+                               int height)
+{
+   return 0;
+}
+
+API tbm_surface_h
+efl_util_screenshot_take_tbm_surface(efl_util_screenshot_h screenshot)
+{
+   return 0;
+}
+
+API int
+efl_util_screenshot_deinitialize(efl_util_screenshot_h screenshot)
+{
+   return EFL_UTIL_ERROR_NONE;
 }