Grab the home key event 36/75636/1
authorsangwan.kwon <sangwan.kwon@samsung.com>
Tue, 21 Jun 2016 00:46:57 +0000 (09:46 +0900)
committersangwan.kwon <sangwan.kwon@samsung.com>
Tue, 21 Jun 2016 00:50:14 +0000 (09:50 +0900)
* If home key pressed, popup should exit.

Change-Id: I20b3fb316bd1930284565bc9f683f17a83dbedcd
Signed-off-by: sangwan.kwon <sangwan.kwon@samsung.com>
packaging/csr-framework.spec
src/framework/ui/popup/CMakeLists.txt
src/framework/ui/popup/popup.cpp
src/framework/ui/popup/popup.h

index 6126eef..c7088b1 100644 (file)
@@ -39,6 +39,7 @@ BuildRequires: pkgconfig(pkgmgr-info)
 BuildRequires: pkgconfig(libsmack)
 BuildRequires: pkgconfig(capi-appfw-application)
 BuildRequires: pkgconfig(elementary)
+BuildRequires: pkgconfig(efl-extension)
 BuildRequires: pkgconfig(icu-i18n)
 %if "%{?tizen_version}" == "3.0"
 BuildRequires: pkgconfig(cynara-client)
index a396536..6f8dd01 100644 (file)
@@ -20,6 +20,7 @@
 PKG_CHECK_MODULES(${TARGET_CSR_POPUP}_DEP
        REQUIRED
        elementary
+       efl-extension
        libsystemd-daemon
        vconf
        pkgmgr-info
index 0f78865..22ebb6f 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <package-info.h>
 #include <app_control.h>
+#include <efl_extension.h>
 
 namespace Csr {
 namespace Ui {
@@ -38,6 +39,8 @@ namespace {
        };
 
        const std::string DEFAULT_URL("https://developer.tizen.org/");
+       const std::string HOME_KEY("XF86Home");
+
 }
 
 Popup::Popup(int buttonN)
@@ -52,6 +55,9 @@ Popup::Popup(int buttonN)
        evas_object_size_hint_min_set(m_win, m_winW, m_winH / 4);
        setRotationToWin(m_win);
 
+       eext_win_keygrab_set(m_win, HOME_KEY.c_str());
+       ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, keyDownCb, NULL);
+
        // Set popup properties.
        m_popup = elm_popup_add(m_win);
        setDefaultProperties(m_popup);
@@ -265,5 +271,19 @@ void Popup::btnClickedCb(void *data, Evas_Object *, void *)
        response = *(reinterpret_cast<int *>(data));
        elm_exit();
 }
+
+
+Eina_Bool Popup::keyDownCb(void *, int , void *ev)
+{
+       DEBUG("Key down event caught.");
+       auto event = reinterpret_cast<Ecore_Event_Key *>(ev);
+
+       if(event->key == HOME_KEY)
+               elm_exit();
+
+       // Let the event continue to other callbacks.
+       return ECORE_CALLBACK_PASS_ON;
+}
+
 } // namespace Ui
 } // namespace Csr
index e977982..8e6518c 100644 (file)
@@ -78,6 +78,7 @@ public:
        static void btnClickedCb(void *data, Evas_Object *, void *);
        static void hypertextClickedCb(void *data, Evas_Object *, void *);
        static void rotationChangedCb(void *data, Evas_Object *, void *);
+       static Eina_Bool keyDownCb(void *, int, void *);
 
        std::vector<Evas_Object *> m_buttons;
        Evas_Object *m_hypertext;