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 EINA_UNUSED, int ev_type EINA_UNUSED, void *ev EINA_UNUSED);
74 static Eina_Bool _e_main_cb_signal_hup(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *ev EINA_UNUSED);
75 static Eina_Bool _e_main_cb_signal_user(void *data EINA_UNUSED, int ev_type EINA_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 EINA_UNUSED);
90 static Eina_Bool _e_main_cb_idle_after(void *data EINA_UNUSED);
91 static Eina_Bool _e_main_cb_startup_fake_end(void *data EINA_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 E_API Eina_Bool e_precache_end = EINA_FALSE;
109 E_API Eina_Bool x_fatal = EINA_FALSE;
110 E_API Eina_Bool good = EINA_FALSE;
111 E_API Eina_Bool evil = EINA_FALSE;
112 E_API Eina_Bool starting = EINA_TRUE;
113 E_API Eina_Bool stopping = EINA_FALSE;
114 E_API Eina_Bool restart = EINA_FALSE;
115 E_API 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");
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_start_time = ecore_time_get();
469 e_first_frame = NULL;
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 if (!eina_streq(elm_theme_get(NULL), "default"))
557 elm_theme_extension_add(NULL, "default");
558 TS("Elementary Init Done");
559 //_e_main_shutdown_push(elm_shutdown);
564 e_error_message_show(_("Enlightenment cannot initialize Emotion!\n"));
565 _e_main_shutdown(-1);
567 TS("Emotion Init Done");
568 _e_main_shutdown_push((void *)emotion_shutdown);
570 /* e doesn't sync to compositor - it should be one */
571 ecore_evas_app_comp_sync_set(0);
573 TS("Ecore_Evas Engine Check");
574 #ifdef HAVE_WAYLAND_ONLY
575 if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_WAYLAND_SHM))
577 e_error_message_show(_("Enlightenment found ecore_evas doesn't support the Wayland SHM\n"
578 "rendering in Evas. Please check your installation of Evas and\n"
579 "Ecore and check they support the Wayland SHM rendering engine."));
580 _e_main_shutdown(-1);
583 if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_XCB))
585 if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_XLIB))
587 e_error_message_show(_("Enlightenment found ecore_evas doesn't support the Software X11\n"
588 "rendering in Evas. Please check your installation of Evas and\n"
589 "Ecore and check they support the Software X11 rendering engine."));
590 _e_main_shutdown(-1);
594 if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_BUFFER))
596 e_error_message_show(_("Enlightenment found ecore_evas doesn't support the Software Buffer\n"
597 "rendering in Evas. Please check your installation of Evas and\n"
598 "Ecore and check they support the Software Buffer rendering engine."));
599 _e_main_shutdown(-1);
601 TS("Ecore_Evas Engine Check Done");
606 e_error_message_show(_("Enlightenment cannot initialize Edje!\n"));
607 _e_main_shutdown(-1);
609 TS("Edje Init Done");
610 _e_main_shutdown_push(edje_shutdown);
613 /*** Initialize E Subsystems We Need ***/
618 e_error_message_show(_("Enlightenment cannot initialize E_Intl!\n"));
619 _e_main_shutdown(-1);
621 TS("E Intl Init Done");
622 _e_main_shutdown_push(e_intl_shutdown);
624 #ifndef HAVE_WAYLAND_ONLY
625 /* init white box of death alert */
629 e_error_message_show(_("Enlightenment cannot initialize its emergency alert system.\n"
630 "Have you set your DISPLAY variable?"));
631 _e_main_shutdown(-1);
633 TS("E_Alert Init Done");
634 _e_main_shutdown_push(e_alert_shutdown);
638 //#ifdef HAVE_WAYLAND
639 /* init uuid store for window/surface properties */
640 TS("E_UUID_Store Init");
641 if (!e_uuid_store_init())
643 e_error_message_show(_("Enlightenment cannot initialize its UUID store.\n"));
644 _e_main_shutdown(-1);
646 TS("E_UUID_Store Init Done");
647 _e_main_shutdown_push(e_uuid_store_shutdown);
650 TS("E Directories Init");
651 /* setup directories we will be using for configurations storage etc. */
652 if (!_e_main_dirs_init())
654 e_error_message_show(_("Enlightenment cannot create directories in your home directory.\n"
655 "Perhaps you have no home directory or the disk is full?"));
656 _e_main_shutdown(-1);
658 TS("E Directories Init Done");
659 _e_main_shutdown_push(_e_main_dirs_shutdown);
661 TS("E_Filereg Init");
662 if (!e_filereg_init())
664 e_error_message_show(_("Enlightenment cannot set up its file registry system.\n"));
665 _e_main_shutdown(-1);
667 TS("E_Filereg Init Done");
668 _e_main_shutdown_push(e_filereg_shutdown);
671 if (!e_config_init())
673 e_error_message_show(_("Enlightenment cannot set up its config system.\n"));
674 _e_main_shutdown(-1);
676 TS("E_Config Init Done");
677 _e_main_shutdown_push(e_config_shutdown);
682 e_error_message_show(_("Enlightenment cannot set up its environment.\n"));
683 _e_main_shutdown(-1);
685 TS("E_Env Init Done");
686 _e_main_shutdown_push(e_env_shutdown);
688 efreet_desktop_environment_set(e_config->desktop_environment);
689 e_util_env_set("E_ICON_THEME", e_config->icon_theme);
690 ecore_exe_run_priority_set(e_config->priority);
691 locked |= e_config->desklock_start_locked;
693 s = getenv("E_DESKLOCK_LOCKED");
694 if ((s) && (!strcmp(s, "locked"))) waslocked = EINA_TRUE;
697 if (!_e_main_path_init())
699 e_error_message_show(_("Enlightenment cannot set up paths for finding files.\n"
700 "Perhaps you are out of memory?"));
701 _e_main_shutdown(-1);
703 TS("E Paths Init Done");
704 _e_main_shutdown_push(_e_main_path_shutdown);
707 if (!e_ipc_init()) _e_main_shutdown(-1);
708 TS("E_Ipc Init Done");
709 _e_main_shutdown_push(e_ipc_shutdown);
711 edje_frametime_set(1.0 / e_config->framerate);
716 e_error_message_show(_("Enlightenment cannot set up its font system.\n"));
717 _e_main_shutdown(-1);
719 TS("E_Font Init Done");
720 _e_main_shutdown_push(e_font_shutdown);
724 TS("E_Font Apply Done");
729 e_error_message_show(_("Enlightenment cannot set up its theme system.\n"));
730 _e_main_shutdown(-1);
732 TS("E_Theme Init Done");
733 _e_main_shutdown_push(e_theme_shutdown);
735 TS("E_Moveresize Init");
737 TS("E_Moveresize Init Done");
738 _e_main_shutdown_push(e_moveresize_shutdown);
740 if (e_config->show_splash)
741 e_init_status_set(_("Setup Message Bus"));
744 _e_main_shutdown_push(e_msgbus_shutdown);
745 TS("E_Msgbus Init Done");
750 e_error_message_show(_("Enlightenment cannot initialize the FDO desktop system.\n"
751 "Perhaps you lack permissions on ~/.cache/efreet or are\n"
752 "out of memory or disk space?"));
753 _e_main_shutdown(-1);
755 TS("Efreet Init Done");
756 _e_main_shutdown_push(efreet_shutdown);
758 if (e_config->show_splash)
759 e_init_status_set(_("Starting International Support"));
760 TS("E_Intl Post Init");
761 if (!e_intl_post_init())
763 e_error_message_show(_("Enlightenment cannot set up its intl system.\n"));
764 _e_main_shutdown(-1);
766 TS("E_Intl Post Init Done");
767 _e_main_shutdown_push(e_intl_post_shutdown);
769 TS("E_Configure Init");
771 TS("E_Configure Init Done");
773 e_screensaver_preinit();
775 if (e_config->show_splash)
776 e_init_status_set(_("Setup Actions"));
777 TS("E_Actions Init");
778 if (!e_actions_init())
780 e_error_message_show(_("Enlightenment cannot set up its actions system.\n"));
781 _e_main_shutdown(-1);
783 TS("E_Actions Init Done");
784 _e_main_shutdown_push(e_actions_shutdown);
786 /* these just add event handlers and can't fail
787 * timestamping them is dumb.
793 if (e_config->show_splash)
794 e_init_status_set(_("Setup Powersave Modes"));
795 TS("E_Powersave Init");
796 if (!e_powersave_init())
798 e_error_message_show(_("Enlightenment cannot set up its powersave modes.\n"));
799 _e_main_shutdown(-1);
801 TS("E_Powersave Init Done");
802 _e_main_shutdown_push(e_powersave_shutdown);
804 if (e_config->show_splash)
805 e_init_status_set(_("Setup Screensaver"));
806 TS("E_Screensaver Init");
807 if (!e_screensaver_init())
809 e_error_message_show(_("Enlightenment cannot configure the X screensaver.\n"));
810 _e_main_shutdown(-1);
812 TS("E_Screensaver Init Done");
813 _e_main_shutdown_push(e_screensaver_shutdown);
815 if (e_config->show_splash)
816 e_init_status_set(_("Setup Screens"));
818 if (!_e_main_screens_init())
820 e_error_message_show(_("Enlightenment set up window management for all the screens on your system\n"
821 "failed. Perhaps another window manager is running?\n"));
822 _e_main_shutdown(-1);
824 TS("Screens Init Done");
825 _e_main_shutdown_push(_e_main_screens_shutdown);
827 TS("E_Pointer Init");
828 if (!e_pointer_init())
830 e_error_message_show(_("Enlightenment cannot set up its pointer system.\n"));
831 _e_main_shutdown(-1);
833 TS("E_Pointer Init Done");
834 _e_main_shutdown_push(e_pointer_shutdown);
840 e_error_message_show(_("Enlightenment cannot set up its scale system.\n"));
841 _e_main_shutdown(-1);
843 TS("E_Scale Init Done");
844 _e_main_shutdown_push(e_scale_shutdown);
846 if (e_config->show_splash)
851 e_error_message_show(_("Enlightenment cannot set up its init screen.\n"));
852 _e_main_shutdown(-1);
854 TS("E_Splash Init Done");
855 _e_main_shutdown_push(e_init_shutdown);
857 if (!((!e_config->show_splash) || (after_restart)))
862 #ifndef DISABLE_FORMAT_TEST
863 TS("Test File Format Support");
864 _e_main_test_formats();
865 TS("Test File Format Support Done");
870 efreet_icon_extension_add(".svg");
871 efreet_icon_extension_add(".jpg");
872 efreet_icon_extension_add(".png");
873 efreet_icon_extension_add(".edj");
876 if (e_config->show_splash)
877 e_init_status_set(_("Setup ACPI"));
880 TS("E_Acpi Init Done");
881 _e_main_shutdown_push(e_acpi_shutdown);
883 if (e_config->show_splash)
884 e_init_status_set(_("Setup Backlight"));
885 TS("E_Backlight Init");
886 if (!e_backlight_init())
888 e_error_message_show(_("Enlightenment cannot configure the backlight.\n"));
889 _e_main_shutdown(-1);
891 TS("E_Backlight Init Done");
893 if (e_config->show_splash)
894 e_init_status_set(_("Setup DPMS"));
898 e_error_message_show(_("Enlightenment cannot configure the DPMS settings.\n"));
899 _e_main_shutdown(-1);
901 TS("E_Dpms Init Done");
902 _e_main_shutdown_push(e_dpms_shutdown);
904 if (e_config->show_splash)
905 e_init_status_set(_("Setup Desklock"));
906 TS("E_Desklock Init");
907 if (!e_desklock_init())
909 e_error_message_show(_("Enlightenment cannot set up its desk locking system.\n"));
910 _e_main_shutdown(-1);
912 TS("E_Desklock Init Done");
913 _e_main_shutdown_push(e_desklock_shutdown);
915 if (waslocked || (locked && ((!after_restart) || (!getenv("E_DESKLOCK_UNLOCKED")))))
916 e_desklock_show(EINA_TRUE);
918 if (e_config->show_splash)
919 e_init_status_set(_("Setup Paths"));
921 _e_main_efreet_paths_init();
922 TS("Efreet Paths Done");
924 if (e_config->show_splash)
925 e_init_status_set(_("Setup System Controls"));
929 e_error_message_show(_("Enlightenment cannot initialize the System Command system.\n"));
930 _e_main_shutdown(-1);
932 TS("E_Sys Init Done");
933 _e_main_shutdown_push(e_sys_shutdown);
935 if (e_config->show_splash)
936 e_init_status_set(_("Setup Execution System"));
940 e_error_message_show(_("Enlightenment cannot set up its exec system.\n"));
941 _e_main_shutdown(-1);
943 TS("E_Exec Init Done");
947 TS("E_Comp Freeze Done");
949 if (e_config->show_splash)
950 e_init_status_set(_("Setup Filemanager"));
954 e_error_message_show(_("Enlightenment cannot initialize the File manager.\n"));
955 _e_main_shutdown(-1);
957 TS("E_Fm2 Init Done");
958 _e_main_shutdown_push(e_fm2_shutdown);
960 if (e_config->show_splash)
961 e_init_status_set(_("Setup Message System"));
965 e_error_message_show(_("Enlightenment cannot set up its msg system.\n"));
966 _e_main_shutdown(-1);
968 TS("E_Msg Init Done");
969 _e_main_shutdown_push(e_msg_shutdown);
971 if (e_config->show_splash)
972 e_init_status_set(_("Setup Grab Input Handling"));
973 TS("E_Grabinput Init");
974 if (!e_grabinput_init())
976 e_error_message_show(_("Enlightenment cannot set up its grab input handling system.\n"));
977 _e_main_shutdown(-1);
979 TS("E_Grabinput Init Done");
980 _e_main_shutdown_push(e_grabinput_shutdown);
982 if (e_config->show_splash)
983 e_init_status_set(_("Setup Modules"));
985 if (!e_module_init())
987 e_error_message_show(_("Enlightenment cannot set up its module system.\n"));
988 _e_main_shutdown(-1);
990 TS("E_Module Init Done");
991 _e_main_shutdown_push(e_module_shutdown);
993 if (e_config->show_splash)
994 e_init_status_set(_("Setup Remembers"));
995 TS("E_Remember Init");
996 if (!e_remember_init(after_restart ? E_STARTUP_RESTART : E_STARTUP_START))
998 e_error_message_show(_("Enlightenment cannot setup remember settings.\n"));
999 _e_main_shutdown(-1);
1001 TS("E_Remember Init Done");
1002 _e_main_shutdown_push(e_remember_shutdown);
1004 if (e_config->show_splash)
1005 e_init_status_set(_("Setup Gadcon"));
1006 TS("E_Gadcon Init");
1007 if (!e_gadcon_init())
1009 e_error_message_show(_("Enlightenment cannot set up its gadget control system.\n"));
1010 _e_main_shutdown(-1);
1012 TS("E_Gadcon Init Done");
1013 _e_main_shutdown_push(e_gadcon_shutdown);
1015 if (e_config->show_splash)
1016 e_init_status_set(_("Setup Toolbars"));
1017 TS("E_Toolbar Init");
1018 if (!e_toolbar_init())
1020 e_error_message_show(_("Enlightenment cannot set up its toolbars.\n"));
1021 _e_main_shutdown(-1);
1023 TS("E_Toolbar Init Done");
1024 _e_main_shutdown_push(e_toolbar_shutdown);
1026 if (e_config->show_splash)
1027 e_init_status_set(_("Setup Wallpaper"));
1031 e_error_message_show(_("Enlightenment cannot set up its desktop background system.\n"));
1032 _e_main_shutdown(-1);
1034 TS("E_Bg Init Done");
1035 _e_main_shutdown_push(e_bg_shutdown);
1037 if (e_config->show_splash)
1038 e_init_status_set(_("Setup Mouse"));
1040 if (!e_mouse_update())
1042 e_error_message_show(_("Enlightenment cannot configure the mouse settings.\n"));
1043 _e_main_shutdown(-1);
1045 TS("E_Mouse Init Done");
1047 if (e_config->show_splash)
1048 e_init_status_set(_("Setup Bindings"));
1049 TS("E_Bindings Init");
1050 if (!e_bindings_init())
1052 e_error_message_show(_("Enlightenment cannot set up its bindings system.\n"));
1053 _e_main_shutdown(-1);
1055 TS("E_Bindings Init Done");
1056 _e_main_shutdown_push(e_bindings_shutdown);
1058 if (e_config->show_splash)
1059 e_init_status_set(_("Setup Thumbnailer"));
1061 if (!e_thumb_init())
1063 e_error_message_show(_("Enlightenment cannot initialize the Thumbnailing system.\n"));
1064 _e_main_shutdown(-1);
1066 TS("E_Thumb Init Done");
1067 _e_main_shutdown_push(e_thumb_shutdown);
1072 e_error_message_show(_("Enlightenment cannot initialize the Icon Cache system.\n"));
1073 _e_main_shutdown(-1);
1075 TS("E_Icon Init Done");
1076 _e_main_shutdown_push(e_icon_shutdown);
1078 TS("E_Update Init");
1079 if (!e_update_init())
1081 e_error_message_show(_("Enlightenment cannot initialize the Update system.\n"));
1082 _e_main_shutdown(-1);
1084 TS("E_Update Init Done");
1085 _e_main_shutdown_push(e_update_shutdown);
1087 if (e_config->show_splash)
1088 e_init_status_set(_("Setup Desktop Environment"));
1089 TS("E_Deskenv Init");
1090 if (!e_deskenv_init())
1092 e_error_message_show(_("Enlightenment cannot initialize its desktop environment.\n"));
1093 _e_main_shutdown(-1);
1095 TS("E_Deskenv Init Done");
1096 _e_main_shutdown_push(e_deskenv_shutdown);
1098 if (e_config->show_splash)
1099 e_init_status_set(_("Setup File Ordering"));
1101 if (!e_order_init())
1103 e_error_message_show(_("Enlightenment cannot set up its order file system.\n"));
1104 _e_main_shutdown(-1);
1106 TS("E_Order Init Done");
1107 _e_main_shutdown_push(e_order_shutdown);
1109 TS("E_Comp_Canvas Keys Grab");
1110 e_comp_canvas_keys_grab();
1111 TS("E_Comp_Canvas Keys Grab Done");
1113 if (e_config->show_splash)
1114 e_init_status_set(_("Load Modules"));
1116 _e_main_modules_load(safe_mode);
1117 TS("Load Modules Done");
1119 TS("Run Startup Apps");
1123 e_startup(E_STARTUP_RESTART);
1125 e_startup(E_STARTUP_START);
1127 TS("Run Startup Apps Done");
1129 if (e_config->show_splash && (!after_restart))
1130 ecore_timer_add(2.0, _e_main_cb_startup_fake_end, NULL);
1134 TS("E_Comp Thaw Done");
1140 TS("E_Test_Helper Init");
1141 e_test_helper_init();
1142 _e_main_shutdown_push(e_test_helper_shutdown);
1143 TS("E_Test_Helper Done");
1145 TS("E_Info_Server Init");
1146 e_info_server_init();
1147 _e_main_shutdown_push(e_info_server_shutdown);
1148 TS("E_Info_Server Done");
1150 if (e_config->show_splash)
1151 e_init_status_set(_("Setup Shelves"));
1153 if (!e_shelf_init())
1155 e_error_message_show(_("Enlightenment cannot set up its module system.\n"));
1156 _e_main_shutdown(-1);
1158 TS("E_Shelf Init Done");
1160 ecore_idle_enterer_before_add(_e_main_shelf_init_job, NULL);
1162 _idle_before = ecore_idle_enterer_before_add(_e_main_cb_idle_before, NULL);
1164 _xdg_data_dirs_augment();
1166 TS("Ecore_Evas Init");
1167 if (!ecore_evas_init())
1169 e_error_message_show(_("Enlightenment cannot initialize Ecore_Evas!\n"));
1170 _e_main_shutdown(-1);
1172 TS("Ecore_Evas Init Done");
1174 /* e doesn't sync to compositor - it should be one */
1175 ecore_evas_app_comp_sync_set(0);
1177 TS("Ecore_Evas Engine Check");
1178 #ifdef HAVE_WAYLAND_ONLY
1179 if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_WAYLAND_SHM))
1181 e_error_message_show(_("Enlightenment found ecore_evas doesn't support the Wayland SHM\n"
1182 "rendering in Evas. Please check your installation of Evas and\n"
1183 "Ecore and check they support the Wayland SHM rendering engine."));
1184 _e_main_shutdown(-1);
1187 if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_XCB))
1189 if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_XLIB))
1191 e_error_message_show(_("Enlightenment found ecore_evas doesn't support the Software X11\n"
1192 "rendering in Evas. Please check your installation of Evas and\n"
1193 "Ecore and check they support the Software X11 rendering engine."));
1194 _e_main_shutdown(-1);
1198 if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_BUFFER))
1200 e_error_message_show(_("Enlightenment found ecore_evas doesn't support the Software Buffer\n"
1201 "rendering in Evas. Please check your installation of Evas and\n"
1202 "Ecore and check they support the Software Buffer rendering engine."));
1203 _e_main_shutdown(-1);
1205 TS("Ecore_Evas Engine Check Done");
1207 /*** Initialize E Subsystems We Need ***/
1209 TS("E Directories Init");
1210 /* setup directories we will be using for configurations storage etc. */
1211 if (!_e_main_dirs_init())
1213 e_error_message_show(_("Enlightenment cannot create directories in your home directory.\n"
1214 "Perhaps you have no home directory or the disk is full?"));
1215 _e_main_shutdown(-1);
1217 TS("E Directories Init Done");
1218 _e_main_shutdown_push(_e_main_dirs_shutdown);
1220 TS("E_Config Init");
1221 if (!e_config_init())
1223 e_error_message_show(_("Enlightenment cannot set up its config system.\n"));
1224 _e_main_shutdown(-1);
1226 TS("E_Config Init Done");
1227 _e_main_shutdown_push(e_config_shutdown);
1232 e_error_message_show(_("Enlightenment cannot set up its environment.\n"));
1233 _e_main_shutdown(-1);
1235 TS("E_Env Init Done");
1236 _e_main_shutdown_push(e_env_shutdown);
1238 efreet_desktop_environment_set(e_config->desktop_environment);
1239 e_util_env_set("E_ICON_THEME", e_config->icon_theme);
1240 ecore_exe_run_priority_set(e_config->priority);
1241 locked |= e_config->desklock_start_locked;
1244 if (!_e_main_path_init())
1246 e_error_message_show(_("Enlightenment cannot set up paths for finding files.\n"
1247 "Perhaps you are out of memory?"));
1248 _e_main_shutdown(-1);
1250 TS("E Paths Init Done");
1251 _e_main_shutdown_push(_e_main_path_shutdown);
1253 ecore_animator_frametime_set(1.0 / e_config->framerate);
1258 e_error_message_show(_("Enlightenment cannot set up its font system.\n"));
1259 _e_main_shutdown(-1);
1261 TS("E_Font Init Done");
1262 _e_main_shutdown_push(e_font_shutdown);
1266 TS("E_Font Apply Done");
1269 if (!e_theme_init())
1271 e_error_message_show(_("Enlightenment cannot set up its theme system.\n"));
1272 _e_main_shutdown(-1);
1274 TS("E_Theme Init Done");
1275 _e_main_shutdown_push(e_theme_shutdown);
1277 TS("E_Moveresize Init");
1278 e_moveresize_init();
1279 TS("E_Moveresize Init Done");
1280 _e_main_shutdown_push(e_moveresize_shutdown);
1282 e_screensaver_preinit();
1284 if (e_config->show_splash)
1285 e_init_status_set(_("Setup Actions"));
1286 TS("E_Actions Init");
1287 if (!e_actions_init())
1289 e_error_message_show(_("Enlightenment cannot set up its actions system.\n"));
1290 _e_main_shutdown(-1);
1292 TS("E_Actions Init Done");
1293 _e_main_shutdown_push(e_actions_shutdown);
1295 /* these just add event handlers and can't fail
1296 * timestamping them is dumb.
1302 if (e_config->show_splash)
1303 e_init_status_set(_("Setup Powersave Modes"));
1304 TS("E_Powersave Init");
1305 if (!e_powersave_init())
1307 e_error_message_show(_("Enlightenment cannot set up its powersave modes.\n"));
1308 _e_main_shutdown(-1);
1310 TS("E_Powersave Init Done");
1311 _e_main_shutdown_push(e_powersave_shutdown);
1313 if (e_config->show_splash)
1314 e_init_status_set(_("Setup Screensaver"));
1315 TS("E_Screensaver Init");
1316 if (!e_screensaver_init())
1318 e_error_message_show(_("Enlightenment cannot configure the X screensaver.\n"));
1319 _e_main_shutdown(-1);
1321 TS("E_Screensaver Init Done");
1322 _e_main_shutdown_push(e_screensaver_shutdown);
1324 if (e_config->show_splash)
1325 e_init_status_set(_("Setup Screens"));
1327 if (!_e_main_screens_init())
1329 e_error_message_show(_("Enlightenment set up window management for all the screens on your system\n"
1330 "failed. Perhaps another window manager is running?\n"));
1331 _e_main_shutdown(-1);
1333 TS("Screens Init Done");
1334 _e_main_shutdown_push(_e_main_screens_shutdown);
1336 if (e_config->show_splash)
1337 e_init_status_set(_("Setup System Controls"));
1341 e_error_message_show(_("Enlightenment cannot initialize the System Command system.\n"));
1342 _e_main_shutdown(-1);
1344 TS("E_Sys Init Done");
1345 _e_main_shutdown_push(e_sys_shutdown);
1347 TS("E_Comp Freeze");
1348 e_comp_all_freeze();
1349 TS("E_Comp Freeze Done");
1351 if (e_config->show_splash)
1352 e_init_status_set(_("Setup Grab Input Handling"));
1353 TS("E_Grabinput Init");
1354 if (!e_grabinput_init())
1356 e_error_message_show(_("Enlightenment cannot set up its grab input handling system.\n"));
1357 _e_main_shutdown(-1);
1359 TS("E_Grabinput Init Done");
1360 _e_main_shutdown_push(e_grabinput_shutdown);
1362 ecore_event_handler_add(E_EVENT_MODULE_INIT_END, _e_main_deferred_job_schedule, NULL);
1364 if (e_config->show_splash)
1365 e_init_status_set(_("Setup Modules"));
1366 TS("E_Module Init");
1367 if (!e_module_init())
1369 e_error_message_show(_("Enlightenment cannot set up its module system.\n"));
1370 _e_main_shutdown(-1);
1372 TS("E_Module Init Done");
1373 _e_main_shutdown_push(e_module_shutdown);
1375 if (e_config->show_splash)
1376 e_init_status_set(_("Setup Remembers"));
1377 TS("E_Remember Init");
1378 if (!e_remember_init(after_restart ? E_STARTUP_RESTART : E_STARTUP_START))
1380 e_error_message_show(_("Enlightenment cannot setup remember settings.\n"));
1381 _e_main_shutdown(-1);
1383 TS("E_Remember Init Done");
1384 _e_main_shutdown_push(e_remember_shutdown);
1386 if (e_config->show_splash)
1387 e_init_status_set(_("Setup Mouse"));
1389 if (!e_mouse_update())
1391 e_error_message_show(_("Enlightenment cannot configure the mouse settings.\n"));
1392 _e_main_shutdown(-1);
1394 TS("E_Mouse Init Done");
1396 if (e_config->show_splash)
1397 e_init_status_set(_("Setup Bindings"));
1398 TS("E_Bindings Init");
1399 if (!e_bindings_init())
1401 e_error_message_show(_("Enlightenment cannot set up its bindings system.\n"));
1402 _e_main_shutdown(-1);
1404 TS("E_Bindings Init Done");
1405 _e_main_shutdown_push(e_bindings_shutdown);
1410 e_error_message_show(_("Enlightenment cannot initialize the Icon Cache system.\n"));
1411 _e_main_shutdown(-1);
1413 TS("E_Icon Init Done");
1414 _e_main_shutdown_push(e_icon_shutdown);
1416 if (e_config->show_splash)
1417 e_init_status_set(_("Load Modules"));
1419 _e_main_modules_load(safe_mode);
1420 TS("Load Modules Done");
1422 if (e_config->show_splash && (!after_restart))
1423 ecore_timer_add(2.0, _e_main_cb_startup_fake_end, NULL);
1427 TS("E_Comp Thaw Done");
1430 _idle_after = ecore_idle_enterer_add(_e_main_cb_idle_after, NULL);
1432 if (e_config->show_splash)
1433 e_init_status_set(_("Almost Done"));
1435 starting = EINA_FALSE;
1438 e_util_env_set("E_RESTART", "1");
1440 TS("MAIN LOOP AT LAST");
1441 if (!setjmp(x_fatal_buff))
1442 ecore_main_loop_begin();
1444 CRI("FATAL: X Died. Connection gone. Abbreviated Shutdown\n");
1446 inloop = EINA_FALSE;
1447 stopping = EINA_TRUE;
1449 //if (!x_fatal) e_canvas_idle_flush();
1451 e_config_save_flush();
1452 _e_main_desk_save();
1453 e_remember_internal_save();
1454 e_comp_internal_save();
1456 _e_main_shutdown(0);
1460 e_util_env_set("E_RESTART_OK", "1");
1461 if (getenv("E_START_MTRACK"))
1462 e_util_env_set("MTRACK", "track");
1463 ecore_app_restart();
1466 e_prefix_shutdown();
1472 e_main_ts(const char *str)
1475 t1 = ecore_time_unix_get();
1476 printf("ESTART: %1.5f [%1.5f] - %s\n", t1 - t0, t1 - t2, str);
1482 /* local functions */
1484 _e_main_shutdown(int errcode)
1490 printf("E: Begin Shutdown Procedure!\n");
1492 if (_idle_before) ecore_idle_enterer_del(_idle_before);
1493 _idle_before = NULL;
1494 if (_idle_after) ecore_idle_enterer_del(_idle_after);
1497 dir = getenv("XDG_RUNTIME_DIR");
1500 char buf_env[PATH_MAX];
1501 snprintf(buf_env, sizeof(buf_env), "%s", dir);
1502 snprintf(buf, sizeof(buf), "%s/.e-deleteme", buf_env);
1503 if (ecore_file_exists(buf)) ecore_file_recursive_rm(buf_env);
1505 for (i = (_e_main_lvl - 1); i >= 0; i--)
1506 (*_e_main_shutdown_func[i])();
1507 #ifdef OBJECT_HASH_CHECK
1508 e_object_hash_shutdown();
1510 if (errcode < 0) exit(errcode);
1514 _e_main_shutdown_push(int (*func)(void))
1517 if (_e_main_lvl > MAX_LEVEL)
1520 e_error_message_show("WARNING: too many init levels. MAX = %i\n",
1524 _e_main_shutdown_func[_e_main_lvl - 1] = func;
1528 _e_main_parse_arguments(int argc, char **argv)
1533 /* handle some command-line parameters */
1534 for (i = 1; i < argc; i++)
1536 if ((!strcmp(argv[i], "-display")) && (i < (argc - 1)))
1539 e_util_env_set("DISPLAY", argv[i]);
1541 else if ((!strcmp(argv[i], "-fake-xinerama-screen")) && (i < (argc - 1)))
1546 if (sscanf(argv[i], "%ix%i+%i+%i", &w, &h, &x, &y) == 4)
1547 e_xinerama_fake_screen_add(x, y, w, h);
1549 else if (!strcmp(argv[i], "-good"))
1553 printf("LA LA LA\n");
1555 else if (!strcmp(argv[i], "-evil"))
1559 printf("MUHAHAHAHHAHAHAHAHA\n");
1561 else if (!strcmp(argv[i], "-psychotic"))
1565 printf("MUHAHALALALALALALALA\n");
1567 else if ((!strcmp(argv[i], "-profile")) && (i < (argc - 1)))
1570 if (!getenv("E_CONF_PROFILE"))
1571 e_util_env_set("E_CONF_PROFILE", argv[i]);
1573 else if (!strcmp(argv[i], "-i-really-know-what-i-am-doing-and-accept-full-responsibility-for-it"))
1574 really_know = EINA_TRUE;
1575 else if (!strcmp(argv[i], "-locked"))
1577 else if (!strcmp(argv[i], "-nopause"))
1578 e_nopause = EINA_TRUE;
1579 else if ((!strcmp(argv[i], "-version")) ||
1580 (!strcmp(argv[i], "--version")))
1582 printf(_("Version: %s\n"), PACKAGE_VERSION);
1583 _e_main_shutdown(-1);
1585 else if ((!strcmp(argv[i], "-h")) ||
1586 (!strcmp(argv[i], "-help")) ||
1587 (!strcmp(argv[i], "--help")))
1592 "\t-display DISPLAY\n"
1593 "\t\tConnect to display named DISPLAY.\n"
1594 "\t\tEG: -display :1.0\n"
1595 "\t-fake-xinerama-screen WxH+X+Y\n"
1596 "\t\tAdd a FAKE xinerama screen (instead of the real ones)\n"
1597 "\t\tgiven the geometry. Add as many as you like. They all\n"
1598 "\t\treplace the real xinerama screens, if any. This can\n"
1599 "\t\tbe used to simulate xinerama.\n"
1600 "\t\tEG: -fake-xinerama-screen 800x600+0+0 -fake-xinerama-screen 800x600+800+0\n"
1601 "\t-profile CONF_PROFILE\n"
1602 "\t\tUse the configuration profile CONF_PROFILE instead of the user selected default or just \"default\".\n"
1608 "\t\tBe psychotic.\n"
1610 "\t\tStart with desklock on, so password will be asked.\n"
1611 "\t-i-really-know-what-i-am-doing-and-accept-full-responsibility-for-it\n"
1612 "\t\tIf you need this help, you don't need this option.\n"
1616 _e_main_shutdown(-1);
1620 /* fix up DISPLAY to be :N.0 if no .screen is in it */
1621 s = getenv("DISPLAY");
1624 char *p, buff[4096];
1626 if (!(p = strrchr(s, ':')))
1628 snprintf(buff, sizeof(buff), "%s:0.0", s);
1629 e_util_env_set("DISPLAY", buff);
1633 if (!strrchr(p, '.'))
1635 snprintf(buff, sizeof(buff), "%s.0", s);
1636 e_util_env_set("DISPLAY", buff);
1641 /* we want to have been launched by enlightenment_start. there is a very */
1642 /* good reason we want to have been launched this way, thus check */
1643 if (!getenv("E_START"))
1645 e_error_message_show(_("You are executing enlightenment directly. This is\n"
1646 "bad. Please do not execute the \"enlightenment\"\n"
1647 "binary. Use the \"enlightenment_start\" launcher. It\n"
1648 "will handle setting up environment variables, paths,\n"
1649 "and launching any other required services etc.\n"
1650 "before enlightenment itself begins running.\n"));
1651 _e_main_shutdown(-1);
1656 _e_main_cb_x_fatal(void *data EINA_UNUSED)
1658 e_error_message_show("Lost X Connection.\n");
1659 ecore_main_loop_quit();
1662 x_fatal = EINA_TRUE;
1663 if (inloop) longjmp(x_fatal_buff, -99);
1668 _e_main_cb_signal_exit(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *ev EINA_UNUSED)
1670 /* called on ctrl-c, kill (pid) (also SIGINT, SIGTERM and SIGQIT) */
1671 e_sys_action_do(E_SYS_EXIT, NULL);
1672 return ECORE_CALLBACK_RENEW;
1676 _e_main_cb_signal_hup(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *ev EINA_UNUSED)
1678 e_sys_action_do(E_SYS_RESTART, NULL);
1679 return ECORE_CALLBACK_RENEW;
1683 _e_main_cb_signal_user(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *ev)
1685 Ecore_Event_Signal_User *e = ev;
1689 // E_Action *a = e_action_find("configuration");
1690 // if ((a) && (a->func.go)) a->func.go(NULL, NULL);
1692 else if (e->number == 2)
1694 // comp module has its own handler for this for enabling/disabling fps debug
1696 return ECORE_CALLBACK_RENEW;
1701 _e_main_dirs_init(void)
1704 const char *dirs[] =
1712 "applications/menu",
1713 "applications/menu/favorite",
1714 "applications/menu/all",
1716 "applications/bar/default",
1717 "applications/startup",
1718 "applications/restart",
1719 "applications/trash",
1720 "applications/desk-lock",
1721 "applications/desk-unlock",
1729 base = e_user_dir_get();
1730 if (ecore_file_mksubdirs(base, dirs) != sizeof(dirs) / sizeof(dirs[0]) - 1)
1732 e_error_message_show("Could not create one of the required "
1733 "subdirectories of '%s'\n", base);
1741 _e_main_dirs_shutdown(void)
1747 _e_main_path_init(void)
1751 /* setup data paths */
1752 path_data = e_path_new();
1755 e_error_message_show("Cannot allocate path for path_data\n");
1758 e_prefix_data_concat_static(buf, "data");
1759 e_path_default_path_append(path_data, buf);
1760 e_path_user_path_set(path_data, &(e_config->path_append_data));
1762 /* setup image paths */
1763 path_images = e_path_new();
1766 e_error_message_show("Cannot allocate path for path_images\n");
1769 e_user_dir_concat_static(buf, "/images");
1770 e_path_default_path_append(path_images, buf);
1771 e_prefix_data_concat_static(buf, "data/images");
1772 e_path_default_path_append(path_images, buf);
1773 e_path_user_path_set(path_images, &(e_config->path_append_images));
1775 /* setup font paths */
1776 path_fonts = e_path_new();
1779 e_error_message_show("Cannot allocate path for path_fonts\n");
1782 e_user_dir_concat_static(buf, "/fonts");
1783 e_path_default_path_append(path_fonts, buf);
1784 e_prefix_data_concat_static(buf, "data/fonts");
1785 e_path_default_path_append(path_fonts, buf);
1786 e_path_user_path_set(path_fonts, &(e_config->path_append_fonts));
1788 /* setup icon paths */
1789 path_icons = e_path_new();
1792 e_error_message_show("Cannot allocate path for path_icons\n");
1795 e_user_dir_concat_static(buf, "/icons");
1796 e_path_default_path_append(path_icons, buf);
1797 e_prefix_data_concat_static(buf, "data/icons");
1798 e_path_default_path_append(path_icons, buf);
1799 e_path_user_path_set(path_icons, &(e_config->path_append_icons));
1801 /* setup module paths */
1802 path_modules = e_path_new();
1805 e_error_message_show("Cannot allocate path for path_modules\n");
1808 e_user_dir_concat_static(buf, "/modules");
1809 e_path_default_path_append(path_modules, buf);
1810 snprintf(buf, sizeof(buf), "%s/enlightenment/modules", e_prefix_lib_get());
1811 e_path_default_path_append(path_modules, buf);
1812 /* FIXME: eventually this has to go - moduels should have installers that
1813 * add appropriate install paths (if not installed to user homedir) to
1814 * e's module search dirs
1816 snprintf(buf, sizeof(buf), "%s/enlightenment/modules_extra", e_prefix_lib_get());
1817 e_path_default_path_append(path_modules, buf);
1818 e_path_user_path_set(path_modules, &(e_config->path_append_modules));
1820 /* setup background paths */
1821 path_backgrounds = e_path_new();
1822 if (!path_backgrounds)
1824 e_error_message_show("Cannot allocate path for path_backgrounds\n");
1827 e_user_dir_concat_static(buf, "/backgrounds");
1828 e_path_default_path_append(path_backgrounds, buf);
1829 e_prefix_data_concat_static(buf, "data/backgrounds");
1830 e_path_default_path_append(path_backgrounds, buf);
1831 e_path_user_path_set(path_backgrounds, &(e_config->path_append_backgrounds));
1833 path_messages = e_path_new();
1836 e_error_message_show("Cannot allocate path for path_messages\n");
1839 e_user_dir_concat_static(buf, "/locale");
1840 e_path_default_path_append(path_messages, buf);
1841 e_path_default_path_append(path_messages, e_prefix_locale_get());
1842 e_path_user_path_set(path_messages, &(e_config->path_append_messages));
1848 _e_main_path_shutdown(void)
1852 e_object_del(E_OBJECT(path_data));
1857 e_object_del(E_OBJECT(path_images));
1862 e_object_del(E_OBJECT(path_fonts));
1867 e_object_del(E_OBJECT(path_icons));
1872 e_object_del(E_OBJECT(path_modules));
1873 path_modules = NULL;
1875 if (path_backgrounds)
1877 e_object_del(E_OBJECT(path_backgrounds));
1878 path_backgrounds = NULL;
1882 e_object_del(E_OBJECT(path_messages));
1883 path_messages = NULL;
1888 #ifndef DISABLE_FORMAT_TEST
1890 _e_main_test_formats(void)
1894 Evas_Object *im, *txt;
1896 char buff[PATH_MAX];
1898 if (e_config->show_splash)
1899 e_init_status_set(_("Testing Format Support"));
1901 if (!(ee = ecore_evas_buffer_new(1, 1)))
1903 e_error_message_show(_("Enlightenment found Evas can't create a buffer canvas. Please check\n"
1904 "Evas has Software Buffer engine support.\n"));
1905 _e_main_shutdown(-1);
1907 evas = ecore_evas_get(ee);
1908 im = evas_object_image_add(evas);
1910 e_prefix_data_concat_static(buff, "data/images/test.svg");
1911 evas_object_image_file_set(im, buff, NULL);
1912 if (evas_object_image_load_error_get(im) != EVAS_LOAD_ERROR_NONE)
1914 e_error_message_show(_("Enlightenment found Evas can't load SVG files. "
1915 "Check Evas has SVG loader support.\n"));
1918 efreet_icon_extension_add(".svg");
1920 e_prefix_data_concat_static(buff, "data/images/test.jpg");
1921 evas_object_image_file_set(im, buff, NULL);
1922 if (evas_object_image_load_error_get(im) != EVAS_LOAD_ERROR_NONE)
1924 e_error_message_show(_("Enlightenment found Evas can't load JPEG files. "
1925 "Check Evas has JPEG loader support.\n"));
1926 _e_main_shutdown(-1);
1928 efreet_icon_extension_add(".jpg");
1930 e_prefix_data_concat_static(buff, "data/images/test.png");
1931 evas_object_image_file_set(im, buff, NULL);
1932 if (evas_object_image_load_error_get(im) != EVAS_LOAD_ERROR_NONE)
1934 e_error_message_show(_("Enlightenment found Evas can't load PNG files. "
1935 "Check Evas has PNG loader support.\n"));
1936 _e_main_shutdown(-1);
1938 efreet_icon_extension_add(".png");
1940 e_prefix_data_concat_static(buff, "data/images/test.edj");
1941 evas_object_image_file_set(im, buff, "images/0");
1942 if (evas_object_image_load_error_get(im) != EVAS_LOAD_ERROR_NONE)
1944 e_error_message_show(_("Enlightenment found Evas can't load EET files. "
1945 "Check Evas has EET loader support.\n"));
1946 _e_main_shutdown(-1);
1948 efreet_icon_extension_add(".edj");
1950 evas_object_del(im);
1952 txt = evas_object_text_add(evas);
1953 evas_object_text_font_set(txt, "Sans", 10);
1954 evas_object_text_text_set(txt, "Hello");
1955 evas_object_geometry_get(txt, NULL, NULL, &tw, &th);
1956 if ((tw <= 0) && (th <= 0))
1958 e_error_message_show(_("Enlightenment found Evas can't load the 'Sans' font. Check Evas has fontconfig\n"
1959 "support and system fontconfig defines a 'Sans' font.\n"));
1960 _e_main_shutdown(-1);
1962 evas_object_del(txt);
1963 ecore_evas_free(ee);
1968 _e_main_screens_init(void)
1970 TS("\tscreens: client");
1971 if (!e_client_init()) return 0;
1972 #ifndef ENABLE_QUICK_INIT
1973 TS("\tscreens: win");
1974 if (!e_win_init()) return 0;
1976 #ifndef HAVE_WAYLAND_ONLY
1980 e_error_message_show(_("Enlightenment cannot setup XKB Keyboard layouts.\n"));
1981 _e_main_shutdown(-1);
1983 TS("E_Xkb Init Done");
1986 TS("Compositor Init");
1989 e_error_message_show(_("Enlightenment cannot create a compositor.\n"));
1990 _e_main_shutdown(-1);
1993 _e_main_desk_restore();
1995 #ifndef HAVE_WAYLAND_ONLY
1996 if (e_config->show_splash)
1997 e_init_status_set(_("Setup DND"));
2001 e_error_message_show(_("Enlightenment cannot set up its dnd system.\n"));
2002 _e_main_shutdown(-1);
2004 TS("E_Dnd Init Done");
2005 _e_main_shutdown_push(e_dnd_shutdown);
2012 _e_main_screens_shutdown(void)
2018 e_client_shutdown();
2019 e_exehist_shutdown();
2020 e_backlight_shutdown();
2029 _e_main_desk_save(void)
2032 char env[1024], name[1024];
2035 EINA_LIST_FOREACH(e_comp->zones, l, zone)
2037 snprintf(name, sizeof(name), "DESK_%d_%d", 0, zone->num);
2038 snprintf(env, sizeof(env), "%d,%d", zone->desk_x_current, zone->desk_y_current);
2039 e_util_env_set(name, env);
2044 _e_main_desk_restore(void)
2052 EINA_LIST_FOREACH(e_comp->zones, l, zone)
2058 snprintf(name, sizeof(name), "DESK_%d_%d", 0, zone->num);
2061 snprintf(buf_e, sizeof(buf_e), "%s", env);
2062 if (!sscanf(buf_e, "%d,%d", &desk_x, &desk_y)) continue;
2063 desk = e_desk_at_xy_get(zone, desk_x, desk_y);
2064 if (!desk) continue;
2068 E_CLIENT_REVERSE_FOREACH(ec)
2069 if ((!e_client_util_ignored_get(ec)) && e_client_util_desk_visible(ec, e_desk_current_get(ec->zone)))
2071 ec->want_focus = ec->take_focus = 1;
2077 _e_main_efreet_paths_init(void)
2081 if ((list = efreet_icon_extra_list_get()))
2083 char buff[PATH_MAX];
2085 e_user_dir_concat_static(buff, "icons");
2086 *list = eina_list_prepend(*list, (void *)eina_stringshare_add(buff));
2087 e_prefix_data_concat_static(buff, "data/icons");
2088 *list = eina_list_prepend(*list, (void *)eina_stringshare_add(buff));
2093 _e_main_modules_load_after(void *d EINA_UNUSED, int type EINA_UNUSED, void *ev EINA_UNUSED)
2095 e_int_config_modules(NULL, NULL);
2096 E_FREE_FUNC(mod_init_end, ecore_event_handler_del);
2097 return ECORE_CALLBACK_RENEW;
2101 _e_main_modules_load(Eina_Bool safe_mode)
2104 e_module_all_load();
2110 crashmodule = getenv("E_MODULE_LOAD");
2111 if (crashmodule) m = e_module_new(crashmodule);
2113 if ((crashmodule) && (m))
2115 e_module_disable(m);
2116 e_object_del(E_OBJECT(m));
2118 e_error_message_show
2119 (_("Enlightenment crashed early on start and has<br>"
2120 "been restarted. There was an error loading the<br>"
2121 "module named: %s. This module has been disabled<br>"
2122 "and will not be loaded."), crashmodule);
2124 (_("Enlightenment crashed early on start and has been restarted"),
2125 _("Enlightenment crashed early on start and has been restarted.<br>"
2126 "There was an error loading the module named: %s<br><br>"
2127 "This module has been disabled and will not be loaded."), crashmodule);
2128 e_module_all_load();
2132 e_error_message_show
2133 (_("Enlightenment crashed early on start and has<br>"
2134 "been restarted. All modules have been disabled<br>"
2135 "and will not be loaded to help remove any problem<br>"
2136 "modules from your configuration. The module<br>"
2137 "configuration dialog should let you select your<br>"
2138 "modules again.\n"));
2140 (_("Enlightenment crashed early on start and has been restarted"),
2141 _("Enlightenment crashed early on start and has been restarted.<br>"
2142 "All modules have been disabled and will not be loaded to help<br>"
2143 "remove any problem modules from your configuration.<br><br>"
2144 "The module configuration dialog should let you select your<br>"
2147 mod_init_end = ecore_event_handler_add(E_EVENT_MODULE_INIT_END, _e_main_modules_load_after, NULL);
2152 _e_main_cb_idle_before(void *data EINA_UNUSED)
2154 e_menu_idler_before();
2155 e_client_idler_before();
2156 e_pointer_idler_before();
2158 return ECORE_CALLBACK_RENEW;
2162 _e_main_cb_idle_after(void *data EINA_UNUSED)
2164 static int first_idle = 1;
2169 #ifdef E_RELEASE_BUILD
2174 e_precache_end = EINA_TRUE;
2177 if (first_idle++ < 60)
2181 e_precache_end = EINA_TRUE;
2185 return ECORE_CALLBACK_RENEW;
2189 _e_main_cb_startup_fake_end(void *data EINA_UNUSED)
2192 return ECORE_CALLBACK_CANCEL;