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 static void _e_main_test_formats(void);
81 static int _e_main_screens_init(void);
82 static int _e_main_screens_shutdown(void);
83 static void _e_main_desk_save(void);
84 static void _e_main_desk_restore(void);
85 static void _e_main_efreet_paths_init(void);
86 static void _e_main_modules_load(Eina_Bool safe_mode);
87 static Eina_Bool _e_main_cb_idle_before(void *data __UNUSED__);
88 static Eina_Bool _e_main_cb_idle_after(void *data __UNUSED__);
89 static Eina_Bool _e_main_cb_startup_fake_end(void *data __UNUSED__);
92 static Eina_Bool really_know = EINA_FALSE;
93 static Eina_Bool locked = EINA_FALSE;
94 static Eina_Bool inloop = EINA_FALSE;
95 static jmp_buf x_fatal_buff;
97 static int _e_main_lvl = 0;
98 static int(*_e_main_shutdown_func[MAX_LEVEL]) (void);
100 static Ecore_Idle_Enterer *_idle_before = NULL;
101 static Ecore_Idle_Enterer *_idle_after = NULL;
103 static Ecore_Event_Handler *mod_init_end = NULL;
105 /* external variables */
106 EAPI Eina_Bool e_precache_end = EINA_FALSE;
107 EAPI Eina_Bool x_fatal = EINA_FALSE;
108 EAPI Eina_Bool good = EINA_FALSE;
109 EAPI Eina_Bool evil = EINA_FALSE;
110 EAPI Eina_Bool starting = EINA_TRUE;
111 EAPI Eina_Bool stopping = EINA_FALSE;
112 EAPI Eina_Bool restart = EINA_FALSE;
113 EAPI Eina_Bool e_nopause = EINA_FALSE;
114 EINTERN const char *e_first_frame = NULL;
115 EINTERN double e_first_frame_start_time = -1;
118 _xdg_check_str(const char *env, const char *str)
124 for (p = strstr(env, str); p; p++, p = strstr(p, str))
126 if ((!p[len]) || (p[len] == ':')) return EINA_TRUE;
132 _xdg_data_dirs_augment(void)
135 const char *p = e_prefix_get();
136 char newpath[4096], buf[4096];
140 s = getenv("XDG_DATA_DIRS");
143 Eina_Bool pfxdata, pfx;
145 pfxdata = !_xdg_check_str(s, e_prefix_data_get());
146 snprintf(newpath, sizeof(newpath), "%s/share", p);
147 pfx = !_xdg_check_str(s, newpath);
150 snprintf(buf, sizeof(buf), "%s%s%s%s%s",
151 pfxdata ? e_prefix_data_get() : "",
156 e_util_env_set("XDG_DATA_DIRS", buf);
161 snprintf(buf, sizeof(buf), "%s:%s/share:/usr/local/share:/usr/share", e_prefix_data_get(), p);
162 e_util_env_set("XDG_DATA_DIRS", buf);
165 s = getenv("XDG_CONFIG_DIRS");
166 snprintf(newpath, sizeof(newpath), "%s/etc/xdg", p);
169 if (!_xdg_check_str(s, newpath))
171 snprintf(buf, sizeof(buf), "%s:%s", newpath, s);
172 e_util_env_set("XDG_CONFIG_DIRS", buf);
177 snprintf(buf, sizeof(buf), "%s:/etc/xdg", newpath);
178 e_util_env_set("XDG_CONFIG_DIRS", buf);
181 if (!getenv("XDG_RUNTIME_DIR"))
185 snprintf(buf, sizeof(buf), "/tmp/xdg-XXXXXX");
187 if (!dir) dir = "/tmp";
190 e_util_env_set("XDG_RUNTIME_DIR", dir);
191 snprintf(buf, sizeof(buf), "%s/.e-deleteme", dir);
192 ecore_file_mkdir(buf);
196 /* set menu prefix so we get our e menu */
197 if (!getenv("XDG_MENU_PREFIX"))
199 e_util_env_set("XDG_MENU_PREFIX", "e-");
203 #ifndef ENABLE_QUICK_INIT
205 _e_main_shelf_init_job(void *data EINA_UNUSED)
207 e_shelf_config_update();
208 return ECORE_CALLBACK_CANCEL;
212 _e_main_subsystem_defer(void *data EINA_UNUSED)
217 ecore_app_args_get(&argc, &argv);
219 /* try to init delayed subsystems */
220 TS("[DEFERRED] Elementary Init");
221 if (!elm_init(argc, argv))
223 e_error_message_show(_("Enlightenment cannot initialize Elementary!\n"));
224 _e_main_shutdown(-1);
226 TS("[DEFERRED] Elementary Init Done");
228 TS("[DEFERRED] Edje Init");
231 e_error_message_show(_("Enlightenment cannot initialize Edje!\n"));
232 _e_main_shutdown(-1);
234 TS("[DEFERRED] Edje Init Done");
235 _e_main_shutdown_push(edje_shutdown);
237 TS("[DEFERRED] Efreet Init");
240 e_error_message_show(_("Enlightenment cannot initialize the FDO desktop system.\n"
241 "Perhaps you lack permissions on ~/.cache/efreet or are\n"
242 "out of memory or disk space?"));
243 _e_main_shutdown(-1);
245 TS("[DEFERRED] Efreet Init Done");
246 _e_main_shutdown_push(efreet_shutdown);
248 TS("[DEFERRED] Screens Init: win");
251 e_error_message_show(_("Enlightenment cannot setup elementary trap!\n"));
252 _e_main_shutdown(-1);
254 TS("[DEFERRED] Screens Init: win Done");
256 TS("[DEFERRED] E_Pointer Init");
257 if (!e_pointer_init())
259 e_error_message_show(_("Enlightenment cannot set up its pointer system.\n"));
260 _e_main_shutdown(-1);
263 TS("[DEFERRED] E_Pointer Init Done");
264 _e_main_shutdown_push(e_pointer_shutdown);
266 TS("[DEFERRED] E_Scale Init");
269 e_error_message_show(_("Enlightenment cannot set up its scale system.\n"));
270 _e_main_shutdown(-1);
272 TS("[DEFERRED E_Scale Init Done");
273 _e_main_shutdown_push(e_scale_shutdown);
275 TS("[DEFERRED] Efreet Paths");
276 _e_main_efreet_paths_init();
277 TS("[DEFERRED] Efreet Paths Done");
279 TS("[DEFERRED] E_Test_Helper Init");
280 e_test_helper_init();
281 _e_main_shutdown_push(e_test_helper_shutdown);
282 TS("[DEFERRED] E_Test_Helper Done");
284 TS("[DEFERRED] E_INFO_SERVER Init");
285 e_info_server_init();
286 _e_main_shutdown_push(e_info_server_shutdown);
287 TS("[DEFERRED] E_INFO_SERVER Done");
289 /* try to do deferred job of any subsystems*/
290 TS("[DEFERRED] Compositor's deferred job");
291 e_comp_deferred_job();
292 TS("[DEFERRED] Compositor's deferred job Done");
294 TS("[DEFERRED] E_Module's deferred job");
295 e_module_deferred_job();
296 TS("[DEFERRED] E_Module's deferred job Done");
298 return ECORE_CALLBACK_DONE;
302 _e_main_deferred_job_schedule(void *d EINA_UNUSED, int type EINA_UNUSED, void *ev EINA_UNUSED)
304 ecore_idler_add(_e_main_subsystem_defer, NULL);
305 return ECORE_CALLBACK_DONE;
310 /* externally accessible functions */
312 main(int argc, char **argv)
314 Eina_Bool nostartup = EINA_FALSE;
315 Eina_Bool safe_mode = EINA_FALSE;
316 Eina_Bool after_restart = EINA_FALSE;
317 Eina_Bool waslocked = 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);
451 e_error_message_show(_("Enlightenment cannot initialize Ecore!\n"));
452 _e_main_shutdown(-1);
454 TS("Ecore Init Done");
455 _e_main_shutdown_push(ecore_shutdown);
457 e_first_frame = getenv("E_FIRST_FRAME");
458 if (e_first_frame && (!e_first_frame[0]))
459 e_first_frame = NULL;
461 e_first_frame_start_time = ecore_time_get();
466 e_error_message_show(_("Enlightenment cannot initialize EIO!\n"));
467 _e_main_shutdown(-1);
470 _e_main_shutdown_push(eio_shutdown);
472 ecore_app_args_set(argc, (const char **)argv);
474 TS("Ecore Event Handlers");
475 if (!ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT,
476 _e_main_cb_signal_exit, NULL))
478 e_error_message_show(_("Enlightenment cannot set up an exit signal handler.\n"
479 "Perhaps you are out of memory?"));
480 _e_main_shutdown(-1);
482 if (!ecore_event_handler_add(ECORE_EVENT_SIGNAL_HUP,
483 _e_main_cb_signal_hup, NULL))
485 e_error_message_show(_("Enlightenment cannot set up a HUP signal handler.\n"
486 "Perhaps you are out of memory?"));
487 _e_main_shutdown(-1);
489 if (!ecore_event_handler_add(ECORE_EVENT_SIGNAL_USER,
490 _e_main_cb_signal_user, NULL))
492 e_error_message_show(_("Enlightenment cannot set up a USER signal handler.\n"
493 "Perhaps you are out of memory?"));
494 _e_main_shutdown(-1);
496 TS("Ecore Event Handlers Done");
498 TS("Ecore_File Init");
499 if (!ecore_file_init())
501 e_error_message_show(_("Enlightenment cannot initialize Ecore_File!\n"));
502 _e_main_shutdown(-1);
504 TS("Ecore_File Init Done");
505 _e_main_shutdown_push(ecore_file_shutdown);
507 #ifndef ENABLE_QUICK_INIT
508 TS("Ecore_Con Init");
509 if (!ecore_con_init())
511 e_error_message_show(_("Enlightenment cannot initialize Ecore_Con!\n"));
512 _e_main_shutdown(-1);
514 TS("Ecore_Con Init Done");
515 _e_main_shutdown_push(ecore_con_shutdown);
517 TS("Ecore_Ipc Init");
518 if (!ecore_ipc_init())
520 e_error_message_show(_("Enlightenment cannot initialize Ecore_Ipc!\n"));
521 _e_main_shutdown(-1);
523 TS("Ecore_Ipc Init Done");
524 _e_main_shutdown_push(ecore_ipc_shutdown);
526 _idle_before = ecore_idle_enterer_before_add(_e_main_cb_idle_before, NULL);
528 _xdg_data_dirs_augment();
530 TS("Ecore_Evas Init");
531 if (!ecore_evas_init())
533 e_error_message_show(_("Enlightenment cannot initialize Ecore_Evas!\n"));
534 _e_main_shutdown(-1);
536 TS("Ecore_Evas Init Done");
537 // _e_main_shutdown_push(ecore_evas_shutdown);
539 TS("Elementary Init");
540 if (!elm_init(argc, argv))
542 e_error_message_show(_("Enlightenment cannot initialize Elementary!\n"));
543 _e_main_shutdown(-1);
545 TS("Elementary Init Done");
546 //_e_main_shutdown_push(elm_shutdown);
551 e_error_message_show(_("Enlightenment cannot initialize Emotion!\n"));
552 _e_main_shutdown(-1);
554 TS("Emotion Init Done");
555 _e_main_shutdown_push((void *)emotion_shutdown);
557 /* e doesn't sync to compositor - it should be one */
558 ecore_evas_app_comp_sync_set(0);
560 TS("Ecore_Evas Engine Check");
561 #ifdef HAVE_WAYLAND_ONLY
562 if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_WAYLAND_SHM))
564 e_error_message_show(_("Enlightenment found ecore_evas doesn't support the Wayland SHM\n"
565 "rendering in Evas. Please check your installation of Evas and\n"
566 "Ecore and check they support the Wayland SHM rendering engine."));
567 _e_main_shutdown(-1);
570 if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_XCB))
572 if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_XLIB))
574 e_error_message_show(_("Enlightenment found ecore_evas doesn't support the Software X11\n"
575 "rendering in Evas. Please check your installation of Evas and\n"
576 "Ecore and check they support the Software X11 rendering engine."));
577 _e_main_shutdown(-1);
581 if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_BUFFER))
583 e_error_message_show(_("Enlightenment found ecore_evas doesn't support the Software Buffer\n"
584 "rendering in Evas. Please check your installation of Evas and\n"
585 "Ecore and check they support the Software Buffer rendering engine."));
586 _e_main_shutdown(-1);
588 TS("Ecore_Evas Engine Check Done");
593 e_error_message_show(_("Enlightenment cannot initialize Edje!\n"));
594 _e_main_shutdown(-1);
596 TS("Edje Init Done");
597 _e_main_shutdown_push(edje_shutdown);
600 /*** Initialize E Subsystems We Need ***/
605 e_error_message_show(_("Enlightenment cannot initialize E_Intl!\n"));
606 _e_main_shutdown(-1);
608 TS("E Intl Init Done");
609 _e_main_shutdown_push(e_intl_shutdown);
611 #ifndef HAVE_WAYLAND_ONLY
612 /* init white box of death alert */
616 e_error_message_show(_("Enlightenment cannot initialize its emergency alert system.\n"
617 "Have you set your DISPLAY variable?"));
618 _e_main_shutdown(-1);
620 TS("E_Alert Init Done");
621 _e_main_shutdown_push(e_alert_shutdown);
624 TS("E_Configure Init");
626 TS("E_Configure Init Done");
628 TS("E Directories Init");
629 /* setup directories we will be using for configurations storage etc. */
630 if (!_e_main_dirs_init())
632 e_error_message_show(_("Enlightenment cannot create directories in your home directory.\n"
633 "Perhaps you have no home directory or the disk is full?"));
634 _e_main_shutdown(-1);
636 TS("E Directories Init Done");
637 _e_main_shutdown_push(_e_main_dirs_shutdown);
639 TS("E_Filereg Init");
640 if (!e_filereg_init())
642 e_error_message_show(_("Enlightenment cannot set up its file registry system.\n"));
643 _e_main_shutdown(-1);
645 TS("E_Filereg Init Done");
646 _e_main_shutdown_push(e_filereg_shutdown);
649 if (!e_config_init())
651 e_error_message_show(_("Enlightenment cannot set up its config system.\n"));
652 _e_main_shutdown(-1);
654 TS("E_Config Init Done");
655 _e_main_shutdown_push(e_config_shutdown);
660 e_error_message_show(_("Enlightenment cannot set up its environment.\n"));
661 _e_main_shutdown(-1);
663 TS("E_Env Init Done");
664 _e_main_shutdown_push(e_env_shutdown);
666 efreet_desktop_environment_set(e_config->desktop_environment);
667 e_util_env_set("E_ICON_THEME", e_config->icon_theme);
668 ecore_exe_run_priority_set(e_config->priority);
669 locked |= e_config->desklock_start_locked;
671 s = getenv("E_DESKLOCK_LOCKED");
672 if ((s) && (!strcmp(s, "locked"))) waslocked = EINA_TRUE;
675 if (!_e_main_path_init())
677 e_error_message_show(_("Enlightenment cannot set up paths for finding files.\n"
678 "Perhaps you are out of memory?"));
679 _e_main_shutdown(-1);
681 TS("E Paths Init Done");
682 _e_main_shutdown_push(_e_main_path_shutdown);
685 if (!e_ipc_init()) _e_main_shutdown(-1);
686 TS("E_Ipc Init Done");
687 _e_main_shutdown_push(e_ipc_shutdown);
689 edje_frametime_set(1.0 / e_config->framerate);
694 e_error_message_show(_("Enlightenment cannot set up its font system.\n"));
695 _e_main_shutdown(-1);
697 TS("E_Font Init Done");
698 _e_main_shutdown_push(e_font_shutdown);
702 TS("E_Font Apply Done");
707 e_error_message_show(_("Enlightenment cannot set up its theme system.\n"));
708 _e_main_shutdown(-1);
710 TS("E_Theme Init Done");
711 _e_main_shutdown_push(e_theme_shutdown);
713 TS("E_Moveresize Init");
715 TS("E_Moveresize Init Done");
716 _e_main_shutdown_push(e_moveresize_shutdown);
718 if (e_config->show_splash)
719 e_init_status_set(_("Setup Message Bus"));
722 _e_main_shutdown_push(e_msgbus_shutdown);
723 TS("E_Msgbus Init Done");
728 e_error_message_show(_("Enlightenment cannot initialize the FDO desktop system.\n"
729 "Perhaps you lack permissions on ~/.cache/efreet or are\n"
730 "out of memory or disk space?"));
731 _e_main_shutdown(-1);
733 TS("Efreet Init Done");
734 _e_main_shutdown_push(efreet_shutdown);
736 if (e_config->show_splash)
737 e_init_status_set(_("Starting International Support"));
738 TS("E_Intl Post Init");
739 if (!e_intl_post_init())
741 e_error_message_show(_("Enlightenment cannot set up its intl system.\n"));
742 _e_main_shutdown(-1);
744 TS("E_Intl Post Init Done");
745 _e_main_shutdown_push(e_intl_post_shutdown);
747 e_screensaver_preinit();
749 if (e_config->show_splash)
750 e_init_status_set(_("Setup Actions"));
751 TS("E_Actions Init");
752 if (!e_actions_init())
754 e_error_message_show(_("Enlightenment cannot set up its actions system.\n"));
755 _e_main_shutdown(-1);
757 TS("E_Actions Init Done");
758 _e_main_shutdown_push(e_actions_shutdown);
760 /* these just add event handlers and can't fail
761 * timestamping them is dumb.
767 if (e_config->show_splash)
768 e_init_status_set(_("Setup Powersave Modes"));
769 TS("E_Powersave Init");
770 if (!e_powersave_init())
772 e_error_message_show(_("Enlightenment cannot set up its powersave modes.\n"));
773 _e_main_shutdown(-1);
775 TS("E_Powersave Init Done");
776 _e_main_shutdown_push(e_powersave_shutdown);
778 if (e_config->show_splash)
779 e_init_status_set(_("Setup Screensaver"));
780 TS("E_Screensaver Init");
781 if (!e_screensaver_init())
783 e_error_message_show(_("Enlightenment cannot configure the X screensaver.\n"));
784 _e_main_shutdown(-1);
786 TS("E_Screensaver Init Done");
787 _e_main_shutdown_push(e_screensaver_shutdown);
789 if (e_config->show_splash)
790 e_init_status_set(_("Setup Screens"));
792 if (!_e_main_screens_init())
794 e_error_message_show(_("Enlightenment set up window management for all the screens on your system\n"
795 "failed. Perhaps another window manager is running?\n"));
796 _e_main_shutdown(-1);
798 TS("Screens Init Done");
799 _e_main_shutdown_push(_e_main_screens_shutdown);
800 e_screensaver_force_update();
802 TS("E_Pointer Init");
803 if (!e_pointer_init())
805 e_error_message_show(_("Enlightenment cannot set up its pointer system.\n"));
806 _e_main_shutdown(-1);
808 TS("E_Pointer Init Done");
809 _e_main_shutdown_push(e_pointer_shutdown);
815 e_error_message_show(_("Enlightenment cannot set up its scale system.\n"));
816 _e_main_shutdown(-1);
818 TS("E_Scale Init Done");
819 _e_main_shutdown_push(e_scale_shutdown);
821 if (e_config->show_splash)
826 e_error_message_show(_("Enlightenment cannot set up its init screen.\n"));
827 _e_main_shutdown(-1);
829 TS("E_Splash Init Done");
830 _e_main_shutdown_push(e_init_shutdown);
832 if (!((!e_config->show_splash) || (after_restart)))
837 TS("Test File Format Support");
838 _e_main_test_formats();
839 TS("Test File Format Support Done");
843 efreet_icon_extension_add(".svg");
844 efreet_icon_extension_add(".jpg");
845 efreet_icon_extension_add(".png");
846 efreet_icon_extension_add(".edj");
849 if (e_config->show_splash)
850 e_init_status_set(_("Setup ACPI"));
853 TS("E_Acpi Init Done");
854 _e_main_shutdown_push(e_acpi_shutdown);
856 if (e_config->show_splash)
857 e_init_status_set(_("Setup Backlight"));
858 TS("E_Backlight Init");
859 if (!e_backlight_init())
861 e_error_message_show(_("Enlightenment cannot configure the backlight.\n"));
862 _e_main_shutdown(-1);
864 TS("E_Backlight Init Done");
866 if (e_config->show_splash)
867 e_init_status_set(_("Setup DPMS"));
871 e_error_message_show(_("Enlightenment cannot configure the DPMS settings.\n"));
872 _e_main_shutdown(-1);
874 TS("E_Dpms Init Done");
875 _e_main_shutdown_push(e_dpms_shutdown);
877 if (e_config->show_splash)
878 e_init_status_set(_("Setup Desklock"));
879 TS("E_Desklock Init");
880 if (!e_desklock_init())
882 e_error_message_show(_("Enlightenment cannot set up its desk locking system.\n"));
883 _e_main_shutdown(-1);
885 TS("E_Desklock Init Done");
886 _e_main_shutdown_push(e_desklock_shutdown);
888 if (waslocked || (locked && ((!after_restart) || (!getenv("E_DESKLOCK_UNLOCKED")))))
889 e_desklock_show(EINA_TRUE);
891 if (e_config->show_splash)
892 e_init_status_set(_("Setup Paths"));
894 _e_main_efreet_paths_init();
895 TS("Efreet Paths Done");
897 if (e_config->show_splash)
898 e_init_status_set(_("Setup System Controls"));
902 e_error_message_show(_("Enlightenment cannot initialize the System Command system.\n"));
903 _e_main_shutdown(-1);
905 TS("E_Sys Init Done");
906 _e_main_shutdown_push(e_sys_shutdown);
908 if (e_config->show_splash)
909 e_init_status_set(_("Setup Execution System"));
913 e_error_message_show(_("Enlightenment cannot set up its exec system.\n"));
914 _e_main_shutdown(-1);
916 TS("E_Exec Init Done");
920 TS("E_Comp Freeze Done");
922 if (e_config->show_splash)
923 e_init_status_set(_("Setup Filemanager"));
927 e_error_message_show(_("Enlightenment cannot initialize the File manager.\n"));
928 _e_main_shutdown(-1);
930 TS("E_Fm2 Init Done");
931 _e_main_shutdown_push(e_fm2_shutdown);
933 if (e_config->show_splash)
934 e_init_status_set(_("Setup Message System"));
938 e_error_message_show(_("Enlightenment cannot set up its msg system.\n"));
939 _e_main_shutdown(-1);
941 TS("E_Msg Init Done");
942 _e_main_shutdown_push(e_msg_shutdown);
944 if (e_config->show_splash)
945 e_init_status_set(_("Setup Grab Input Handling"));
946 TS("E_Grabinput Init");
947 if (!e_grabinput_init())
949 e_error_message_show(_("Enlightenment cannot set up its grab input handling system.\n"));
950 _e_main_shutdown(-1);
952 TS("E_Grabinput Init Done");
953 _e_main_shutdown_push(e_grabinput_shutdown);
955 if (e_config->show_splash)
956 e_init_status_set(_("Setup Modules"));
958 if (!e_module_init())
960 e_error_message_show(_("Enlightenment cannot set up its module system.\n"));
961 _e_main_shutdown(-1);
963 TS("E_Module Init Done");
964 _e_main_shutdown_push(e_module_shutdown);
966 if (e_config->show_splash)
967 e_init_status_set(_("Setup Remembers"));
968 TS("E_Remember Init");
969 if (!e_remember_init(after_restart ? E_STARTUP_RESTART : E_STARTUP_START))
971 e_error_message_show(_("Enlightenment cannot setup remember settings.\n"));
972 _e_main_shutdown(-1);
974 TS("E_Remember Init Done");
975 _e_main_shutdown_push(e_remember_shutdown);
977 if (e_config->show_splash)
978 e_init_status_set(_("Setup Color Classes"));
979 TS("E_Color_Class Init");
980 if (!e_color_class_init())
982 e_error_message_show(_("Enlightenment cannot set up its color class system.\n"));
983 _e_main_shutdown(-1);
985 TS("E_Color_Class Init Done");
986 _e_main_shutdown_push(e_color_class_shutdown);
988 if (e_config->show_splash)
989 e_init_status_set(_("Setup Gadcon"));
991 if (!e_gadcon_init())
993 e_error_message_show(_("Enlightenment cannot set up its gadget control system.\n"));
994 _e_main_shutdown(-1);
996 TS("E_Gadcon Init Done");
997 _e_main_shutdown_push(e_gadcon_shutdown);
999 if (e_config->show_splash)
1000 e_init_status_set(_("Setup Toolbars"));
1001 TS("E_Toolbar Init");
1002 if (!e_toolbar_init())
1004 e_error_message_show(_("Enlightenment cannot set up its toolbars.\n"));
1005 _e_main_shutdown(-1);
1007 TS("E_Toolbar Init Done");
1008 _e_main_shutdown_push(e_toolbar_shutdown);
1010 if (e_config->show_splash)
1011 e_init_status_set(_("Setup Wallpaper"));
1015 e_error_message_show(_("Enlightenment cannot set up its desktop background system.\n"));
1016 _e_main_shutdown(-1);
1018 TS("E_Bg Init Done");
1019 _e_main_shutdown_push(e_bg_shutdown);
1021 if (e_config->show_splash)
1022 e_init_status_set(_("Setup Mouse"));
1024 if (!e_mouse_update())
1026 e_error_message_show(_("Enlightenment cannot configure the mouse settings.\n"));
1027 _e_main_shutdown(-1);
1029 TS("E_Mouse Init Done");
1031 if (e_config->show_splash)
1032 e_init_status_set(_("Setup Bindings"));
1033 TS("E_Bindings Init");
1034 if (!e_bindings_init())
1036 e_error_message_show(_("Enlightenment cannot set up its bindings system.\n"));
1037 _e_main_shutdown(-1);
1039 TS("E_Bindings Init Done");
1040 _e_main_shutdown_push(e_bindings_shutdown);
1042 if (e_config->show_splash)
1043 e_init_status_set(_("Setup Thumbnailer"));
1045 if (!e_thumb_init())
1047 e_error_message_show(_("Enlightenment cannot initialize the Thumbnailing system.\n"));
1048 _e_main_shutdown(-1);
1050 TS("E_Thumb Init Done");
1051 _e_main_shutdown_push(e_thumb_shutdown);
1056 e_error_message_show(_("Enlightenment cannot initialize the Icon Cache system.\n"));
1057 _e_main_shutdown(-1);
1059 TS("E_Icon Init Done");
1060 _e_main_shutdown_push(e_icon_shutdown);
1062 TS("E_Update Init");
1063 if (!e_update_init())
1065 e_error_message_show(_("Enlightenment cannot initialize the Update system.\n"));
1066 _e_main_shutdown(-1);
1068 TS("E_Update Init Done");
1069 _e_main_shutdown_push(e_update_shutdown);
1071 if (e_config->show_splash)
1072 e_init_status_set(_("Setup Desktop Environment"));
1073 TS("E_Deskenv Init");
1074 if (!e_deskenv_init())
1076 e_error_message_show(_("Enlightenment cannot initialize its desktop environment.\n"));
1077 _e_main_shutdown(-1);
1079 TS("E_Deskenv Init Done");
1080 _e_main_shutdown_push(e_deskenv_shutdown);
1082 if (e_config->show_splash)
1083 e_init_status_set(_("Setup File Ordering"));
1085 if (!e_order_init())
1087 e_error_message_show(_("Enlightenment cannot set up its order file system.\n"));
1088 _e_main_shutdown(-1);
1090 TS("E_Order Init Done");
1091 _e_main_shutdown_push(e_order_shutdown);
1093 TS("E_Manager Keys Grab");
1094 e_managers_keys_grab();
1095 TS("E_Manager Keys Grab Done");
1097 if (e_config->show_splash)
1098 e_init_status_set(_("Load Modules"));
1100 _e_main_modules_load(safe_mode);
1101 TS("Load Modules Done");
1103 TS("Run Startup Apps");
1107 e_startup(E_STARTUP_RESTART);
1109 e_startup(E_STARTUP_START);
1111 TS("Run Startup Apps Done");
1113 if (e_config->show_splash && (!after_restart))
1114 ecore_timer_add(2.0, _e_main_cb_startup_fake_end, NULL);
1118 TS("E_Comp Thaw Done");
1124 TS("E_Test_Helper Init");
1125 e_test_helper_init();
1126 _e_main_shutdown_push(e_test_helper_shutdown);
1127 TS("E_Test_Helper Done");
1129 TS("E_Info_Server Init");
1130 e_info_server_init();
1131 _e_main_shutdown_push(e_info_server_shutdown);
1132 TS("E_Info_Server Done");
1134 if (e_config->show_splash)
1135 e_init_status_set(_("Setup Shelves"));
1137 if (!e_shelf_init())
1139 e_error_message_show(_("Enlightenment cannot set up its module system.\n"));
1140 _e_main_shutdown(-1);
1142 TS("E_Shelf Init Done");
1144 ecore_idle_enterer_before_add(_e_main_shelf_init_job, NULL);
1146 _idle_before = ecore_idle_enterer_before_add(_e_main_cb_idle_before, NULL);
1148 _xdg_data_dirs_augment();
1150 TS("Ecore_Evas Init");
1151 if (!ecore_evas_init())
1153 e_error_message_show(_("Enlightenment cannot initialize Ecore_Evas!\n"));
1154 _e_main_shutdown(-1);
1156 TS("Ecore_Evas Init Done");
1158 /* e doesn't sync to compositor - it should be one */
1159 ecore_evas_app_comp_sync_set(0);
1161 TS("Ecore_Evas Engine Check");
1162 #ifdef HAVE_WAYLAND_ONLY
1163 if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_WAYLAND_SHM))
1165 e_error_message_show(_("Enlightenment found ecore_evas doesn't support the Wayland SHM\n"
1166 "rendering in Evas. Please check your installation of Evas and\n"
1167 "Ecore and check they support the Wayland SHM rendering engine."));
1168 _e_main_shutdown(-1);
1171 if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_XCB))
1173 if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_XLIB))
1175 e_error_message_show(_("Enlightenment found ecore_evas doesn't support the Software X11\n"
1176 "rendering in Evas. Please check your installation of Evas and\n"
1177 "Ecore and check they support the Software X11 rendering engine."));
1178 _e_main_shutdown(-1);
1182 if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_BUFFER))
1184 e_error_message_show(_("Enlightenment found ecore_evas doesn't support the Software Buffer\n"
1185 "rendering in Evas. Please check your installation of Evas and\n"
1186 "Ecore and check they support the Software Buffer rendering engine."));
1187 _e_main_shutdown(-1);
1189 TS("Ecore_Evas Engine Check Done");
1191 /*** Initialize E Subsystems We Need ***/
1193 TS("E Directories Init");
1194 /* setup directories we will be using for configurations storage etc. */
1195 if (!_e_main_dirs_init())
1197 e_error_message_show(_("Enlightenment cannot create directories in your home directory.\n"
1198 "Perhaps you have no home directory or the disk is full?"));
1199 _e_main_shutdown(-1);
1201 TS("E Directories Init Done");
1202 _e_main_shutdown_push(_e_main_dirs_shutdown);
1204 TS("E_Config Init");
1205 if (!e_config_init())
1207 e_error_message_show(_("Enlightenment cannot set up its config system.\n"));
1208 _e_main_shutdown(-1);
1210 TS("E_Config Init Done");
1211 _e_main_shutdown_push(e_config_shutdown);
1216 e_error_message_show(_("Enlightenment cannot set up its environment.\n"));
1217 _e_main_shutdown(-1);
1219 TS("E_Env Init Done");
1220 _e_main_shutdown_push(e_env_shutdown);
1222 efreet_desktop_environment_set(e_config->desktop_environment);
1223 e_util_env_set("E_ICON_THEME", e_config->icon_theme);
1224 ecore_exe_run_priority_set(e_config->priority);
1225 locked |= e_config->desklock_start_locked;
1227 s = getenv("E_DESKLOCK_LOCKED");
1228 if ((s) && (!strcmp(s, "locked"))) waslocked = EINA_TRUE;
1231 if (!_e_main_path_init())
1233 e_error_message_show(_("Enlightenment cannot set up paths for finding files.\n"
1234 "Perhaps you are out of memory?"));
1235 _e_main_shutdown(-1);
1237 TS("E Paths Init Done");
1238 _e_main_shutdown_push(_e_main_path_shutdown);
1240 ecore_animator_frametime_set(1.0 / e_config->framerate);
1245 e_error_message_show(_("Enlightenment cannot set up its font system.\n"));
1246 _e_main_shutdown(-1);
1248 TS("E_Font Init Done");
1249 _e_main_shutdown_push(e_font_shutdown);
1253 TS("E_Font Apply Done");
1256 if (!e_theme_init())
1258 e_error_message_show(_("Enlightenment cannot set up its theme system.\n"));
1259 _e_main_shutdown(-1);
1261 TS("E_Theme Init Done");
1262 _e_main_shutdown_push(e_theme_shutdown);
1264 TS("E_Moveresize Init");
1265 e_moveresize_init();
1266 TS("E_Moveresize Init Done");
1267 _e_main_shutdown_push(e_moveresize_shutdown);
1269 e_screensaver_preinit();
1271 if (e_config->show_splash)
1272 e_init_status_set(_("Setup Actions"));
1273 TS("E_Actions Init");
1274 if (!e_actions_init())
1276 e_error_message_show(_("Enlightenment cannot set up its actions system.\n"));
1277 _e_main_shutdown(-1);
1279 TS("E_Actions Init Done");
1280 _e_main_shutdown_push(e_actions_shutdown);
1282 /* these just add event handlers and can't fail
1283 * timestamping them is dumb.
1289 if (e_config->show_splash)
1290 e_init_status_set(_("Setup Powersave Modes"));
1291 TS("E_Powersave Init");
1292 if (!e_powersave_init())
1294 e_error_message_show(_("Enlightenment cannot set up its powersave modes.\n"));
1295 _e_main_shutdown(-1);
1297 TS("E_Powersave Init Done");
1298 _e_main_shutdown_push(e_powersave_shutdown);
1300 if (e_config->show_splash)
1301 e_init_status_set(_("Setup Screensaver"));
1302 TS("E_Screensaver Init");
1303 if (!e_screensaver_init())
1305 e_error_message_show(_("Enlightenment cannot configure the X screensaver.\n"));
1306 _e_main_shutdown(-1);
1308 TS("E_Screensaver Init Done");
1309 _e_main_shutdown_push(e_screensaver_shutdown);
1311 if (e_config->show_splash)
1312 e_init_status_set(_("Setup Screens"));
1314 if (!_e_main_screens_init())
1316 e_error_message_show(_("Enlightenment set up window management for all the screens on your system\n"
1317 "failed. Perhaps another window manager is running?\n"));
1318 _e_main_shutdown(-1);
1320 TS("Screens Init Done");
1321 _e_main_shutdown_push(_e_main_screens_shutdown);
1322 e_screensaver_force_update();
1324 if (e_config->show_splash)
1325 e_init_status_set(_("Setup System Controls"));
1329 e_error_message_show(_("Enlightenment cannot initialize the System Command system.\n"));
1330 _e_main_shutdown(-1);
1332 TS("E_Sys Init Done");
1333 _e_main_shutdown_push(e_sys_shutdown);
1335 TS("E_Comp Freeze");
1336 e_comp_all_freeze();
1337 TS("E_Comp Freeze Done");
1339 if (e_config->show_splash)
1340 e_init_status_set(_("Setup Grab Input Handling"));
1341 TS("E_Grabinput Init");
1342 if (!e_grabinput_init())
1344 e_error_message_show(_("Enlightenment cannot set up its grab input handling system.\n"));
1345 _e_main_shutdown(-1);
1347 TS("E_Grabinput Init Done");
1348 _e_main_shutdown_push(e_grabinput_shutdown);
1350 ecore_event_handler_add(E_EVENT_MODULE_INIT_END, _e_main_deferred_job_schedule, NULL);
1352 if (e_config->show_splash)
1353 e_init_status_set(_("Setup Modules"));
1354 TS("E_Module Init");
1355 if (!e_module_init())
1357 e_error_message_show(_("Enlightenment cannot set up its module system.\n"));
1358 _e_main_shutdown(-1);
1360 TS("E_Module Init Done");
1361 _e_main_shutdown_push(e_module_shutdown);
1363 if (e_config->show_splash)
1364 e_init_status_set(_("Setup Remembers"));
1365 TS("E_Remember Init");
1366 if (!e_remember_init(after_restart ? E_STARTUP_RESTART : E_STARTUP_START))
1368 e_error_message_show(_("Enlightenment cannot setup remember settings.\n"));
1369 _e_main_shutdown(-1);
1371 TS("E_Remember Init Done");
1372 _e_main_shutdown_push(e_remember_shutdown);
1374 if (e_config->show_splash)
1375 e_init_status_set(_("Setup Mouse"));
1377 if (!e_mouse_update())
1379 e_error_message_show(_("Enlightenment cannot configure the mouse settings.\n"));
1380 _e_main_shutdown(-1);
1382 TS("E_Mouse Init Done");
1384 if (e_config->show_splash)
1385 e_init_status_set(_("Setup Bindings"));
1386 TS("E_Bindings Init");
1387 if (!e_bindings_init())
1389 e_error_message_show(_("Enlightenment cannot set up its bindings system.\n"));
1390 _e_main_shutdown(-1);
1392 TS("E_Bindings Init Done");
1393 _e_main_shutdown_push(e_bindings_shutdown);
1398 e_error_message_show(_("Enlightenment cannot initialize the Icon Cache system.\n"));
1399 _e_main_shutdown(-1);
1401 TS("E_Icon Init Done");
1402 _e_main_shutdown_push(e_icon_shutdown);
1404 TS("E_Manager Keys Grab");
1405 e_managers_keys_grab();
1406 TS("E_Manager Keys Grab Done");
1408 if (e_config->show_splash)
1409 e_init_status_set(_("Load Modules"));
1411 _e_main_modules_load(safe_mode);
1412 TS("Load Modules Done");
1414 if (e_config->show_splash && (!after_restart))
1415 ecore_timer_add(2.0, _e_main_cb_startup_fake_end, NULL);
1419 TS("E_Comp Thaw Done");
1422 _idle_after = ecore_idle_enterer_add(_e_main_cb_idle_after, NULL);
1424 if (e_config->show_splash)
1425 e_init_status_set(_("Almost Done"));
1427 starting = EINA_FALSE;
1430 e_util_env_set("E_RESTART", "1");
1432 TS("MAIN LOOP AT LAST");
1433 if (!setjmp(x_fatal_buff))
1434 ecore_main_loop_begin();
1436 CRI("FATAL: X Died. Connection gone. Abbreviated Shutdown\n");
1438 inloop = EINA_FALSE;
1439 stopping = EINA_TRUE;
1441 //if (!x_fatal) e_canvas_idle_flush();
1443 e_config_save_flush();
1444 _e_main_desk_save();
1445 e_remember_internal_save();
1446 e_comp_internal_save();
1448 _e_main_shutdown(0);
1452 e_util_env_set("E_RESTART_OK", "1");
1453 if (getenv("E_START_MTRACK"))
1454 e_util_env_set("MTRACK", "track");
1455 ecore_app_restart();
1458 e_prefix_shutdown();
1464 e_main_ts(const char *str)
1467 t1 = ecore_time_unix_get();
1468 printf("ESTART: %1.5f [%1.5f] - %s\n", t1 - t0, t1 - t2, str);
1474 /* local functions */
1476 _e_main_shutdown(int errcode)
1482 printf("E: Begin Shutdown Procedure!\n");
1484 if (_idle_before) ecore_idle_enterer_del(_idle_before);
1485 _idle_before = NULL;
1486 if (_idle_after) ecore_idle_enterer_del(_idle_after);
1489 dir = getenv("XDG_RUNTIME_DIR");
1492 char buf_env[PATH_MAX];
1493 snprintf(buf_env, sizeof(buf_env), "%s", dir);
1494 snprintf(buf, sizeof(buf), "%s/.e-deleteme", buf_env);
1495 if (ecore_file_exists(buf)) ecore_file_recursive_rm(buf_env);
1497 for (i = (_e_main_lvl - 1); i >= 0; i--)
1498 (*_e_main_shutdown_func[i])();
1499 #ifdef OBJECT_HASH_CHECK
1500 e_object_hash_shutdown();
1502 if (errcode < 0) exit(errcode);
1506 _e_main_shutdown_push(int (*func)(void))
1509 if (_e_main_lvl > MAX_LEVEL)
1512 e_error_message_show("WARNING: too many init levels. MAX = %i\n",
1516 _e_main_shutdown_func[_e_main_lvl - 1] = func;
1520 _e_main_parse_arguments(int argc, char **argv)
1525 /* handle some command-line parameters */
1526 for (i = 1; i < argc; i++)
1528 if ((!strcmp(argv[i], "-display")) && (i < (argc - 1)))
1531 e_util_env_set("DISPLAY", argv[i]);
1533 else if ((!strcmp(argv[i], "-fake-xinerama-screen")) && (i < (argc - 1)))
1538 if (sscanf(argv[i], "%ix%i+%i+%i", &w, &h, &x, &y) == 4)
1539 e_xinerama_fake_screen_add(x, y, w, h);
1541 else if (!strcmp(argv[i], "-good"))
1545 printf("LA LA LA\n");
1547 else if (!strcmp(argv[i], "-evil"))
1551 printf("MUHAHAHAHHAHAHAHAHA\n");
1553 else if (!strcmp(argv[i], "-psychotic"))
1557 printf("MUHAHALALALALALALALA\n");
1559 else if ((!strcmp(argv[i], "-profile")) && (i < (argc - 1)))
1562 if (!getenv("E_CONF_PROFILE"))
1563 e_util_env_set("E_CONF_PROFILE", argv[i]);
1565 else if (!strcmp(argv[i], "-i-really-know-what-i-am-doing-and-accept-full-responsibility-for-it"))
1566 really_know = EINA_TRUE;
1567 else if (!strcmp(argv[i], "-locked"))
1569 else if (!strcmp(argv[i], "-nopause"))
1570 e_nopause = EINA_TRUE;
1571 else if ((!strcmp(argv[i], "-h")) ||
1572 (!strcmp(argv[i], "-help")) ||
1573 (!strcmp(argv[i], "--help")))
1578 "\t-display DISPLAY\n"
1579 "\t\tConnect to display named DISPLAY.\n"
1580 "\t\tEG: -display :1.0\n"
1581 "\t-fake-xinerama-screen WxH+X+Y\n"
1582 "\t\tAdd a FAKE xinerama screen (instead of the real ones)\n"
1583 "\t\tgiven the geometry. Add as many as you like. They all\n"
1584 "\t\treplace the real xinerama screens, if any. This can\n"
1585 "\t\tbe used to simulate xinerama.\n"
1586 "\t\tEG: -fake-xinerama-screen 800x600+0+0 -fake-xinerama-screen 800x600+800+0\n"
1587 "\t-profile CONF_PROFILE\n"
1588 "\t\tUse the configuration profile CONF_PROFILE instead of the user selected default or just \"default\".\n"
1594 "\t\tBe psychotic.\n"
1596 "\t\tStart with desklock on, so password will be asked.\n"
1597 "\t-i-really-know-what-i-am-doing-and-accept-full-responsibility-for-it\n"
1598 "\t\tIf you need this help, you don't need this option.\n"
1601 _e_main_shutdown(-1);
1605 /* fix up DISPLAY to be :N.0 if no .screen is in it */
1606 s = getenv("DISPLAY");
1609 char *p, buff[4096];
1611 if (!(p = strrchr(s, ':')))
1613 snprintf(buff, sizeof(buff), "%s:0.0", s);
1614 e_util_env_set("DISPLAY", buff);
1618 if (!strrchr(p, '.'))
1620 snprintf(buff, sizeof(buff), "%s.0", s);
1621 e_util_env_set("DISPLAY", buff);
1626 /* we want to have been launched by enlightenment_start. there is a very */
1627 /* good reason we want to have been launched this way, thus check */
1628 if (!getenv("E_START"))
1630 e_error_message_show(_("You are executing enlightenment directly. This is\n"
1631 "bad. Please do not execute the \"enlightenment\"\n"
1632 "binary. Use the \"enlightenment_start\" launcher. It\n"
1633 "will handle setting up environment variables, paths,\n"
1634 "and launching any other required services etc.\n"
1635 "before enlightenment itself begins running.\n"));
1636 _e_main_shutdown(-1);
1641 _e_main_cb_x_fatal(void *data __UNUSED__)
1643 e_error_message_show("Lost X Connection.\n");
1644 ecore_main_loop_quit();
1647 x_fatal = EINA_TRUE;
1648 if (inloop) longjmp(x_fatal_buff, -99);
1653 _e_main_cb_signal_exit(void *data __UNUSED__, int ev_type __UNUSED__, void *ev __UNUSED__)
1655 /* called on ctrl-c, kill (pid) (also SIGINT, SIGTERM and SIGQIT) */
1656 e_sys_action_do(E_SYS_EXIT, NULL);
1657 return ECORE_CALLBACK_RENEW;
1661 _e_main_cb_signal_hup(void *data __UNUSED__, int ev_type __UNUSED__, void *ev __UNUSED__)
1663 e_sys_action_do(E_SYS_RESTART, NULL);
1664 return ECORE_CALLBACK_RENEW;
1668 _e_main_cb_signal_user(void *data __UNUSED__, int ev_type __UNUSED__, void *ev)
1670 Ecore_Event_Signal_User *e = ev;
1674 // E_Action *a = e_action_find("configuration");
1675 // if ((a) && (a->func.go)) a->func.go(NULL, NULL);
1677 else if (e->number == 2)
1679 // comp module has its own handler for this for enabling/disabling fps debug
1681 return ECORE_CALLBACK_RENEW;
1686 _e_main_dirs_init(void)
1689 const char *dirs[] =
1697 "applications/menu",
1698 "applications/menu/favorite",
1699 "applications/menu/all",
1701 "applications/bar/default",
1702 "applications/startup",
1703 "applications/restart",
1704 "applications/trash",
1705 "applications/desk-lock",
1706 "applications/desk-unlock",
1714 base = e_user_dir_get();
1715 if (ecore_file_mksubdirs(base, dirs) != sizeof(dirs) / sizeof(dirs[0]) - 1)
1717 e_error_message_show("Could not create one of the required "
1718 "subdirectories of '%s'\n", base);
1726 _e_main_dirs_shutdown(void)
1732 _e_main_path_init(void)
1736 /* setup data paths */
1737 path_data = e_path_new();
1740 e_error_message_show("Cannot allocate path for path_data\n");
1743 e_prefix_data_concat_static(buf, "data");
1744 e_path_default_path_append(path_data, buf);
1745 e_path_user_path_set(path_data, &(e_config->path_append_data));
1747 /* setup image paths */
1748 path_images = e_path_new();
1751 e_error_message_show("Cannot allocate path for path_images\n");
1754 e_user_dir_concat_static(buf, "/images");
1755 e_path_default_path_append(path_images, buf);
1756 e_prefix_data_concat_static(buf, "data/images");
1757 e_path_default_path_append(path_images, buf);
1758 e_path_user_path_set(path_images, &(e_config->path_append_images));
1760 /* setup font paths */
1761 path_fonts = e_path_new();
1764 e_error_message_show("Cannot allocate path for path_fonts\n");
1767 e_user_dir_concat_static(buf, "/fonts");
1768 e_path_default_path_append(path_fonts, buf);
1769 e_prefix_data_concat_static(buf, "data/fonts");
1770 e_path_default_path_append(path_fonts, buf);
1771 e_path_user_path_set(path_fonts, &(e_config->path_append_fonts));
1773 /* setup icon paths */
1774 path_icons = e_path_new();
1777 e_error_message_show("Cannot allocate path for path_icons\n");
1780 e_user_dir_concat_static(buf, "/icons");
1781 e_path_default_path_append(path_icons, buf);
1782 e_prefix_data_concat_static(buf, "data/icons");
1783 e_path_default_path_append(path_icons, buf);
1784 e_path_user_path_set(path_icons, &(e_config->path_append_icons));
1786 /* setup module paths */
1787 path_modules = e_path_new();
1790 e_error_message_show("Cannot allocate path for path_modules\n");
1793 e_user_dir_concat_static(buf, "/modules");
1794 e_path_default_path_append(path_modules, buf);
1795 snprintf(buf, sizeof(buf), "%s/enlightenment/modules", e_prefix_lib_get());
1796 e_path_default_path_append(path_modules, buf);
1797 /* FIXME: eventually this has to go - moduels should have installers that
1798 * add appropriate install paths (if not installed to user homedir) to
1799 * e's module search dirs
1801 snprintf(buf, sizeof(buf), "%s/enlightenment/modules_extra", e_prefix_lib_get());
1802 e_path_default_path_append(path_modules, buf);
1803 e_path_user_path_set(path_modules, &(e_config->path_append_modules));
1805 /* setup background paths */
1806 path_backgrounds = e_path_new();
1807 if (!path_backgrounds)
1809 e_error_message_show("Cannot allocate path for path_backgrounds\n");
1812 e_user_dir_concat_static(buf, "/backgrounds");
1813 e_path_default_path_append(path_backgrounds, buf);
1814 e_prefix_data_concat_static(buf, "data/backgrounds");
1815 e_path_default_path_append(path_backgrounds, buf);
1816 e_path_user_path_set(path_backgrounds, &(e_config->path_append_backgrounds));
1818 path_messages = e_path_new();
1821 e_error_message_show("Cannot allocate path for path_messages\n");
1824 e_user_dir_concat_static(buf, "/locale");
1825 e_path_default_path_append(path_messages, buf);
1826 e_path_default_path_append(path_messages, e_prefix_locale_get());
1827 e_path_user_path_set(path_messages, &(e_config->path_append_messages));
1833 _e_main_path_shutdown(void)
1837 e_object_del(E_OBJECT(path_data));
1842 e_object_del(E_OBJECT(path_images));
1847 e_object_del(E_OBJECT(path_fonts));
1852 e_object_del(E_OBJECT(path_icons));
1857 e_object_del(E_OBJECT(path_modules));
1858 path_modules = NULL;
1860 if (path_backgrounds)
1862 e_object_del(E_OBJECT(path_backgrounds));
1863 path_backgrounds = NULL;
1867 e_object_del(E_OBJECT(path_messages));
1868 path_messages = NULL;
1874 _e_main_test_formats(void)
1878 Evas_Object *im, *txt;
1880 char buff[PATH_MAX];
1882 if (e_config->show_splash)
1883 e_init_status_set(_("Testing Format Support"));
1885 if (!(ee = ecore_evas_buffer_new(1, 1)))
1887 e_error_message_show(_("Enlightenment found Evas can't create a buffer canvas. Please check\n"
1888 "Evas has Software Buffer engine support.\n"));
1889 _e_main_shutdown(-1);
1891 evas = ecore_evas_get(ee);
1892 im = evas_object_image_add(evas);
1894 e_prefix_data_concat_static(buff, "data/images/test.svg");
1895 evas_object_image_file_set(im, buff, NULL);
1896 if (evas_object_image_load_error_get(im) != EVAS_LOAD_ERROR_NONE)
1898 e_error_message_show(_("Enlightenment found Evas can't load SVG files. "
1899 "Check Evas has SVG loader support.\n"));
1902 efreet_icon_extension_add(".svg");
1904 e_prefix_data_concat_static(buff, "data/images/test.jpg");
1905 evas_object_image_file_set(im, buff, NULL);
1906 if (evas_object_image_load_error_get(im) != EVAS_LOAD_ERROR_NONE)
1908 e_error_message_show(_("Enlightenment found Evas can't load JPEG files. "
1909 "Check Evas has JPEG loader support.\n"));
1910 _e_main_shutdown(-1);
1912 efreet_icon_extension_add(".jpg");
1914 e_prefix_data_concat_static(buff, "data/images/test.png");
1915 evas_object_image_file_set(im, buff, NULL);
1916 if (evas_object_image_load_error_get(im) != EVAS_LOAD_ERROR_NONE)
1918 e_error_message_show(_("Enlightenment found Evas can't load PNG files. "
1919 "Check Evas has PNG loader support.\n"));
1920 _e_main_shutdown(-1);
1922 efreet_icon_extension_add(".png");
1924 e_prefix_data_concat_static(buff, "data/images/test.edj");
1925 evas_object_image_file_set(im, buff, "images/0");
1926 if (evas_object_image_load_error_get(im) != EVAS_LOAD_ERROR_NONE)
1928 e_error_message_show(_("Enlightenment found Evas can't load EET files. "
1929 "Check Evas has EET loader support.\n"));
1930 _e_main_shutdown(-1);
1932 efreet_icon_extension_add(".edj");
1934 evas_object_del(im);
1936 txt = evas_object_text_add(evas);
1937 evas_object_text_font_set(txt, "Sans", 10);
1938 evas_object_text_text_set(txt, "Hello");
1939 evas_object_geometry_get(txt, NULL, NULL, &tw, &th);
1940 if ((tw <= 0) && (th <= 0))
1942 e_error_message_show(_("Enlightenment found Evas can't load the 'Sans' font. Check Evas has fontconfig\n"
1943 "support and system fontconfig defines a 'Sans' font.\n"));
1944 _e_main_shutdown(-1);
1946 evas_object_del(txt);
1947 ecore_evas_free(ee);
1951 _e_main_screens_init(void)
1953 TS("\tscreens: manager");
1954 if (!e_manager_init()) return 0;
1956 TS("\tscreens: client");
1957 if (!e_client_init()) return 0;
1958 #ifndef ENABLE_QUICK_INIT
1959 TS("\tscreens: win");
1960 if (!e_win_init()) return 0;
1962 #ifndef HAVE_WAYLAND_ONLY
1966 e_error_message_show(_("Enlightenment cannot setup XKB Keyboard layouts.\n"));
1967 _e_main_shutdown(-1);
1969 TS("E_Xkb Init Done");
1972 TS("Compositor Init");
1975 e_error_message_show(_("Enlightenment cannot create a compositor.\n"));
1976 _e_main_shutdown(-1);
1979 _e_main_desk_restore();
1981 #ifndef HAVE_WAYLAND_ONLY
1982 if (e_config->show_splash)
1983 e_init_status_set(_("Setup DND"));
1987 e_error_message_show(_("Enlightenment cannot set up its dnd system.\n"));
1988 _e_main_shutdown(-1);
1990 TS("E_Dnd Init Done");
1991 _e_main_shutdown_push(e_dnd_shutdown);
1998 _e_main_screens_shutdown(void)
2004 e_client_shutdown();
2005 e_exehist_shutdown();
2006 e_backlight_shutdown();
2011 e_manager_shutdown();
2016 _e_main_desk_save(void)
2019 char env[1024], name[1024];
2022 EINA_LIST_FOREACH(e_comp->zones, l, zone)
2024 snprintf(name, sizeof(name), "DESK_%d_%d", e_comp->num, zone->num);
2025 snprintf(env, sizeof(env), "%d,%d", zone->desk_x_current, zone->desk_y_current);
2026 e_util_env_set(name, env);
2031 _e_main_desk_restore(void)
2038 EINA_LIST_FOREACH(e_comp->zones, l, zone)
2044 snprintf(name, sizeof(name), "DESK_%d_%d", e_comp->num, zone->num);
2047 snprintf(buf_e, sizeof(buf_e), "%s", env);
2048 if (!sscanf(buf_e, "%d,%d", &desk_x, &desk_y)) continue;
2049 desk = e_desk_at_xy_get(zone, desk_x, desk_y);
2050 if (!desk) continue;
2056 _e_main_efreet_paths_init(void)
2060 if ((list = efreet_icon_extra_list_get()))
2062 char buff[PATH_MAX];
2064 e_user_dir_concat_static(buff, "icons");
2065 *list = eina_list_prepend(*list, (void *)eina_stringshare_add(buff));
2066 e_prefix_data_concat_static(buff, "data/icons");
2067 *list = eina_list_prepend(*list, (void *)eina_stringshare_add(buff));
2072 _e_main_modules_load_after(void *d EINA_UNUSED, int type EINA_UNUSED, void *ev EINA_UNUSED)
2074 e_int_config_modules(NULL, NULL);
2075 E_FREE_FUNC(mod_init_end, ecore_event_handler_del);
2076 return ECORE_CALLBACK_RENEW;
2080 _e_main_modules_load(Eina_Bool safe_mode)
2083 e_module_all_load();
2089 crashmodule = getenv("E_MODULE_LOAD");
2090 if (crashmodule) m = e_module_new(crashmodule);
2092 if ((crashmodule) && (m))
2094 e_module_disable(m);
2095 e_object_del(E_OBJECT(m));
2097 e_error_message_show
2098 (_("Enlightenment crashed early on start and has<br>"
2099 "been restarted. There was an error loading the<br>"
2100 "module named: %s. This module has been disabled<br>"
2101 "and will not be loaded."), crashmodule);
2103 (_("Enlightenment crashed early on start and has been restarted"),
2104 _("Enlightenment crashed early on start and has been restarted.<br>"
2105 "There was an error loading the module named: %s<br><br>"
2106 "This module has been disabled and will not be loaded."), crashmodule);
2107 e_module_all_load();
2111 e_error_message_show
2112 (_("Enlightenment crashed early on start and has<br>"
2113 "been restarted. All modules have been disabled<br>"
2114 "and will not be loaded to help remove any problem<br>"
2115 "modules from your configuration. The module<br>"
2116 "configuration dialog should let you select your<br>"
2117 "modules again.\n"));
2119 (_("Enlightenment crashed early on start and has been restarted"),
2120 _("Enlightenment crashed early on start and has been restarted.<br>"
2121 "All modules have been disabled and will not be loaded to help<br>"
2122 "remove any problem modules from your configuration.<br><br>"
2123 "The module configuration dialog should let you select your<br>"
2126 mod_init_end = ecore_event_handler_add(E_EVENT_MODULE_INIT_END, _e_main_modules_load_after, NULL);
2131 _e_main_cb_idle_before(void *data __UNUSED__)
2133 e_menu_idler_before();
2134 e_client_idler_before();
2135 e_pointer_idler_before();
2137 return ECORE_CALLBACK_RENEW;
2141 _e_main_cb_idle_after(void *data __UNUSED__)
2143 static int first_idle = 1;
2148 #ifdef E_RELEASE_BUILD
2153 e_precache_end = EINA_TRUE;
2156 if (first_idle++ < 60)
2160 e_precache_end = EINA_TRUE;
2164 return ECORE_CALLBACK_RENEW;
2168 _e_main_cb_startup_fake_end(void *data __UNUSED__)
2171 return ECORE_CALLBACK_CANCEL;