powerkey-popup : add home key callback in mobile 29/99829/2 accepted/tizen/3.0/common/20161125.101629 accepted/tizen/3.0/mobile/20161125.081037 accepted/tizen/3.0/tv/20161125.081043 accepted/tizen/3.0/wearable/20161125.081046 submit/tizen_3.0/20161124.101901
authorlokilee73 <changjoo.lee@samsung.com>
Thu, 24 Nov 2016 08:00:37 +0000 (17:00 +0900)
committerlokilee73 <changjoo.lee@samsung.com>
Thu, 24 Nov 2016 08:02:46 +0000 (17:02 +0900)
Change-Id: I5d96b368f2c37dd6e487dbffb19c4205b2ff5ec7
Signed-off-by: lokilee73 <changjoo.lee@samsung.com>
src/powerkey/powerkey-mobile.c

index 411d38f..0feb0a6 100755 (executable)
 #define DEVICED_OBJECT_PATH            "/Org/Tizen/System/DeviceD"
 #define DEVICED_INTERFACE_NAME DEVICED_BUS_NAME
 
+#define POWEROFF_KEY   "XF86PowerOff"
+#define BACK_KEY       "XF86Back"
+#define HOME_KEY       "XF86Home"
+
 int clicked_index = 0;
 
 static void pm_state_changed(keynode_t *key, void *data);
@@ -196,6 +200,23 @@ static Evas_Object* gl_image_get_cb(void *data, Evas_Object *obj, const char *pa
        }
 }
 
+Eina_Bool KeyUpCb(void *data, int type, void *event)
+{
+       Ecore_Event_Key *e = event;
+       const struct popup_ops *ops = data;
+
+       if (!strncmp(e->key, BACK_KEY, sizeof(BACK_KEY)) || !strncmp(e->key, HOME_KEY, sizeof(HOME_KEY)))
+       {
+               _D("HOME_KEY or BACK KEY is pressed");
+               if (ops)
+                       unload_simple_popup(ops);
+               terminate_if_no_popup();
+       }
+
+       // Let the event continue to other callbacks.
+       return ECORE_CALLBACK_PASS_ON;
+}
+
 int powerkey_list(bundle *b, const struct popup_ops *ops)
 {
        Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new();
@@ -229,8 +250,8 @@ int powerkey_list(bundle *b, const struct popup_ops *ops)
        box = elm_box_add(popup);
        evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
 
-       /* back key */
-       eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, event_back_key_up, (void*)ops);
+       /* back & home key */
+       ecore_event_handler_add(ECORE_EVENT_KEY_UP, KeyUpCb, (void*)ops);
 
        /* genlist */
        genlist = elm_genlist_add(box);