summaryrefslogtreecommitdiff
path: root/src/lib/ecore/ecore_events.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/ecore/ecore_events.c')
-rw-r--r--src/lib/ecore/ecore_events.c150
1 files changed, 0 insertions, 150 deletions
diff --git a/src/lib/ecore/ecore_events.c b/src/lib/ecore/ecore_events.c
index 76de86b..b0a6607 100644
--- a/src/lib/ecore/ecore_events.c
+++ b/src/lib/ecore/ecore_events.c
@@ -7,21 +7,6 @@
7#include "Ecore.h" 7#include "Ecore.h"
8#include "ecore_private.h" 8#include "ecore_private.h"
9 9
10typedef struct _Ecore_Future_Schedule_Entry
11{
12 Eina_Future_Schedule_Entry base;
13 Eina_Future_Scheduler_Cb cb;
14 Eina_Future *future;
15 Eina_Value value;
16} Ecore_Future_Schedule_Entry;
17
18//////
19// XXX: still using legacy ecore events
20static Eina_Bool shutting_down = EINA_FALSE;
21static Eina_Mempool *mp_future_schedule_entry = NULL;
22//
23//////
24
25static Ecore_Event_Message_Handler *_event_msg_handler = NULL; 10static Ecore_Event_Message_Handler *_event_msg_handler = NULL;
26 11
27EAPI Ecore_Event_Handler * 12EAPI Ecore_Event_Handler *
@@ -126,106 +111,6 @@ ecore_event_current_event_get(void)
126 return ecore_event_message_handler_current_event_get(_event_msg_handler); 111 return ecore_event_message_handler_current_event_get(_event_msg_handler);
127} 112}
128 113
129static void _future_dispatch_cb(void *data, const Efl_Event *ev EINA_UNUSED);
130static void _event_del_cb(void *data, const Efl_Event *ev);
131
132EFL_CALLBACKS_ARRAY_DEFINE(ecore_future_callbacks,
133 { EFL_LOOP_EVENT_IDLE_ENTER, _future_dispatch_cb },
134 { EFL_LOOP_EVENT_IDLE, _future_dispatch_cb },
135 { EFL_EVENT_DEL, _event_del_cb });
136
137static void
138_future_dispatch_cb(void *data, const Efl_Event *ev EINA_UNUSED)
139{
140 Efl_Loop_Future_Scheduler *loopsched = data;
141 Eina_List *entries = loopsched->future_entries;
142 Ecore_Future_Schedule_Entry *entry;
143
144 loopsched->future_entries = NULL;
145 efl_event_callback_array_del((Eo *) loopsched->loop, ecore_future_callbacks(), loopsched);
146
147 EINA_LIST_FREE(entries, entry)
148 {
149 entry->cb(entry->future, entry->value);
150 eina_mempool_free(mp_future_schedule_entry, entry);
151 }
152}
153
154static void
155_event_del_cb(void *data, const Efl_Event *ev EINA_UNUSED)
156{
157 Efl_Loop_Future_Scheduler *loopsched = data;
158 Eina_List *entries = loopsched->future_entries;
159 Ecore_Future_Schedule_Entry *entry;
160
161 loopsched->future_entries = NULL;
162 efl_event_callback_array_del((Eo *) loopsched->loop, ecore_future_callbacks(), loopsched);
163
164 EINA_LIST_FREE(entries, entry)
165 {
166 eina_future_cancel(entry->future);
167 eina_value_flush(&entry->value);
168 eina_mempool_free(mp_future_schedule_entry, entry);
169 }
170}
171
172static Eina_Future_Schedule_Entry *
173ecore_future_schedule(Eina_Future_Scheduler *sched,
174 Eina_Future_Scheduler_Cb cb,
175 Eina_Future *future,
176 Eina_Value value)
177{
178 Efl_Loop_Future_Scheduler *loopsched = (Efl_Loop_Future_Scheduler *)sched;
179 Ecore_Future_Schedule_Entry *entry;
180
181 entry = eina_mempool_malloc(mp_future_schedule_entry, sizeof(*entry));
182 EINA_SAFETY_ON_NULL_RETURN_VAL(entry, NULL);
183 entry->base.scheduler = sched;
184 entry->cb = cb;
185 entry->future = future;
186 entry->value = value;
187
188 if (!loopsched->future_entries)
189 efl_event_callback_array_add((Eo *) loopsched->loop, ecore_future_callbacks(), loopsched);
190
191 loopsched->future_entries = eina_list_append(loopsched->future_entries, entry);
192 return &entry->base;
193}
194
195static void
196ecore_future_recall(Eina_Future_Schedule_Entry *s_entry)
197{
198 Ecore_Future_Schedule_Entry *entry = (Ecore_Future_Schedule_Entry *)s_entry;
199 Efl_Loop_Future_Scheduler *loopsched;
200 Eina_List *lookup;
201
202 if (shutting_down) return;
203
204 loopsched = (Efl_Loop_Future_Scheduler *) entry->base.scheduler;
205
206 lookup = eina_list_data_find_list(loopsched->future_entries, entry);
207 if (!lookup) return;
208
209 loopsched->future_entries = eina_list_remove_list(loopsched->future_entries, lookup);
210 if (!loopsched->future_entries)
211 efl_event_callback_array_del((Eo *) loopsched->loop, ecore_future_callbacks(), loopsched);
212
213 eina_value_flush(&entry->value);
214 eina_mempool_free(mp_future_schedule_entry, entry);
215
216}
217
218static Eina_Future_Scheduler ecore_future_scheduler = {
219 .schedule = ecore_future_schedule,
220 .recall = ecore_future_recall,
221};
222
223Eina_Future_Scheduler *
224_ecore_event_future_scheduler_get(void)
225{
226 return &ecore_future_scheduler;
227}
228
229Eina_Bool 114Eina_Bool
230_ecore_event_init(void) 115_ecore_event_init(void)
231{ 116{
@@ -267,47 +152,12 @@ _ecore_event_init(void)
267 // ECORE_EVENT_COUNT 11 152 // ECORE_EVENT_COUNT 11
268 // no need to do as it was a count, nto an event 153 // no need to do as it was a count, nto an event
269 154
270 //////
271 // XXX: ecore future still using legacy...
272 shutting_down = EINA_FALSE;
273// ECORE_EV_FUTURE_ID = ecore_event_type_new();
274// future_handler = ecore_event_handler_add(ECORE_EV_FUTURE_ID, ecore_future_dispatched, NULL);
275// EINA_SAFETY_ON_NULL_GOTO(future_handler, err_handler);
276 //FIXME: Is 512 too high?
277 if (!mp_future_schedule_entry)
278 {
279 mp_future_schedule_entry = eina_mempool_add
280 (choice, "Ecore_Future_Event", NULL,
281 sizeof(Ecore_Future_Schedule_Entry), 512);
282 EINA_SAFETY_ON_NULL_GOTO(mp_future_schedule_entry, err_pool);
283 }
284 //
285 //////
286
287 return EINA_TRUE; 155 return EINA_TRUE;
288
289 err_pool:
290// XXX:
291// ecore_event_handler_del(future_handler);
292// future_handler = NULL;
293// err_handler:
294// ECORE_EV_FUTURE_ID = -1;
295 return EINA_FALSE;
296} 156}
297 157
298void 158void
299_ecore_event_shutdown(void) 159_ecore_event_shutdown(void)
300{ 160{
301 shutting_down = EINA_TRUE;
302
303 //////
304 // XXX: ecore future still using legacy...
305// ecore_event_handler_del(future_handler);
306// future_handler = NULL;
307// ECORE_EV_FUTURE_ID = -1;
308 //
309 //////
310
311 efl_loop_message_handler_message_clear(_event_msg_handler); 161 efl_loop_message_handler_message_clear(_event_msg_handler);
312 _event_msg_handler = NULL; 162 _event_msg_handler = NULL;
313} 163}