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] Screens Init: win");
231 e_error_message_show(_("Enlightenment cannot setup elementary trap!\n"));
232 _e_main_shutdown(-1);
234 TS("[DEFERRED] Screens Init: win Done");
236 TS("[DEFERRED] E_Scale Init");
239 e_error_message_show(_("Enlightenment cannot set up its scale system.\n"));
240 _e_main_shutdown(-1);
242 TS("[DEFERRED E_Scale Init Done");
243 _e_main_shutdown_push(e_scale_shutdown);
245 TS("[DEFERRED] E_Test_Helper Init");
246 e_test_helper_init();
247 _e_main_shutdown_push(e_test_helper_shutdown);
248 TS("[DEFERRED] E_Test_Helper Done");
250 TS("[DEFERRED] E_INFO_SERVER Init");
251 e_info_server_init();
252 _e_main_shutdown_push(e_info_server_shutdown);
253 TS("[DEFERRED] E_INFO_SERVER Done");
255 /* try to do deferred job of any subsystems*/
256 TS("[DEFERRED] Compositor's deferred job");
257 e_comp_deferred_job();
258 TS("[DEFERRED] Compositor's deferred job Done");
260 TS("[DEFERRED] E_Module's deferred job");
261 e_module_deferred_job();
262 TS("[DEFERRED] E_Module's deferred job Done");
264 return ECORE_CALLBACK_DONE;
268 _e_main_deferred_job_schedule(void *d EINA_UNUSED, int type EINA_UNUSED, void *ev EINA_UNUSED)
270 ecore_idler_add(_e_main_subsystem_defer, NULL);
271 return ECORE_CALLBACK_DONE;
276 /* externally accessible functions */
278 main(int argc, char **argv)
280 Eina_Bool nostartup = EINA_FALSE;
281 Eina_Bool safe_mode = EINA_FALSE;
282 Eina_Bool after_restart = EINA_FALSE;
283 Eina_Bool waslocked = EINA_FALSE;
284 double t = 0.0, tstart = 0.0;
285 char *s = NULL, buff[32];
286 struct sigaction action;
289 # ifdef PR_SET_PTRACER
290 # ifdef PR_SET_PTRACER_ANY
291 prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY);
297 t0 = t1 = t2 = ecore_time_unix_get();
301 /* trap deadly bug signals and allow some form of sane recovery */
302 /* or ability to gdb attach and debug at this point - better than your */
303 /* wm/desktop vanishing and not knowing what happened */
304 if (!getenv("NOTIFY_SOCKET"))
307 action.sa_sigaction = e_sigseg_act;
308 action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
309 sigemptyset(&action.sa_mask);
310 sigaction(SIGSEGV, &action, NULL);
312 action.sa_sigaction = e_sigill_act;
313 action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
314 sigemptyset(&action.sa_mask);
315 sigaction(SIGILL, &action, NULL);
317 action.sa_sigaction = e_sigfpe_act;
318 action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
319 sigemptyset(&action.sa_mask);
320 sigaction(SIGFPE, &action, NULL);
322 #ifndef HAVE_WAYLAND_ONLY
323 action.sa_sigaction = e_sigbus_act;
324 action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
325 sigemptyset(&action.sa_mask);
326 sigaction(SIGBUS, &action, NULL);
329 action.sa_sigaction = e_sigabrt_act;
330 action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
331 sigemptyset(&action.sa_mask);
332 sigaction(SIGABRT, &action, NULL);
333 TS("Signal Trap Done");
336 t = ecore_time_unix_get();
337 s = getenv("E_START_TIME");
338 if ((s) && (!getenv("E_RESTART_OK")))
341 if ((t - tstart) < 5.0) safe_mode = EINA_TRUE;
344 snprintf(buff, sizeof(buff), "%1.1f", tstart);
345 e_util_env_set("E_START_TIME", buff);
347 if (getenv("E_START_MTRACK"))
348 e_util_env_set("MTRACK", NULL);
352 e_error_message_show(_("Enlightenment cannot initialize Eina!\n"));
353 _e_main_shutdown(-1);
355 _e_main_shutdown_push(eina_shutdown);
356 #ifdef OBJECT_HASH_CHECK
357 e_object_hash_init();
361 e_error_message_show(_("Enlightenment could not create a logging domain!\n"));
362 _e_main_shutdown(-1);
368 t1 = ecore_time_unix_get(); \
369 printf("ESTART: %1.5f [%1.5f] - %s\n", t1 - t0, t1 - t2, x); \
373 TS("Eina Init Done");
374 _e_main_shutdown_push(e_log_shutdown);
376 TS("Determine Prefix");
377 if (!e_prefix_determine(argv[0]))
380 "ERROR: Enlightenment cannot determine it's installed\n"
381 " prefix from the system or argv[0].\n"
382 " This is because it is not on Linux AND has been\n"
383 " executed strangely. This is unusual.\n");
385 TS("Determine Prefix Done");
387 /* for debugging by redirecting stdout of e to a log file to tail */
388 setvbuf(stdout, NULL, _IONBF, 0);
390 TS("Environment Variables");
391 if (getenv("E_RESTART")) after_restart = EINA_TRUE;
392 if (getenv("DESKTOP_STARTUP_ID"))
393 e_util_env_set("DESKTOP_STARTUP_ID", NULL);
394 e_util_env_set("E_RESTART_OK", NULL);
395 e_util_env_set("PANTS", "ON");
396 e_util_env_set("DESKTOP", "Enlightenment-0.17.0");
397 TS("Environment Variables Done");
399 TS("Parse Arguments");
400 _e_main_parse_arguments(argc, argv);
401 TS("Parse Arguments Done");
403 /*** Initialize Core EFL Libraries We Need ***/
408 e_error_message_show(_("Enlightenment cannot initialize Eet!\n"));
409 _e_main_shutdown(-1);
412 _e_main_shutdown_push(eet_shutdown);
417 e_error_message_show(_("Enlightenment cannot initialize Ecore!\n"));
418 _e_main_shutdown(-1);
420 TS("Ecore Init Done");
421 _e_main_shutdown_push(ecore_shutdown);
423 e_first_frame = getenv("E_FIRST_FRAME");
424 if (e_first_frame && (!e_first_frame[0]))
425 e_first_frame = NULL;
427 e_first_frame_start_time = ecore_time_get();
432 e_error_message_show(_("Enlightenment cannot initialize EIO!\n"));
433 _e_main_shutdown(-1);
436 _e_main_shutdown_push(eio_shutdown);
438 ecore_app_args_set(argc, (const char **)argv);
440 TS("Ecore Event Handlers");
441 if (!ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT,
442 _e_main_cb_signal_exit, NULL))
444 e_error_message_show(_("Enlightenment cannot set up an exit signal handler.\n"
445 "Perhaps you are out of memory?"));
446 _e_main_shutdown(-1);
448 if (!ecore_event_handler_add(ECORE_EVENT_SIGNAL_HUP,
449 _e_main_cb_signal_hup, NULL))
451 e_error_message_show(_("Enlightenment cannot set up a HUP signal handler.\n"
452 "Perhaps you are out of memory?"));
453 _e_main_shutdown(-1);
455 if (!ecore_event_handler_add(ECORE_EVENT_SIGNAL_USER,
456 _e_main_cb_signal_user, NULL))
458 e_error_message_show(_("Enlightenment cannot set up a USER signal handler.\n"
459 "Perhaps you are out of memory?"));
460 _e_main_shutdown(-1);
462 TS("Ecore Event Handlers Done");
464 TS("Ecore_File Init");
465 if (!ecore_file_init())
467 e_error_message_show(_("Enlightenment cannot initialize Ecore_File!\n"));
468 _e_main_shutdown(-1);
470 TS("Ecore_File Init Done");
471 _e_main_shutdown_push(ecore_file_shutdown);
473 #ifndef ENABLE_QUICK_INIT
474 TS("Ecore_Con Init");
475 if (!ecore_con_init())
477 e_error_message_show(_("Enlightenment cannot initialize Ecore_Con!\n"));
478 _e_main_shutdown(-1);
480 TS("Ecore_Con Init Done");
481 _e_main_shutdown_push(ecore_con_shutdown);
483 TS("Ecore_Ipc Init");
484 if (!ecore_ipc_init())
486 e_error_message_show(_("Enlightenment cannot initialize Ecore_Ipc!\n"));
487 _e_main_shutdown(-1);
489 TS("Ecore_Ipc Init Done");
490 _e_main_shutdown_push(ecore_ipc_shutdown);
492 _idle_before = ecore_idle_enterer_before_add(_e_main_cb_idle_before, NULL);
494 _xdg_data_dirs_augment();
496 TS("Ecore_Evas Init");
497 if (!ecore_evas_init())
499 e_error_message_show(_("Enlightenment cannot initialize Ecore_Evas!\n"));
500 _e_main_shutdown(-1);
502 TS("Ecore_Evas Init Done");
503 // _e_main_shutdown_push(ecore_evas_shutdown);
505 TS("Elementary Init");
506 if (!elm_init(argc, argv))
508 e_error_message_show(_("Enlightenment cannot initialize Elementary!\n"));
509 _e_main_shutdown(-1);
511 TS("Elementary Init Done");
512 //_e_main_shutdown_push(elm_shutdown);
517 e_error_message_show(_("Enlightenment cannot initialize Emotion!\n"));
518 _e_main_shutdown(-1);
520 TS("Emotion Init Done");
521 _e_main_shutdown_push((void *)emotion_shutdown);
523 /* e doesn't sync to compositor - it should be one */
524 ecore_evas_app_comp_sync_set(0);
526 TS("Ecore_Evas Engine Check");
527 #ifdef HAVE_WAYLAND_ONLY
528 if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_WAYLAND_SHM))
530 e_error_message_show(_("Enlightenment found ecore_evas doesn't support the Wayland SHM\n"
531 "rendering in Evas. Please check your installation of Evas and\n"
532 "Ecore and check they support the Wayland SHM rendering engine."));
533 _e_main_shutdown(-1);
536 if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_XCB))
538 if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_XLIB))
540 e_error_message_show(_("Enlightenment found ecore_evas doesn't support the Software X11\n"
541 "rendering in Evas. Please check your installation of Evas and\n"
542 "Ecore and check they support the Software X11 rendering engine."));
543 _e_main_shutdown(-1);
547 if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_BUFFER))
549 e_error_message_show(_("Enlightenment found ecore_evas doesn't support the Software Buffer\n"
550 "rendering in Evas. Please check your installation of Evas and\n"
551 "Ecore and check they support the Software Buffer rendering engine."));
552 _e_main_shutdown(-1);
554 TS("Ecore_Evas Engine Check Done");
559 e_error_message_show(_("Enlightenment cannot initialize Edje!\n"));
560 _e_main_shutdown(-1);
562 TS("Edje Init Done");
563 _e_main_shutdown_push(edje_shutdown);
566 /*** Initialize E Subsystems We Need ***/
571 e_error_message_show(_("Enlightenment cannot initialize E_Intl!\n"));
572 _e_main_shutdown(-1);
574 TS("E Intl Init Done");
575 _e_main_shutdown_push(e_intl_shutdown);
577 #ifndef HAVE_WAYLAND_ONLY
578 /* init white box of death alert */
582 e_error_message_show(_("Enlightenment cannot initialize its emergency alert system.\n"
583 "Have you set your DISPLAY variable?"));
584 _e_main_shutdown(-1);
586 TS("E_Alert Init Done");
587 _e_main_shutdown_push(e_alert_shutdown);
590 TS("E_Configure Init");
592 TS("E_Configure Init Done");
594 TS("E Directories Init");
595 /* setup directories we will be using for configurations storage etc. */
596 if (!_e_main_dirs_init())
598 e_error_message_show(_("Enlightenment cannot create directories in your home directory.\n"
599 "Perhaps you have no home directory or the disk is full?"));
600 _e_main_shutdown(-1);
602 TS("E Directories Init Done");
603 _e_main_shutdown_push(_e_main_dirs_shutdown);
605 TS("E_Filereg Init");
606 if (!e_filereg_init())
608 e_error_message_show(_("Enlightenment cannot set up its file registry system.\n"));
609 _e_main_shutdown(-1);
611 TS("E_Filereg Init Done");
612 _e_main_shutdown_push(e_filereg_shutdown);
615 if (!e_config_init())
617 e_error_message_show(_("Enlightenment cannot set up its config system.\n"));
618 _e_main_shutdown(-1);
620 TS("E_Config Init Done");
621 _e_main_shutdown_push(e_config_shutdown);
626 e_error_message_show(_("Enlightenment cannot set up its environment.\n"));
627 _e_main_shutdown(-1);
629 TS("E_Env Init Done");
630 _e_main_shutdown_push(e_env_shutdown);
632 efreet_desktop_environment_set(e_config->desktop_environment);
633 e_util_env_set("E_ICON_THEME", e_config->icon_theme);
634 ecore_exe_run_priority_set(e_config->priority);
635 locked |= e_config->desklock_start_locked;
637 s = getenv("E_DESKLOCK_LOCKED");
638 if ((s) && (!strcmp(s, "locked"))) waslocked = EINA_TRUE;
641 if (!_e_main_path_init())
643 e_error_message_show(_("Enlightenment cannot set up paths for finding files.\n"
644 "Perhaps you are out of memory?"));
645 _e_main_shutdown(-1);
647 TS("E Paths Init Done");
648 _e_main_shutdown_push(_e_main_path_shutdown);
651 if (!e_ipc_init()) _e_main_shutdown(-1);
652 TS("E_Ipc Init Done");
653 _e_main_shutdown_push(e_ipc_shutdown);
655 edje_frametime_set(1.0 / e_config->framerate);
660 e_error_message_show(_("Enlightenment cannot set up its font system.\n"));
661 _e_main_shutdown(-1);
663 TS("E_Font Init Done");
664 _e_main_shutdown_push(e_font_shutdown);
668 TS("E_Font Apply Done");
673 e_error_message_show(_("Enlightenment cannot set up its theme system.\n"));
674 _e_main_shutdown(-1);
676 TS("E_Theme Init Done");
677 _e_main_shutdown_push(e_theme_shutdown);
679 TS("E_Moveresize Init");
681 TS("E_Moveresize Init Done");
682 _e_main_shutdown_push(e_moveresize_shutdown);
684 if (e_config->show_splash)
685 e_init_status_set(_("Setup Message Bus"));
688 _e_main_shutdown_push(e_msgbus_shutdown);
689 TS("E_Msgbus Init Done");
694 e_error_message_show(_("Enlightenment cannot initialize the FDO desktop system.\n"
695 "Perhaps you lack permissions on ~/.cache/efreet or are\n"
696 "out of memory or disk space?"));
697 _e_main_shutdown(-1);
699 TS("Efreet Init Done");
700 _e_main_shutdown_push(efreet_shutdown);
702 if (e_config->show_splash)
703 e_init_status_set(_("Starting International Support"));
704 TS("E_Intl Post Init");
705 if (!e_intl_post_init())
707 e_error_message_show(_("Enlightenment cannot set up its intl system.\n"));
708 _e_main_shutdown(-1);
710 TS("E_Intl Post Init Done");
711 _e_main_shutdown_push(e_intl_post_shutdown);
713 e_screensaver_preinit();
715 if (e_config->show_splash)
716 e_init_status_set(_("Setup Actions"));
717 TS("E_Actions Init");
718 if (!e_actions_init())
720 e_error_message_show(_("Enlightenment cannot set up its actions system.\n"));
721 _e_main_shutdown(-1);
723 TS("E_Actions Init Done");
724 _e_main_shutdown_push(e_actions_shutdown);
726 /* these just add event handlers and can't fail
727 * timestamping them is dumb.
733 if (e_config->show_splash)
734 e_init_status_set(_("Setup Powersave Modes"));
735 TS("E_Powersave Init");
736 if (!e_powersave_init())
738 e_error_message_show(_("Enlightenment cannot set up its powersave modes.\n"));
739 _e_main_shutdown(-1);
741 TS("E_Powersave Init Done");
742 _e_main_shutdown_push(e_powersave_shutdown);
744 if (e_config->show_splash)
745 e_init_status_set(_("Setup Screensaver"));
746 TS("E_Screensaver Init");
747 if (!e_screensaver_init())
749 e_error_message_show(_("Enlightenment cannot configure the X screensaver.\n"));
750 _e_main_shutdown(-1);
752 TS("E_Screensaver Init Done");
753 _e_main_shutdown_push(e_screensaver_shutdown);
755 if (e_config->show_splash)
756 e_init_status_set(_("Setup Screens"));
758 if (!_e_main_screens_init())
760 e_error_message_show(_("Enlightenment set up window management for all the screens on your system\n"
761 "failed. Perhaps another window manager is running?\n"));
762 _e_main_shutdown(-1);
764 TS("Screens Init Done");
765 _e_main_shutdown_push(_e_main_screens_shutdown);
766 e_screensaver_force_update();
768 TS("E_Pointer Init");
769 if (!e_pointer_init())
771 e_error_message_show(_("Enlightenment cannot set up its pointer system.\n"));
772 _e_main_shutdown(-1);
774 TS("E_Pointer Init Done");
775 _e_main_shutdown_push(e_pointer_shutdown);
781 e_error_message_show(_("Enlightenment cannot set up its scale system.\n"));
782 _e_main_shutdown(-1);
784 TS("E_Scale Init Done");
785 _e_main_shutdown_push(e_scale_shutdown);
787 if (e_config->show_splash)
792 e_error_message_show(_("Enlightenment cannot set up its init screen.\n"));
793 _e_main_shutdown(-1);
795 TS("E_Splash Init Done");
796 _e_main_shutdown_push(e_init_shutdown);
798 if (!((!e_config->show_splash) || (after_restart)))
803 TS("Test File Format Support");
804 _e_main_test_formats();
805 TS("Test File Format Support Done");
809 efreet_icon_extension_add(".svg");
810 efreet_icon_extension_add(".jpg");
811 efreet_icon_extension_add(".png");
812 efreet_icon_extension_add(".edj");
815 if (e_config->show_splash)
816 e_init_status_set(_("Setup ACPI"));
819 TS("E_Acpi Init Done");
820 _e_main_shutdown_push(e_acpi_shutdown);
822 if (e_config->show_splash)
823 e_init_status_set(_("Setup Backlight"));
824 TS("E_Backlight Init");
825 if (!e_backlight_init())
827 e_error_message_show(_("Enlightenment cannot configure the backlight.\n"));
828 _e_main_shutdown(-1);
830 TS("E_Backlight Init Done");
832 if (e_config->show_splash)
833 e_init_status_set(_("Setup DPMS"));
837 e_error_message_show(_("Enlightenment cannot configure the DPMS settings.\n"));
838 _e_main_shutdown(-1);
840 TS("E_Dpms Init Done");
841 _e_main_shutdown_push(e_dpms_shutdown);
843 if (e_config->show_splash)
844 e_init_status_set(_("Setup Desklock"));
845 TS("E_Desklock Init");
846 if (!e_desklock_init())
848 e_error_message_show(_("Enlightenment cannot set up its desk locking system.\n"));
849 _e_main_shutdown(-1);
851 TS("E_Desklock Init Done");
852 _e_main_shutdown_push(e_desklock_shutdown);
854 if (waslocked || (locked && ((!after_restart) || (!getenv("E_DESKLOCK_UNLOCKED")))))
855 e_desklock_show(EINA_TRUE);
857 if (e_config->show_splash)
858 e_init_status_set(_("Setup Paths"));
860 _e_main_efreet_paths_init();
861 TS("Efreet Paths Done");
863 if (e_config->show_splash)
864 e_init_status_set(_("Setup System Controls"));
868 e_error_message_show(_("Enlightenment cannot initialize the System Command system.\n"));
869 _e_main_shutdown(-1);
871 TS("E_Sys Init Done");
872 _e_main_shutdown_push(e_sys_shutdown);
874 if (e_config->show_splash)
875 e_init_status_set(_("Setup Execution System"));
879 e_error_message_show(_("Enlightenment cannot set up its exec system.\n"));
880 _e_main_shutdown(-1);
882 TS("E_Exec Init Done");
886 TS("E_Comp Freeze Done");
888 if (e_config->show_splash)
889 e_init_status_set(_("Setup Filemanager"));
893 e_error_message_show(_("Enlightenment cannot initialize the File manager.\n"));
894 _e_main_shutdown(-1);
896 TS("E_Fm2 Init Done");
897 _e_main_shutdown_push(e_fm2_shutdown);
899 if (e_config->show_splash)
900 e_init_status_set(_("Setup Message System"));
904 e_error_message_show(_("Enlightenment cannot set up its msg system.\n"));
905 _e_main_shutdown(-1);
907 TS("E_Msg Init Done");
908 _e_main_shutdown_push(e_msg_shutdown);
910 if (e_config->show_splash)
911 e_init_status_set(_("Setup Grab Input Handling"));
912 TS("E_Grabinput Init");
913 if (!e_grabinput_init())
915 e_error_message_show(_("Enlightenment cannot set up its grab input handling system.\n"));
916 _e_main_shutdown(-1);
918 TS("E_Grabinput Init Done");
919 _e_main_shutdown_push(e_grabinput_shutdown);
921 if (e_config->show_splash)
922 e_init_status_set(_("Setup Modules"));
924 if (!e_module_init())
926 e_error_message_show(_("Enlightenment cannot set up its module system.\n"));
927 _e_main_shutdown(-1);
929 TS("E_Module Init Done");
930 _e_main_shutdown_push(e_module_shutdown);
932 if (e_config->show_splash)
933 e_init_status_set(_("Setup Remembers"));
934 TS("E_Remember Init");
935 if (!e_remember_init(after_restart ? E_STARTUP_RESTART : E_STARTUP_START))
937 e_error_message_show(_("Enlightenment cannot setup remember settings.\n"));
938 _e_main_shutdown(-1);
940 TS("E_Remember Init Done");
941 _e_main_shutdown_push(e_remember_shutdown);
943 if (e_config->show_splash)
944 e_init_status_set(_("Setup Color Classes"));
945 TS("E_Color_Class Init");
946 if (!e_color_class_init())
948 e_error_message_show(_("Enlightenment cannot set up its color class system.\n"));
949 _e_main_shutdown(-1);
951 TS("E_Color_Class Init Done");
952 _e_main_shutdown_push(e_color_class_shutdown);
954 if (e_config->show_splash)
955 e_init_status_set(_("Setup Gadcon"));
957 if (!e_gadcon_init())
959 e_error_message_show(_("Enlightenment cannot set up its gadget control system.\n"));
960 _e_main_shutdown(-1);
962 TS("E_Gadcon Init Done");
963 _e_main_shutdown_push(e_gadcon_shutdown);
965 if (e_config->show_splash)
966 e_init_status_set(_("Setup Toolbars"));
967 TS("E_Toolbar Init");
968 if (!e_toolbar_init())
970 e_error_message_show(_("Enlightenment cannot set up its toolbars.\n"));
971 _e_main_shutdown(-1);
973 TS("E_Toolbar Init Done");
974 _e_main_shutdown_push(e_toolbar_shutdown);
976 if (e_config->show_splash)
977 e_init_status_set(_("Setup Wallpaper"));
981 e_error_message_show(_("Enlightenment cannot set up its desktop background system.\n"));
982 _e_main_shutdown(-1);
984 TS("E_Bg Init Done");
985 _e_main_shutdown_push(e_bg_shutdown);
987 if (e_config->show_splash)
988 e_init_status_set(_("Setup Mouse"));
990 if (!e_mouse_update())
992 e_error_message_show(_("Enlightenment cannot configure the mouse settings.\n"));
993 _e_main_shutdown(-1);
995 TS("E_Mouse Init Done");
997 if (e_config->show_splash)
998 e_init_status_set(_("Setup Bindings"));
999 TS("E_Bindings Init");
1000 if (!e_bindings_init())
1002 e_error_message_show(_("Enlightenment cannot set up its bindings system.\n"));
1003 _e_main_shutdown(-1);
1005 TS("E_Bindings Init Done");
1006 _e_main_shutdown_push(e_bindings_shutdown);
1008 if (e_config->show_splash)
1009 e_init_status_set(_("Setup Thumbnailer"));
1011 if (!e_thumb_init())
1013 e_error_message_show(_("Enlightenment cannot initialize the Thumbnailing system.\n"));
1014 _e_main_shutdown(-1);
1016 TS("E_Thumb Init Done");
1017 _e_main_shutdown_push(e_thumb_shutdown);
1022 e_error_message_show(_("Enlightenment cannot initialize the Icon Cache system.\n"));
1023 _e_main_shutdown(-1);
1025 TS("E_Icon Init Done");
1026 _e_main_shutdown_push(e_icon_shutdown);
1028 TS("E_Update Init");
1029 if (!e_update_init())
1031 e_error_message_show(_("Enlightenment cannot initialize the Update system.\n"));
1032 _e_main_shutdown(-1);
1034 TS("E_Update Init Done");
1035 _e_main_shutdown_push(e_update_shutdown);
1037 if (e_config->show_splash)
1038 e_init_status_set(_("Setup Desktop Environment"));
1039 TS("E_Deskenv Init");
1040 if (!e_deskenv_init())
1042 e_error_message_show(_("Enlightenment cannot initialize its desktop environment.\n"));
1043 _e_main_shutdown(-1);
1045 TS("E_Deskenv Init Done");
1046 _e_main_shutdown_push(e_deskenv_shutdown);
1048 if (e_config->show_splash)
1049 e_init_status_set(_("Setup File Ordering"));
1051 if (!e_order_init())
1053 e_error_message_show(_("Enlightenment cannot set up its order file system.\n"));
1054 _e_main_shutdown(-1);
1056 TS("E_Order Init Done");
1057 _e_main_shutdown_push(e_order_shutdown);
1059 TS("E_Manager Keys Grab");
1060 e_managers_keys_grab();
1061 TS("E_Manager Keys Grab Done");
1063 if (e_config->show_splash)
1064 e_init_status_set(_("Load Modules"));
1066 _e_main_modules_load(safe_mode);
1067 TS("Load Modules Done");
1069 TS("Run Startup Apps");
1073 e_startup(E_STARTUP_RESTART);
1075 e_startup(E_STARTUP_START);
1077 TS("Run Startup Apps Done");
1079 if (e_config->show_splash && (!after_restart))
1080 ecore_timer_add(2.0, _e_main_cb_startup_fake_end, NULL);
1084 TS("E_Comp Thaw Done");
1090 TS("E_Test_Helper Init");
1091 e_test_helper_init();
1092 _e_main_shutdown_push(e_test_helper_shutdown);
1093 TS("E_Test_Helper Done");
1095 TS("E_Info_Server Init");
1096 e_info_server_init();
1097 _e_main_shutdown_push(e_info_server_shutdown);
1098 TS("E_Info_Server Done");
1100 if (e_config->show_splash)
1101 e_init_status_set(_("Setup Shelves"));
1103 if (!e_shelf_init())
1105 e_error_message_show(_("Enlightenment cannot set up its module system.\n"));
1106 _e_main_shutdown(-1);
1108 TS("E_Shelf Init Done");
1110 ecore_idle_enterer_before_add(_e_main_shelf_init_job, NULL);
1112 _idle_before = ecore_idle_enterer_before_add(_e_main_cb_idle_before, NULL);
1114 _xdg_data_dirs_augment();
1116 TS("Ecore_Evas Init");
1117 if (!ecore_evas_init())
1119 e_error_message_show(_("Enlightenment cannot initialize Ecore_Evas!\n"));
1120 _e_main_shutdown(-1);
1122 TS("Ecore_Evas Init Done");
1124 /* e doesn't sync to compositor - it should be one */
1125 ecore_evas_app_comp_sync_set(0);
1127 TS("Ecore_Evas Engine Check");
1128 #ifdef HAVE_WAYLAND_ONLY
1129 if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_WAYLAND_SHM))
1131 e_error_message_show(_("Enlightenment found ecore_evas doesn't support the Wayland SHM\n"
1132 "rendering in Evas. Please check your installation of Evas and\n"
1133 "Ecore and check they support the Wayland SHM rendering engine."));
1134 _e_main_shutdown(-1);
1137 if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_XCB))
1139 if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_XLIB))
1141 e_error_message_show(_("Enlightenment found ecore_evas doesn't support the Software X11\n"
1142 "rendering in Evas. Please check your installation of Evas and\n"
1143 "Ecore and check they support the Software X11 rendering engine."));
1144 _e_main_shutdown(-1);
1148 if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_BUFFER))
1150 e_error_message_show(_("Enlightenment found ecore_evas doesn't support the Software Buffer\n"
1151 "rendering in Evas. Please check your installation of Evas and\n"
1152 "Ecore and check they support the Software Buffer rendering engine."));
1153 _e_main_shutdown(-1);
1155 TS("Ecore_Evas Engine Check Done");
1160 e_error_message_show(_("Enlightenment cannot initialize Edje!\n"));
1161 _e_main_shutdown(-1);
1163 TS("Edje Init Done");
1164 _e_main_shutdown_push(edje_shutdown);
1167 /*** Initialize E Subsystems We Need ***/
1169 TS("E Directories Init");
1170 /* setup directories we will be using for configurations storage etc. */
1171 if (!_e_main_dirs_init())
1173 e_error_message_show(_("Enlightenment cannot create directories in your home directory.\n"
1174 "Perhaps you have no home directory or the disk is full?"));
1175 _e_main_shutdown(-1);
1177 TS("E Directories Init Done");
1178 _e_main_shutdown_push(_e_main_dirs_shutdown);
1180 TS("E_Config Init");
1181 if (!e_config_init())
1183 e_error_message_show(_("Enlightenment cannot set up its config system.\n"));
1184 _e_main_shutdown(-1);
1186 TS("E_Config Init Done");
1187 _e_main_shutdown_push(e_config_shutdown);
1192 e_error_message_show(_("Enlightenment cannot set up its environment.\n"));
1193 _e_main_shutdown(-1);
1195 TS("E_Env Init Done");
1196 _e_main_shutdown_push(e_env_shutdown);
1198 efreet_desktop_environment_set(e_config->desktop_environment);
1199 e_util_env_set("E_ICON_THEME", e_config->icon_theme);
1200 ecore_exe_run_priority_set(e_config->priority);
1201 locked |= e_config->desklock_start_locked;
1203 s = getenv("E_DESKLOCK_LOCKED");
1204 if ((s) && (!strcmp(s, "locked"))) waslocked = EINA_TRUE;
1207 if (!_e_main_path_init())
1209 e_error_message_show(_("Enlightenment cannot set up paths for finding files.\n"
1210 "Perhaps you are out of memory?"));
1211 _e_main_shutdown(-1);
1213 TS("E Paths Init Done");
1214 _e_main_shutdown_push(_e_main_path_shutdown);
1216 edje_frametime_set(1.0 / e_config->framerate);
1221 e_error_message_show(_("Enlightenment cannot set up its font system.\n"));
1222 _e_main_shutdown(-1);
1224 TS("E_Font Init Done");
1225 _e_main_shutdown_push(e_font_shutdown);
1229 TS("E_Font Apply Done");
1232 if (!e_theme_init())
1234 e_error_message_show(_("Enlightenment cannot set up its theme system.\n"));
1235 _e_main_shutdown(-1);
1237 TS("E_Theme Init Done");
1238 _e_main_shutdown_push(e_theme_shutdown);
1240 TS("E_Moveresize Init");
1241 e_moveresize_init();
1242 TS("E_Moveresize Init Done");
1243 _e_main_shutdown_push(e_moveresize_shutdown);
1248 e_error_message_show(_("Enlightenment cannot initialize the FDO desktop system.\n"
1249 "Perhaps you lack permissions on ~/.cache/efreet or are\n"
1250 "out of memory or disk space?"));
1251 _e_main_shutdown(-1);
1253 TS("Efreet Init Done");
1254 _e_main_shutdown_push(efreet_shutdown);
1256 e_screensaver_preinit();
1258 if (e_config->show_splash)
1259 e_init_status_set(_("Setup Actions"));
1260 TS("E_Actions Init");
1261 if (!e_actions_init())
1263 e_error_message_show(_("Enlightenment cannot set up its actions system.\n"));
1264 _e_main_shutdown(-1);
1266 TS("E_Actions Init Done");
1267 _e_main_shutdown_push(e_actions_shutdown);
1269 /* these just add event handlers and can't fail
1270 * timestamping them is dumb.
1276 if (e_config->show_splash)
1277 e_init_status_set(_("Setup Powersave Modes"));
1278 TS("E_Powersave Init");
1279 if (!e_powersave_init())
1281 e_error_message_show(_("Enlightenment cannot set up its powersave modes.\n"));
1282 _e_main_shutdown(-1);
1284 TS("E_Powersave Init Done");
1285 _e_main_shutdown_push(e_powersave_shutdown);
1287 if (e_config->show_splash)
1288 e_init_status_set(_("Setup Screensaver"));
1289 TS("E_Screensaver Init");
1290 if (!e_screensaver_init())
1292 e_error_message_show(_("Enlightenment cannot configure the X screensaver.\n"));
1293 _e_main_shutdown(-1);
1295 TS("E_Screensaver Init Done");
1296 _e_main_shutdown_push(e_screensaver_shutdown);
1298 if (e_config->show_splash)
1299 e_init_status_set(_("Setup Screens"));
1301 if (!_e_main_screens_init())
1303 e_error_message_show(_("Enlightenment set up window management for all the screens on your system\n"
1304 "failed. Perhaps another window manager is running?\n"));
1305 _e_main_shutdown(-1);
1307 TS("Screens Init Done");
1308 _e_main_shutdown_push(_e_main_screens_shutdown);
1309 e_screensaver_force_update();
1311 TS("E_Pointer Init");
1312 if (!e_pointer_init())
1314 e_error_message_show(_("Enlightenment cannot set up its pointer system.\n"));
1315 _e_main_shutdown(-1);
1317 TS("E_Pointer Init Done");
1318 _e_main_shutdown_push(e_pointer_shutdown);
1321 if (e_config->show_splash)
1322 e_init_status_set(_("Setup Paths"));
1324 _e_main_efreet_paths_init();
1325 TS("Efreet Paths Done");
1327 if (e_config->show_splash)
1328 e_init_status_set(_("Setup System Controls"));
1332 e_error_message_show(_("Enlightenment cannot initialize the System Command system.\n"));
1333 _e_main_shutdown(-1);
1335 TS("E_Sys Init Done");
1336 _e_main_shutdown_push(e_sys_shutdown);
1338 TS("E_Comp Freeze");
1339 e_comp_all_freeze();
1340 TS("E_Comp Freeze Done");
1342 if (e_config->show_splash)
1343 e_init_status_set(_("Setup Grab Input Handling"));
1344 TS("E_Grabinput Init");
1345 if (!e_grabinput_init())
1347 e_error_message_show(_("Enlightenment cannot set up its grab input handling system.\n"));
1348 _e_main_shutdown(-1);
1350 TS("E_Grabinput Init Done");
1351 _e_main_shutdown_push(e_grabinput_shutdown);
1353 ecore_event_handler_add(E_EVENT_MODULE_INIT_END, _e_main_deferred_job_schedule, NULL);
1355 if (e_config->show_splash)
1356 e_init_status_set(_("Setup Modules"));
1357 TS("E_Module Init");
1358 if (!e_module_init())
1360 e_error_message_show(_("Enlightenment cannot set up its module system.\n"));
1361 _e_main_shutdown(-1);
1363 TS("E_Module Init Done");
1364 _e_main_shutdown_push(e_module_shutdown);
1366 if (e_config->show_splash)
1367 e_init_status_set(_("Setup Remembers"));
1368 TS("E_Remember Init");
1369 if (!e_remember_init(after_restart ? E_STARTUP_RESTART : E_STARTUP_START))
1371 e_error_message_show(_("Enlightenment cannot setup remember settings.\n"));
1372 _e_main_shutdown(-1);
1374 TS("E_Remember Init Done");
1375 _e_main_shutdown_push(e_remember_shutdown);
1377 if (e_config->show_splash)
1378 e_init_status_set(_("Setup Mouse"));
1380 if (!e_mouse_update())
1382 e_error_message_show(_("Enlightenment cannot configure the mouse settings.\n"));
1383 _e_main_shutdown(-1);
1385 TS("E_Mouse Init Done");
1387 if (e_config->show_splash)
1388 e_init_status_set(_("Setup Bindings"));
1389 TS("E_Bindings Init");
1390 if (!e_bindings_init())
1392 e_error_message_show(_("Enlightenment cannot set up its bindings system.\n"));
1393 _e_main_shutdown(-1);
1395 TS("E_Bindings Init Done");
1396 _e_main_shutdown_push(e_bindings_shutdown);
1401 e_error_message_show(_("Enlightenment cannot initialize the Icon Cache system.\n"));
1402 _e_main_shutdown(-1);
1404 TS("E_Icon Init Done");
1405 _e_main_shutdown_push(e_icon_shutdown);
1407 TS("E_Manager Keys Grab");
1408 e_managers_keys_grab();
1409 TS("E_Manager Keys Grab Done");
1411 if (e_config->show_splash)
1412 e_init_status_set(_("Load Modules"));
1414 _e_main_modules_load(safe_mode);
1415 TS("Load Modules Done");
1417 if (e_config->show_splash && (!after_restart))
1418 ecore_timer_add(2.0, _e_main_cb_startup_fake_end, NULL);
1422 TS("E_Comp Thaw Done");
1425 _idle_after = ecore_idle_enterer_add(_e_main_cb_idle_after, NULL);
1427 if (e_config->show_splash)
1428 e_init_status_set(_("Almost Done"));
1430 starting = EINA_FALSE;
1433 e_util_env_set("E_RESTART", "1");
1435 TS("MAIN LOOP AT LAST");
1436 if (!setjmp(x_fatal_buff))
1437 ecore_main_loop_begin();
1439 CRI("FATAL: X Died. Connection gone. Abbreviated Shutdown\n");
1441 inloop = EINA_FALSE;
1442 stopping = EINA_TRUE;
1444 //if (!x_fatal) e_canvas_idle_flush();
1446 e_config_save_flush();
1447 _e_main_desk_save();
1448 e_remember_internal_save();
1449 e_comp_internal_save();
1451 _e_main_shutdown(0);
1455 e_util_env_set("E_RESTART_OK", "1");
1456 if (getenv("E_START_MTRACK"))
1457 e_util_env_set("MTRACK", "track");
1458 ecore_app_restart();
1461 e_prefix_shutdown();
1467 e_main_ts(const char *str)
1470 t1 = ecore_time_unix_get();
1471 printf("ESTART: %1.5f [%1.5f] - %s\n", t1 - t0, t1 - t2, str);
1477 /* local functions */
1479 _e_main_shutdown(int errcode)
1485 printf("E: Begin Shutdown Procedure!\n");
1487 if (_idle_before) ecore_idle_enterer_del(_idle_before);
1488 _idle_before = NULL;
1489 if (_idle_after) ecore_idle_enterer_del(_idle_after);
1492 dir = getenv("XDG_RUNTIME_DIR");
1495 char buf_env[PATH_MAX];
1496 snprintf(buf_env, sizeof(buf_env), "%s", dir);
1497 snprintf(buf, sizeof(buf), "%s/.e-deleteme", buf_env);
1498 if (ecore_file_exists(buf)) ecore_file_recursive_rm(buf_env);
1500 for (i = (_e_main_lvl - 1); i >= 0; i--)
1501 (*_e_main_shutdown_func[i])();
1502 #ifdef OBJECT_HASH_CHECK
1503 e_object_hash_shutdown();
1505 if (errcode < 0) exit(errcode);
1509 _e_main_shutdown_push(int (*func)(void))
1512 if (_e_main_lvl > MAX_LEVEL)
1515 e_error_message_show("WARNING: too many init levels. MAX = %i\n",
1519 _e_main_shutdown_func[_e_main_lvl - 1] = func;
1523 _e_main_parse_arguments(int argc, char **argv)
1528 /* handle some command-line parameters */
1529 for (i = 1; i < argc; i++)
1531 if ((!strcmp(argv[i], "-display")) && (i < (argc - 1)))
1534 e_util_env_set("DISPLAY", argv[i]);
1536 else if ((!strcmp(argv[i], "-fake-xinerama-screen")) && (i < (argc - 1)))
1541 if (sscanf(argv[i], "%ix%i+%i+%i", &w, &h, &x, &y) == 4)
1542 e_xinerama_fake_screen_add(x, y, w, h);
1544 else if (!strcmp(argv[i], "-good"))
1548 printf("LA LA LA\n");
1550 else if (!strcmp(argv[i], "-evil"))
1554 printf("MUHAHAHAHHAHAHAHAHA\n");
1556 else if (!strcmp(argv[i], "-psychotic"))
1560 printf("MUHAHALALALALALALALA\n");
1562 else if ((!strcmp(argv[i], "-profile")) && (i < (argc - 1)))
1565 if (!getenv("E_CONF_PROFILE"))
1566 e_util_env_set("E_CONF_PROFILE", argv[i]);
1568 else if (!strcmp(argv[i], "-i-really-know-what-i-am-doing-and-accept-full-responsibility-for-it"))
1569 really_know = EINA_TRUE;
1570 else if (!strcmp(argv[i], "-locked"))
1572 else if (!strcmp(argv[i], "-nopause"))
1573 e_nopause = EINA_TRUE;
1574 else if ((!strcmp(argv[i], "-h")) ||
1575 (!strcmp(argv[i], "-help")) ||
1576 (!strcmp(argv[i], "--help")))
1581 "\t-display DISPLAY\n"
1582 "\t\tConnect to display named DISPLAY.\n"
1583 "\t\tEG: -display :1.0\n"
1584 "\t-fake-xinerama-screen WxH+X+Y\n"
1585 "\t\tAdd a FAKE xinerama screen (instead of the real ones)\n"
1586 "\t\tgiven the geometry. Add as many as you like. They all\n"
1587 "\t\treplace the real xinerama screens, if any. This can\n"
1588 "\t\tbe used to simulate xinerama.\n"
1589 "\t\tEG: -fake-xinerama-screen 800x600+0+0 -fake-xinerama-screen 800x600+800+0\n"
1590 "\t-profile CONF_PROFILE\n"
1591 "\t\tUse the configuration profile CONF_PROFILE instead of the user selected default or just \"default\".\n"
1597 "\t\tBe psychotic.\n"
1599 "\t\tStart with desklock on, so password will be asked.\n"
1600 "\t-i-really-know-what-i-am-doing-and-accept-full-responsibility-for-it\n"
1601 "\t\tIf you need this help, you don't need this option.\n"
1604 _e_main_shutdown(-1);
1608 /* fix up DISPLAY to be :N.0 if no .screen is in it */
1609 s = getenv("DISPLAY");
1612 char *p, buff[4096];
1614 if (!(p = strrchr(s, ':')))
1616 snprintf(buff, sizeof(buff), "%s:0.0", s);
1617 e_util_env_set("DISPLAY", buff);
1621 if (!strrchr(p, '.'))
1623 snprintf(buff, sizeof(buff), "%s.0", s);
1624 e_util_env_set("DISPLAY", buff);
1629 /* we want to have been launched by enlightenment_start. there is a very */
1630 /* good reason we want to have been launched this way, thus check */
1631 if (!getenv("E_START"))
1633 e_error_message_show(_("You are executing enlightenment directly. This is\n"
1634 "bad. Please do not execute the \"enlightenment\"\n"
1635 "binary. Use the \"enlightenment_start\" launcher. It\n"
1636 "will handle setting up environment variables, paths,\n"
1637 "and launching any other required services etc.\n"
1638 "before enlightenment itself begins running.\n"));
1639 _e_main_shutdown(-1);
1644 _e_main_cb_x_fatal(void *data __UNUSED__)
1646 e_error_message_show("Lost X Connection.\n");
1647 ecore_main_loop_quit();
1650 x_fatal = EINA_TRUE;
1651 if (inloop) longjmp(x_fatal_buff, -99);
1656 _e_main_cb_signal_exit(void *data __UNUSED__, int ev_type __UNUSED__, void *ev __UNUSED__)
1658 /* called on ctrl-c, kill (pid) (also SIGINT, SIGTERM and SIGQIT) */
1659 e_sys_action_do(E_SYS_EXIT, NULL);
1660 return ECORE_CALLBACK_RENEW;
1664 _e_main_cb_signal_hup(void *data __UNUSED__, int ev_type __UNUSED__, void *ev __UNUSED__)
1666 e_sys_action_do(E_SYS_RESTART, NULL);
1667 return ECORE_CALLBACK_RENEW;
1671 _e_main_cb_signal_user(void *data __UNUSED__, int ev_type __UNUSED__, void *ev)
1673 Ecore_Event_Signal_User *e = ev;
1677 // E_Action *a = e_action_find("configuration");
1678 // if ((a) && (a->func.go)) a->func.go(NULL, NULL);
1680 else if (e->number == 2)
1682 // comp module has its own handler for this for enabling/disabling fps debug
1684 return ECORE_CALLBACK_RENEW;
1689 _e_main_dirs_init(void)
1692 const char *dirs[] =
1700 "applications/menu",
1701 "applications/menu/favorite",
1702 "applications/menu/all",
1704 "applications/bar/default",
1705 "applications/startup",
1706 "applications/restart",
1707 "applications/trash",
1708 "applications/desk-lock",
1709 "applications/desk-unlock",
1717 base = e_user_dir_get();
1718 if (ecore_file_mksubdirs(base, dirs) != sizeof(dirs) / sizeof(dirs[0]) - 1)
1720 e_error_message_show("Could not create one of the required "
1721 "subdirectories of '%s'\n", base);
1729 _e_main_dirs_shutdown(void)
1735 _e_main_path_init(void)
1739 /* setup data paths */
1740 path_data = e_path_new();
1743 e_error_message_show("Cannot allocate path for path_data\n");
1746 e_prefix_data_concat_static(buf, "data");
1747 e_path_default_path_append(path_data, buf);
1748 e_path_user_path_set(path_data, &(e_config->path_append_data));
1750 /* setup image paths */
1751 path_images = e_path_new();
1754 e_error_message_show("Cannot allocate path for path_images\n");
1757 e_user_dir_concat_static(buf, "/images");
1758 e_path_default_path_append(path_images, buf);
1759 e_prefix_data_concat_static(buf, "data/images");
1760 e_path_default_path_append(path_images, buf);
1761 e_path_user_path_set(path_images, &(e_config->path_append_images));
1763 /* setup font paths */
1764 path_fonts = e_path_new();
1767 e_error_message_show("Cannot allocate path for path_fonts\n");
1770 e_user_dir_concat_static(buf, "/fonts");
1771 e_path_default_path_append(path_fonts, buf);
1772 e_prefix_data_concat_static(buf, "data/fonts");
1773 e_path_default_path_append(path_fonts, buf);
1774 e_path_user_path_set(path_fonts, &(e_config->path_append_fonts));
1776 /* setup icon paths */
1777 path_icons = e_path_new();
1780 e_error_message_show("Cannot allocate path for path_icons\n");
1783 e_user_dir_concat_static(buf, "/icons");
1784 e_path_default_path_append(path_icons, buf);
1785 e_prefix_data_concat_static(buf, "data/icons");
1786 e_path_default_path_append(path_icons, buf);
1787 e_path_user_path_set(path_icons, &(e_config->path_append_icons));
1789 /* setup module paths */
1790 path_modules = e_path_new();
1793 e_error_message_show("Cannot allocate path for path_modules\n");
1796 e_user_dir_concat_static(buf, "/modules");
1797 e_path_default_path_append(path_modules, buf);
1798 snprintf(buf, sizeof(buf), "%s/enlightenment/modules", e_prefix_lib_get());
1799 e_path_default_path_append(path_modules, buf);
1800 /* FIXME: eventually this has to go - moduels should have installers that
1801 * add appropriate install paths (if not installed to user homedir) to
1802 * e's module search dirs
1804 snprintf(buf, sizeof(buf), "%s/enlightenment/modules_extra", e_prefix_lib_get());
1805 e_path_default_path_append(path_modules, buf);
1806 e_path_user_path_set(path_modules, &(e_config->path_append_modules));
1808 /* setup background paths */
1809 path_backgrounds = e_path_new();
1810 if (!path_backgrounds)
1812 e_error_message_show("Cannot allocate path for path_backgrounds\n");
1815 e_user_dir_concat_static(buf, "/backgrounds");
1816 e_path_default_path_append(path_backgrounds, buf);
1817 e_prefix_data_concat_static(buf, "data/backgrounds");
1818 e_path_default_path_append(path_backgrounds, buf);
1819 e_path_user_path_set(path_backgrounds, &(e_config->path_append_backgrounds));
1821 path_messages = e_path_new();
1824 e_error_message_show("Cannot allocate path for path_messages\n");
1827 e_user_dir_concat_static(buf, "/locale");
1828 e_path_default_path_append(path_messages, buf);
1829 e_path_default_path_append(path_messages, e_prefix_locale_get());
1830 e_path_user_path_set(path_messages, &(e_config->path_append_messages));
1836 _e_main_path_shutdown(void)
1840 e_object_del(E_OBJECT(path_data));
1845 e_object_del(E_OBJECT(path_images));
1850 e_object_del(E_OBJECT(path_fonts));
1855 e_object_del(E_OBJECT(path_icons));
1860 e_object_del(E_OBJECT(path_modules));
1861 path_modules = NULL;
1863 if (path_backgrounds)
1865 e_object_del(E_OBJECT(path_backgrounds));
1866 path_backgrounds = NULL;
1870 e_object_del(E_OBJECT(path_messages));
1871 path_messages = NULL;
1877 _e_main_test_formats(void)
1881 Evas_Object *im, *txt;
1883 char buff[PATH_MAX];
1885 if (e_config->show_splash)
1886 e_init_status_set(_("Testing Format Support"));
1888 if (!(ee = ecore_evas_buffer_new(1, 1)))
1890 e_error_message_show(_("Enlightenment found Evas can't create a buffer canvas. Please check\n"
1891 "Evas has Software Buffer engine support.\n"));
1892 _e_main_shutdown(-1);
1894 evas = ecore_evas_get(ee);
1895 im = evas_object_image_add(evas);
1897 e_prefix_data_concat_static(buff, "data/images/test.svg");
1898 evas_object_image_file_set(im, buff, NULL);
1899 if (evas_object_image_load_error_get(im) != EVAS_LOAD_ERROR_NONE)
1901 e_error_message_show(_("Enlightenment found Evas can't load SVG files. "
1902 "Check Evas has SVG loader support.\n"));
1905 efreet_icon_extension_add(".svg");
1907 e_prefix_data_concat_static(buff, "data/images/test.jpg");
1908 evas_object_image_file_set(im, buff, NULL);
1909 if (evas_object_image_load_error_get(im) != EVAS_LOAD_ERROR_NONE)
1911 e_error_message_show(_("Enlightenment found Evas can't load JPEG files. "
1912 "Check Evas has JPEG loader support.\n"));
1913 _e_main_shutdown(-1);
1915 efreet_icon_extension_add(".jpg");
1917 e_prefix_data_concat_static(buff, "data/images/test.png");
1918 evas_object_image_file_set(im, buff, NULL);
1919 if (evas_object_image_load_error_get(im) != EVAS_LOAD_ERROR_NONE)
1921 e_error_message_show(_("Enlightenment found Evas can't load PNG files. "
1922 "Check Evas has PNG loader support.\n"));
1923 _e_main_shutdown(-1);
1925 efreet_icon_extension_add(".png");
1927 e_prefix_data_concat_static(buff, "data/images/test.edj");
1928 evas_object_image_file_set(im, buff, "images/0");
1929 if (evas_object_image_load_error_get(im) != EVAS_LOAD_ERROR_NONE)
1931 e_error_message_show(_("Enlightenment found Evas can't load EET files. "
1932 "Check Evas has EET loader support.\n"));
1933 _e_main_shutdown(-1);
1935 efreet_icon_extension_add(".edj");
1937 evas_object_del(im);
1939 txt = evas_object_text_add(evas);
1940 evas_object_text_font_set(txt, "Sans", 10);
1941 evas_object_text_text_set(txt, "Hello");
1942 evas_object_geometry_get(txt, NULL, NULL, &tw, &th);
1943 if ((tw <= 0) && (th <= 0))
1945 e_error_message_show(_("Enlightenment found Evas can't load the 'Sans' font. Check Evas has fontconfig\n"
1946 "support and system fontconfig defines a 'Sans' font.\n"));
1947 _e_main_shutdown(-1);
1949 evas_object_del(txt);
1950 ecore_evas_free(ee);
1954 _e_main_screens_init(void)
1956 TS("\tscreens: manager");
1957 if (!e_manager_init()) return 0;
1959 TS("\tscreens: client");
1960 if (!e_client_init()) return 0;
1961 #ifndef ENABLE_QUICK_INIT
1962 TS("\tscreens: win");
1963 if (!e_win_init()) return 0;
1965 #ifndef HAVE_WAYLAND_ONLY
1969 e_error_message_show(_("Enlightenment cannot setup XKB Keyboard layouts.\n"));
1970 _e_main_shutdown(-1);
1972 TS("E_Xkb Init Done");
1975 TS("Compositor Init");
1978 e_error_message_show(_("Enlightenment cannot create a compositor.\n"));
1979 _e_main_shutdown(-1);
1982 _e_main_desk_restore();
1984 #ifndef HAVE_WAYLAND_ONLY
1985 if (e_config->show_splash)
1986 e_init_status_set(_("Setup DND"));
1990 e_error_message_show(_("Enlightenment cannot set up its dnd system.\n"));
1991 _e_main_shutdown(-1);
1993 TS("E_Dnd Init Done");
1994 _e_main_shutdown_push(e_dnd_shutdown);
2001 _e_main_screens_shutdown(void)
2007 e_client_shutdown();
2008 e_exehist_shutdown();
2009 e_backlight_shutdown();
2014 e_manager_shutdown();
2019 _e_main_desk_save(void)
2022 char env[1024], name[1024];
2025 EINA_LIST_FOREACH(e_comp->zones, l, zone)
2027 snprintf(name, sizeof(name), "DESK_%d_%d", e_comp->num, zone->num);
2028 snprintf(env, sizeof(env), "%d,%d", zone->desk_x_current, zone->desk_y_current);
2029 e_util_env_set(name, env);
2034 _e_main_desk_restore(void)
2041 EINA_LIST_FOREACH(e_comp->zones, l, zone)
2047 snprintf(name, sizeof(name), "DESK_%d_%d", e_comp->num, zone->num);
2050 snprintf(buf_e, sizeof(buf_e), "%s", env);
2051 if (!sscanf(buf_e, "%d,%d", &desk_x, &desk_y)) continue;
2052 desk = e_desk_at_xy_get(zone, desk_x, desk_y);
2053 if (!desk) continue;
2059 _e_main_efreet_paths_init(void)
2063 if ((list = efreet_icon_extra_list_get()))
2065 char buff[PATH_MAX];
2067 e_user_dir_concat_static(buff, "icons");
2068 *list = eina_list_prepend(*list, (void *)eina_stringshare_add(buff));
2069 e_prefix_data_concat_static(buff, "data/icons");
2070 *list = eina_list_prepend(*list, (void *)eina_stringshare_add(buff));
2075 _e_main_modules_load_after(void *d EINA_UNUSED, int type EINA_UNUSED, void *ev EINA_UNUSED)
2077 e_int_config_modules(NULL, NULL);
2078 E_FREE_FUNC(mod_init_end, ecore_event_handler_del);
2079 return ECORE_CALLBACK_RENEW;
2083 _e_main_modules_load(Eina_Bool safe_mode)
2086 e_module_all_load();
2092 crashmodule = getenv("E_MODULE_LOAD");
2093 if (crashmodule) m = e_module_new(crashmodule);
2095 if ((crashmodule) && (m))
2097 e_module_disable(m);
2098 e_object_del(E_OBJECT(m));
2100 e_error_message_show
2101 (_("Enlightenment crashed early on start and has<br>"
2102 "been restarted. There was an error loading the<br>"
2103 "module named: %s. This module has been disabled<br>"
2104 "and will not be loaded."), crashmodule);
2106 (_("Enlightenment crashed early on start and has been restarted"),
2107 _("Enlightenment crashed early on start and has been restarted.<br>"
2108 "There was an error loading the module named: %s<br><br>"
2109 "This module has been disabled and will not be loaded."), crashmodule);
2110 e_module_all_load();
2114 e_error_message_show
2115 (_("Enlightenment crashed early on start and has<br>"
2116 "been restarted. All modules have been disabled<br>"
2117 "and will not be loaded to help remove any problem<br>"
2118 "modules from your configuration. The module<br>"
2119 "configuration dialog should let you select your<br>"
2120 "modules again.\n"));
2122 (_("Enlightenment crashed early on start and has been restarted"),
2123 _("Enlightenment crashed early on start and has been restarted.<br>"
2124 "All modules have been disabled and will not be loaded to help<br>"
2125 "remove any problem modules from your configuration.<br><br>"
2126 "The module configuration dialog should let you select your<br>"
2129 mod_init_end = ecore_event_handler_add(E_EVENT_MODULE_INIT_END, _e_main_modules_load_after, NULL);
2134 _e_main_cb_idle_before(void *data __UNUSED__)
2136 e_menu_idler_before();
2137 e_client_idler_before();
2138 e_pointer_idler_before();
2140 return ECORE_CALLBACK_RENEW;
2144 _e_main_cb_idle_after(void *data __UNUSED__)
2146 static int first_idle = 1;
2151 #ifdef E_RELEASE_BUILD
2156 e_precache_end = EINA_TRUE;
2159 if (first_idle++ < 60)
2163 e_precache_end = EINA_TRUE;
2167 return ECORE_CALLBACK_RENEW;
2171 _e_main_cb_startup_fake_end(void *data __UNUSED__)
2174 return ECORE_CALLBACK_CANCEL;