Tizen 2.1 release
[platform/core/uifw/e17.git] / src / modules / illume-home / e_mod_main.c
1 #include "e.h"
2 #include "e_mod_main.h"
3 #include "e_mod_config.h"
4 #include "e_busycover.h"
5
6 #define IL_HOME_WIN_TYPE 0xE0b0102f
7
8 /* local structures */
9 typedef struct _Il_Home_Win Il_Home_Win;
10 typedef struct _Il_Home_Exec Il_Home_Exec;
11
12 struct _Il_Home_Win 
13 {
14    E_Object e_obj_inherit;
15
16    E_Win *win;
17    Evas_Object *o_bg, *o_sf, *o_fm, *o_cover;
18    E_Busycover *cover;
19    E_Zone *zone;
20 };
21
22 struct _Il_Home_Exec 
23 {
24    E_Busycover *cover;
25    Efreet_Desktop *desktop;
26    Ecore_Exe *exec;
27    E_Border *border;
28    E_Zone *zone;
29    Ecore_Timer *timeout;
30    int startup_id;
31    pid_t pid;
32    void *handle;
33 };
34
35 /* local function prototypes */
36 static void _il_home_apps_populate(void);
37 static void _il_home_apps_unpopulate(void);
38 static void _il_home_desks_populate(void);
39 static void _il_home_desktop_run(Il_Home_Win *hwin, Efreet_Desktop *desktop);
40 static E_Border *_il_home_desktop_find_border(E_Zone *zone, Efreet_Desktop *desktop);
41 static void _il_home_win_new(E_Zone *zone);
42 static void _il_home_win_cb_free(Il_Home_Win *hwin);
43 static void _il_home_win_cb_resize(E_Win *win);
44 static void _il_home_fmc_set(Evas_Object *obj);
45 static Eina_Bool _il_home_update_deferred(void *data __UNUSED__);
46 static void _il_home_pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y);
47 static void _il_home_pan_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y);
48 static void _il_home_pan_max_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y);
49 static void _il_home_pan_child_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h);
50 static void _il_home_cb_selected(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__);
51 static Eina_Bool _il_home_desktop_cache_update(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__);
52 static Eina_Bool _il_home_cb_border_add(void *data __UNUSED__, int type __UNUSED__, void *event);
53 static Eina_Bool _il_home_cb_border_del(void *data __UNUSED__, int type __UNUSED__, void *event);
54 static Eina_Bool _il_home_cb_exe_del(void *data __UNUSED__, int type __UNUSED__, void *event);
55 static Eina_Bool _il_home_cb_exe_timeout(void *data);
56 static Eina_Bool _il_home_cb_client_message(void *data __UNUSED__, int type __UNUSED__, void *event);
57 static Eina_Bool _il_home_cb_prop_change(void *data __UNUSED__, int type __UNUSED__, void *event);
58 static Eina_Bool _il_home_cb_bg_change(void *data __UNUSED__, int type __UNUSED__, void *event);
59
60 /* local variables */
61 static Eina_List *hwins = NULL;
62 static Eina_List *hdls = NULL;
63 static Eina_List *desks = NULL;
64 static Eina_List *exes = NULL;
65 static Ecore_Timer *defer = NULL;
66
67 /* public functions */
68 EAPI E_Module_Api e_modapi = { E_MODULE_API_VERSION, "Illume Home" };
69
70 EAPI void *
71 e_modapi_init(E_Module *m) 
72 {
73    E_Manager *man;
74    Eina_List *ml;
75
76    if (!il_home_config_init(m)) return NULL;
77
78    _il_home_apps_unpopulate();
79    _il_home_apps_populate();
80
81    hdls = 
82      eina_list_append(hdls, 
83                       ecore_event_handler_add(EFREET_EVENT_DESKTOP_CACHE_UPDATE, 
84                                               _il_home_desktop_cache_update, 
85                                               NULL));
86
87    hdls = 
88      eina_list_append(hdls, 
89                       ecore_event_handler_add(E_EVENT_BORDER_ADD, 
90                                               _il_home_cb_border_add, NULL));
91    hdls = 
92      eina_list_append(hdls, 
93                       ecore_event_handler_add(E_EVENT_BORDER_REMOVE, 
94                                               _il_home_cb_border_del, NULL));
95    hdls = 
96      eina_list_append(hdls, 
97                       ecore_event_handler_add(ECORE_EXE_EVENT_DEL, 
98                                               _il_home_cb_exe_del, NULL));
99    hdls = 
100      eina_list_append(hdls, 
101                       ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, 
102                                               _il_home_cb_client_message, 
103                                               NULL));
104    hdls = 
105      eina_list_append(hdls, 
106                       ecore_event_handler_add(ECORE_X_EVENT_WINDOW_PROPERTY, 
107                                               _il_home_cb_prop_change, 
108                                               NULL));
109    hdls = 
110      eina_list_append(hdls, 
111                       ecore_event_handler_add(E_EVENT_BG_UPDATE, 
112                                               _il_home_cb_bg_change, NULL));
113
114    EINA_LIST_FOREACH(e_manager_list(), ml, man) 
115      {
116         E_Container *con;
117         Eina_List *cl;
118
119         EINA_LIST_FOREACH(man->containers, cl, con) 
120           {
121              E_Zone *zone;
122              Eina_List *zl;
123
124              EINA_LIST_FOREACH(con->zones, zl, zone) 
125                {
126                   Ecore_X_Illume_Mode mode;
127
128                   mode = ecore_x_e_illume_mode_get(zone->black_win);
129                   _il_home_win_new(zone);
130                   if (mode > ECORE_X_ILLUME_MODE_SINGLE)
131                     _il_home_win_new(zone);
132                }
133           }
134      }
135
136    return m;
137 }
138
139 EAPI int 
140 e_modapi_shutdown(E_Module *m __UNUSED__) 
141 {
142    Ecore_Event_Handler *hdl;
143    Il_Home_Win *hwin;
144    Il_Home_Exec *exe;
145
146    EINA_LIST_FREE(hwins, hwin)
147      e_object_del(E_OBJECT(hwin));
148
149    EINA_LIST_FREE(exes, exe) 
150      {
151         if (exe->exec) 
152           {
153              ecore_exe_terminate(exe->exec);
154              ecore_exe_free(exe->exec);
155           }
156         if (exe->handle) e_busycover_pop(exe->cover, exe->handle);
157         if (exe->timeout) ecore_timer_del(exe->timeout);
158         if (exe->desktop) efreet_desktop_free(exe->desktop);
159         E_FREE(exe);
160      }
161
162    EINA_LIST_FREE(hdls, hdl)
163      ecore_event_handler_del(hdl);
164
165    _il_home_apps_unpopulate();
166
167    il_home_config_shutdown();
168    return 1;
169 }
170
171 EAPI int 
172 e_modapi_save(E_Module *m __UNUSED__) 
173 {
174    return il_home_config_save();
175 }
176
177 void 
178 il_home_win_cfg_update(void) 
179 {
180    _il_home_apps_unpopulate();
181    _il_home_apps_populate();
182 }
183
184 /* local function prototypes */
185 static void 
186 _il_home_apps_populate(void) 
187 {
188    Il_Home_Win *hwin;
189    Eina_List *l;
190    char buff[PATH_MAX];
191
192    e_user_dir_concat_static(buff, "appshadow");
193    ecore_file_mkpath(buff);
194
195    _il_home_desks_populate();
196
197    EINA_LIST_FOREACH(hwins, l, hwin) 
198      {
199         _il_home_fmc_set(hwin->o_fm);
200         e_fm2_path_set(hwin->o_fm, NULL, buff);
201      }
202 }
203
204 static void 
205 _il_home_apps_unpopulate(void) 
206 {
207    Efreet_Desktop *desktop;
208    Eina_List *files;
209    char buff[PATH_MAX], *file;
210    size_t len;
211
212    EINA_LIST_FREE(desks, desktop) 
213      efreet_desktop_free(desktop);
214
215    len = e_user_dir_concat_static(buff, "appshadow");
216    if ((len + 2) >= sizeof(buff)) return;
217
218    files = ecore_file_ls(buff);
219    buff[len] = '/';
220    len++;
221
222    EINA_LIST_FREE(files, file) 
223      {
224         if (eina_strlcpy(buff + len, file, sizeof(buff) - len) >= sizeof(buff) - len)
225           continue;
226         ecore_file_unlink(buff);
227         free(file);
228      }
229 }
230
231 static void 
232 _il_home_desks_populate(void) 
233 {
234    Efreet_Menu *menu, *entry;
235    Eina_List *ml, *settings, *sys, *kbd;
236    Efreet_Desktop *desktop;
237    int num = 0;
238
239    if (!(menu = efreet_menu_get())) return;
240
241    settings = efreet_util_desktop_category_list("Settings");
242    sys = efreet_util_desktop_category_list("System");
243    kbd = efreet_util_desktop_category_list("Keyboard");
244
245    EINA_LIST_FOREACH(menu->entries, ml, entry) 
246      {
247         Eina_List *sl;
248         Efreet_Menu *sm;
249
250         if (entry->type != EFREET_MENU_ENTRY_MENU) continue;
251         EINA_LIST_FOREACH(entry->entries, sl, sm) 
252           {
253              char buff[PATH_MAX];
254
255              if (sm->type != EFREET_MENU_ENTRY_DESKTOP) continue;
256              if (!(desktop = sm->desktop)) continue;
257              if ((settings) && (sys) && 
258                  (eina_list_data_find(settings, desktop)) && 
259                  (eina_list_data_find(sys, desktop))) continue;
260              if ((kbd) && (eina_list_data_find(kbd, desktop))) 
261                continue;
262              efreet_desktop_ref(desktop);
263              desks = eina_list_append(desks, desktop);
264              e_user_dir_snprintf(buff, sizeof(buff), 
265                                  "appshadow/%04x.desktop", num);
266              ecore_file_symlink(desktop->orig_path, buff);
267              num++;
268           }
269      }
270
271    efreet_menu_free(menu);
272
273    EINA_LIST_FREE(settings, desktop)
274      efreet_desktop_free(desktop);
275    EINA_LIST_FREE(sys, desktop)
276      efreet_desktop_free(desktop);
277    EINA_LIST_FREE(kbd, desktop)
278      efreet_desktop_free(desktop);
279 }
280
281 static void 
282 _il_home_desktop_run(Il_Home_Win *hwin, Efreet_Desktop *desktop) 
283 {
284    E_Exec_Instance *eins;
285    Il_Home_Exec *exec;
286    Eina_List *l;
287    E_Border *bd;
288    char buff[4096];
289
290    if ((!hwin) || (!desktop) || (!desktop->exec)) return;
291    EINA_LIST_FOREACH(exes, l, exec) 
292      {
293         if (exec->desktop != desktop) continue;
294         if ((exec->border) && (exec->border->zone == hwin->zone)) 
295           {
296              e_border_uniconify(exec->border);
297              e_border_raise(exec->border);
298              e_border_focus_set(exec->border, 1, 1);
299              return;
300           }
301      }
302    if ((bd = _il_home_desktop_find_border(hwin->zone, desktop))) 
303      {
304         e_border_uniconify(bd);
305         e_border_raise(bd);
306         e_border_focus_set(bd, 1, 1);
307         return;
308      }
309
310    exec = E_NEW(Il_Home_Exec, 1);
311    if (!exec) return;
312    exec->cover = hwin->cover;
313    eins = e_exec(hwin->zone, desktop, NULL, NULL, "illume-home");
314    exec->desktop = desktop;
315    exec->zone = hwin->zone;
316    if (eins) 
317      {
318         exec->exec = eins->exe;
319         exec->startup_id = eins->startup_id;
320         if (eins->exe) 
321           exec->pid = ecore_exe_pid_get(eins->exe);
322      }
323    exec->timeout = ecore_timer_add(2.0, _il_home_cb_exe_timeout, exec);
324    snprintf(buff, sizeof(buff), "Starting %s", desktop->name);
325    exec->handle = e_busycover_push(hwin->cover, buff, NULL);
326    exes = eina_list_append(exes, exec);
327 }
328
329 static E_Border *
330 _il_home_desktop_find_border(E_Zone *zone, Efreet_Desktop *desktop) 
331 {
332    Eina_List *l;
333    E_Border *bd;
334    char *exe = NULL, *p;
335
336    if (!desktop) return NULL;
337    if (!desktop->exec) return NULL;
338    p = strchr(desktop->exec, ' ');
339    if (!p)
340      exe = strdup(desktop->exec);
341    else 
342      {
343         size_t s = p - desktop->exec + 1;
344         exe = calloc(1, s);
345         if (exe) eina_strlcpy(exe, desktop->exec, s);
346      }
347    if (exe) 
348      {
349         p = strrchr(exe, '/');
350         if (p) strcpy(exe, p + 1);
351      }
352
353    EINA_LIST_FOREACH(e_border_client_list(), l, bd) 
354      {
355         if (bd->zone != zone) continue;
356         if (e_exec_startup_id_pid_find(bd->client.netwm.pid, 
357                                        bd->client.netwm.startup_id) == desktop) 
358           {
359              if (exe) free(exe);
360              return bd;
361           }
362         if (exe) 
363           {
364              if (bd->client.icccm.command.argv) 
365                {
366                   char *pp;
367
368                   pp = strrchr(bd->client.icccm.command.argv[0], '/');
369                   if (!pp) pp = bd->client.icccm.command.argv[0];
370                   if (!strcmp(exe, pp)) 
371                     {
372                        free(exe);
373                        return bd;
374                     }
375                }
376              if ((bd->client.icccm.name) && 
377                  (!strcasecmp(bd->client.icccm.name, exe))) 
378                {
379                   free(exe);
380                   return bd;
381                }
382           }
383      }
384    if (exe) free(exe);
385    return NULL;
386 }
387
388 static void 
389 _il_home_win_new(E_Zone *zone) 
390 {
391    Il_Home_Win *hwin;
392    Evas *evas;
393    E_Desk *desk;
394    char buff[PATH_MAX];
395    const char *bgfile;
396
397    hwin = E_OBJECT_ALLOC(Il_Home_Win, IL_HOME_WIN_TYPE, _il_home_win_cb_free);
398    if (!hwin) return;
399
400    hwin->zone = zone;
401    hwin->win = e_win_new(zone->container);
402    if (!hwin->win) 
403      {
404         e_object_del(E_OBJECT(hwin));
405         return;
406      }
407    hwin->win->data = hwin;
408    e_win_title_set(hwin->win, _("Illume Home"));
409    e_win_name_class_set(hwin->win, "Illume-Home", "Illume-Home");
410    e_win_resize_callback_set(hwin->win, _il_home_win_cb_resize);
411    e_win_no_remember_set(hwin->win, EINA_TRUE);
412
413    snprintf(buff, sizeof(buff), "%s/e-module-illume-home.edj", 
414             il_home_cfg->mod_dir);
415
416    evas = e_win_evas_get(hwin->win);
417
418    desk = e_desk_current_get(zone);
419    if (desk)
420      bgfile = e_bg_file_get(zone->container->num, zone->num, desk->x, desk->y);
421    else
422      bgfile = e_bg_file_get(zone->container->num, zone->num, -1, -1);
423
424    hwin->o_bg = edje_object_add(evas);
425    edje_object_file_set(hwin->o_bg, bgfile, "e/desktop/background");
426    evas_object_move(hwin->o_bg, 0, 0);
427    evas_object_show(hwin->o_bg);
428
429    hwin->o_sf = e_scrollframe_add(evas);
430    e_scrollframe_single_dir_set(hwin->o_sf, EINA_TRUE);
431    e_scrollframe_custom_edje_file_set(hwin->o_sf, buff, 
432                                       "modules/illume-home/launcher/scrollview");
433    evas_object_move(hwin->o_sf, 0, 0);
434    evas_object_show(hwin->o_sf);
435
436    hwin->o_fm = e_fm2_add(evas);
437    _il_home_fmc_set(hwin->o_fm);
438    evas_object_show(hwin->o_fm);
439    e_user_dir_concat_static(buff, "appshadow");
440    e_fm2_path_set(hwin->o_fm, NULL, buff);
441    e_fm2_window_object_set(hwin->o_fm, E_OBJECT(hwin->win));
442    e_scrollframe_extern_pan_set(hwin->o_sf, hwin->o_fm, 
443                                 _il_home_pan_set, 
444                                 _il_home_pan_get, 
445                                 _il_home_pan_max_get, 
446                                 _il_home_pan_child_size_get);
447    evas_object_propagate_events_set(hwin->o_fm, 0);
448    evas_object_smart_callback_add(hwin->o_fm, "selected", 
449                                   _il_home_cb_selected, hwin);
450
451    hwin->cover = e_busycover_new(hwin->win);
452
453    e_win_move_resize(hwin->win, zone->x, zone->y, zone->w, (zone->h / 2));
454    e_win_show(hwin->win);
455    e_border_zone_set(hwin->win->border, zone);
456    if (hwin->win->evas_win) 
457      e_drop_xdnd_register_set(hwin->win->evas_win, EINA_TRUE);
458
459    hwins = eina_list_append(hwins, hwin);
460 }
461
462 static void 
463 _il_home_win_cb_free(Il_Home_Win *hwin) 
464 {
465    if (hwin->win->evas_win) e_drop_xdnd_register_set(hwin->win->evas_win, 0);
466    if (hwin->cover) e_object_del(E_OBJECT(hwin->cover));
467    if (hwin->o_bg) evas_object_del(hwin->o_bg);
468    if (hwin->o_sf) evas_object_del(hwin->o_sf);
469    if (hwin->o_fm) evas_object_del(hwin->o_fm);
470    if (hwin->win) e_object_del(E_OBJECT(hwin->win));
471    E_FREE(hwin);
472 }
473
474 static void 
475 _il_home_win_cb_resize(E_Win *win) 
476 {
477    Il_Home_Win *hwin;
478
479    if (!(hwin = win->data)) return;
480    if (hwin->o_bg) evas_object_resize(hwin->o_bg, win->w, win->h);
481    if (hwin->o_sf) evas_object_resize(hwin->o_sf, win->w, win->h);
482    if (hwin->cover) e_busycover_resize(hwin->cover, win->w, win->h);
483 }
484
485 static void 
486 _il_home_fmc_set(Evas_Object *obj) 
487 {
488    E_Fm2_Config fmc;
489
490    if (!obj) return;
491    memset(&fmc, 0, sizeof(E_Fm2_Config));
492    fmc.view.mode = E_FM2_VIEW_MODE_GRID_ICONS;
493    fmc.view.open_dirs_in_place = 1;
494    fmc.view.selector = 0;
495    fmc.view.single_click = il_home_cfg->single_click;
496    fmc.view.single_click_delay = il_home_cfg->single_click_delay;
497    fmc.view.no_subdir_jump = 1;
498    fmc.icon.extension.show = 0;
499    fmc.icon.icon.w = il_home_cfg->icon_size * e_scale / 2.0;
500    fmc.icon.icon.h = il_home_cfg->icon_size * e_scale / 2.0;
501    fmc.icon.fixed.w = il_home_cfg->icon_size * e_scale / 2.0;
502    fmc.icon.fixed.h = il_home_cfg->icon_size * e_scale / 2.0;
503    fmc.list.sort.no_case = 0;
504    fmc.list.sort.dirs.first = 1;
505    fmc.list.sort.dirs.last = 0;
506    fmc.selection.single = 1;
507    fmc.selection.windows_modifiers = 0;
508    e_fm2_config_set(obj, &fmc);
509 }
510
511 static Eina_Bool
512 _il_home_update_deferred(void *data __UNUSED__) 
513 {
514    _il_home_apps_unpopulate();
515    _il_home_apps_populate();
516    defer = NULL;
517    return ECORE_CALLBACK_CANCEL;
518 }
519
520 static void 
521 _il_home_pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y) 
522 {
523    e_fm2_pan_set(obj, x, y);
524 }
525
526 static void 
527 _il_home_pan_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y) 
528 {
529    e_fm2_pan_get(obj, x, y);
530 }
531
532 static void 
533 _il_home_pan_max_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y) 
534 {
535    e_fm2_pan_max_get(obj, x, y);
536 }
537
538 static void 
539 _il_home_pan_child_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h) 
540 {
541    e_fm2_pan_child_size_get(obj, w, h);
542 }
543
544 static void 
545 _il_home_cb_selected(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__) 
546 {
547    Il_Home_Win *hwin;
548    Eina_List *selected;
549    E_Fm2_Icon_Info *ici;
550
551    if (!(hwin = data)) return;
552    if (!(selected = e_fm2_selected_list_get(hwin->o_fm))) return;
553    EINA_LIST_FREE(selected, ici) 
554      {
555         Efreet_Desktop *desktop;
556
557         if ((!ici) || (!ici->real_link)) continue;
558         if (!(desktop = efreet_desktop_get(ici->real_link))) continue;
559         _il_home_desktop_run(hwin, desktop);
560      }
561 }
562
563 static Eina_Bool
564 _il_home_desktop_cache_update(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__) 
565 {
566    if (defer) ecore_timer_del(defer);
567    defer = ecore_timer_add(0.5, _il_home_update_deferred, NULL);
568    return ECORE_CALLBACK_PASS_ON;
569 }
570
571 static Eina_Bool
572 _il_home_cb_border_add(void *data __UNUSED__, int type __UNUSED__, void *event) 
573 {
574    E_Event_Border_Add *ev;
575    Il_Home_Exec *exe;
576    Eina_List *l;
577
578    ev = event;
579    EINA_LIST_FOREACH(exes, l, exe) 
580      {
581         if (!exe->border) 
582           {
583              if ((exe->startup_id == ev->border->client.netwm.startup_id) || 
584                  (exe->pid == ev->border->client.netwm.pid)) 
585                {
586                   exe->border = ev->border;
587                }
588           }
589         if (!exe->border) continue;
590         if (exe->border->zone != exe->zone) 
591           {
592              exe->border->zone = exe->zone;
593              exe->border->x = exe->zone->x;
594              exe->border->y = exe->zone->y;
595              exe->border->changes.pos = 1;
596              exe->border->changed = 1;
597           }
598         if (exe->handle) 
599           {
600              e_busycover_pop(exe->cover, exe->handle);
601              exe->handle = NULL;
602           }
603         if (exe->timeout) ecore_timer_del(exe->timeout);
604         exe->timeout = NULL;
605      }
606    return ECORE_CALLBACK_PASS_ON;
607 }
608
609 static Eina_Bool
610 _il_home_cb_border_del(void *data __UNUSED__, int type __UNUSED__, void *event) 
611 {
612    E_Event_Border_Remove *ev;
613    Il_Home_Exec *exe;
614    Eina_List *l;
615
616    ev = event;
617    EINA_LIST_FOREACH(exes, l, exe) 
618      {
619         if (exe->border == ev->border) 
620           {
621              if (exe->exec) ecore_exe_free(exe->exec);
622              exe->exec = NULL;
623              if (exe->handle) e_busycover_pop(exe->cover, exe->handle);
624              exe->handle = NULL;
625              exe->border = NULL;
626              exes = eina_list_remove(exes, exe);
627              E_FREE(exe);
628              break;
629           }
630      }
631    return ECORE_CALLBACK_PASS_ON;
632 }
633
634 static Eina_Bool
635 _il_home_cb_exe_del(void *data __UNUSED__, int type __UNUSED__, void *event) 
636 {
637    Il_Home_Exec *exe;
638    Ecore_Exe_Event_Del *ev;
639    Eina_List *l;
640
641    ev = event;
642    EINA_LIST_FOREACH(exes, l, exe) 
643      {
644         if (exe->pid == ev->pid) 
645           {
646              if (exe->handle) 
647                {
648                   e_busycover_pop(exe->cover, exe->handle);
649                   exe->handle = NULL;
650                }
651              exes = eina_list_remove_list(exes, l);
652              if (exe->timeout) ecore_timer_del(exe->timeout);
653              if (exe->desktop) efreet_desktop_free(exe->desktop);
654              E_FREE(exe);
655              break;
656           }
657      }
658    return ECORE_CALLBACK_PASS_ON;
659 }
660
661 static Eina_Bool
662 _il_home_cb_exe_timeout(void *data) 
663 {
664    Il_Home_Exec *exe;
665
666    if (!(exe = data)) return ECORE_CALLBACK_CANCEL;
667    if (exe->handle) e_busycover_pop(exe->cover, exe->handle);
668    exe->handle = NULL;
669    if (!exe->border) 
670      {
671         exes = eina_list_remove(exes, exe);
672         if (exe->desktop) efreet_desktop_free(exe->desktop);
673         E_FREE(exe);
674         return ECORE_CALLBACK_CANCEL;
675      }
676    exe->timeout = NULL;
677    return ECORE_CALLBACK_CANCEL;
678 }
679
680 static Eina_Bool
681 _il_home_cb_client_message(void *data __UNUSED__, int type __UNUSED__, void *event) 
682 {
683    Ecore_X_Event_Client_Message *ev;
684
685    ev = event;
686    if (ev->message_type == ECORE_X_ATOM_E_ILLUME_HOME_NEW) 
687      {
688         E_Zone *zone;
689
690         zone = e_util_zone_window_find(ev->win);
691         if (zone->black_win != ev->win) return ECORE_CALLBACK_PASS_ON;
692         _il_home_win_new(zone);
693      }
694    else if (ev->message_type == ECORE_X_ATOM_E_ILLUME_HOME_DEL) 
695      {
696         E_Border *bd;
697         Eina_List *l;
698         Il_Home_Win *hwin;
699
700         if (!(bd = e_border_find_by_client_window(ev->win))) return ECORE_CALLBACK_PASS_ON;
701         EINA_LIST_FOREACH(hwins, l, hwin) 
702           {
703              if (hwin->win->border == bd) 
704                {
705                   hwins = eina_list_remove_list(hwins, hwins);
706                   e_object_del(E_OBJECT(hwin));
707                   break;
708                }
709           }
710      }
711    return ECORE_CALLBACK_PASS_ON;
712 }
713
714 static Eina_Bool
715 _il_home_cb_prop_change(void *data __UNUSED__, int type __UNUSED__, void *event) 
716 {
717    Ecore_X_Event_Window_Property *ev;
718    Il_Home_Win *hwin;
719    Eina_List *l;
720
721    ev = event;
722    if (ev->atom != ATM_ENLIGHTENMENT_SCALE) return ECORE_CALLBACK_PASS_ON;
723    EINA_LIST_FOREACH(hwins, l, hwin) 
724      if (hwin->o_fm) 
725        {
726           _il_home_fmc_set(hwin->o_fm);
727           e_fm2_refresh(hwin->o_fm);
728        }
729
730    return ECORE_CALLBACK_PASS_ON;
731 }
732
733 static Eina_Bool
734 _il_home_cb_bg_change(void *data __UNUSED__, int type, void *event __UNUSED__) 
735 {
736    Il_Home_Win *hwin;
737    Eina_List *l;
738
739    if (type != E_EVENT_BG_UPDATE) return ECORE_CALLBACK_PASS_ON;
740
741    EINA_LIST_FOREACH(hwins, l, hwin) 
742      {
743         E_Zone *zone;
744         E_Desk *desk;
745         const char *bgfile;
746
747         zone = hwin->zone;
748         desk = e_desk_current_get(zone);
749         if (desk)
750           bgfile = e_bg_file_get(zone->container->num, zone->num, desk->x, desk->y);
751         else
752           bgfile = e_bg_file_get(zone->container->num, zone->num, -1, -1);
753         edje_object_file_set(hwin->o_bg, bgfile, "e/desktop/background");
754      }
755
756    return ECORE_CALLBACK_PASS_ON;
757 }