From: dongsug.song Date: Tue, 11 Oct 2016 00:54:27 +0000 (+0900) Subject: Add key grab list API X-Git-Tag: dali_1.2.46~6^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git;a=commitdiff_plain;h=ab728612e020139b7f996115032576dc47154335 Add key grab list API - User can set numbers of key grab at a same time. Change-Id: I286ec710e8260906173ef2cc0ebd55647b1a1d45 Signed-off-by: dongsug.song --- diff --git a/adaptors/ecore/wayland/key-grab-ecore-wl.cpp b/adaptors/ecore/wayland/key-grab-ecore-wl.cpp old mode 100644 new mode 100755 index afe3859..551000c --- a/adaptors/ecore/wayland/key-grab-ecore-wl.cpp +++ b/adaptors/ecore/wayland/key-grab-ecore-wl.cpp @@ -27,6 +27,8 @@ #include #include +#include + using namespace std; namespace Dali @@ -40,11 +42,13 @@ bool GrabKeyTopmost( Window window, Dali::KEY daliKey ) return GrabKey( window, daliKey, TOPMOST); } + bool UngrabKeyTopmost( Window window, Dali::KEY daliKey ) { return UngrabKey( window, daliKey ); } + bool GrabKey( Window window, Dali::KEY daliKey, KeyGrabMode grabMode ) { Ecore_Wl_Window_Keygrab_Mode wlGrabMode; @@ -58,11 +62,11 @@ bool GrabKey( Window window, Dali::KEY daliKey, KeyGrabMode grabMode ) } else if( grabMode == OVERRIDE_EXCLUSIVE ) { - wlGrabMode = ECORE_WL_WINDOW_KEYGRAB_EXCLUSIVE; + wlGrabMode = ECORE_WL_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE; } else if( grabMode == EXCLUSIVE ) { - wlGrabMode = ECORE_WL_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE; + wlGrabMode = ECORE_WL_WINDOW_KEYGRAB_EXCLUSIVE; } else { @@ -74,6 +78,7 @@ bool GrabKey( Window window, Dali::KEY daliKey, KeyGrabMode grabMode ) 0, 0, 0, wlGrabMode ); } + bool UngrabKey( Window window, Dali::KEY daliKey ) { return ecore_wl_window_keygrab_unset( AnyCast( window.GetNativeHandle() ), @@ -81,8 +86,152 @@ bool UngrabKey( Window window, Dali::KEY daliKey ) 0, 0 ); } + +bool GrabKeyList( Window window, const Dali::Vector& daliKeyVector, const Dali::Vector& grabModeVector, Dali::Vector& returnVector) +{ + const Dali::Vector::SizeType returnCount = returnVector.Count(); + const Dali::Vector::SizeType keyCount = daliKeyVector.Count(); + const Dali::Vector::SizeType keyGrabModeCount = grabModeVector.Count(); + + if( keyCount != keyGrabModeCount || keyCount != returnCount || keyCount == 0 ) + { + return false; + } + + eina_init(); + + Eina_List* keyList = NULL; + { + for( Dali::Vector::SizeType index = 0; index < keyCount; ++index ) + { + Ecore_Wl_Window_Keygrab_Info info; + info.key = const_cast(Dali::Internal::Adaptor::KeyLookup::GetKeyName( daliKeyVector[index] )); + + switch( grabModeVector[index] ) + { + case TOPMOST: + { + info.mode = ECORE_WL_WINDOW_KEYGRAB_TOPMOST; + break; + } + case SHARED: + { + info.mode = ECORE_WL_WINDOW_KEYGRAB_SHARED; + break; + } + case OVERRIDE_EXCLUSIVE: + { + info.mode = ECORE_WL_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE; + break; + } + case EXCLUSIVE: + { + info.mode = ECORE_WL_WINDOW_KEYGRAB_EXCLUSIVE; + break; + } + default: + { + info.mode = ECORE_WL_WINDOW_KEYGRAB_UNKNOWN; + break; + } + } + + keyList = eina_list_append( keyList, &info ); + } + } + + Eina_List* grabList = ecore_wl_window_keygrab_list_set( AnyCast( window.GetNativeHandle() ), keyList ); + + returnVector.Resize( keyCount, true ); + + Eina_List* l = NULL; + Eina_List* m = NULL; + void *listData = NULL; + void *data = NULL; + if( grabList != NULL ) + { + EINA_LIST_FOREACH( grabList, m, data ) + { + Dali::Vector::SizeType index = 0; + EINA_LIST_FOREACH( keyList, l, listData ) + { + if((static_cast(listData))->key == NULL) + { + DALI_LOG_ERROR("input key list has null data!"); + break; + } + + if( strcmp( static_cast(data), static_cast(listData)->key ) == 0 ) + { + returnVector[index] = false; + } + ++index; + } + } + } + + eina_list_free( keyList ); + eina_list_free( grabList ); + eina_shutdown(); + + return true; +} + +bool UngrabKeyList( Window window, const Dali::Vector& daliKeyVector, Dali::Vector& returnVector) +{ + const Dali::Vector::SizeType returnCount = returnVector.Count(); + const Dali::Vector::SizeType keyCount = daliKeyVector.Count(); + + if( keyCount != returnCount ||keyCount == 0 ) + { + return false; + } + + eina_init(); + + Eina_List* keyList = NULL; + { + for( Dali::Vector::SizeType index = 0; index < keyCount; ++index ) + { + Ecore_Wl_Window_Keygrab_Info info; + info.key = const_cast(Dali::Internal::Adaptor::KeyLookup::GetKeyName( daliKeyVector[index] )); + keyList = eina_list_append( keyList, &info ); + } + } + + Eina_List* ungrabList = ecore_wl_window_keygrab_list_unset( AnyCast( window.GetNativeHandle() ), keyList ); + + returnVector.Resize( keyCount, true ); + + Eina_List* l = NULL; + Eina_List* m = NULL; + void *listData = NULL; + void *data = NULL; + + if( ungrabList != NULL ) + { + EINA_LIST_FOREACH( ungrabList, m, data ) + { + Dali::Vector::SizeType index = 0; + EINA_LIST_FOREACH( keyList, l, listData ) + { + if( strcmp( static_cast(data), static_cast(listData)->key ) == 0 ) + { + returnVector[index] = false; + } + ++index; + } + } + } + + eina_list_free( keyList ); + eina_list_free( ungrabList ); + eina_shutdown(); + + return true; +} + } // namespace KeyGrab } // namespace Dali - diff --git a/adaptors/tizen/key-grab.h b/adaptors/tizen/key-grab.h old mode 100644 new mode 100755 index 43090f5..725c282 --- a/adaptors/tizen/key-grab.h +++ b/adaptors/tizen/key-grab.h @@ -20,6 +20,7 @@ // INTERNAL INCLUDES #include +#include #include "key.h" namespace Dali @@ -109,6 +110,45 @@ DALI_IMPORT_API bool GrabKey( Window window, Dali::KEY daliKey, KeyGrabMode grab */ DALI_IMPORT_API bool UngrabKey( Window window, Dali::KEY daliKey ); + +/** + * @PLATFORM + * @brief Grabs the list of keys specified by @Dali::Vector of keys for @a window in @Vector of grabModes. + * + * @details This function can be used for following example scenarios: + * - TV - A user might want to change the volume or channel of the background TV contents while focusing on the foregrund app. + * - Mobile - When a user presses Home key, the homescreen appears regardless of current foreground app. + * - Mobile - Using volume up/down as zoom up/down in camera apps. + * + * @SINCE_1_2.0 + * @PRIVLEVEL_PLATFORM + * @PRIVILEGE_KEYGRAB + * @param[in] window The window to set + * @param[in] daliKeyVector The Dali::Vector of key codes to grab (defined in key.h) + * @param[in] grabModeVector The Dali::Vector of grab modes for the keys + * @param[in] returnVector The Dali::Vector of return boolean values for the results of multiple grab succeeds/fails + * @return bool false when error occurs + */ +DALI_IMPORT_API bool GrabKeyList( Window window, const Dali::Vector& daliKeyVector, const Dali::Vector& grabModeVector, Dali::Vector& returnVector); + + +/** + * @PLATFORM + * @brief Ungrabs the list of keys specified by @Dali::Vector of keys for @a window. + * + * @SINCE_1_2.0 + * @PRIVLEVEL_PLATFORM + * @PRIVILEGE_KEYGRAB + * @param[in] window The window to set + * @param[in] daliKeyVector The Dali::Vector of key codes to ungrab (defined in key.h) + * @param[in] returnVector The Dali::Vector of return boolean values for the results of multiple ungrab succeeds/fails + * @return bool false when error occurs + * @note If this function is called between key down and up events of a grabbed key, + * an application doesn't receive the key up event. + */ +DALI_IMPORT_API bool UngrabKeyList( Window window, const Dali::Vector& daliKeyVector, Dali::Vector& returnVector); + + } // namespace KeyGrab /**