3 # include <sys/prctl.h>
12 t1 = ecore_time_unix_get(); \
13 printf("ESTART: %1.5f [%1.5f] - %s\n", t1 - t0, t1 - t2, x); \
16 static double t0, t1, t2;
22 * i need to make more use of these when i'm baffled as to when something is
25 * void *(*__malloc_hook)(size_t size, const void *caller);
27 * void *(*__realloc_hook)(void *ptr, size_t size, const void *caller);
29 * void *(*__memalign_hook)(size_t alignment, size_t size,
30 * const void *caller);
32 * void (*__free_hook)(void *ptr, const void *caller);
34 * void (*__malloc_initialize_hook)(void);
36 * void (*__after_morecore_hook)(void);
39 static void my_init_hook(void);
40 static void my_free_hook(void *p, const void *caller);
42 static void (*old_free_hook)(void *ptr, const void *caller) = NULL;
43 void (*__free_hook)(void *ptr, const void *caller);
45 void (*__malloc_initialize_hook) (void) = my_init_hook;
49 old_free_hook = __free_hook;
50 __free_hook = my_free_hook;
53 //void *magicfree = NULL;
56 my_free_hook(void *p, const void *caller)
58 __free_hook = old_free_hook;
59 // if ((p) && (p == magicfree))
61 // printf("CAUGHT!!!!! %p ...\n", p);
65 __free_hook = my_free_hook;
69 /* local function prototypes */
70 static void _e_main_shutdown(int errcode);
71 static void _e_main_shutdown_push(int (*func)(void));
72 static void _e_main_parse_arguments(int argc, char **argv);
73 static Eina_Bool _e_main_cb_signal_exit(void *data __UNUSED__, int ev_type __UNUSED__, void *ev __UNUSED__);
74 static Eina_Bool _e_main_cb_signal_hup(void *data __UNUSED__, int ev_type __UNUSED__, void *ev __UNUSED__);
75 static Eina_Bool _e_main_cb_signal_user(void *data __UNUSED__, int ev_type __UNUSED__, void *ev);
76 static int _e_main_dirs_init(void);
77 static int _e_main_dirs_shutdown(void);
78 static int _e_main_path_init(void);
79 static int _e_main_path_shutdown(void);
80 #ifndef DISABLE_FORMAT_TEST
81 static void _e_main_test_formats(void);
83 static int _e_main_screens_init(void);
84 static int _e_main_screens_shutdown(void);
85 static void _e_main_desk_save(void);
86 static void _e_main_desk_restore(void);
87 static void _e_main_efreet_paths_init(void);
88 static void _e_main_modules_load(Eina_Bool safe_mode);
89 static Eina_Bool _e_main_cb_idle_before(void *data __UNUSED__);
90 static Eina_Bool _e_main_cb_idle_after(void *data __UNUSED__);
91 static Eina_Bool _e_main_cb_startup_fake_end(void *data __UNUSED__);
94 static Eina_Bool really_know = EINA_FALSE;
95 static Eina_Bool locked = EINA_FALSE;
96 static Eina_Bool inloop = EINA_FALSE;
97 static jmp_buf x_fatal_buff;
99 static int _e_main_lvl = 0;
100 static int(*_e_main_shutdown_func[MAX_LEVEL]) (void);
102 static Ecore_Idle_Enterer *_idle_before = NULL;
103 static Ecore_Idle_Enterer *_idle_after = NULL;
105 static Ecore_Event_Handler *mod_init_end = NULL;
107 /* external variables */
108 EAPI Eina_Bool e_precache_end = EINA_FALSE;
109 EAPI Eina_Bool x_fatal = EINA_FALSE;
110 EAPI Eina_Bool good = EINA_FALSE;
111 EAPI Eina_Bool evil = EINA_FALSE;
112 EAPI Eina_Bool starting = EINA_TRUE;
113 EAPI Eina_Bool stopping = EINA_FALSE;
114 EAPI Eina_Bool restart = EINA_FALSE;
115 EAPI Eina_Bool e_nopause = EINA_FALSE;
116 EINTERN const char *e_first_frame = NULL;
117 EINTERN double e_first_frame_start_time = -1;
120 _xdg_check_str(const char *env, const char *str)
126 for (p = strstr(env, str); p; p++, p = strstr(p, str))
128 if ((!p[len]) || (p[len] == ':')) return EINA_TRUE;
134 _xdg_data_dirs_augment(void)
137 const char *p = e_prefix_get();
138 char newpath[4096], buf[4096];
142 s = getenv("XDG_DATA_DIRS");
145 Eina_Bool pfxdata, pfx;
147 pfxdata = !_xdg_check_str(s, e_prefix_data_get());
148 snprintf(newpath, sizeof(newpath), "%s/share", p);
149 pfx = !_xdg_check_str(s, newpath);
152 snprintf(buf, sizeof(buf), "%s%s%s%s%s",
153 pfxdata ? e_prefix_data_get() : "",
158 e_util_env_set("XDG_DATA_DIRS", buf);
163 snprintf(buf, sizeof(buf), "%s:%s/share:/usr/local/share:/usr/share", e_prefix_data_get(), p);
164 e_util_env_set("XDG_DATA_DIRS", buf);
167 s = getenv("XDG_CONFIG_DIRS");
168 snprintf(newpath, sizeof(newpath), "%s/etc/xdg", p);
171 if (!_xdg_check_str(s, newpath))
173 snprintf(buf, sizeof(buf), "%s:%s", newpath, s);
174 e_util_env_set("XDG_CONFIG_DIRS", buf);
179 snprintf(buf, sizeof(buf), "%s:/etc/xdg", newpath);
180 e_util_env_set("XDG_CONFIG_DIRS", buf);
183 if (!getenv("XDG_RUNTIME_DIR"))
187 snprintf(buf, sizeof(buf), "/tmp/xdg-XXXXXX");
189 if (!dir) dir = "/tmp";
192 e_util_env_set("XDG_RUNTIME_DIR", dir);
193 snprintf(buf, sizeof(buf), "%s/.e-deleteme", dir);
194 ecore_file_mkdir(buf);
198 /* set menu prefix so we get our e menu */
199 if (!getenv("XDG_MENU_PREFIX"))
201 e_util_env_set("XDG_MENU_PREFIX", "e-");
205 #ifndef ENABLE_QUICK_INIT
207 _e_main_shelf_init_job(void *data EINA_UNUSED)
209 e_shelf_config_update();
210 return ECORE_CALLBACK_CANCEL;
214 _e_main_subsystem_defer(void *data EINA_UNUSED)
219 ecore_app_args_get(&argc, &argv);
221 /* try to init delayed subsystems */
222 TS("[DEFERRED] Elementary Init");
223 if (!elm_init(argc, argv))
225 e_error_message_show(_("Enlightenment cannot initialize Elementary!\n"));
226 _e_main_shutdown(-1);
228 TS("[DEFERRED] Elementary Init Done");
230 TS("[DEFERRED] Edje Init");
233 e_error_message_show(_("Enlightenment cannot initialize Edje!\n"));
234 _e_main_shutdown(-1);
236 TS("[DEFERRED] Edje Init Done");
237 _e_main_shutdown_push(edje_shutdown);
239 TS("[DEFERRED] Efreet Init");
242 e_error_message_show(_("Enlightenment cannot initialize the FDO desktop system.\n"
243 "Perhaps you lack permissions on ~/.cache/efreet or are\n"
244 "out of memory or disk space?"));
245 _e_main_shutdown(-1);
247 TS("[DEFERRED] Efreet Init Done");
248 _e_main_shutdown_push(efreet_shutdown);
250 TS("[DEFERRED] Screens Init: win");
253 e_error_message_show(_("Enlightenment cannot setup elementary trap!\n"));
254 _e_main_shutdown(-1);
256 TS("[DEFERRED] Screens Init: win Done");
258 TS("[DEFERRED] E_Pointer Init");
259 if (!e_pointer_init())
261 e_error_message_show(_("Enlightenment cannot set up its pointer system.\n"));
262 _e_main_shutdown(-1);
265 TS("[DEFERRED] E_Pointer Init Done");
266 _e_main_shutdown_push(e_pointer_shutdown);
268 TS("[DEFERRED] E_Scale Init");
271 e_error_message_show(_("Enlightenment cannot set up its scale system.\n"));
272 _e_main_shutdown(-1);
274 TS("[DEFERRED E_Scale Init Done");
275 _e_main_shutdown_push(e_scale_shutdown);
277 TS("[DEFERRED] Efreet Paths");
278 _e_main_efreet_paths_init();
279 TS("[DEFERRED] Efreet Paths Done");
281 TS("[DEFERRED] E_Test_Helper Init");
282 e_test_helper_init();
283 _e_main_shutdown_push(e_test_helper_shutdown);
284 TS("[DEFERRED] E_Test_Helper Done");
286 TS("[DEFERRED] E_INFO_SERVER Init");
287 e_info_server_init();
288 _e_main_shutdown_push(e_info_server_shutdown);
289 TS("[DEFERRED] E_INFO_SERVER Done");
291 /* try to do deferred job of any subsystems*/
292 TS("[DEFERRED] Compositor's deferred job");
293 e_comp_deferred_job();
294 TS("[DEFERRED] Compositor's deferred job Done");
296 TS("[DEFERRED] E_Module's deferred job");
297 e_module_deferred_job();
298 TS("[DEFERRED] E_Module's deferred job Done");
300 return ECORE_CALLBACK_DONE;
304 _e_main_deferred_job_schedule(void *d EINA_UNUSED, int type EINA_UNUSED, void *ev EINA_UNUSED)
306 ecore_idler_add(_e_main_subsystem_defer, NULL);
307 return ECORE_CALLBACK_DONE;
312 /* externally accessible functions */
314 main(int argc, char **argv)
316 Eina_Bool safe_mode = EINA_FALSE;
317 Eina_Bool after_restart = EINA_FALSE;
318 double t = 0.0, tstart = 0.0;
319 char *s = NULL, buff[32];
320 struct sigaction action;
323 # ifdef PR_SET_PTRACER
324 # ifdef PR_SET_PTRACER_ANY
325 prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY);
331 t0 = t1 = t2 = ecore_time_unix_get();
335 /* trap deadly bug signals and allow some form of sane recovery */
336 /* or ability to gdb attach and debug at this point - better than your */
337 /* wm/desktop vanishing and not knowing what happened */
338 if (!getenv("NOTIFY_SOCKET"))
341 action.sa_sigaction = e_sigseg_act;
342 action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
343 sigemptyset(&action.sa_mask);
344 sigaction(SIGSEGV, &action, NULL);
346 action.sa_sigaction = e_sigill_act;
347 action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
348 sigemptyset(&action.sa_mask);
349 sigaction(SIGILL, &action, NULL);
351 action.sa_sigaction = e_sigfpe_act;
352 action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
353 sigemptyset(&action.sa_mask);
354 sigaction(SIGFPE, &action, NULL);
356 #ifndef HAVE_WAYLAND_ONLY
357 action.sa_sigaction = e_sigbus_act;
358 action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
359 sigemptyset(&action.sa_mask);
360 sigaction(SIGBUS, &action, NULL);
363 action.sa_sigaction = e_sigabrt_act;
364 action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
365 sigemptyset(&action.sa_mask);
366 sigaction(SIGABRT, &action, NULL);
367 TS("Signal Trap Done");
370 t = ecore_time_unix_get();
371 s = getenv("E_START_TIME");
372 if ((s) && (!getenv("E_RESTART_OK")))
375 if ((t - tstart) < 5.0) safe_mode = EINA_TRUE;
378 snprintf(buff, sizeof(buff), "%1.1f", tstart);
379 e_util_env_set("E_START_TIME", buff);
381 if (getenv("E_START_MTRACK"))
382 e_util_env_set("MTRACK", NULL);
386 e_error_message_show(_("Enlightenment cannot initialize Eina!\n"));
387 _e_main_shutdown(-1);
389 _e_main_shutdown_push(eina_shutdown);
390 #ifdef OBJECT_HASH_CHECK
391 e_object_hash_init();
395 e_error_message_show(_("Enlightenment could not create a logging domain!\n"));
396 _e_main_shutdown(-1);
402 t1 = ecore_time_unix_get(); \
403 printf("ESTART: %1.5f [%1.5f] - %s\n", t1 - t0, t1 - t2, x); \
407 TS("Eina Init Done");
408 _e_main_shutdown_push(e_log_shutdown);
410 TS("Determine Prefix");
411 if (!e_prefix_determine(argv[0]))
414 "ERROR: Enlightenment cannot determine it's installed\n"
415 " prefix from the system or argv[0].\n"
416 " This is because it is not on Linux AND has been\n"
417 " executed strangely. This is unusual.\n");
419 TS("Determine Prefix Done");
421 /* for debugging by redirecting stdout of e to a log file to tail */
422 setvbuf(stdout, NULL, _IONBF, 0);
424 TS("Environment Variables");
425 if (getenv("E_RESTART")) after_restart = EINA_TRUE;
426 if (getenv("DESKTOP_STARTUP_ID"))
427 e_util_env_set("DESKTOP_STARTUP_ID", NULL);
428 e_util_env_set("E_RESTART_OK", NULL);
429 e_util_env_set("PANTS", "ON");
430 e_util_env_set("DESKTOP", "Enlightenment-0.17.0");
431 TS("Environment Variables Done");
433 TS("Parse Arguments");
434 _e_main_parse_arguments(argc, argv);
435 TS("Parse Arguments Done");
437 /*** Initialize Core EFL Libraries We Need ***/
442 e_error_message_show(_("Enlightenment cannot initialize Eet!\n"));
443 _e_main_shutdown(-1);
446 _e_main_shutdown_push(eet_shutdown);
448 #ifdef ENABLE_QUICK_INIT
449 /* Allow ecore to not load system modules.
450 * Without it ecore_init will block until dbus authentication
451 * and registration are complete.
453 ecore_app_no_system_modules();
459 e_error_message_show(_("Enlightenment cannot initialize Ecore!\n"));
460 _e_main_shutdown(-1);
462 TS("Ecore Init Done");
463 _e_main_shutdown_push(ecore_shutdown);
465 e_first_frame = getenv("E_FIRST_FRAME");
466 if (e_first_frame && (!e_first_frame[0]))
467 e_first_frame = NULL;
469 e_first_frame_start_time = ecore_time_get();
474 e_error_message_show(_("Enlightenment cannot initialize EIO!\n"));
475 _e_main_shutdown(-1);
478 _e_main_shutdown_push(eio_shutdown);
480 ecore_app_args_set(argc, (const char **)argv);
482 TS("Ecore Event Handlers");
483 if (!ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT,
484 _e_main_cb_signal_exit, NULL))
486 e_error_message_show(_("Enlightenment cannot set up an exit signal handler.\n"
487 "Perhaps you are out of memory?"));
488 _e_main_shutdown(-1);
490 if (!ecore_event_handler_add(ECORE_EVENT_SIGNAL_HUP,
491 _e_main_cb_signal_hup, NULL))
493 e_error_message_show(_("Enlightenment cannot set up a HUP signal handler.\n"
494 "Perhaps you are out of memory?"));
495 _e_main_shutdown(-1);
497 if (!ecore_event_handler_add(ECORE_EVENT_SIGNAL_USER,
498 _e_main_cb_signal_user, NULL))
500 e_error_message_show(_("Enlightenment cannot set up a USER signal handler.\n"
501 "Perhaps you are out of memory?"));
502 _e_main_shutdown(-1);
504 TS("Ecore Event Handlers Done");
506 TS("Ecore_File Init");
507 if (!ecore_file_init())
509 e_error_message_show(_("Enlightenment cannot initialize Ecore_File!\n"));
510 _e_main_shutdown(-1);
512 TS("Ecore_File Init Done");
513 _e_main_shutdown_push(ecore_file_shutdown);
515 #ifndef ENABLE_QUICK_INIT
516 Eina_Bool nostartup = EINA_FALSE;
517 Eina_Bool waslocked = EINA_FALSE;
519 TS("Ecore_Con Init");
520 if (!ecore_con_init())
522 e_error_message_show(_("Enlightenment cannot initialize Ecore_Con!\n"));
523 _e_main_shutdown(-1);
525 TS("Ecore_Con Init Done");
526 _e_main_shutdown_push(ecore_con_shutdown);
528 TS("Ecore_Ipc Init");
529 if (!ecore_ipc_init())
531 e_error_message_show(_("Enlightenment cannot initialize Ecore_Ipc!\n"));
532 _e_main_shutdown(-1);
534 TS("Ecore_Ipc Init Done");
535 _e_main_shutdown_push(ecore_ipc_shutdown);
537 _idle_before = ecore_idle_enterer_before_add(_e_main_cb_idle_before, NULL);
539 _xdg_data_dirs_augment();
541 TS("Ecore_Evas Init");
542 if (!ecore_evas_init())
544 e_error_message_show(_("Enlightenment cannot initialize Ecore_Evas!\n"));
545 _e_main_shutdown(-1);
547 TS("Ecore_Evas Init Done");
548 // _e_main_shutdown_push(ecore_evas_shutdown);
550 TS("Elementary Init");
551 if (!elm_init(argc, argv))
553 e_error_message_show(_("Enlightenment cannot initialize Elementary!\n"));
554 _e_main_shutdown(-1);
556 TS("Elementary Init Done");
557 //_e_main_shutdown_push(elm_shutdown);
562 e_error_message_show(_("Enlightenment cannot initialize Emotion!\n"));
563 _e_main_shutdown(-1);
565 TS("Emotion Init Done");
566 _e_main_shutdown_push((void *)emotion_shutdown);
568 /* e doesn't sync to compositor - it should be one */
569 ecore_evas_app_comp_sync_set(0);
571 TS("Ecore_Evas Engine Check");
572 #ifdef HAVE_WAYLAND_ONLY
573 if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_WAYLAND_SHM))
575 e_error_message_show(_("Enlightenment found ecore_evas doesn't support the Wayland SHM\n"
576 "rendering in Evas. Please check your installation of Evas and\n"
577 "Ecore and check they support the Wayland SHM rendering engine."));
578 _e_main_shutdown(-1);
581 if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_XCB))
583 if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_XLIB))
585 e_error_message_show(_("Enlightenment found ecore_evas doesn't support the Software X11\n"
586 "rendering in Evas. Please check your installation of Evas and\n"
587 "Ecore and check they support the Software X11 rendering engine."));
588 _e_main_shutdown(-1);
592 if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_BUFFER))
594 e_error_message_show(_("Enlightenment found ecore_evas doesn't support the Software Buffer\n"
595 "rendering in Evas. Please check your installation of Evas and\n"
596 "Ecore and check they support the Software Buffer rendering engine."));
597 _e_main_shutdown(-1);
599 TS("Ecore_Evas Engine Check Done");
604 e_error_message_show(_("Enlightenment cannot initialize Edje!\n"));
605 _e_main_shutdown(-1);
607 TS("Edje Init Done");
608 _e_main_shutdown_push(edje_shutdown);
611 /*** Initialize E Subsystems We Need ***/
616 e_error_message_show(_("Enlightenment cannot initialize E_Intl!\n"));
617 _e_main_shutdown(-1);
619 TS("E Intl Init Done");
620 _e_main_shutdown_push(e_intl_shutdown);
622 #ifndef HAVE_WAYLAND_ONLY
623 /* init white box of death alert */
627 e_error_message_show(_("Enlightenment cannot initialize its emergency alert system.\n"
628 "Have you set your DISPLAY variable?"));
629 _e_main_shutdown(-1);
631 TS("E_Alert Init Done");
632 _e_main_shutdown_push(e_alert_shutdown);
635 TS("E_Configure Init");
637 TS("E_Configure Init Done");
639 TS("E Directories Init");
640 /* setup directories we will be using for configurations storage etc. */
641 if (!_e_main_dirs_init())
643 e_error_message_show(_("Enlightenment cannot create directories in your home directory.\n"
644 "Perhaps you have no home directory or the disk is full?"));
645 _e_main_shutdown(-1);
647 TS("E Directories Init Done");
648 _e_main_shutdown_push(_e_main_dirs_shutdown);
650 TS("E_Filereg Init");
651 if (!e_filereg_init())
653 e_error_message_show(_("Enlightenment cannot set up its file registry system.\n"));
654 _e_main_shutdown(-1);
656 TS("E_Filereg Init Done");
657 _e_main_shutdown_push(e_filereg_shutdown);
660 if (!e_config_init())
662 e_error_message_show(_("Enlightenment cannot set up its config system.\n"));
663 _e_main_shutdown(-1);
665 TS("E_Config Init Done");
666 _e_main_shutdown_push(e_config_shutdown);
671 e_error_message_show(_("Enlightenment cannot set up its environment.\n"));
672 _e_main_shutdown(-1);
674 TS("E_Env Init Done");
675 _e_main_shutdown_push(e_env_shutdown);
677 efreet_desktop_environment_set(e_config->desktop_environment);
678 e_util_env_set("E_ICON_THEME", e_config->icon_theme);
679 ecore_exe_run_priority_set(e_config->priority);
680 locked |= e_config->desklock_start_locked;
682 s = getenv("E_DESKLOCK_LOCKED");
683 if ((s) && (!strcmp(s, "locked"))) waslocked = EINA_TRUE;
686 if (!_e_main_path_init())
688 e_error_message_show(_("Enlightenment cannot set up paths for finding files.\n"
689 "Perhaps you are out of memory?"));
690 _e_main_shutdown(-1);
692 TS("E Paths Init Done");
693 _e_main_shutdown_push(_e_main_path_shutdown);
696 if (!e_ipc_init()) _e_main_shutdown(-1);
697 TS("E_Ipc Init Done");
698 _e_main_shutdown_push(e_ipc_shutdown);
700 edje_frametime_set(1.0 / e_config->framerate);
705 e_error_message_show(_("Enlightenment cannot set up its font system.\n"));
706 _e_main_shutdown(-1);
708 TS("E_Font Init Done");
709 _e_main_shutdown_push(e_font_shutdown);
713 TS("E_Font Apply Done");
718 e_error_message_show(_("Enlightenment cannot set up its theme system.\n"));
719 _e_main_shutdown(-1);
721 TS("E_Theme Init Done");
722 _e_main_shutdown_push(e_theme_shutdown);
724 TS("E_Moveresize Init");
726 TS("E_Moveresize Init Done");
727 _e_main_shutdown_push(e_moveresize_shutdown);
729 if (e_config->show_splash)
730 e_init_status_set(_("Setup Message Bus"));
733 _e_main_shutdown_push(e_msgbus_shutdown);
734 TS("E_Msgbus Init Done");
739 e_error_message_show(_("Enlightenment cannot initialize the FDO desktop system.\n"
740 "Perhaps you lack permissions on ~/.cache/efreet or are\n"
741 "out of memory or disk space?"));
742 _e_main_shutdown(-1);
744 TS("Efreet Init Done");
745 _e_main_shutdown_push(efreet_shutdown);
747 if (e_config->show_splash)
748 e_init_status_set(_("Starting International Support"));
749 TS("E_Intl Post Init");
750 if (!e_intl_post_init())
752 e_error_message_show(_("Enlightenment cannot set up its intl system.\n"));
753 _e_main_shutdown(-1);
755 TS("E_Intl Post Init Done");
756 _e_main_shutdown_push(e_intl_post_shutdown);
758 e_screensaver_preinit();
760 if (e_config->show_splash)
761 e_init_status_set(_("Setup Actions"));
762 TS("E_Actions Init");
763 if (!e_actions_init())
765 e_error_message_show(_("Enlightenment cannot set up its actions system.\n"));
766 _e_main_shutdown(-1);
768 TS("E_Actions Init Done");
769 _e_main_shutdown_push(e_actions_shutdown);
771 /* these just add event handlers and can't fail
772 * timestamping them is dumb.
778 if (e_config->show_splash)
779 e_init_status_set(_("Setup Powersave Modes"));
780 TS("E_Powersave Init");
781 if (!e_powersave_init())
783 e_error_message_show(_("Enlightenment cannot set up its powersave modes.\n"));
784 _e_main_shutdown(-1);
786 TS("E_Powersave Init Done");
787 _e_main_shutdown_push(e_powersave_shutdown);
789 if (e_config->show_splash)
790 e_init_status_set(_("Setup Screensaver"));
791 TS("E_Screensaver Init");
792 if (!e_screensaver_init())
794 e_error_message_show(_("Enlightenment cannot configure the X screensaver.\n"));
795 _e_main_shutdown(-1);
797 TS("E_Screensaver Init Done");
798 _e_main_shutdown_push(e_screensaver_shutdown);
800 if (e_config->show_splash)
801 e_init_status_set(_("Setup Screens"));
803 if (!_e_main_screens_init())
805 e_error_message_show(_("Enlightenment set up window management for all the screens on your system\n"
806 "failed. Perhaps another window manager is running?\n"));
807 _e_main_shutdown(-1);
809 TS("Screens Init Done");
810 _e_main_shutdown_push(_e_main_screens_shutdown);
811 e_screensaver_force_update();
813 TS("E_Pointer Init");
814 if (!e_pointer_init())
816 e_error_message_show(_("Enlightenment cannot set up its pointer system.\n"));
817 _e_main_shutdown(-1);
819 TS("E_Pointer Init Done");
820 _e_main_shutdown_push(e_pointer_shutdown);
826 e_error_message_show(_("Enlightenment cannot set up its scale system.\n"));
827 _e_main_shutdown(-1);
829 TS("E_Scale Init Done");
830 _e_main_shutdown_push(e_scale_shutdown);
832 if (e_config->show_splash)
837 e_error_message_show(_("Enlightenment cannot set up its init screen.\n"));
838 _e_main_shutdown(-1);
840 TS("E_Splash Init Done");
841 _e_main_shutdown_push(e_init_shutdown);
843 if (!((!e_config->show_splash) || (after_restart)))
848 #ifndef DISABLE_FORMAT_TEST
849 TS("Test File Format Support");
850 _e_main_test_formats();
851 TS("Test File Format Support Done");
856 efreet_icon_extension_add(".svg");
857 efreet_icon_extension_add(".jpg");
858 efreet_icon_extension_add(".png");
859 efreet_icon_extension_add(".edj");
862 if (e_config->show_splash)
863 e_init_status_set(_("Setup ACPI"));
866 TS("E_Acpi Init Done");
867 _e_main_shutdown_push(e_acpi_shutdown);
869 if (e_config->show_splash)
870 e_init_status_set(_("Setup Backlight"));
871 TS("E_Backlight Init");
872 if (!e_backlight_init())
874 e_error_message_show(_("Enlightenment cannot configure the backlight.\n"));
875 _e_main_shutdown(-1);
877 TS("E_Backlight Init Done");
879 if (e_config->show_splash)
880 e_init_status_set(_("Setup DPMS"));
884 e_error_message_show(_("Enlightenment cannot configure the DPMS settings.\n"));
885 _e_main_shutdown(-1);
887 TS("E_Dpms Init Done");
888 _e_main_shutdown_push(e_dpms_shutdown);
890 if (e_config->show_splash)
891 e_init_status_set(_("Setup Desklock"));
892 TS("E_Desklock Init");
893 if (!e_desklock_init())
895 e_error_message_show(_("Enlightenment cannot set up its desk locking system.\n"));
896 _e_main_shutdown(-1);
898 TS("E_Desklock Init Done");
899 _e_main_shutdown_push(e_desklock_shutdown);
901 if (waslocked || (locked && ((!after_restart) || (!getenv("E_DESKLOCK_UNLOCKED")))))
902 e_desklock_show(EINA_TRUE);
904 if (e_config->show_splash)
905 e_init_status_set(_("Setup Paths"));
907 _e_main_efreet_paths_init();
908 TS("Efreet Paths Done");
910 if (e_config->show_splash)
911 e_init_status_set(_("Setup System Controls"));
915 e_error_message_show(_("Enlightenment cannot initialize the System Command system.\n"));
916 _e_main_shutdown(-1);
918 TS("E_Sys Init Done");
919 _e_main_shutdown_push(e_sys_shutdown);
921 if (e_config->show_splash)
922 e_init_status_set(_("Setup Execution System"));
926 e_error_message_show(_("Enlightenment cannot set up its exec system.\n"));
927 _e_main_shutdown(-1);
929 TS("E_Exec Init Done");
933 TS("E_Comp Freeze Done");
935 if (e_config->show_splash)
936 e_init_status_set(_("Setup Filemanager"));
940 e_error_message_show(_("Enlightenment cannot initialize the File manager.\n"));
941 _e_main_shutdown(-1);
943 TS("E_Fm2 Init Done");
944 _e_main_shutdown_push(e_fm2_shutdown);
946 if (e_config->show_splash)
947 e_init_status_set(_("Setup Message System"));
951 e_error_message_show(_("Enlightenment cannot set up its msg system.\n"));
952 _e_main_shutdown(-1);
954 TS("E_Msg Init Done");
955 _e_main_shutdown_push(e_msg_shutdown);
957 if (e_config->show_splash)
958 e_init_status_set(_("Setup Grab Input Handling"));
959 TS("E_Grabinput Init");
960 if (!e_grabinput_init())
962 e_error_message_show(_("Enlightenment cannot set up its grab input handling system.\n"));
963 _e_main_shutdown(-1);
965 TS("E_Grabinput Init Done");
966 _e_main_shutdown_push(e_grabinput_shutdown);
968 if (e_config->show_splash)
969 e_init_status_set(_("Setup Modules"));
971 if (!e_module_init())
973 e_error_message_show(_("Enlightenment cannot set up its module system.\n"));
974 _e_main_shutdown(-1);
976 TS("E_Module Init Done");
977 _e_main_shutdown_push(e_module_shutdown);
979 if (e_config->show_splash)
980 e_init_status_set(_("Setup Remembers"));
981 TS("E_Remember Init");
982 if (!e_remember_init(after_restart ? E_STARTUP_RESTART : E_STARTUP_START))
984 e_error_message_show(_("Enlightenment cannot setup remember settings.\n"));
985 _e_main_shutdown(-1);
987 TS("E_Remember Init Done");
988 _e_main_shutdown_push(e_remember_shutdown);
990 if (e_config->show_splash)
991 e_init_status_set(_("Setup Color Classes"));
992 TS("E_Color_Class Init");
993 if (!e_color_class_init())
995 e_error_message_show(_("Enlightenment cannot set up its color class system.\n"));
996 _e_main_shutdown(-1);
998 TS("E_Color_Class Init Done");
999 _e_main_shutdown_push(e_color_class_shutdown);
1001 if (e_config->show_splash)
1002 e_init_status_set(_("Setup Gadcon"));
1003 TS("E_Gadcon Init");
1004 if (!e_gadcon_init())
1006 e_error_message_show(_("Enlightenment cannot set up its gadget control system.\n"));
1007 _e_main_shutdown(-1);
1009 TS("E_Gadcon Init Done");
1010 _e_main_shutdown_push(e_gadcon_shutdown);
1012 if (e_config->show_splash)
1013 e_init_status_set(_("Setup Toolbars"));
1014 TS("E_Toolbar Init");
1015 if (!e_toolbar_init())
1017 e_error_message_show(_("Enlightenment cannot set up its toolbars.\n"));
1018 _e_main_shutdown(-1);
1020 TS("E_Toolbar Init Done");
1021 _e_main_shutdown_push(e_toolbar_shutdown);
1023 if (e_config->show_splash)
1024 e_init_status_set(_("Setup Wallpaper"));
1028 e_error_message_show(_("Enlightenment cannot set up its desktop background system.\n"));
1029 _e_main_shutdown(-1);
1031 TS("E_Bg Init Done");
1032 _e_main_shutdown_push(e_bg_shutdown);
1034 if (e_config->show_splash)
1035 e_init_status_set(_("Setup Mouse"));
1037 if (!e_mouse_update())
1039 e_error_message_show(_("Enlightenment cannot configure the mouse settings.\n"));
1040 _e_main_shutdown(-1);
1042 TS("E_Mouse Init Done");
1044 if (e_config->show_splash)
1045 e_init_status_set(_("Setup Bindings"));
1046 TS("E_Bindings Init");
1047 if (!e_bindings_init())
1049 e_error_message_show(_("Enlightenment cannot set up its bindings system.\n"));
1050 _e_main_shutdown(-1);
1052 TS("E_Bindings Init Done");
1053 _e_main_shutdown_push(e_bindings_shutdown);
1055 if (e_config->show_splash)
1056 e_init_status_set(_("Setup Thumbnailer"));
1058 if (!e_thumb_init())
1060 e_error_message_show(_("Enlightenment cannot initialize the Thumbnailing system.\n"));
1061 _e_main_shutdown(-1);
1063 TS("E_Thumb Init Done");
1064 _e_main_shutdown_push(e_thumb_shutdown);
1069 e_error_message_show(_("Enlightenment cannot initialize the Icon Cache system.\n"));
1070 _e_main_shutdown(-1);
1072 TS("E_Icon Init Done");
1073 _e_main_shutdown_push(e_icon_shutdown);
1075 TS("E_Update Init");
1076 if (!e_update_init())
1078 e_error_message_show(_("Enlightenment cannot initialize the Update system.\n"));
1079 _e_main_shutdown(-1);
1081 TS("E_Update Init Done");
1082 _e_main_shutdown_push(e_update_shutdown);
1084 if (e_config->show_splash)
1085 e_init_status_set(_("Setup Desktop Environment"));
1086 TS("E_Deskenv Init");
1087 if (!e_deskenv_init())
1089 e_error_message_show(_("Enlightenment cannot initialize its desktop environment.\n"));
1090 _e_main_shutdown(-1);
1092 TS("E_Deskenv Init Done");
1093 _e_main_shutdown_push(e_deskenv_shutdown);
1095 if (e_config->show_splash)
1096 e_init_status_set(_("Setup File Ordering"));
1098 if (!e_order_init())
1100 e_error_message_show(_("Enlightenment cannot set up its order file system.\n"));
1101 _e_main_shutdown(-1);
1103 TS("E_Order Init Done");
1104 _e_main_shutdown_push(e_order_shutdown);
1106 TS("E_Manager Keys Grab");
1107 e_managers_keys_grab();
1108 TS("E_Manager Keys Grab Done");
1110 if (e_config->show_splash)
1111 e_init_status_set(_("Load Modules"));
1113 _e_main_modules_load(safe_mode);
1114 TS("Load Modules Done");
1116 TS("Run Startup Apps");
1120 e_startup(E_STARTUP_RESTART);
1122 e_startup(E_STARTUP_START);
1124 TS("Run Startup Apps Done");
1126 if (e_config->show_splash && (!after_restart))
1127 ecore_timer_add(2.0, _e_main_cb_startup_fake_end, NULL);
1131 TS("E_Comp Thaw Done");
1137 TS("E_Test_Helper Init");
1138 e_test_helper_init();
1139 _e_main_shutdown_push(e_test_helper_shutdown);
1140 TS("E_Test_Helper Done");
1142 TS("E_Info_Server Init");
1143 e_info_server_init();
1144 _e_main_shutdown_push(e_info_server_shutdown);
1145 TS("E_Info_Server Done");
1147 if (e_config->show_splash)
1148 e_init_status_set(_("Setup Shelves"));
1150 if (!e_shelf_init())
1152 e_error_message_show(_("Enlightenment cannot set up its module system.\n"));
1153 _e_main_shutdown(-1);
1155 TS("E_Shelf Init Done");
1157 ecore_idle_enterer_before_add(_e_main_shelf_init_job, NULL);
1159 _idle_before = ecore_idle_enterer_before_add(_e_main_cb_idle_before, NULL);
1161 _xdg_data_dirs_augment();
1163 TS("Ecore_Evas Init");
1164 if (!ecore_evas_init())
1166 e_error_message_show(_("Enlightenment cannot initialize Ecore_Evas!\n"));
1167 _e_main_shutdown(-1);
1169 TS("Ecore_Evas Init Done");
1171 /* e doesn't sync to compositor - it should be one */
1172 ecore_evas_app_comp_sync_set(0);
1174 TS("Ecore_Evas Engine Check");
1175 #ifdef HAVE_WAYLAND_ONLY
1176 if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_WAYLAND_SHM))
1178 e_error_message_show(_("Enlightenment found ecore_evas doesn't support the Wayland SHM\n"
1179 "rendering in Evas. Please check your installation of Evas and\n"
1180 "Ecore and check they support the Wayland SHM rendering engine."));
1181 _e_main_shutdown(-1);
1184 if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_XCB))
1186 if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_XLIB))
1188 e_error_message_show(_("Enlightenment found ecore_evas doesn't support the Software X11\n"
1189 "rendering in Evas. Please check your installation of Evas and\n"
1190 "Ecore and check they support the Software X11 rendering engine."));
1191 _e_main_shutdown(-1);
1195 if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_BUFFER))
1197 e_error_message_show(_("Enlightenment found ecore_evas doesn't support the Software Buffer\n"
1198 "rendering in Evas. Please check your installation of Evas and\n"
1199 "Ecore and check they support the Software Buffer rendering engine."));
1200 _e_main_shutdown(-1);
1202 TS("Ecore_Evas Engine Check Done");
1204 /*** Initialize E Subsystems We Need ***/
1206 TS("E Directories Init");
1207 /* setup directories we will be using for configurations storage etc. */
1208 if (!_e_main_dirs_init())
1210 e_error_message_show(_("Enlightenment cannot create directories in your home directory.\n"
1211 "Perhaps you have no home directory or the disk is full?"));
1212 _e_main_shutdown(-1);
1214 TS("E Directories Init Done");
1215 _e_main_shutdown_push(_e_main_dirs_shutdown);
1217 TS("E_Config Init");
1218 if (!e_config_init())
1220 e_error_message_show(_("Enlightenment cannot set up its config system.\n"));
1221 _e_main_shutdown(-1);
1223 TS("E_Config Init Done");
1224 _e_main_shutdown_push(e_config_shutdown);
1229 e_error_message_show(_("Enlightenment cannot set up its environment.\n"));
1230 _e_main_shutdown(-1);
1232 TS("E_Env Init Done");
1233 _e_main_shutdown_push(e_env_shutdown);
1235 efreet_desktop_environment_set(e_config->desktop_environment);
1236 e_util_env_set("E_ICON_THEME", e_config->icon_theme);
1237 ecore_exe_run_priority_set(e_config->priority);
1238 locked |= e_config->desklock_start_locked;
1241 if (!_e_main_path_init())
1243 e_error_message_show(_("Enlightenment cannot set up paths for finding files.\n"
1244 "Perhaps you are out of memory?"));
1245 _e_main_shutdown(-1);
1247 TS("E Paths Init Done");
1248 _e_main_shutdown_push(_e_main_path_shutdown);
1250 ecore_animator_frametime_set(1.0 / e_config->framerate);
1255 e_error_message_show(_("Enlightenment cannot set up its font system.\n"));
1256 _e_main_shutdown(-1);
1258 TS("E_Font Init Done");
1259 _e_main_shutdown_push(e_font_shutdown);
1263 TS("E_Font Apply Done");
1266 if (!e_theme_init())
1268 e_error_message_show(_("Enlightenment cannot set up its theme system.\n"));
1269 _e_main_shutdown(-1);
1271 TS("E_Theme Init Done");
1272 _e_main_shutdown_push(e_theme_shutdown);
1274 TS("E_Moveresize Init");
1275 e_moveresize_init();
1276 TS("E_Moveresize Init Done");
1277 _e_main_shutdown_push(e_moveresize_shutdown);
1279 e_screensaver_preinit();
1281 if (e_config->show_splash)
1282 e_init_status_set(_("Setup Actions"));
1283 TS("E_Actions Init");
1284 if (!e_actions_init())
1286 e_error_message_show(_("Enlightenment cannot set up its actions system.\n"));
1287 _e_main_shutdown(-1);
1289 TS("E_Actions Init Done");
1290 _e_main_shutdown_push(e_actions_shutdown);
1292 /* these just add event handlers and can't fail
1293 * timestamping them is dumb.
1299 if (e_config->show_splash)
1300 e_init_status_set(_("Setup Powersave Modes"));
1301 TS("E_Powersave Init");
1302 if (!e_powersave_init())
1304 e_error_message_show(_("Enlightenment cannot set up its powersave modes.\n"));
1305 _e_main_shutdown(-1);
1307 TS("E_Powersave Init Done");
1308 _e_main_shutdown_push(e_powersave_shutdown);
1310 if (e_config->show_splash)
1311 e_init_status_set(_("Setup Screensaver"));
1312 TS("E_Screensaver Init");
1313 if (!e_screensaver_init())
1315 e_error_message_show(_("Enlightenment cannot configure the X screensaver.\n"));
1316 _e_main_shutdown(-1);
1318 TS("E_Screensaver Init Done");
1319 _e_main_shutdown_push(e_screensaver_shutdown);
1321 if (e_config->show_splash)
1322 e_init_status_set(_("Setup Screens"));
1324 if (!_e_main_screens_init())
1326 e_error_message_show(_("Enlightenment set up window management for all the screens on your system\n"
1327 "failed. Perhaps another window manager is running?\n"));
1328 _e_main_shutdown(-1);
1330 TS("Screens Init Done");
1331 _e_main_shutdown_push(_e_main_screens_shutdown);
1332 e_screensaver_force_update();
1334 if (e_config->show_splash)
1335 e_init_status_set(_("Setup System Controls"));
1339 e_error_message_show(_("Enlightenment cannot initialize the System Command system.\n"));
1340 _e_main_shutdown(-1);
1342 TS("E_Sys Init Done");
1343 _e_main_shutdown_push(e_sys_shutdown);
1345 TS("E_Comp Freeze");
1346 e_comp_all_freeze();
1347 TS("E_Comp Freeze Done");
1349 if (e_config->show_splash)
1350 e_init_status_set(_("Setup Grab Input Handling"));
1351 TS("E_Grabinput Init");
1352 if (!e_grabinput_init())
1354 e_error_message_show(_("Enlightenment cannot set up its grab input handling system.\n"));
1355 _e_main_shutdown(-1);
1357 TS("E_Grabinput Init Done");
1358 _e_main_shutdown_push(e_grabinput_shutdown);
1360 ecore_event_handler_add(E_EVENT_MODULE_INIT_END, _e_main_deferred_job_schedule, NULL);
1362 if (e_config->show_splash)
1363 e_init_status_set(_("Setup Modules"));
1364 TS("E_Module Init");
1365 if (!e_module_init())
1367 e_error_message_show(_("Enlightenment cannot set up its module system.\n"));
1368 _e_main_shutdown(-1);
1370 TS("E_Module Init Done");
1371 _e_main_shutdown_push(e_module_shutdown);
1373 if (e_config->show_splash)
1374 e_init_status_set(_("Setup Remembers"));
1375 TS("E_Remember Init");
1376 if (!e_remember_init(after_restart ? E_STARTUP_RESTART : E_STARTUP_START))
1378 e_error_message_show(_("Enlightenment cannot setup remember settings.\n"));
1379 _e_main_shutdown(-1);
1381 TS("E_Remember Init Done");
1382 _e_main_shutdown_push(e_remember_shutdown);
1384 if (e_config->show_splash)
1385 e_init_status_set(_("Setup Mouse"));
1387 if (!e_mouse_update())
1389 e_error_message_show(_("Enlightenment cannot configure the mouse settings.\n"));
1390 _e_main_shutdown(-1);
1392 TS("E_Mouse Init Done");
1394 if (e_config->show_splash)
1395 e_init_status_set(_("Setup Bindings"));
1396 TS("E_Bindings Init");
1397 if (!e_bindings_init())
1399 e_error_message_show(_("Enlightenment cannot set up its bindings system.\n"));
1400 _e_main_shutdown(-1);
1402 TS("E_Bindings Init Done");
1403 _e_main_shutdown_push(e_bindings_shutdown);
1408 e_error_message_show(_("Enlightenment cannot initialize the Icon Cache system.\n"));
1409 _e_main_shutdown(-1);
1411 TS("E_Icon Init Done");
1412 _e_main_shutdown_push(e_icon_shutdown);
1414 TS("E_Manager Keys Grab");
1415 e_managers_keys_grab();
1416 TS("E_Manager Keys Grab Done");
1418 if (e_config->show_splash)
1419 e_init_status_set(_("Load Modules"));
1421 _e_main_modules_load(safe_mode);
1422 TS("Load Modules Done");
1424 if (e_config->show_splash && (!after_restart))
1425 ecore_timer_add(2.0, _e_main_cb_startup_fake_end, NULL);
1429 TS("E_Comp Thaw Done");
1432 _idle_after = ecore_idle_enterer_add(_e_main_cb_idle_after, NULL);
1434 if (e_config->show_splash)
1435 e_init_status_set(_("Almost Done"));
1437 starting = EINA_FALSE;
1440 e_util_env_set("E_RESTART", "1");
1442 TS("MAIN LOOP AT LAST");
1443 if (!setjmp(x_fatal_buff))
1444 ecore_main_loop_begin();
1446 CRI("FATAL: X Died. Connection gone. Abbreviated Shutdown\n");
1448 inloop = EINA_FALSE;
1449 stopping = EINA_TRUE;
1451 //if (!x_fatal) e_canvas_idle_flush();
1453 e_config_save_flush();
1454 _e_main_desk_save();
1455 e_remember_internal_save();
1456 e_comp_internal_save();
1458 _e_main_shutdown(0);
1462 e_util_env_set("E_RESTART_OK", "1");
1463 if (getenv("E_START_MTRACK"))
1464 e_util_env_set("MTRACK", "track");
1465 ecore_app_restart();
1468 e_prefix_shutdown();
1474 e_main_ts(const char *str)
1477 t1 = ecore_time_unix_get();
1478 printf("ESTART: %1.5f [%1.5f] - %s\n", t1 - t0, t1 - t2, str);
1484 /* local functions */
1486 _e_main_shutdown(int errcode)
1492 printf("E: Begin Shutdown Procedure!\n");
1494 if (_idle_before) ecore_idle_enterer_del(_idle_before);
1495 _idle_before = NULL;
1496 if (_idle_after) ecore_idle_enterer_del(_idle_after);
1499 dir = getenv("XDG_RUNTIME_DIR");
1502 char buf_env[PATH_MAX];
1503 snprintf(buf_env, sizeof(buf_env), "%s", dir);
1504 snprintf(buf, sizeof(buf), "%s/.e-deleteme", buf_env);
1505 if (ecore_file_exists(buf)) ecore_file_recursive_rm(buf_env);
1507 for (i = (_e_main_lvl - 1); i >= 0; i--)
1508 (*_e_main_shutdown_func[i])();
1509 #ifdef OBJECT_HASH_CHECK
1510 e_object_hash_shutdown();
1512 if (errcode < 0) exit(errcode);
1516 _e_main_shutdown_push(int (*func)(void))
1519 if (_e_main_lvl > MAX_LEVEL)
1522 e_error_message_show("WARNING: too many init levels. MAX = %i\n",
1526 _e_main_shutdown_func[_e_main_lvl - 1] = func;
1530 _e_main_parse_arguments(int argc, char **argv)
1535 /* handle some command-line parameters */
1536 for (i = 1; i < argc; i++)
1538 if ((!strcmp(argv[i], "-display")) && (i < (argc - 1)))
1541 e_util_env_set("DISPLAY", argv[i]);
1543 else if ((!strcmp(argv[i], "-fake-xinerama-screen")) && (i < (argc - 1)))
1548 if (sscanf(argv[i], "%ix%i+%i+%i", &w, &h, &x, &y) == 4)
1549 e_xinerama_fake_screen_add(x, y, w, h);
1551 else if (!strcmp(argv[i], "-good"))
1555 printf("LA LA LA\n");
1557 else if (!strcmp(argv[i], "-evil"))
1561 printf("MUHAHAHAHHAHAHAHAHA\n");
1563 else if (!strcmp(argv[i], "-psychotic"))
1567 printf("MUHAHALALALALALALALA\n");
1569 else if ((!strcmp(argv[i], "-profile")) && (i < (argc - 1)))
1572 if (!getenv("E_CONF_PROFILE"))
1573 e_util_env_set("E_CONF_PROFILE", argv[i]);
1575 else if (!strcmp(argv[i], "-i-really-know-what-i-am-doing-and-accept-full-responsibility-for-it"))
1576 really_know = EINA_TRUE;
1577 else if (!strcmp(argv[i], "-locked"))
1579 else if (!strcmp(argv[i], "-nopause"))
1580 e_nopause = EINA_TRUE;
1581 else if ((!strcmp(argv[i], "-h")) ||
1582 (!strcmp(argv[i], "-help")) ||
1583 (!strcmp(argv[i], "--help")))
1588 "\t-display DISPLAY\n"
1589 "\t\tConnect to display named DISPLAY.\n"
1590 "\t\tEG: -display :1.0\n"
1591 "\t-fake-xinerama-screen WxH+X+Y\n"
1592 "\t\tAdd a FAKE xinerama screen (instead of the real ones)\n"
1593 "\t\tgiven the geometry. Add as many as you like. They all\n"
1594 "\t\treplace the real xinerama screens, if any. This can\n"
1595 "\t\tbe used to simulate xinerama.\n"
1596 "\t\tEG: -fake-xinerama-screen 800x600+0+0 -fake-xinerama-screen 800x600+800+0\n"
1597 "\t-profile CONF_PROFILE\n"
1598 "\t\tUse the configuration profile CONF_PROFILE instead of the user selected default or just \"default\".\n"
1604 "\t\tBe psychotic.\n"
1606 "\t\tStart with desklock on, so password will be asked.\n"
1607 "\t-i-really-know-what-i-am-doing-and-accept-full-responsibility-for-it\n"
1608 "\t\tIf you need this help, you don't need this option.\n"
1611 _e_main_shutdown(-1);
1615 /* fix up DISPLAY to be :N.0 if no .screen is in it */
1616 s = getenv("DISPLAY");
1619 char *p, buff[4096];
1621 if (!(p = strrchr(s, ':')))
1623 snprintf(buff, sizeof(buff), "%s:0.0", s);
1624 e_util_env_set("DISPLAY", buff);
1628 if (!strrchr(p, '.'))
1630 snprintf(buff, sizeof(buff), "%s.0", s);
1631 e_util_env_set("DISPLAY", buff);
1636 /* we want to have been launched by enlightenment_start. there is a very */
1637 /* good reason we want to have been launched this way, thus check */
1638 if (!getenv("E_START"))
1640 e_error_message_show(_("You are executing enlightenment directly. This is\n"
1641 "bad. Please do not execute the \"enlightenment\"\n"
1642 "binary. Use the \"enlightenment_start\" launcher. It\n"
1643 "will handle setting up environment variables, paths,\n"
1644 "and launching any other required services etc.\n"
1645 "before enlightenment itself begins running.\n"));
1646 _e_main_shutdown(-1);
1651 _e_main_cb_x_fatal(void *data __UNUSED__)
1653 e_error_message_show("Lost X Connection.\n");
1654 ecore_main_loop_quit();
1657 x_fatal = EINA_TRUE;
1658 if (inloop) longjmp(x_fatal_buff, -99);
1663 _e_main_cb_signal_exit(void *data __UNUSED__, int ev_type __UNUSED__, void *ev __UNUSED__)
1665 /* called on ctrl-c, kill (pid) (also SIGINT, SIGTERM and SIGQIT) */
1666 e_sys_action_do(E_SYS_EXIT, NULL);
1667 return ECORE_CALLBACK_RENEW;
1671 _e_main_cb_signal_hup(void *data __UNUSED__, int ev_type __UNUSED__, void *ev __UNUSED__)
1673 e_sys_action_do(E_SYS_RESTART, NULL);
1674 return ECORE_CALLBACK_RENEW;
1678 _e_main_cb_signal_user(void *data __UNUSED__, int ev_type __UNUSED__, void *ev)
1680 Ecore_Event_Signal_User *e = ev;
1684 // E_Action *a = e_action_find("configuration");
1685 // if ((a) && (a->func.go)) a->func.go(NULL, NULL);
1687 else if (e->number == 2)
1689 // comp module has its own handler for this for enabling/disabling fps debug
1691 return ECORE_CALLBACK_RENEW;
1696 _e_main_dirs_init(void)
1699 const char *dirs[] =
1707 "applications/menu",
1708 "applications/menu/favorite",
1709 "applications/menu/all",
1711 "applications/bar/default",
1712 "applications/startup",
1713 "applications/restart",
1714 "applications/trash",
1715 "applications/desk-lock",
1716 "applications/desk-unlock",
1724 base = e_user_dir_get();
1725 if (ecore_file_mksubdirs(base, dirs) != sizeof(dirs) / sizeof(dirs[0]) - 1)
1727 e_error_message_show("Could not create one of the required "
1728 "subdirectories of '%s'\n", base);
1736 _e_main_dirs_shutdown(void)
1742 _e_main_path_init(void)
1746 /* setup data paths */
1747 path_data = e_path_new();
1750 e_error_message_show("Cannot allocate path for path_data\n");
1753 e_prefix_data_concat_static(buf, "data");
1754 e_path_default_path_append(path_data, buf);
1755 e_path_user_path_set(path_data, &(e_config->path_append_data));
1757 /* setup image paths */
1758 path_images = e_path_new();
1761 e_error_message_show("Cannot allocate path for path_images\n");
1764 e_user_dir_concat_static(buf, "/images");
1765 e_path_default_path_append(path_images, buf);
1766 e_prefix_data_concat_static(buf, "data/images");
1767 e_path_default_path_append(path_images, buf);
1768 e_path_user_path_set(path_images, &(e_config->path_append_images));
1770 /* setup font paths */
1771 path_fonts = e_path_new();
1774 e_error_message_show("Cannot allocate path for path_fonts\n");
1777 e_user_dir_concat_static(buf, "/fonts");
1778 e_path_default_path_append(path_fonts, buf);
1779 e_prefix_data_concat_static(buf, "data/fonts");
1780 e_path_default_path_append(path_fonts, buf);
1781 e_path_user_path_set(path_fonts, &(e_config->path_append_fonts));
1783 /* setup icon paths */
1784 path_icons = e_path_new();
1787 e_error_message_show("Cannot allocate path for path_icons\n");
1790 e_user_dir_concat_static(buf, "/icons");
1791 e_path_default_path_append(path_icons, buf);
1792 e_prefix_data_concat_static(buf, "data/icons");
1793 e_path_default_path_append(path_icons, buf);
1794 e_path_user_path_set(path_icons, &(e_config->path_append_icons));
1796 /* setup module paths */
1797 path_modules = e_path_new();
1800 e_error_message_show("Cannot allocate path for path_modules\n");
1803 e_user_dir_concat_static(buf, "/modules");
1804 e_path_default_path_append(path_modules, buf);
1805 snprintf(buf, sizeof(buf), "%s/enlightenment/modules", e_prefix_lib_get());
1806 e_path_default_path_append(path_modules, buf);
1807 /* FIXME: eventually this has to go - moduels should have installers that
1808 * add appropriate install paths (if not installed to user homedir) to
1809 * e's module search dirs
1811 snprintf(buf, sizeof(buf), "%s/enlightenment/modules_extra", e_prefix_lib_get());
1812 e_path_default_path_append(path_modules, buf);
1813 e_path_user_path_set(path_modules, &(e_config->path_append_modules));
1815 /* setup background paths */
1816 path_backgrounds = e_path_new();
1817 if (!path_backgrounds)
1819 e_error_message_show("Cannot allocate path for path_backgrounds\n");
1822 e_user_dir_concat_static(buf, "/backgrounds");
1823 e_path_default_path_append(path_backgrounds, buf);
1824 e_prefix_data_concat_static(buf, "data/backgrounds");
1825 e_path_default_path_append(path_backgrounds, buf);
1826 e_path_user_path_set(path_backgrounds, &(e_config->path_append_backgrounds));
1828 path_messages = e_path_new();
1831 e_error_message_show("Cannot allocate path for path_messages\n");
1834 e_user_dir_concat_static(buf, "/locale");
1835 e_path_default_path_append(path_messages, buf);
1836 e_path_default_path_append(path_messages, e_prefix_locale_get());
1837 e_path_user_path_set(path_messages, &(e_config->path_append_messages));
1843 _e_main_path_shutdown(void)
1847 e_object_del(E_OBJECT(path_data));
1852 e_object_del(E_OBJECT(path_images));
1857 e_object_del(E_OBJECT(path_fonts));
1862 e_object_del(E_OBJECT(path_icons));
1867 e_object_del(E_OBJECT(path_modules));
1868 path_modules = NULL;
1870 if (path_backgrounds)
1872 e_object_del(E_OBJECT(path_backgrounds));
1873 path_backgrounds = NULL;
1877 e_object_del(E_OBJECT(path_messages));
1878 path_messages = NULL;
1883 #ifndef DISABLE_FORMAT_TEST
1885 _e_main_test_formats(void)
1889 Evas_Object *im, *txt;
1891 char buff[PATH_MAX];
1893 if (e_config->show_splash)
1894 e_init_status_set(_("Testing Format Support"));
1896 if (!(ee = ecore_evas_buffer_new(1, 1)))
1898 e_error_message_show(_("Enlightenment found Evas can't create a buffer canvas. Please check\n"
1899 "Evas has Software Buffer engine support.\n"));
1900 _e_main_shutdown(-1);
1902 evas = ecore_evas_get(ee);
1903 im = evas_object_image_add(evas);
1905 e_prefix_data_concat_static(buff, "data/images/test.svg");
1906 evas_object_image_file_set(im, buff, NULL);
1907 if (evas_object_image_load_error_get(im) != EVAS_LOAD_ERROR_NONE)
1909 e_error_message_show(_("Enlightenment found Evas can't load SVG files. "
1910 "Check Evas has SVG loader support.\n"));
1913 efreet_icon_extension_add(".svg");
1915 e_prefix_data_concat_static(buff, "data/images/test.jpg");
1916 evas_object_image_file_set(im, buff, NULL);
1917 if (evas_object_image_load_error_get(im) != EVAS_LOAD_ERROR_NONE)
1919 e_error_message_show(_("Enlightenment found Evas can't load JPEG files. "
1920 "Check Evas has JPEG loader support.\n"));
1921 _e_main_shutdown(-1);
1923 efreet_icon_extension_add(".jpg");
1925 e_prefix_data_concat_static(buff, "data/images/test.png");
1926 evas_object_image_file_set(im, buff, NULL);
1927 if (evas_object_image_load_error_get(im) != EVAS_LOAD_ERROR_NONE)
1929 e_error_message_show(_("Enlightenment found Evas can't load PNG files. "
1930 "Check Evas has PNG loader support.\n"));
1931 _e_main_shutdown(-1);
1933 efreet_icon_extension_add(".png");
1935 e_prefix_data_concat_static(buff, "data/images/test.edj");
1936 evas_object_image_file_set(im, buff, "images/0");
1937 if (evas_object_image_load_error_get(im) != EVAS_LOAD_ERROR_NONE)
1939 e_error_message_show(_("Enlightenment found Evas can't load EET files. "
1940 "Check Evas has EET loader support.\n"));
1941 _e_main_shutdown(-1);
1943 efreet_icon_extension_add(".edj");
1945 evas_object_del(im);
1947 txt = evas_object_text_add(evas);
1948 evas_object_text_font_set(txt, "Sans", 10);
1949 evas_object_text_text_set(txt, "Hello");
1950 evas_object_geometry_get(txt, NULL, NULL, &tw, &th);
1951 if ((tw <= 0) && (th <= 0))
1953 e_error_message_show(_("Enlightenment found Evas can't load the 'Sans' font. Check Evas has fontconfig\n"
1954 "support and system fontconfig defines a 'Sans' font.\n"));
1955 _e_main_shutdown(-1);
1957 evas_object_del(txt);
1958 ecore_evas_free(ee);
1963 _e_main_screens_init(void)
1965 TS("\tscreens: manager");
1966 if (!e_manager_init()) return 0;
1968 TS("\tscreens: client");
1969 if (!e_client_init()) return 0;
1970 #ifndef ENABLE_QUICK_INIT
1971 TS("\tscreens: win");
1972 if (!e_win_init()) return 0;
1974 #ifndef HAVE_WAYLAND_ONLY
1978 e_error_message_show(_("Enlightenment cannot setup XKB Keyboard layouts.\n"));
1979 _e_main_shutdown(-1);
1981 TS("E_Xkb Init Done");
1984 TS("Compositor Init");
1987 e_error_message_show(_("Enlightenment cannot create a compositor.\n"));
1988 _e_main_shutdown(-1);
1991 _e_main_desk_restore();
1993 #ifndef HAVE_WAYLAND_ONLY
1994 if (e_config->show_splash)
1995 e_init_status_set(_("Setup DND"));
1999 e_error_message_show(_("Enlightenment cannot set up its dnd system.\n"));
2000 _e_main_shutdown(-1);
2002 TS("E_Dnd Init Done");
2003 _e_main_shutdown_push(e_dnd_shutdown);
2010 _e_main_screens_shutdown(void)
2016 e_client_shutdown();
2017 e_exehist_shutdown();
2018 e_backlight_shutdown();
2023 e_manager_shutdown();
2028 _e_main_desk_save(void)
2031 char env[1024], name[1024];
2034 EINA_LIST_FOREACH(e_comp->zones, l, zone)
2036 snprintf(name, sizeof(name), "DESK_%d_%d", e_comp->num, zone->num);
2037 snprintf(env, sizeof(env), "%d,%d", zone->desk_x_current, zone->desk_y_current);
2038 e_util_env_set(name, env);
2043 _e_main_desk_restore(void)
2050 EINA_LIST_FOREACH(e_comp->zones, l, zone)
2056 snprintf(name, sizeof(name), "DESK_%d_%d", e_comp->num, zone->num);
2059 snprintf(buf_e, sizeof(buf_e), "%s", env);
2060 if (!sscanf(buf_e, "%d,%d", &desk_x, &desk_y)) continue;
2061 desk = e_desk_at_xy_get(zone, desk_x, desk_y);
2062 if (!desk) continue;
2068 _e_main_efreet_paths_init(void)
2072 if ((list = efreet_icon_extra_list_get()))
2074 char buff[PATH_MAX];
2076 e_user_dir_concat_static(buff, "icons");
2077 *list = eina_list_prepend(*list, (void *)eina_stringshare_add(buff));
2078 e_prefix_data_concat_static(buff, "data/icons");
2079 *list = eina_list_prepend(*list, (void *)eina_stringshare_add(buff));
2084 _e_main_modules_load_after(void *d EINA_UNUSED, int type EINA_UNUSED, void *ev EINA_UNUSED)
2086 e_int_config_modules(NULL, NULL);
2087 E_FREE_FUNC(mod_init_end, ecore_event_handler_del);
2088 return ECORE_CALLBACK_RENEW;
2092 _e_main_modules_load(Eina_Bool safe_mode)
2095 e_module_all_load();
2101 crashmodule = getenv("E_MODULE_LOAD");
2102 if (crashmodule) m = e_module_new(crashmodule);
2104 if ((crashmodule) && (m))
2106 e_module_disable(m);
2107 e_object_del(E_OBJECT(m));
2109 e_error_message_show
2110 (_("Enlightenment crashed early on start and has<br>"
2111 "been restarted. There was an error loading the<br>"
2112 "module named: %s. This module has been disabled<br>"
2113 "and will not be loaded."), crashmodule);
2115 (_("Enlightenment crashed early on start and has been restarted"),
2116 _("Enlightenment crashed early on start and has been restarted.<br>"
2117 "There was an error loading the module named: %s<br><br>"
2118 "This module has been disabled and will not be loaded."), crashmodule);
2119 e_module_all_load();
2123 e_error_message_show
2124 (_("Enlightenment crashed early on start and has<br>"
2125 "been restarted. All modules have been disabled<br>"
2126 "and will not be loaded to help remove any problem<br>"
2127 "modules from your configuration. The module<br>"
2128 "configuration dialog should let you select your<br>"
2129 "modules again.\n"));
2131 (_("Enlightenment crashed early on start and has been restarted"),
2132 _("Enlightenment crashed early on start and has been restarted.<br>"
2133 "All modules have been disabled and will not be loaded to help<br>"
2134 "remove any problem modules from your configuration.<br><br>"
2135 "The module configuration dialog should let you select your<br>"
2138 mod_init_end = ecore_event_handler_add(E_EVENT_MODULE_INIT_END, _e_main_modules_load_after, NULL);
2143 _e_main_cb_idle_before(void *data __UNUSED__)
2145 e_menu_idler_before();
2146 e_client_idler_before();
2147 e_pointer_idler_before();
2149 return ECORE_CALLBACK_RENEW;
2153 _e_main_cb_idle_after(void *data __UNUSED__)
2155 static int first_idle = 1;
2160 #ifdef E_RELEASE_BUILD
2165 e_precache_end = EINA_TRUE;
2168 if (first_idle++ < 60)
2172 e_precache_end = EINA_TRUE;
2176 return ECORE_CALLBACK_RENEW;
2180 _e_main_cb_startup_fake_end(void *data __UNUSED__)
2183 return ECORE_CALLBACK_CANCEL;