$(adaptor_ecore_wayland_dir)/render-surface-ecore-wl.cpp \
$(adaptor_ecore_wayland_dir)/virtual-keyboard-impl-ecore-wl.cpp \
$(adaptor_ecore_wayland_dir)/window-impl-ecore-wl.cpp \
- $(adaptor_ecore_wayland_dir)/window-render-surface-ecore-wl.cpp
+ $(adaptor_ecore_wayland_dir)/window-render-surface-ecore-wl.cpp \
+ $(adaptor_ecore_wayland_dir)/key-grab-ecore-wl.cpp
adaptor_ecore_wayland_tizen_common_internal_default_profile_src_files = \
$(adaptor_ecore_wayland_dir)/render-surface-factory-ecore-wl.cpp \
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ *
+ */
+
+// CLASS HEADER
+#include <key-grab.h>
+
+// EXTERNAL INCLUDES
+#include <Ecore_Wayland.h>
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+#include <window.h>
+#include <key-impl.h>
+
+#include <iostream>
+using namespace std;
+
+namespace Dali
+{
+
+namespace KeyGrab
+{
+
+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;
+ if( grabMode == TOPMOST )
+ {
+ wlGrabMode = ECORE_WL_WINDOW_KEYGRAB_TOPMOST;
+ }
+ else if( grabMode == SHARED )
+ {
+ wlGrabMode = ECORE_WL_WINDOW_KEYGRAB_SHARED;
+ }
+ else if( grabMode == OVERRIDE_EXCLUSIVE )
+ {
+ wlGrabMode = ECORE_WL_WINDOW_KEYGRAB_EXCLUSIVE;
+ }
+ else if( grabMode == EXCLUSIVE )
+ {
+ wlGrabMode = ECORE_WL_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
+ }
+ else
+ {
+ return false;
+ }
+
+ return ecore_wl_window_keygrab_set( AnyCast<Ecore_Wl_Window*>( window.GetNativeHandle() ),
+ Dali::Internal::Adaptor::KeyLookup::GetKeyName( daliKey ),
+ 0, 0, 0, wlGrabMode );
+}
+
+bool UngrabKey( Window window, Dali::KEY daliKey )
+{
+ return ecore_wl_window_keygrab_unset( AnyCast<Ecore_Wl_Window*>( window.GetNativeHandle() ),
+ Dali::Internal::Adaptor::KeyLookup::GetKeyName( daliKey ),
+ 0, 0 );
+}
+
+} // namespace KeyGrab
+
+} // namespace Dali
+
+
adaptor_tizen_internal_native_image_src_files = \
$(adaptor_tizen_dir)/native-image-source-impl-tizen.cpp
+
+public_api_adaptor_tizen_header_files = \
+ $(adaptor_tizen_dir)/key-grab.h
--- /dev/null
+#ifndef __DALI_KEY_GRAB_H__
+#define __DALI_KEY_GRAB_H__
+
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/public-api/common/dali-common.h>
+#include "key.h"
+
+namespace Dali
+{
+/**
+ * @addtogroup dali_adaptor_framework
+ * @{
+ */
+
+class Window;
+
+/**
+ * @brief Key grab functions.
+ * @SINCE_1_0.0
+ */
+namespace KeyGrab
+{
+
+/**
+ * @brief Grabs the key specfied by @a key for @a window only when @a window is the topmost window.
+ *
+ * This function can be used for following example scenarios:
+ * - Mobile - Using volume up/down as zoom up/down in camera apps.
+ *
+ * @SINCE_1_0.0
+ * @param[in] window The window to set
+ * @param[in] daliKey The key code to grab (defined in key.h)
+ * @return true if the grab succeeds.
+ */
+DALI_IMPORT_API bool GrabKeyTopmost( Window window, Dali::KEY daliKey );
+
+/**
+ * @brief Ungrabs the key specfied by @a key for @a window.
+ *
+ * @SINCE_1_0.0
+ * @param[in] window The window to set
+ * @param[in] daliKey The key code to ungrab (defined in key.h)
+ * @return true if the ungrab succeeds.
+ * @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 UngrabKeyTopmost( Window window, Dali::KEY daliKey );
+
+/**
+ * @brief Key grab mode for platform-level APIs.
+ * @SINCE_1_0.0
+ */
+enum KeyGrabMode
+{
+ TOPMOST = 0, ///< Grab a key only when on the top of the grabbing-window stack mode. @SINCE_1_0.0
+ SHARED, ///< Grab a key together with the other client window(s) mode. @SINCE_1_0.0
+ OVERRIDE_EXCLUSIVE, ///< Grab a key exclusively regardless of the grabbing-window's position on the window stack with the possibility of overriding the grab by the other client window mode. @SINCE_1_0.0
+ EXCLUSIVE ///< Grab a key exclusively regardless of the grabbing-window's position on the window stack mode. @SINCE_1_0.0
+};
+
+/**
+ * @PLATFORM
+ * @brief Grabs the key specfied by @a key for @a window in @a grabMode.
+ *
+ * @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_0.0
+ * @PRIVLEVEL_PLATFORM
+ * @PRIVILEGE_KEYGRAB
+ * @param[in] window The window to set
+ * @param[in] daliKey The key code to grab (defined in key.h)
+ * @param[in] grabMode The grab mode for the key
+ * @return true if the grab succeeds.
+ */
+DALI_IMPORT_API bool GrabKey( Window window, Dali::KEY daliKey, KeyGrabMode grabMode );
+
+/**
+ * @PLATFORM
+ * @brief Ungrabs the key specfied by @a key for @a window.
+ *
+ * @SINCE_1_0.0
+ * @PRIVLEVEL_PLATFORM
+ * @PRIVILEGE_KEYGRAB
+ * @param[in] window The window to set
+ * @param[in] daliKey The key code to ungrab (defined in key.h)
+ * @return true if the ungrab succeeds.
+ * @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 UngrabKey( Window window, Dali::KEY daliKey );
+
+} // namespace KeyGrab
+
+/**
+ * @}
+ */
+} // namespace Dali
+
+#endif // __DALI_KEY_GRAB_H__
{
}
-//} // Wayland
+
} // Adaptor
} // Internal
} // Dali
$(_adaptor_x11_internal_src_files) \
$(adaptor_x11_dir)/framework-x.cpp \
$(adaptor_x11_dir)/key-mapping-x.cpp \
- $(adaptor_x11_dir)/window-extensions.cpp
+ $(adaptor_x11_dir)/window-extensions.cpp \
+ $(adaptor_x11_dir)/key-grab-x.cpp
adaptor_x11_tv_internal_src_files = \
$(_adaptor_x11_internal_src_files) \
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ *
+ */
+
+// CLASS HEADER
+#include <key-grab.h>
+
+// EXTERNAL INCLUDES
+#include <Ecore_X.h>
+#include <utilX.h>
+
+// INTERNAL INCLUDES
+#include <window.h>
+#include <key-impl.h>
+#include <ecore-x-types.h>
+
+namespace Dali
+{
+
+namespace KeyGrab
+{
+
+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 )
+{
+ int xGrabMode;
+ if( grabMode == TOPMOST )
+ {
+ xGrabMode = TOP_POSITION_GRAB;
+ }
+ else if( grabMode == SHARED )
+ {
+ xGrabMode = SHARED_GRAB;
+ }
+ else if( grabMode == OVERRIDE_EXCLUSIVE )
+ {
+ xGrabMode = OR_EXCLUSIVE_GRAB;
+ }
+ else if( grabMode == EXCLUSIVE )
+ {
+ xGrabMode = EXCLUSIVE_GRAB;
+ }
+ else
+ {
+ return false;
+ }
+
+ int ret = utilx_grab_key ( static_cast<Display*>( ecore_x_display_get() ),
+ static_cast<XWindow>( AnyCast<Ecore_X_Window>( window.GetNativeHandle() ) ),
+ Dali::Internal::Adaptor::KeyLookup::GetKeyName( daliKey ), xGrabMode );
+ return ret==0;
+}
+
+bool UngrabKey( Window window, Dali::KEY daliKey )
+{
+ int ret = utilx_ungrab_key ( static_cast<Display*>( ecore_x_display_get() ),
+ static_cast<XWindow>( AnyCast<Ecore_X_Window>( window.GetNativeHandle() ) ),
+ Dali::Internal::Adaptor::KeyLookup::GetKeyName( daliKey ) );
+ return ret==0;
+}
+
+} // namespace KeyGrab
+
+} // namespace Dali
+
+
utc-Dali-Application.cpp
utc-Dali-FileLoader.cpp
utc-Dali-BitmapLoader.cpp
+ #utc-Dali-KeyGrab.cpp
)
LIST(APPEND TC_SOURCES
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <map>
+#include <string.h>
+#include <iostream>
+
+// CLASS HEADER
+#include <stdlib.h>
+#include <iostream>
+#include <dali.h>
+#include <dali-test-suite-utils.h>
+#include <dali/public-api/adaptor-framework/key-grab.h>
+
+extern int gArgc;
+extern char ** gArgv;
+
+using namespace Dali;
+
+void utc_dali_adaptor_keygrab_startup(void)
+{
+ test_return_value = TET_UNDEF;
+}
+
+void utc_dali_adaptor_keygrab_cleanup(void)
+{
+ test_return_value = TET_PASS;
+}
+
+// Copied from key-impl.cpp
+struct KeyLookup
+{
+ const char* keyName; ///< X string representation
+ const KEY daliKeyCode; ///< Dali Enum Representation
+ const bool deviceButton; ///< Whether the key is from a button on the device
+};
+
+// Taken from key-impl.cpp
+KeyLookup TestKeyLookupTable[]=
+{
+ { "Escape", DALI_KEY_ESCAPE, false }, // item not defined in utilX
+ { "Menu", DALI_KEY_MENU, false }, // item not defined in utilX
+
+ // Now the key names are used as literal string not defined symbols,
+ // since these definition in utilX.h is deprecated and we're guided not to use them
+ { "XF86Camera", DALI_KEY_CAMERA, false },
+ { "XF86Camera_Full", DALI_KEY_CONFIG, false },
+ { "XF86PowerOff", DALI_KEY_POWER, true },
+ { "Cancel", DALI_KEY_CANCEL, false },
+ { "XF86AudioPlay", DALI_KEY_PLAY_CD, false },
+ { "XF86AudioStop", DALI_KEY_STOP_CD, false },
+ { "XF86AudioPause", DALI_KEY_PAUSE_CD, false },
+ { "XF86AudioNext", DALI_KEY_NEXT_SONG, false },
+ { "XF86AudioPrev", DALI_KEY_PREVIOUS_SONG, false },
+ { "XF86AudioRewind", DALI_KEY_REWIND, false },
+ { "XF86AudioForward", DALI_KEY_FASTFORWARD, false },
+ { "XF86AudioMedia", DALI_KEY_MEDIA, false },
+ { "XF86AudioPlayPause", DALI_KEY_PLAY_PAUSE, false },
+ { "XF86AudioMute", DALI_KEY_MUTE, false },
+ { "XF86Menu", DALI_KEY_MENU, true },
+ { "XF86HomePage", DALI_KEY_HOMEPAGE, false },
+ { "XF86WWW", DALI_KEY_WEBPAGE, false },
+ { "XF86Mail", DALI_KEY_MAIL, false },
+ { "XF86ScreenSaver", DALI_KEY_SCREENSAVER, false },
+ { "XF86MonBrightnessUp", DALI_KEY_BRIGHTNESS_UP, false },
+ { "XF86MonBrightnessDown", DALI_KEY_BRIGHTNESS_DOWN, false },
+ { "XF86SoftKBD", DALI_KEY_SOFT_KBD, false },
+ { "XF86QuickPanel", DALI_KEY_QUICK_PANEL, false },
+ { "XF86TaskPane", DALI_KEY_TASK_SWITCH, false },
+ { "XF86Apps", DALI_KEY_APPS, false },
+ { "XF86Search", DALI_KEY_SEARCH, false },
+ { "XF86Voice", DALI_KEY_VOICE, false },
+ { "Hangul", DALI_KEY_LANGUAGE, false },
+ { "XF86AudioRaiseVolume", DALI_KEY_VOLUME_UP, true },
+ { "XF86AudioLowerVolume", DALI_KEY_VOLUME_DOWN, true },
+
+ { "BackSpace", DALI_KEY_BACKSPACE, false },
+ { "Left", DALI_KEY_CURSOR_LEFT, false },
+ { "Right", DALI_KEY_CURSOR_RIGHT, false }
+};
+
+const std::size_t KEY_LOOKUP_COUNT = (sizeof( TestKeyLookupTable))/ (sizeof(KeyLookup));
+
+enum TEST_TYPE
+{
+ GRAB_KEY_TOPMOST_P,
+ UNGRAB_KEY_TOPMOST_P
+};
+
+struct MyTestApp : public ConnectionTracker
+{
+ MyTestApp( Application& app, int type )
+ : mApplication( app ),
+ mTestType( type )
+ {
+ mApplication.InitSignal().Connect( this, &MyTestApp::OnInit );
+ }
+
+ void OnInit(Application& app)
+ {
+ mTimer = Timer::New( 500 );
+ mTimer.TickSignal().Connect( this, &MyTestApp::Tick );
+ mTimer.Start();
+
+ ExcuteTest();
+ }
+
+ bool Tick()
+ {
+ mTimer.Stop();
+ mApplication.Quit();
+ return true;
+ }
+
+ void ExcuteTest()
+ {
+ switch (mTestType)
+ {
+ case GRAB_KEY_TOPMOST_P:
+ TestGrabKeyTopmostP();
+ break;
+ case UNGRAB_KEY_TOPMOST_P:
+ TestUngrabKeyTopmostP();
+ break;
+ }
+ }
+
+ void TestGrabKeyTopmostP()
+ {
+ for ( std::size_t i = 0; i < KEY_LOOKUP_COUNT; ++i )
+ {
+ DALI_TEST_CHECK( KeyGrab::GrabKeyTopmost( mApplication.GetWindow(), TestKeyLookupTable[i].daliKeyCode ) );
+ }
+ }
+
+ void TestUngrabKeyTopmostP()
+ {
+ for ( std::size_t i = 0; i < KEY_LOOKUP_COUNT; ++i )
+ {
+ DALI_TEST_CHECK( KeyGrab::GrabKeyTopmost( mApplication.GetWindow(), TestKeyLookupTable[i].daliKeyCode ) );
+ DALI_TEST_CHECK( KeyGrab::UngrabKeyTopmost( mApplication.GetWindow(), TestKeyLookupTable[i].daliKeyCode ) );
+ }
+ }
+
+ // Data
+ Application& mApplication;
+ int mTestType;
+ Timer mTimer;
+};
+
+int UtcDaliKeyGrabGrabKeyTopmostP(void)
+{
+ Application application = Application::New( &gArgc, &gArgv );
+ MyTestApp testApp( application, GRAB_KEY_TOPMOST_P );
+ application.MainLoop();
+ END_TEST;
+}
+
+int UtcDaliKeyGrabUngrabKeyTopmostP(void)
+{
+ Application application = Application::New( &gArgc, &gArgv );
+ MyTestApp testApp( application, UNGRAB_KEY_TOPMOST_P );
+ application.MainLoop();
+ END_TEST;
+}
DALI_ADAPTOR_CFLAGS="$DALI_ADAPTOR_CFLAGS -DTPK_CURL_ENABLED "
fi
+PKG_CHECK_MODULES(UTILX, utilX, [ utilx_available=yes ], [ utilx_available=no ] )
+
DALI_ADAPTOR_CFLAGS="$DALI_ADAPTOR_CFLAGS -DPLATFORM_TIZEN"
AC_ARG_ENABLE(exportall,
$(LIBDRM_CFLAGS) \
$(LIBEXIF_CFLAGS) \
$(LIBCURL_CFLAGS) \
- $(TPKP_CURL_CFLAGS)
+ $(TPKP_CURL_CFLAGS) \
+ $(UTILX_CFLAGS)
# Todo, as soon as common repos are updated on build server remove this.
if !COMMON_PROFILE
$(LIBCURL_LIBS) \
$(HARFBUZZ_LIBS) \
$(TPKP_CURL_LIBS) \
+ $(UTILX_LIBS) \
-lgif \
-lpthread \
-lturbojpeg \
tizentextabstractiondevelapi_HEADERS = $(text_abstraction_header_files)
if !UBUNTU_PROFILE
+tizenadaptorframeworkpublicapi_HEADERS += $(public_api_adaptor_tizen_header_files)
if !WAYLAND
tizenadaptorframeworkdevelapi_HEADERS += $(devel_api_adaptor_tizen_x11_header_files)
DALI_ADAPTOR_CFLAGS="$DALI_ADAPTOR_CFLAGS -DTPK_CURL_ENABLED "
fi
+PKG_CHECK_MODULES(UTILX, utilX, [ utilx_available=yes ], [ utilx_available=no ] )
+
DALI_ADAPTOR_CFLAGS="$DALI_ADAPTOR_CFLAGS -DPLATFORM_TIZEN"
AC_ARG_ENABLE(exportall,