Add key handler for esc of keyboard / merge latest code using private
authorHyungdeuk Kim <hd3.kim@samsung.com>
Tue, 13 Aug 2013 04:28:48 +0000 (13:28 +0900)
committerHyungdeuk Kim <hd3.kim@samsung.com>
Tue, 13 Aug 2013 04:38:35 +0000 (13:38 +0900)
Change-Id: Ida24ade6a65257a965c9954ac086abc89820dfc9

packaging/syspopup.spec
syspopup/syspopup.c
syspopup/syspopup_efl.c

index 9a8046c..407a641 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       syspopup
 Summary:    syspopup package
-Version:    0.0.98
+Version:    0.0.99
 Release:    1
 Group:      System/Libraries
 License:    Apache License, Version 2.0
@@ -115,6 +115,9 @@ touch %{buildroot}%{_datadir}/popup_noti_term
 /usr/share/packages/org.tizen.syspopup-app.xml
 
 %changelog
+* Tue Aug 13 2013 - Hyungdeuk Kim <hd3.kim@samsung.com>
+- Add key handler for esc of keyboard
+
 * Fri Jun 21 2013 - Hyungdeuk Kim <hd3.kim@samsung.com>
 - Change end key term info of wifi-qs
 
index 295a94c..0bbca22 100755 (executable)
@@ -28,6 +28,8 @@
 #include <X11/Xatom.h>
 #include <X11/Xutil.h>
 
+#define WIN_PROP_NAME "SYSTEM_POPUP"
+
 static int __utilx_ss_get_window_property(Display *dpy, Window win, Atom atom,
                                          Atom type, unsigned int *val,
                                          unsigned int len)
@@ -228,17 +230,21 @@ int X_syspopup_rotation_get(Display *dpy, Window win)
        return -1;
 }
 
-int X_syspopup_process_keydown(int id, const char *keyname)
+int X_syspopup_process_keypress(int id, const char *keyname)
 {
        Display *d;
        Window win;
        syspopup *sp = NULL;
 
-       if (strcmp(keyname, KEY_END) == 0) {
+       _D("key press - %s", keyname);
+
+       if ((strcmp(keyname, KEY_END) == 0) ||
+               (strcmp(keyname, "Escape") == 0))
+       {
                d = XOpenDisplay(NULL);
                sp = _syspopup_find_by_id(id);
                if (sp != NULL) {
-                       _D("find key down - %s", sp->name);
+                       _D("find - %s / endkey_act - %d", sp->name, sp->endkey_act);
                        if (sp->endkey_act == SYSPOPUP_KEYEND_TERM) {
                                if (sp->def_term_fn != NULL)
                                        sp->def_term_fn(sp->dupped_bundle,
@@ -253,7 +259,6 @@ int X_syspopup_process_keydown(int id, const char *keyname)
                                win = (Window) sp->internal_data;
                                XUnmapWindow(d, win);
                        }
-
                } else {
                        _E("no find key down");
                }
@@ -284,6 +289,17 @@ int X_syspopup_process_rotate(int id)
 
        return 0;
 }
+#else
+static void __efl_rotation_set(Evas_Object* win, Ecore_X_Window xwin)
+{
+       ecore_x_icccm_name_class_set(xwin, WIN_PROP_NAME, WIN_PROP_NAME);
+       if (elm_win_wm_rotation_supported_get(win)) {
+               int rots[4] = { 0, 90, 180, 270 };
+               elm_win_wm_rotation_available_rotations_set(win, &rots, 4);
+       } else {
+               _E("win rotation no supported");
+       }
+}
 #endif
 
 int X_make_syspopup(bundle *b, Display *dpy, Window xwin, void *win,
@@ -321,7 +337,7 @@ int X_make_syspopup(bundle *b, Display *dpy, Window xwin, void *win,
                _syspopup_info_free(info);
                return -1;
        }
-       
+
        sp->name = strdup(info->name);
        sp->def_term_fn = handler->def_term_fn;
        sp->def_timeout_fn = handler->def_timeout_fn;
@@ -347,7 +363,11 @@ int X_make_syspopup(bundle *b, Display *dpy, Window xwin, void *win,
                __X_syspopup_disable_focus (dpy, xwin);
        }
 
+#ifdef ROTATE_USING_X_CLIENT
        rotate_func(dpy, xwin, sp);
+#else
+       __efl_rotation_set((Evas_Object* )win,(Ecore_X_Window)xwin);
+#endif
 
        if (is_unviewable == 1) {
                XMapWindow(dpy, xwin);
@@ -362,8 +382,8 @@ int X_make_syspopup(bundle *b, Display *dpy, Window xwin, void *win,
  * @brief       This API reset created the system popup's properties
  *
  *             This API reset created the system popup's properties based on
- *             system popup information DB after extracting popup name from 
- *             given bundle system popup properties to be reset : timeout, 
+ *             system popup information DB after extracting popup name from
+ *             given bundle system popup properties to be reset : timeout,
  *             default action type, ....
  *
  * @param[in]   b              bundle received by app_reset handler
@@ -377,7 +397,6 @@ int X_syspopup_reset(bundle *b)
        const char *popup_name;
        syspopup_info_t *info;
        syspopup *sp = NULL;
-       int (*rotate_func) (Display *, Window, syspopup *);
 
        popup_name = _syspopup_get_name_from_bundle(b);
        if (popup_name == NULL)
@@ -406,9 +425,14 @@ int X_syspopup_reset(bundle *b)
                if (info->focus == 1) {
                        __X_syspopup_disable_focus (d, win);
                }
+
+#ifdef ROTATE_USING_X_CLIENT
+               int (*rotate_func) (Display *, Window, syspopup *);
                rotate_func = sp->rotate_cb;
                rotate_func(d, win, sp);
-
+#else
+               __efl_rotation_set((Evas_Object *)sp->win, (Ecore_X_Window)win);
+#endif
                XMapWindow(d, win);
                /*XMapRaised(d,win);*/
                XCloseDisplay(d);
index 39d9c7b..163fab7 100755 (executable)
@@ -30,9 +30,7 @@
 #include <Ecore_Input.h>
 #include <Ecore_X.h>
 
-#define WIN_PROP_NAME "SYSTEM_POPUP"
-
-static Eina_Bool __x_keydown_cb(void *data, int type, void *event)
+static Eina_Bool __x_keypress_cb(void *data, int type, void *event)
 {
        int id = (int)data;
        Ecore_Event_Key *ev = event;
@@ -40,9 +38,9 @@ static Eina_Bool __x_keydown_cb(void *data, int type, void *event)
        if (ev == NULL)
                return 0;
 
-       X_syspopup_process_keydown(id, ev->keyname);
+       X_syspopup_process_keypress(id, ev->keyname);
 
-       return ECORE_CALLBACK_DONE;
+       return ECORE_CALLBACK_RENEW;
 }
 
 #ifdef ROTATE_USING_X_CLIENT
@@ -119,22 +117,14 @@ API int syspopup_create(bundle *b, syspopup_handler *handler,
                        return -1;
                }
 
-               ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, __x_keydown_cb,
-                                       (void *)id);
-
                /* X_syspopup_core should process 2 events */
                /* First, rotate event */
-               /* Second, keydown event */
+               /* Second, keypress event */
+               utilx_grab_key(dpy, xwin, KEY_BACK, TOP_POSITION_GRAB);
+               ecore_event_handler_add(ECORE_EVENT_KEY_UP, __x_keypress_cb, (void *)id);
+
 #ifdef ROTATE_USING_X_CLIENT
                ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE,__x_rotate_cb, (void *)id);
-#else
-               ecore_x_icccm_name_class_set(xwin, WIN_PROP_NAME, WIN_PROP_NAME);
-               if (elm_win_wm_rotation_supported_get(parent)) {
-                       int rots[4] = { 0, 90, 180, 270 };
-                       elm_win_wm_rotation_available_rotations_set(parent, &rots, 4);
-               } else {
-                       _E("win rotation no supported");
-               }
 #endif
        }