$(adaptor_tizen_dir)/vsync-monitor-tizen.cpp \
$(adaptor_tizen_dir)/tilt-sensor-impl-tizen.cpp \
$(adaptor_tizen_dir)/tts-player-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) 2014 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
+{
+class Window;
+
+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.
+ *
+ * @note This function is only specified by Tizen.
+ * @param[in] window The window to set
+ * @param[in] dailKey The key code to grab (defined in key.h)
+ * @return true if the grab succeed.
+ */
+DALI_IMPORT_API bool GrabKeyTopmost( Window window, Dali::KEY daliKey );
+
+/**
+ * @brief Ungrabs the key specfied by @a key for @a window.
+ *
+ * @note This function is only specified by Tizen.
+ * @param[in] window The window to set
+ * @param[in] dailKey The key code to ungrab (defined in key.h)
+ * @return true if the ungrab succeed.
+ */
+DALI_IMPORT_API bool UngrabKeyTopmost( Window window, Dali::KEY daliKey );
+
+/**
+ * @brief Key grab mode for platform-level APIs.
+ */
+enum KeyGrabMode
+{
+ TOPMOST = 0, ///< Grab a key only when on the top of the grabbing-window stack mode.
+ SHARED, ///< Grab a key together with the other client window(s) mode.
+ 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.
+ EXCLUSIVE ///< Grab a key exclusively regardless of the grabbing-window's position on the window stack mode.
+};
+
+/**
+ * @brief Grabs the key specfied by @a key for @a window in @a grabMode.
+ *
+ * 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.
+ *
+ * @privlevel platform
+ * @note This function is only specified by Tizen.
+ * @param[in] window The window to set
+ * @param[in] dailKey The key code to grab (defined in key.h)
+ * @param[in] grabMode The grab mode for the key
+ * @return true if the grab succeed.
+ */
+DALI_IMPORT_API bool GrabKey( Window window, Dali::KEY daliKey, KeyGrabMode grabMode );
+
+/**
+ * @brief Ungrabs the key specfied by @a key for @a window.
+ *
+ * @privlevel platform
+ * @note This function is only specified by Tizen.
+ * @param[in] window The window to set
+ * @param[in] dailKey The key code to ungrab (defined in key.h)
+ * @return true if the ungrab succeed.
+ */
+DALI_IMPORT_API bool UngrabKey( Window window, Dali::KEY daliKey );
+
+} // namespace KeyGrab
+
+} // namespace Dali
+
+#endif // __DALI_KEY_GRAB_H__
$(adaptor_wayland_dir)/pixmap-render-surface-wl.cpp \
$(adaptor_wayland_dir)/ecore-wl-render-surface.cpp \
$(adaptor_wayland_dir)/window-render-surface-wl.cpp \
- $(adaptor_wayland_dir)/key-mapping-wl.cpp
+ $(adaptor_wayland_dir)/key-mapping-wl.cpp \
+ $(adaptor_wayland_dir)/key-grab-wl.cpp
adaptor_wayland_tizen_common_internal_default_profile_src_files = \
$(adaptor_wayland_dir)/ecore-wl-render-surface-factory.cpp \
--- /dev/null
+/*
+ * Copyright (c) 2014 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
+
+
mClientMessagehandler( NULL ),
mEcoreWindow( 0 )
{
+ // store ecore window handle
+ ECore::WindowRenderSurface* wlWindow( dynamic_cast< ECore::WindowRenderSurface * >( mWindow->mSurface ) );
+ if( wlWindow )
+ {
+ mEcoreWindow = wlWindow->GetWlWindow();
+ }
+ DALI_ASSERT_ALWAYS( mEcoreWindow != 0 && "There is no ecore wl window");
}
/**
$(adaptor_x11_dir)/accessibility-manager-impl-x.cpp \
$(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) 2014 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.h>
+#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
+
+
#!/bin/bash
-TEMP=`getopt -o rn --long rebuild,no-gen \
+TEMP=`getopt -o rn --long rebuild,no-gen,enable-profile: \
-n 'genmake' -- "$@"`
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
opt_rebuild=false
opt_generate=true
+enable_profile=""
while true ; do
case "$1" in
-r|--rebuild) opt_rebuild=true ; shift ;;
-n|--no-gen) opt_generate=false ; shift ;;
+ --enable-profile) enable_profile=$2 ; shift ;;
--) shift ; break ;;
*) shift ;; # Ignore
esac
(cd src/$1; ../../scripts/tcheadgen.sh tct-$1-core.h)
if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi
fi
- (cd build ; cmake .. -DMODULE=$1 ; make -j7 )
+ (cd build ; cmake .. -DMODULE=$1 -DENABLE_PROFILE=$enable_profile; make -j7 )
}
if [ -n "$1" ] ; then
+include(CMakeDependentOption)
+CMAKE_DEPENDENT_OPTION(UBUNTU_PROFILE "Ubuntu Profile" ON "ENABLE_PROFILE STREQUAL UBUNTU" OFF)
+
IF( DEFINED MODULE )
MESSAGE(STATUS "Building: ${CMAKE_CURRENT_SOURCE_DIR}/${MODULE}")
ADD_SUBDIRECTORY(${MODULE})
utc-Dali-Application.cpp
)
+if(NOT UBUNTU_PROFILE)
+LIST(APPEND TC_SOURCES
+ utc-Dali-KeyGrab.cpp
+)
+endif()
+
LIST(APPEND TC_SOURCES
dali-test-suite-utils/test-harness.cpp
dali-test-suite-utils/dali-test-suite-utils.cpp
--- /dev/null
+/*
+ * Copyright (c) 2014 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.h
+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
+};
+
+KeyLookup TestKeyLookupTable[]=
+{
+ { "XF86Camera", DALI_KEY_CAMERA, false },
+ { "XF86Camera_Full", DALI_KEY_CONFIG, false },
+ { "XF86PowerOff", DALI_KEY_POWER, true },
+ { "Cancel", DALI_KEY_CANCEL, 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 },
+ { "XF86HomePage", DALI_KEY_HOMEPAGE, false },
+ { "XF86WWW", DALI_KEY_WEBPAGE, 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 },
+};
+
+const std::size_t KEY_LOOKUP_COUNT = (sizeof( TestKeyLookupTable))/ (sizeof(KeyLookup));
+
+enum TEST_TYPE
+{
+ GRAB_KEY_P,
+ UNGRAB_KEY_P,
+ 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)
+ {
+ mStartTimer = Timer::New( 100 );
+ mStartTimer.TickSignal().Connect( this, &MyTestApp::StartTick );
+ mStartTimer.Start();
+
+ mTimer = Timer::New( 500 );
+ mTimer.TickSignal().Connect( this, &MyTestApp::Tick );
+ mTimer.Start();
+ }
+
+ bool StartTick()
+ {
+ mStartTimer.Stop();
+ ExcuteTest();
+ return true;
+ }
+
+ bool Tick()
+ {
+ mTimer.Stop();
+ mApplication.Quit();
+ return true;
+ }
+
+ void ExcuteTest()
+ {
+ switch (mTestType)
+ {
+ case GRAB_KEY_P:
+ TestGrabKeyP();
+ break;
+ case UNGRAB_KEY_P:
+ TestUngrabKeyP();
+ break;
+ case UNGRAB_KEY_N:
+ TestUngrabKeyN();
+ break;
+ case GRAB_KEY_TOPMOST_P:
+ TestGrabKeyTopmostP();
+ break;
+ case UNGRAB_KEY_TOPMOST_P:
+ TestUngrabKeyTopmostP();
+ break;
+ }
+ }
+
+ void TestGrabKeyP()
+ {
+ for ( std::size_t i = 0; i < KEY_LOOKUP_COUNT; ++i )
+ {
+ DALI_TEST_CHECK( KeyGrab::GrabKey( mApplication.GetWindow(), TestKeyLookupTable[i].daliKeyCode, KeyGrab::TOPMOST ) );
+ DALI_TEST_CHECK( KeyGrab::GrabKey( mApplication.GetWindow(), TestKeyLookupTable[i].daliKeyCode, KeyGrab::SHARED ) );
+ }
+ }
+
+ void TestUngrabKeyP()
+ {
+ for ( std::size_t i = 0; i < KEY_LOOKUP_COUNT; ++i )
+ {
+ DALI_TEST_CHECK( KeyGrab::GrabKey( mApplication.GetWindow(), TestKeyLookupTable[i].daliKeyCode, KeyGrab::TOPMOST ) );
+ DALI_TEST_CHECK( KeyGrab::UngrabKey( mApplication.GetWindow(), TestKeyLookupTable[i].daliKeyCode ) );
+ }
+ }
+
+ 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, mStartTimer;
+};
+
+int UtcDaliKeyGrabGrabKeyP(void)
+{
+ Application application = Application::New( &gArgc, &gArgv );
+ MyTestApp testApp( application, GRAB_KEY_P );
+ application.MainLoop();
+ END_TEST;
+}
+
+int UtcDaliKeyGrabUngrabKeyP(void)
+{
+ Application application = Application::New( &gArgc, &gArgv );
+ MyTestApp testApp( application, UNGRAB_KEY_P );
+ application.MainLoop();
+ END_TEST;
+}
+
+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;
+}
+
libdali_adaptor_la_LIBADD += -ljpeg
endif
+if !UBUNTU_PROFILE
+if WAYLAND
+else
+# X11
+libdali_adaptor_la_CXXFLAGS += $(UTILX_CFLAGS)
+libdali_adaptor_la_LIBADD += $(UTILX_LIBS)
+endif
+endif
+
tizenadaptorpublicapidir = $(devincludepath)/dali/public-api
tizenadaptorpublicapi_HEADERS = $(public_api_header_files)
tizentextabstractiondevelapi_HEADERS = $(text_abstraction_header_files)
if !UBUNTU_PROFILE
+tizenadaptorframeworkpublicapi_HEADERS += $(public_api_adaptor_tizen_header_files)
if !WAYLAND
tizenadaptorframeworkpublicapi_HEADERS += $(public_api_adaptor_tizen_x11_header_files)
PKG_CHECK_MODULES(VCONF, vconf)
PKG_CHECK_MODULES(CAPI_SYSTEM_SYSTEM_SETTINGS, capi-system-system-settings)
+if test "x$enable_wayland" != "xyes"; then
+PKG_CHECK_MODULES(UTILX, utilX)
+fi
+
if test "x$with_over_tizen_2_2" = "xyes"; then
PKG_CHECK_MODULES(CAPI_SYSTEM_INFO, capi-system-info)
fi