summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2016-08-17 19:39:10 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2016-08-26 10:18:00 +0900
commitc1e7589c14af9561273d7fca02e7e8ab15b831d1 (patch)
treec7d64ead0c9f9e5835503540c4a23018449f678a /src
parent405680e836eb47d7dd8f59a4761386e7a80d9244 (diff)
evas events: Switch key up/down event to new eo type
Diffstat (limited to 'src')
-rw-r--r--src/lib/efl/interfaces/efl_common_internal.h2
-rw-r--r--src/lib/evas/canvas/efl_event_key.c1
-rw-r--r--src/lib/evas/canvas/evas_events.c213
3 files changed, 85 insertions, 131 deletions
diff --git a/src/lib/efl/interfaces/efl_common_internal.h b/src/lib/efl/interfaces/efl_common_internal.h
index b095b90..5063fe8 100644
--- a/src/lib/efl/interfaces/efl_common_internal.h
+++ b/src/lib/efl/interfaces/efl_common_internal.h
@@ -44,7 +44,6 @@ struct _Efl_Event_Pointer_Data
44 Efl_Pointer_Flags button_flags; 44 Efl_Pointer_Flags button_flags;
45 Efl_Event_Flags event_flags; 45 Efl_Event_Flags event_flags;
46 void *data; /* evas data - whatever that is */ 46 void *data; /* evas data - whatever that is */
47 const Efl_Event_Description *event_desc;
48 Eina_Bool window_pos; /* true if positions are window-relative 47 Eina_Bool window_pos; /* true if positions are window-relative
49 (see input vs. feed: this is "input") */ 48 (see input vs. feed: this is "input") */
50 Evas_Modifier *modifiers; 49 Evas_Modifier *modifiers;
@@ -76,6 +75,7 @@ struct _Efl_Event_Key_Data
76 Eina_Bool evas_done : 1; /* set by evas */ 75 Eina_Bool evas_done : 1; /* set by evas */
77 Eina_Bool fake : 1; 76 Eina_Bool fake : 1;
78 Eina_Bool win_fed : 1; 77 Eina_Bool win_fed : 1;
78 Eina_Bool no_stringshare : 1;
79}; 79};
80 80
81struct _Efl_Input_Device_Data 81struct _Efl_Input_Device_Data
diff --git a/src/lib/evas/canvas/efl_event_key.c b/src/lib/evas/canvas/efl_event_key.c
index d5de747..3642b33 100644
--- a/src/lib/evas/canvas/efl_event_key.c
+++ b/src/lib/evas/canvas/efl_event_key.c
@@ -80,6 +80,7 @@ static inline void
80_efl_event_key_free(Efl_Event_Key_Data *pd) 80_efl_event_key_free(Efl_Event_Key_Data *pd)
81{ 81{
82 free(pd->legacy); 82 free(pd->legacy);
83 if (pd->no_stringshare) return;
83 eina_stringshare_del(pd->key); 84 eina_stringshare_del(pd->key);
84 eina_stringshare_del(pd->keyname); 85 eina_stringshare_del(pd->keyname);
85 eina_stringshare_del(pd->string); 86 eina_stringshare_del(pd->string);
diff --git a/src/lib/evas/canvas/evas_events.c b/src/lib/evas/canvas/evas_events.c
index acd2b2e..6ea5846 100644
--- a/src/lib/evas/canvas/evas_events.c
+++ b/src/lib/evas/canvas/evas_events.c
@@ -2837,54 +2837,23 @@ evas_event_feed_multi_move(Eo *eo_e, int d, int x, int y, double rad, double rad
2837} 2837}
2838 2838
2839static void 2839static void
2840_canvas_event_feed_key_down_internal(Eo *eo_e, 2840_canvas_event_feed_key_down_internal(Evas_Public_Data *e, Efl_Event_Key_Data *ev)
2841 void *_pd,
2842 const char *keyname,
2843 const char *key,
2844 const char *string,
2845 const char *compose,
2846 unsigned int timestamp,
2847 const void *data,
2848 unsigned int keycode,
2849 Efl_Event_Key_Data *ke)
2850{ 2841{
2851 void *efl_event_info = NULL; 2842 Eina_Bool exclusive = EINA_FALSE;
2852 Evas_Public_Data *e = _pd;
2853 int event_id = 0; 2843 int event_id = 0;
2854 2844
2855 if (!keyname) return; 2845 if (!e || !ev) return;
2856 if (e->is_frozen) return; 2846 if (e->is_frozen) return;
2857 e->last_timestamp = timestamp; 2847 e->last_timestamp = ev->timestamp;
2858 _evas_walk(e); 2848 _evas_walk(e);
2859 2849
2860 Evas_Event_Key_Down ev;
2861 Eina_Bool exclusive;
2862
2863 _evas_object_event_new(); 2850 _evas_object_event_new();
2864
2865 event_id = _evas_event_counter; 2851 event_id = _evas_event_counter;
2866 exclusive = EINA_FALSE;
2867 ev.keyname = (char *)keyname;
2868 ev.data = (void *)data;
2869 ev.modifiers = &(e->modifiers);
2870 ev.locks = &(e->locks);
2871 ev.key = key;
2872 ev.string = string;
2873 ev.compose = compose;
2874 ev.timestamp = timestamp;
2875 ev.event_flags = e->default_event_flags;
2876 ev.dev = _evas_device_top_get(eo_e);
2877 ev.keycode = keycode;
2878 if (ev.dev) efl_ref(ev.dev);
2879 2852
2880 if (ke) 2853 ev->modifiers = &(e->modifiers);
2881 { 2854 ev->locks = &(e->locks);
2882 ke->device = ev.dev; 2855 ev->event_flags = e->default_event_flags;
2883 ke->event_flags = ev.event_flags; 2856 if (ev->device) efl_ref(ev->device);
2884 ke->modifiers = ev.modifiers;
2885 ke->locks = ev.locks;
2886 efl_event_info = ke->eo;
2887 }
2888 2857
2889 if (e->grabs) 2858 if (e->grabs)
2890 { 2859 {
@@ -2904,7 +2873,7 @@ _canvas_event_feed_key_down_internal(Eo *eo_e,
2904 if (!g->is_active) continue; 2873 if (!g->is_active) continue;
2905 if (((e->modifiers.mask & g->modifiers) || 2874 if (((e->modifiers.mask & g->modifiers) ||
2906 (g->modifiers == e->modifiers.mask)) && 2875 (g->modifiers == e->modifiers.mask)) &&
2907 (!strcmp(keyname, g->keyname))) 2876 (!strcmp(ev->keyname, g->keyname)))
2908 { 2877 {
2909 if (!(e->modifiers.mask & g->not_modifiers)) 2878 if (!(e->modifiers.mask & g->not_modifiers))
2910 { 2879 {
@@ -2912,8 +2881,8 @@ _canvas_event_feed_key_down_internal(Eo *eo_e,
2912 if (!e->is_frozen && 2881 if (!e->is_frozen &&
2913 !evas_event_freezes_through(g->object, object_obj)) 2882 !evas_event_freezes_through(g->object, object_obj))
2914 { 2883 {
2915 EV_CALL(g->object, object_obj, EVAS_CALLBACK_KEY_DOWN, 2884 evas_object_event_callback_call(g->object, object_obj, EVAS_CALLBACK_KEY_DOWN, NULL,
2916 &ev, event_id, efl_event_info, NULL); 2885 event_id, EFL_EVENT_KEY_DOWN, ev->eo);
2917 } 2886 }
2918 if (g->exclusive) exclusive = EINA_TRUE; 2887 if (g->exclusive) exclusive = EINA_TRUE;
2919 } 2888 }
@@ -2940,79 +2909,39 @@ _canvas_event_feed_key_down_internal(Eo *eo_e,
2940 } 2909 }
2941 } 2910 }
2942 } 2911 }
2943 if (!ke) EV_DEL(efl_event_info);
2944 if ((e->focused) && (!exclusive)) 2912 if ((e->focused) && (!exclusive))
2945 { 2913 {
2946 Evas_Object_Protected_Data *focused_obj = efl_data_scope_get(e->focused, EFL_CANVAS_OBJECT_CLASS); 2914 Evas_Object_Protected_Data *focused_obj = efl_data_scope_get(e->focused, EFL_CANVAS_OBJECT_CLASS);
2947 if (!e->is_frozen && !evas_event_freezes_through(e->focused, focused_obj)) 2915 if (!e->is_frozen && !evas_event_freezes_through(e->focused, focused_obj))
2948 { 2916 {
2949 EV_CALL(e->focused, focused_obj, EVAS_CALLBACK_KEY_DOWN, 2917 evas_object_event_callback_call(e->focused, focused_obj, EVAS_CALLBACK_KEY_DOWN, NULL,
2950 &ev, event_id, efl_event_info, NULL); 2918 event_id, EFL_EVENT_KEY_DOWN, ev->eo);
2951 } 2919 }
2952 } 2920 }
2953 _evas_post_event_callback_call(eo_e, e); 2921 _evas_post_event_callback_call(e->evas, e);
2954 if (ev.dev) efl_unref(ev.dev);
2955 _evas_unwalk(e); 2922 _evas_unwalk(e);
2956 2923
2957 if (ke) 2924 if (ev->device) efl_unref(ev->device);
2958 {
2959 ke->device = NULL;
2960 ke->event_flags = 0;
2961 ke->modifiers = NULL;
2962 ke->locks = NULL;
2963 }
2964 else
2965 EV_DEL(efl_event_info);
2966} 2925}
2967 2926
2968static void 2927static void
2969_canvas_event_feed_key_up_internal(Eo *eo_e, 2928_canvas_event_feed_key_up_internal(Evas_Public_Data *e, Efl_Event_Key_Data *ev)
2970 void *_pd, 2929{
2971 const char *keyname, 2930 Eina_Bool exclusive = EINA_FALSE;
2972 const char *key,
2973 const char *string,
2974 const char *compose,
2975 unsigned int timestamp,
2976 const void *data,
2977 unsigned int keycode,
2978 Efl_Event_Key_Data *ke)
2979{
2980 void *efl_event_info = NULL;
2981 Evas_Public_Data *e = _pd;
2982 int event_id = 0; 2931 int event_id = 0;
2983 if (!keyname) return; 2932
2933 if (!e || !ev) return;
2984 if (e->is_frozen) return; 2934 if (e->is_frozen) return;
2985 e->last_timestamp = timestamp; 2935 e->last_timestamp = ev->timestamp;
2986 _evas_walk(e); 2936 _evas_walk(e);
2987 2937
2988 Evas_Event_Key_Up ev;
2989 Eina_Bool exclusive;
2990
2991 _evas_object_event_new(); 2938 _evas_object_event_new();
2992
2993 event_id = _evas_event_counter; 2939 event_id = _evas_event_counter;
2994 exclusive = EINA_FALSE;
2995 ev.keyname = (char *)keyname;
2996 ev.data = (void *)data;
2997 ev.modifiers = &(e->modifiers);
2998 ev.locks = &(e->locks);
2999 ev.key = key;
3000 ev.string = string;
3001 ev.compose = compose;
3002 ev.timestamp = timestamp;
3003 ev.event_flags = e->default_event_flags;
3004 ev.dev = _evas_device_top_get(eo_e);
3005 ev.keycode = keycode;
3006 if (ev.dev) efl_ref(ev.dev);
3007 2940
3008 if (ke) 2941 ev->modifiers = &(e->modifiers);
3009 { 2942 ev->locks = &(e->locks);
3010 ke->device = ev.dev; 2943 ev->event_flags = e->default_event_flags;
3011 ke->event_flags = ev.event_flags; 2944 if (ev->device) efl_ref(ev->device);
3012 ke->modifiers = ev.modifiers;
3013 ke->locks = ev.locks;
3014 efl_event_info = ke->eo;
3015 }
3016 2945
3017 if (e->grabs) 2946 if (e->grabs)
3018 { 2947 {
@@ -3033,15 +2962,15 @@ _canvas_event_feed_key_up_internal(Eo *eo_e,
3033 if (((e->modifiers.mask & g->modifiers) || 2962 if (((e->modifiers.mask & g->modifiers) ||
3034 (g->modifiers == e->modifiers.mask)) && 2963 (g->modifiers == e->modifiers.mask)) &&
3035 (!(e->modifiers.mask & g->not_modifiers)) && 2964 (!(e->modifiers.mask & g->not_modifiers)) &&
3036 (!strcmp(keyname, g->keyname))) 2965 (!strcmp(ev->keyname, g->keyname)))
3037 { 2966 {
3038 Evas_Object_Protected_Data *object_obj = efl_data_scope_get(g->object, EFL_CANVAS_OBJECT_CLASS); 2967 Evas_Object_Protected_Data *object_obj = efl_data_scope_get(g->object, EFL_CANVAS_OBJECT_CLASS);
3039 if (!e->is_frozen && 2968 if (!e->is_frozen &&
3040 !evas_event_freezes_through(g->object, object_obj)) 2969 !evas_event_freezes_through(g->object, object_obj))
3041 { 2970 {
3042 evas_object_event_callback_call 2971 evas_object_event_callback_call
3043 (g->object, object_obj, EVAS_CALLBACK_KEY_UP, 2972 (g->object, object_obj, EVAS_CALLBACK_KEY_UP, NULL,
3044 &ev, event_id, EFL_EVENT_KEY_UP, efl_event_info); 2973 event_id, EFL_EVENT_KEY_UP, ev->eo);
3045 } 2974 }
3046 if (g->exclusive) exclusive = EINA_TRUE; 2975 if (g->exclusive) exclusive = EINA_TRUE;
3047 } 2976 }
@@ -3075,53 +3004,79 @@ _canvas_event_feed_key_up_internal(Eo *eo_e,
3075 if (!e->is_frozen && !evas_event_freezes_through(e->focused, focused_obj)) 3004 if (!e->is_frozen && !evas_event_freezes_through(e->focused, focused_obj))
3076 { 3005 {
3077 evas_object_event_callback_call 3006 evas_object_event_callback_call
3078 (e->focused, focused_obj, EVAS_CALLBACK_KEY_UP, 3007 (e->focused, focused_obj, EVAS_CALLBACK_KEY_UP, NULL,
3079 &ev, event_id, EFL_EVENT_KEY_UP, efl_event_info); 3008 event_id, EFL_EVENT_KEY_UP, ev->eo);
3080 } 3009 }
3081 } 3010 }
3082 _evas_post_event_callback_call(eo_e, e); 3011 _evas_post_event_callback_call(e->evas, e);
3083 if (ev.dev) efl_unref(ev.dev);
3084 _evas_unwalk(e); 3012 _evas_unwalk(e);
3085 3013
3086 if (ke) 3014 if (ev->device) efl_unref(ev->device);
3087 { 3015}
3088 ke->device = NULL; 3016
3089 ke->event_flags = 0; 3017static void
3090 ke->modifiers = NULL; 3018_canvas_event_feed_key_legacy(Eo *eo_e, Evas_Public_Data *e,
3091 ke->locks = NULL; 3019 const char *keyname, const char *key,
3092 } 3020 const char *string, const char *compose,
3021 unsigned int timestamp, const void *data,
3022 unsigned int keycode, Eina_Bool down)
3023{
3024 Efl_Event_Key_Data *ev = NULL;
3025 Efl_Event_Key *evt;
3026
3027 if (!keyname) return;
3028
3029 evt = efl_event_instance_get(EFL_EVENT_KEY_CLASS, eo_e, (void **) &ev);
3030 if (!ev) return;
3031
3032 ev->keyname = (char *) keyname;
3033 ev->data = (void *) data;
3034 ev->key = key;
3035 ev->string = string;
3036 ev->compose = compose;
3037 ev->timestamp = timestamp;
3038 ev->keycode = keycode;
3039 ev->no_stringshare = EINA_TRUE;
3040 ev->device = _evas_device_top_get(e->evas);
3041
3042 if (down)
3043 _canvas_event_feed_key_down_internal(e, ev);
3044 else
3045 _canvas_event_feed_key_up_internal(e, ev);
3046
3047 efl_del(evt);
3093} 3048}
3094 3049
3095EAPI void 3050EAPI void
3096evas_event_feed_key_down(Eo *eo_e, const char *keyname, const char *key, const char *string, const char *compose, unsigned int timestamp, const void *data) 3051evas_event_feed_key_down(Eo *eo_e, const char *keyname, const char *key, const char *string, const char *compose, unsigned int timestamp, const void *data)
3097{ 3052{
3098 Evas_Public_Data *e = efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS); 3053 Evas_Public_Data *e = efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS);
3099 _canvas_event_feed_key_down_internal(eo_e, e, keyname, key, string, 3054 _canvas_event_feed_key_legacy(eo_e, e, keyname, key, string,
3100 compose, timestamp, data, 0, NULL); 3055 compose, timestamp, data, 0, 1);
3101} 3056}
3102 3057
3103EAPI void 3058EAPI void
3104evas_event_feed_key_up(Eo *eo_e, const char *keyname, const char *key, const char *string, const char *compose, unsigned int timestamp, const void *data) 3059evas_event_feed_key_up(Eo *eo_e, const char *keyname, const char *key, const char *string, const char *compose, unsigned int timestamp, const void *data)
3105{ 3060{
3106 Evas_Public_Data *e = efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS); 3061 Evas_Public_Data *e = efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS);
3107 _canvas_event_feed_key_up_internal(eo_e, e, keyname, key, string, 3062 _canvas_event_feed_key_legacy(eo_e, e, keyname, key, string,
3108 compose, timestamp, data, 0, NULL); 3063 compose, timestamp, data, 0, 0);
3109} 3064}
3110 3065
3111EAPI void 3066EAPI void
3112evas_event_feed_key_down_with_keycode(Eo *eo_e, const char *keyname, const char *key, const char *string, const char *compose, unsigned int timestamp, const void *data, unsigned int keycode) 3067evas_event_feed_key_down_with_keycode(Eo *eo_e, const char *keyname, const char *key, const char *string, const char *compose, unsigned int timestamp, const void *data, unsigned int keycode)
3113{ 3068{
3114 Evas_Public_Data *e = efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS); 3069 Evas_Public_Data *e = efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS);
3115 _canvas_event_feed_key_down_internal(eo_e, e, keyname, key, string, 3070 _canvas_event_feed_key_legacy(eo_e, e, keyname, key, string,
3116 compose, timestamp, data, keycode, NULL); 3071 compose, timestamp, data, keycode, 1);
3117} 3072}
3118 3073
3119EAPI void 3074EAPI void
3120evas_event_feed_key_up_with_keycode(Eo *eo_e, const char *keyname, const char *key, const char *string, const char *compose, unsigned int timestamp, const void *data, unsigned int keycode) 3075evas_event_feed_key_up_with_keycode(Eo *eo_e, const char *keyname, const char *key, const char *string, const char *compose, unsigned int timestamp, const void *data, unsigned int keycode)
3121{ 3076{
3122 Evas_Public_Data *e = efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS); 3077 Evas_Public_Data *e = efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS);
3123 _canvas_event_feed_key_up_internal(eo_e, e, keyname, key, string, 3078 _canvas_event_feed_key_legacy(eo_e, e, keyname, key, string,
3124 compose, timestamp, data, keycode, NULL); 3079 compose, timestamp, data, keycode, 0);
3125} 3080}
3126 3081
3127EAPI void 3082EAPI void
@@ -3140,7 +3095,7 @@ evas_event_feed_hold(Eo *eo_e, int hold, unsigned int timestamp, const void *dat
3140 _evas_object_event_new(); 3095 _evas_object_event_new();
3141 event_id = _evas_event_counter; 3096 event_id = _evas_event_counter;
3142 3097
3143 evt = efl_event_instance_get(EFL_EVENT_HOLD_CLASS, eo_e, &ev); 3098 evt = efl_event_instance_get(EFL_EVENT_HOLD_CLASS, eo_e, (void **) &ev);
3144 if (!ev) return; 3099 if (!ev) return;
3145 3100
3146 ev->hold = !!hold; 3101 ev->hold = !!hold;
@@ -3557,25 +3512,23 @@ _evas_canvas_event_key_cb(void *data, const Eo_Event *event)
3557 Efl_Event_Key *evt = event->info; 3512 Efl_Event_Key *evt = event->info;
3558 Evas_Public_Data *e = data; 3513 Evas_Public_Data *e = data;
3559 Efl_Event_Key_Data *ev; 3514 Efl_Event_Key_Data *ev;
3515 Eina_Bool nodev = 0;
3560 3516
3561 ev = efl_data_scope_get(evt, EFL_EVENT_KEY_CLASS); 3517 ev = efl_data_scope_get(evt, EFL_EVENT_KEY_CLASS);
3562 if (!ev) return; 3518 if (!ev) return;
3563 3519
3564 if (ev->pressed) 3520 if (!ev->device)
3565 { 3521 {
3566 _canvas_event_feed_key_down_internal(e->evas, e, ev->keyname, ev->key, 3522 nodev = 1;
3567 ev->string, ev->compose, 3523 ev->device = _evas_device_top_get(e->evas);
3568 ev->timestamp, ev->data,
3569 ev->keycode, ev);
3570 } 3524 }
3525
3526 if (ev->pressed)
3527 _canvas_event_feed_key_down_internal(e, ev);
3571 else 3528 else
3572 { 3529 _canvas_event_feed_key_up_internal(e, ev);
3573 _canvas_event_feed_key_up_internal(e->evas, e, ev->keyname, ev->key,
3574 ev->string, ev->compose,
3575 ev->timestamp, ev->data,
3576 ev->keycode, ev);
3577 }
3578 3530
3531 if (nodev) ev->device = NULL;
3579 ev->evas_done = EINA_TRUE; 3532 ev->evas_done = EINA_TRUE;
3580} 3533}
3581 3534