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);
90 static Eina_Bool _e_main_cb_idle_before(void *data __UNUSED__);
91 static Eina_Bool _e_main_cb_idle_after(void *data __UNUSED__);
92 static Eina_Bool _e_main_cb_startup_fake_end(void *data __UNUSED__);
94 static Eina_Bool _e_main_cb_idle_before(void *data EINA_UNUSED);
95 static Eina_Bool _e_main_cb_idle_after(void *data EINA_UNUSED);
96 static Eina_Bool _e_main_cb_startup_fake_end(void *data EINA_UNUSED);
100 static Eina_Bool really_know = EINA_FALSE;
101 static Eina_Bool locked = EINA_FALSE;
102 static Eina_Bool inloop = EINA_FALSE;
103 static jmp_buf x_fatal_buff;
105 static int _e_main_lvl = 0;
106 static int(*_e_main_shutdown_func[MAX_LEVEL]) (void);
108 static Ecore_Idle_Enterer *_idle_before = NULL;
109 static Ecore_Idle_Enterer *_idle_after = NULL;
111 static Ecore_Event_Handler *mod_init_end = NULL;
113 /* external variables */
114 E_API Eina_Bool e_precache_end = EINA_FALSE;
115 E_API Eina_Bool x_fatal = EINA_FALSE;
116 E_API Eina_Bool good = EINA_FALSE;
117 E_API Eina_Bool evil = EINA_FALSE;
118 E_API Eina_Bool starting = EINA_TRUE;
119 E_API Eina_Bool stopping = EINA_FALSE;
120 E_API Eina_Bool restart = EINA_FALSE;
121 E_API Eina_Bool e_nopause = EINA_FALSE;
122 EINTERN const char *e_first_frame = NULL;
123 EINTERN double e_first_frame_start_time = -1;
126 _xdg_check_str(const char *env, const char *str)
132 for (p = strstr(env, str); p; p++, p = strstr(p, str))
134 if ((!p[len]) || (p[len] == ':')) return EINA_TRUE;
140 _xdg_data_dirs_augment(void)
143 const char *p = e_prefix_get();
144 char newpath[4096], buf[4096];
148 s = getenv("XDG_DATA_DIRS");
151 Eina_Bool pfxdata, pfx;
153 pfxdata = !_xdg_check_str(s, e_prefix_data_get());
154 snprintf(newpath, sizeof(newpath), "%s/share", p);
155 pfx = !_xdg_check_str(s, newpath);
158 snprintf(buf, sizeof(buf), "%s%s%s%s%s",
159 pfxdata ? e_prefix_data_get() : "",
164 e_util_env_set("XDG_DATA_DIRS", buf);
169 snprintf(buf, sizeof(buf), "%s:%s/share:/usr/local/share:/usr/share", e_prefix_data_get(), p);
170 e_util_env_set("XDG_DATA_DIRS", buf);
173 s = getenv("XDG_CONFIG_DIRS");
174 snprintf(newpath, sizeof(newpath), "%s/etc/xdg", p);
177 if (!_xdg_check_str(s, newpath))
179 snprintf(buf, sizeof(buf), "%s:%s", newpath, s);
180 e_util_env_set("XDG_CONFIG_DIRS", buf);
185 snprintf(buf, sizeof(buf), "%s:/etc/xdg", newpath);
186 e_util_env_set("XDG_CONFIG_DIRS", buf);
189 if (!getenv("XDG_RUNTIME_DIR"))
193 snprintf(buf, sizeof(buf), "/tmp/xdg-XXXXXX");
195 if (!dir) dir = "/tmp";
198 e_util_env_set("XDG_RUNTIME_DIR", dir);
199 snprintf(buf, sizeof(buf), "%s/.e-deleteme", dir);
200 ecore_file_mkdir(buf);
204 /* set menu prefix so we get our e menu */
205 if (!getenv("XDG_MENU_PREFIX"))
207 e_util_env_set("XDG_MENU_PREFIX", "e-");
211 #ifndef ENABLE_QUICK_INIT
213 _e_main_shelf_init_job(void *data EINA_UNUSED)
215 e_shelf_config_update();
216 return ECORE_CALLBACK_CANCEL;
220 _e_main_subsystem_defer(void *data EINA_UNUSED)
225 ecore_app_args_get(&argc, &argv);
227 /* try to init delayed subsystems */
228 TS("[DEFERRED] Elementary Init");
229 if (!elm_init(argc, argv))
231 e_error_message_show(_("Enlightenment cannot initialize Elementary!\n"));
232 _e_main_shutdown(-1);
234 TS("[DEFERRED] Elementary Init Done");
236 TS("[DEFERRED] Edje Init");
239 e_error_message_show(_("Enlightenment cannot initialize Edje!\n"));
240 _e_main_shutdown(-1);
242 TS("[DEFERRED] Edje Init Done");
243 _e_main_shutdown_push(edje_shutdown);
245 TS("[DEFERRED] Efreet Init");
248 e_error_message_show(_("Enlightenment cannot initialize the FDO desktop system.\n"
249 "Perhaps you lack permissions on ~/.cache/efreet or are\n"
250 "out of memory or disk space?"));
251 _e_main_shutdown(-1);
253 TS("[DEFERRED] Efreet Init Done");
254 _e_main_shutdown_push(efreet_shutdown);
256 TS("[DEFERRED] Screens Init: win");
259 e_error_message_show(_("Enlightenment cannot setup elementary trap!\n"));
260 _e_main_shutdown(-1);
262 TS("[DEFERRED] Screens Init: win Done");
264 TS("[DEFERRED] E_Pointer Init");
265 if (!e_pointer_init())
267 e_error_message_show(_("Enlightenment cannot set up its pointer system.\n"));
268 _e_main_shutdown(-1);
271 TS("[DEFERRED] E_Pointer Init Done");
272 _e_main_shutdown_push(e_pointer_shutdown);
274 TS("[DEFERRED] E_Scale Init");
277 e_error_message_show(_("Enlightenment cannot set up its scale system.\n"));
278 _e_main_shutdown(-1);
280 TS("[DEFERRED E_Scale Init Done");
281 _e_main_shutdown_push(e_scale_shutdown);
283 TS("[DEFERRED] Efreet Paths");
284 _e_main_efreet_paths_init();
285 TS("[DEFERRED] Efreet Paths Done");
287 TS("[DEFERRED] E_Test_Helper Init");
288 e_test_helper_init();
289 _e_main_shutdown_push(e_test_helper_shutdown);
290 TS("[DEFERRED] E_Test_Helper Done");
292 TS("[DEFERRED] E_INFO_SERVER Init");
293 e_info_server_init();
294 _e_main_shutdown_push(e_info_server_shutdown);
295 TS("[DEFERRED] E_INFO_SERVER Done");
297 /* try to do deferred job of any subsystems*/
298 TS("[DEFERRED] Compositor's deferred job");
299 e_comp_deferred_job();
300 TS("[DEFERRED] Compositor's deferred job Done");
302 TS("[DEFERRED] E_Module's deferred job");
303 e_module_deferred_job();
304 TS("[DEFERRED] E_Module's deferred job Done");
306 return ECORE_CALLBACK_DONE;
310 _e_main_deferred_job_schedule(void *d EINA_UNUSED, int type EINA_UNUSED, void *ev EINA_UNUSED)
312 ecore_idler_add(_e_main_subsystem_defer, NULL);
313 return ECORE_CALLBACK_DONE;
318 /* externally accessible functions */
320 main(int argc, char **argv)
322 Eina_Bool safe_mode = EINA_FALSE;
323 Eina_Bool after_restart = EINA_FALSE;
324 double t = 0.0, tstart = 0.0;
325 char *s = NULL, buff[32];
326 struct sigaction action;
329 # ifdef PR_SET_PTRACER
330 # ifdef PR_SET_PTRACER_ANY
331 prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY);
337 t0 = t1 = t2 = ecore_time_unix_get();
341 /* trap deadly bug signals and allow some form of sane recovery */
342 /* or ability to gdb attach and debug at this point - better than your */
343 /* wm/desktop vanishing and not knowing what happened */
344 if (!getenv("NOTIFY_SOCKET"))
347 action.sa_sigaction = e_sigseg_act;
348 action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
349 sigemptyset(&action.sa_mask);
350 sigaction(SIGSEGV, &action, NULL);
352 action.sa_sigaction = e_sigill_act;
353 action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
354 sigemptyset(&action.sa_mask);
355 sigaction(SIGILL, &action, NULL);
357 action.sa_sigaction = e_sigfpe_act;
358 action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
359 sigemptyset(&action.sa_mask);
360 sigaction(SIGFPE, &action, NULL);
362 #ifndef HAVE_WAYLAND_ONLY
363 action.sa_sigaction = e_sigbus_act;
364 action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
365 sigemptyset(&action.sa_mask);
366 sigaction(SIGBUS, &action, NULL);
369 action.sa_sigaction = e_sigabrt_act;
370 action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
371 sigemptyset(&action.sa_mask);
372 sigaction(SIGABRT, &action, NULL);
373 TS("Signal Trap Done");
376 t = ecore_time_unix_get();
377 s = getenv("E_START_TIME");
378 if ((s) && (!getenv("E_RESTART_OK")))
381 if ((t - tstart) < 5.0) safe_mode = EINA_TRUE;
384 snprintf(buff, sizeof(buff), "%1.1f", tstart);
385 e_util_env_set("E_START_TIME", buff);
387 if (getenv("E_START_MTRACK"))
388 e_util_env_set("MTRACK", NULL);
392 e_error_message_show(_("Enlightenment cannot initialize Eina!\n"));
393 _e_main_shutdown(-1);
395 _e_main_shutdown_push(eina_shutdown);
396 #ifdef OBJECT_HASH_CHECK
397 e_object_hash_init();
401 e_error_message_show(_("Enlightenment could not create a logging domain!\n"));
402 _e_main_shutdown(-1);
408 t1 = ecore_time_unix_get(); \
409 printf("ESTART: %1.5f [%1.5f] - %s\n", t1 - t0, t1 - t2, x); \
413 TS("Eina Init Done");
414 _e_main_shutdown_push(e_log_shutdown);
416 TS("Determine Prefix");
417 if (!e_prefix_determine(argv[0]))
420 "ERROR: Enlightenment cannot determine it's installed\n"
421 " prefix from the system or argv[0].\n"
422 " This is because it is not on Linux AND has been\n"
423 " executed strangely. This is unusual.\n");
425 TS("Determine Prefix Done");
427 /* for debugging by redirecting stdout of e to a log file to tail */
428 setvbuf(stdout, NULL, _IONBF, 0);
430 TS("Environment Variables");
431 if (getenv("E_RESTART")) after_restart = EINA_TRUE;
432 if (getenv("DESKTOP_STARTUP_ID"))
433 e_util_env_set("DESKTOP_STARTUP_ID", NULL);
434 e_util_env_set("E_RESTART_OK", NULL);
435 e_util_env_set("PANTS", "ON");
436 e_util_env_set("DESKTOP", "Enlightenment");
437 TS("Environment Variables Done");
439 TS("Parse Arguments");
440 _e_main_parse_arguments(argc, argv);
441 TS("Parse Arguments Done");
443 /*** Initialize Core EFL Libraries We Need ***/
448 e_error_message_show(_("Enlightenment cannot initialize Eet!\n"));
449 _e_main_shutdown(-1);
452 _e_main_shutdown_push(eet_shutdown);
454 #ifdef ENABLE_QUICK_INIT
455 /* Allow ecore to not load system modules.
456 * Without it ecore_init will block until dbus authentication
457 * and registration are complete.
459 ecore_app_no_system_modules();
465 e_error_message_show(_("Enlightenment cannot initialize Ecore!\n"));
466 _e_main_shutdown(-1);
468 TS("Ecore Init Done");
469 _e_main_shutdown_push(ecore_shutdown);
471 e_first_frame = getenv("E_FIRST_FRAME");
472 if (e_first_frame && e_first_frame[0])
473 e_first_frame_start_time = ecore_time_get();
475 e_first_frame = NULL;
480 e_error_message_show(_("Enlightenment cannot initialize EIO!\n"));
481 _e_main_shutdown(-1);
484 _e_main_shutdown_push(eio_shutdown);
486 ecore_app_args_set(argc, (const char **)argv);
488 TS("Ecore Event Handlers");
489 if (!ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT,
490 _e_main_cb_signal_exit, NULL))
492 e_error_message_show(_("Enlightenment cannot set up an exit signal handler.\n"
493 "Perhaps you are out of memory?"));
494 _e_main_shutdown(-1);
496 if (!ecore_event_handler_add(ECORE_EVENT_SIGNAL_HUP,
497 _e_main_cb_signal_hup, NULL))
499 e_error_message_show(_("Enlightenment cannot set up a HUP signal handler.\n"
500 "Perhaps you are out of memory?"));
501 _e_main_shutdown(-1);
503 if (!ecore_event_handler_add(ECORE_EVENT_SIGNAL_USER,
504 _e_main_cb_signal_user, NULL))
506 e_error_message_show(_("Enlightenment cannot set up a USER signal handler.\n"
507 "Perhaps you are out of memory?"));
508 _e_main_shutdown(-1);
510 TS("Ecore Event Handlers Done");
512 TS("Ecore_File Init");
513 if (!ecore_file_init())
515 e_error_message_show(_("Enlightenment cannot initialize Ecore_File!\n"));
516 _e_main_shutdown(-1);
518 TS("Ecore_File Init Done");
519 _e_main_shutdown_push(ecore_file_shutdown);
521 #ifndef ENABLE_QUICK_INIT
522 Eina_Bool nostartup = EINA_FALSE;
523 Eina_Bool waslocked = EINA_FALSE;
525 TS("Ecore_Con Init");
526 if (!ecore_con_init())
528 e_error_message_show(_("Enlightenment cannot initialize Ecore_Con!\n"));
529 _e_main_shutdown(-1);
531 TS("Ecore_Con Init Done");
532 _e_main_shutdown_push(ecore_con_shutdown);
534 TS("Ecore_Ipc Init");
535 if (!ecore_ipc_init())
537 e_error_message_show(_("Enlightenment cannot initialize Ecore_Ipc!\n"));
538 _e_main_shutdown(-1);
540 TS("Ecore_Ipc Init Done");
541 _e_main_shutdown_push(ecore_ipc_shutdown);
543 _idle_before = ecore_idle_enterer_before_add(_e_main_cb_idle_before, NULL);
545 _xdg_data_dirs_augment();
547 TS("Ecore_Evas Init");
548 if (!ecore_evas_init())
550 e_error_message_show(_("Enlightenment cannot initialize Ecore_Evas!\n"));
551 _e_main_shutdown(-1);
553 TS("Ecore_Evas Init Done");
554 // _e_main_shutdown_push(ecore_evas_shutdown);
556 TS("Elementary Init");
557 if (!elm_init(argc, argv))
559 e_error_message_show(_("Enlightenment cannot initialize Elementary!\n"));
560 _e_main_shutdown(-1);
562 if (!eina_streq(elm_theme_get(NULL), "default"))
563 elm_theme_extension_add(NULL, "default");
564 TS("Elementary Init Done");
565 //_e_main_shutdown_push(elm_shutdown);
570 e_error_message_show(_("Enlightenment cannot initialize Emotion!\n"));
571 _e_main_shutdown(-1);
573 TS("Emotion Init Done");
574 _e_main_shutdown_push((void *)emotion_shutdown);
576 /* e doesn't sync to compositor - it should be one */
577 ecore_evas_app_comp_sync_set(0);
579 TS("Ecore_Evas Engine Check");
580 #ifdef HAVE_WAYLAND_ONLY
581 if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_WAYLAND_SHM))
583 e_error_message_show(_("Enlightenment found ecore_evas doesn't support the Wayland SHM\n"
584 "rendering in Evas. Please check your installation of Evas and\n"
585 "Ecore and check they support the Wayland SHM rendering engine."));
586 _e_main_shutdown(-1);
589 if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_XCB))
591 if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_XLIB))
593 e_error_message_show(_("Enlightenment found ecore_evas doesn't support the Software X11\n"
594 "rendering in Evas. Please check your installation of Evas and\n"
595 "Ecore and check they support the Software X11 rendering engine."));
596 _e_main_shutdown(-1);
600 if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_BUFFER))
602 e_error_message_show(_("Enlightenment found ecore_evas doesn't support the Software Buffer\n"
603 "rendering in Evas. Please check your installation of Evas and\n"
604 "Ecore and check they support the Software Buffer rendering engine."));
605 _e_main_shutdown(-1);
607 TS("Ecore_Evas Engine Check Done");
612 e_error_message_show(_("Enlightenment cannot initialize Edje!\n"));
613 _e_main_shutdown(-1);
615 TS("Edje Init Done");
616 _e_main_shutdown_push(edje_shutdown);
619 /*** Initialize E Subsystems We Need ***/
624 e_error_message_show(_("Enlightenment cannot initialize E_Intl!\n"));
625 _e_main_shutdown(-1);
627 TS("E Intl Init Done");
628 _e_main_shutdown_push(e_intl_shutdown);
630 #ifndef HAVE_WAYLAND_ONLY
631 /* init white box of death alert */
635 e_error_message_show(_("Enlightenment cannot initialize its emergency alert system.\n"
636 "Have you set your DISPLAY variable?"));
637 _e_main_shutdown(-1);
639 TS("E_Alert Init Done");
640 _e_main_shutdown_push(e_alert_shutdown);
644 //#ifdef HAVE_WAYLAND
645 /* init uuid store for window/surface properties */
646 TS("E_UUID_Store Init");
647 if (!e_uuid_store_init())
649 e_error_message_show(_("Enlightenment cannot initialize its UUID store.\n"));
650 _e_main_shutdown(-1);
652 TS("E_UUID_Store Init Done");
653 _e_main_shutdown_push(e_uuid_store_shutdown);
656 TS("E Directories Init");
657 /* setup directories we will be using for configurations storage etc. */
658 if (!_e_main_dirs_init())
660 e_error_message_show(_("Enlightenment cannot create directories in your home directory.\n"
661 "Perhaps you have no home directory or the disk is full?"));
662 _e_main_shutdown(-1);
664 TS("E Directories Init Done");
665 _e_main_shutdown_push(_e_main_dirs_shutdown);
667 TS("E_Filereg Init");
668 if (!e_filereg_init())
670 e_error_message_show(_("Enlightenment cannot set up its file registry system.\n"));
671 _e_main_shutdown(-1);
673 TS("E_Filereg Init Done");
674 _e_main_shutdown_push(e_filereg_shutdown);
677 if (!e_config_init())
679 e_error_message_show(_("Enlightenment cannot set up its config system.\n"));
680 _e_main_shutdown(-1);
682 TS("E_Config Init Done");
683 _e_main_shutdown_push(e_config_shutdown);
688 e_error_message_show(_("Enlightenment cannot set up its environment.\n"));
689 _e_main_shutdown(-1);
691 TS("E_Env Init Done");
692 _e_main_shutdown_push(e_env_shutdown);
694 efreet_desktop_environment_set(e_config->desktop_environment);
695 e_util_env_set("E_ICON_THEME", e_config->icon_theme);
696 ecore_exe_run_priority_set(e_config->priority);
697 locked |= e_config->desklock_start_locked;
699 s = getenv("E_DESKLOCK_LOCKED");
700 if ((s) && (!strcmp(s, "locked"))) waslocked = EINA_TRUE;
703 if (!_e_main_path_init())
705 e_error_message_show(_("Enlightenment cannot set up paths for finding files.\n"
706 "Perhaps you are out of memory?"));
707 _e_main_shutdown(-1);
709 TS("E Paths Init Done");
710 _e_main_shutdown_push(_e_main_path_shutdown);
713 if (!e_ipc_init()) _e_main_shutdown(-1);
714 TS("E_Ipc Init Done");
715 _e_main_shutdown_push(e_ipc_shutdown);
717 edje_frametime_set(1.0 / e_config->framerate);
722 e_error_message_show(_("Enlightenment cannot set up its font system.\n"));
723 _e_main_shutdown(-1);
725 TS("E_Font Init Done");
726 _e_main_shutdown_push(e_font_shutdown);
730 TS("E_Font Apply Done");
735 e_error_message_show(_("Enlightenment cannot set up its theme system.\n"));
736 _e_main_shutdown(-1);
738 TS("E_Theme Init Done");
739 _e_main_shutdown_push(e_theme_shutdown);
741 TS("E_Moveresize Init");
743 TS("E_Moveresize Init Done");
744 _e_main_shutdown_push(e_moveresize_shutdown);
746 if (e_config->show_splash)
747 e_init_status_set(_("Setup Message Bus"));
750 _e_main_shutdown_push(e_msgbus_shutdown);
751 TS("E_Msgbus Init Done");
756 e_error_message_show(_("Enlightenment cannot initialize the FDO desktop system.\n"
757 "Perhaps you lack permissions on ~/.cache/efreet or are\n"
758 "out of memory or disk space?"));
759 _e_main_shutdown(-1);
761 TS("Efreet Init Done");
762 _e_main_shutdown_push(efreet_shutdown);
764 if (e_config->show_splash)
765 e_init_status_set(_("Starting International Support"));
766 TS("E_Intl Post Init");
767 if (!e_intl_post_init())
769 e_error_message_show(_("Enlightenment cannot set up its intl system.\n"));
770 _e_main_shutdown(-1);
772 TS("E_Intl Post Init Done");
773 _e_main_shutdown_push(e_intl_post_shutdown);
775 TS("E_Configure Init");
777 TS("E_Configure Init Done");
779 e_screensaver_preinit();
781 if (e_config->show_splash)
782 e_init_status_set(_("Setup Actions"));
783 TS("E_Actions Init");
784 if (!e_actions_init())
786 e_error_message_show(_("Enlightenment cannot set up its actions system.\n"));
787 _e_main_shutdown(-1);
789 TS("E_Actions Init Done");
790 _e_main_shutdown_push(e_actions_shutdown);
792 /* these just add event handlers and can't fail
793 * timestamping them is dumb.
799 if (e_config->show_splash)
800 e_init_status_set(_("Setup Powersave Modes"));
801 TS("E_Powersave Init");
802 if (!e_powersave_init())
804 e_error_message_show(_("Enlightenment cannot set up its powersave modes.\n"));
805 _e_main_shutdown(-1);
807 TS("E_Powersave Init Done");
808 _e_main_shutdown_push(e_powersave_shutdown);
810 if (e_config->show_splash)
811 e_init_status_set(_("Setup Screensaver"));
812 TS("E_Screensaver Init");
813 if (!e_screensaver_init())
815 e_error_message_show(_("Enlightenment cannot configure the X screensaver.\n"));
816 _e_main_shutdown(-1);
818 TS("E_Screensaver Init Done");
819 _e_main_shutdown_push(e_screensaver_shutdown);
821 if (e_config->show_splash)
822 e_init_status_set(_("Setup Screens"));
824 if (!_e_main_screens_init())
826 e_error_message_show(_("Enlightenment set up window management for all the screens on your system\n"
827 "failed. Perhaps another window manager is running?\n"));
828 _e_main_shutdown(-1);
830 TS("Screens Init Done");
831 _e_main_shutdown_push(_e_main_screens_shutdown);
833 TS("E_Pointer Init");
834 if (!e_pointer_init())
836 e_error_message_show(_("Enlightenment cannot set up its pointer system.\n"));
837 _e_main_shutdown(-1);
839 TS("E_Pointer Init Done");
840 _e_main_shutdown_push(e_pointer_shutdown);
846 e_error_message_show(_("Enlightenment cannot set up its scale system.\n"));
847 _e_main_shutdown(-1);
849 TS("E_Scale Init Done");
850 _e_main_shutdown_push(e_scale_shutdown);
852 if (e_config->show_splash)
857 e_error_message_show(_("Enlightenment cannot set up its init screen.\n"));
858 _e_main_shutdown(-1);
860 TS("E_Splash Init Done");
861 _e_main_shutdown_push(e_init_shutdown);
863 if (!((!e_config->show_splash) || (after_restart)))
868 #ifndef DISABLE_FORMAT_TEST
869 TS("Test File Format Support");
870 _e_main_test_formats();
871 TS("Test File Format Support Done");
876 efreet_icon_extension_add(".svg");
877 efreet_icon_extension_add(".jpg");
878 efreet_icon_extension_add(".png");
879 efreet_icon_extension_add(".edj");
882 if (e_config->show_splash)
883 e_init_status_set(_("Setup ACPI"));
886 TS("E_Acpi Init Done");
887 _e_main_shutdown_push(e_acpi_shutdown);
889 if (e_config->show_splash)
890 e_init_status_set(_("Setup Backlight"));
891 TS("E_Backlight Init");
892 if (!e_backlight_init())
894 e_error_message_show(_("Enlightenment cannot configure the backlight.\n"));
895 _e_main_shutdown(-1);
897 TS("E_Backlight Init Done");
899 if (e_config->show_splash)
900 e_init_status_set(_("Setup DPMS"));
904 e_error_message_show(_("Enlightenment cannot configure the DPMS settings.\n"));
905 _e_main_shutdown(-1);
907 TS("E_Dpms Init Done");
908 _e_main_shutdown_push(e_dpms_shutdown);
910 if (e_config->show_splash)
911 e_init_status_set(_("Setup Desklock"));
912 TS("E_Desklock Init");
913 if (!e_desklock_init())
915 e_error_message_show(_("Enlightenment cannot set up its desk locking system.\n"));
916 _e_main_shutdown(-1);
918 TS("E_Desklock Init Done");
919 _e_main_shutdown_push(e_desklock_shutdown);
921 if (waslocked || (locked && ((!after_restart) || (!getenv("E_DESKLOCK_UNLOCKED")))))
922 e_desklock_show(EINA_TRUE);
924 if (e_config->show_splash)
925 e_init_status_set(_("Setup Paths"));
927 _e_main_efreet_paths_init();
928 TS("Efreet Paths Done");
930 if (e_config->show_splash)
931 e_init_status_set(_("Setup System Controls"));
935 e_error_message_show(_("Enlightenment cannot initialize the System Command system.\n"));
936 _e_main_shutdown(-1);
938 TS("E_Sys Init Done");
939 _e_main_shutdown_push(e_sys_shutdown);
941 if (e_config->show_splash)
942 e_init_status_set(_("Setup Execution System"));
946 e_error_message_show(_("Enlightenment cannot set up its exec system.\n"));
947 _e_main_shutdown(-1);
949 TS("E_Exec Init Done");
953 TS("E_Comp Freeze Done");
955 if (e_config->show_splash)
956 e_init_status_set(_("Setup Filemanager"));
960 e_error_message_show(_("Enlightenment cannot initialize the File manager.\n"));
961 _e_main_shutdown(-1);
963 TS("E_Fm2 Init Done");
964 _e_main_shutdown_push(e_fm2_shutdown);
966 if (e_config->show_splash)
967 e_init_status_set(_("Setup Message System"));
971 e_error_message_show(_("Enlightenment cannot set up its msg system.\n"));
972 _e_main_shutdown(-1);
974 TS("E_Msg Init Done");
975 _e_main_shutdown_push(e_msg_shutdown);
977 if (e_config->show_splash)
978 e_init_status_set(_("Setup Grab Input Handling"));
979 TS("E_Grabinput Init");
980 if (!e_grabinput_init())
982 e_error_message_show(_("Enlightenment cannot set up its grab input handling system.\n"));
983 _e_main_shutdown(-1);
985 TS("E_Grabinput Init Done");
986 _e_main_shutdown_push(e_grabinput_shutdown);
988 if (e_config->show_splash)
989 e_init_status_set(_("Setup Modules"));
991 if (!e_module_init())
993 e_error_message_show(_("Enlightenment cannot set up its module system.\n"));
994 _e_main_shutdown(-1);
996 TS("E_Module Init Done");
997 _e_main_shutdown_push(e_module_shutdown);
999 if (e_config->show_splash)
1000 e_init_status_set(_("Setup Remembers"));
1001 TS("E_Remember Init");
1002 if (!e_remember_init(after_restart ? E_STARTUP_RESTART : E_STARTUP_START))
1004 e_error_message_show(_("Enlightenment cannot setup remember settings.\n"));
1005 _e_main_shutdown(-1);
1007 TS("E_Remember Init Done");
1008 _e_main_shutdown_push(e_remember_shutdown);
1010 if (e_config->show_splash)
1011 e_init_status_set(_("Setup Gadcon"));
1012 TS("E_Gadcon Init");
1013 if (!e_gadcon_init())
1015 e_error_message_show(_("Enlightenment cannot set up its gadget control system.\n"));
1016 _e_main_shutdown(-1);
1018 TS("E_Gadcon Init Done");
1019 _e_main_shutdown_push(e_gadcon_shutdown);
1021 if (e_config->show_splash)
1022 e_init_status_set(_("Setup Toolbars"));
1023 TS("E_Toolbar Init");
1024 if (!e_toolbar_init())
1026 e_error_message_show(_("Enlightenment cannot set up its toolbars.\n"));
1027 _e_main_shutdown(-1);
1029 TS("E_Toolbar Init Done");
1030 _e_main_shutdown_push(e_toolbar_shutdown);
1032 if (e_config->show_splash)
1033 e_init_status_set(_("Setup Wallpaper"));
1037 e_error_message_show(_("Enlightenment cannot set up its desktop background system.\n"));
1038 _e_main_shutdown(-1);
1040 TS("E_Bg Init Done");
1041 _e_main_shutdown_push(e_bg_shutdown);
1043 if (e_config->show_splash)
1044 e_init_status_set(_("Setup Mouse"));
1046 if (!e_mouse_update())
1048 e_error_message_show(_("Enlightenment cannot configure the mouse settings.\n"));
1049 _e_main_shutdown(-1);
1051 TS("E_Mouse Init Done");
1053 if (e_config->show_splash)
1054 e_init_status_set(_("Setup Bindings"));
1055 TS("E_Bindings Init");
1056 if (!e_bindings_init())
1058 e_error_message_show(_("Enlightenment cannot set up its bindings system.\n"));
1059 _e_main_shutdown(-1);
1061 TS("E_Bindings Init Done");
1062 _e_main_shutdown_push(e_bindings_shutdown);
1064 if (e_config->show_splash)
1065 e_init_status_set(_("Setup Thumbnailer"));
1067 if (!e_thumb_init())
1069 e_error_message_show(_("Enlightenment cannot initialize the Thumbnailing system.\n"));
1070 _e_main_shutdown(-1);
1072 TS("E_Thumb Init Done");
1073 _e_main_shutdown_push(e_thumb_shutdown);
1078 e_error_message_show(_("Enlightenment cannot initialize the Icon Cache system.\n"));
1079 _e_main_shutdown(-1);
1081 TS("E_Icon Init Done");
1082 _e_main_shutdown_push(e_icon_shutdown);
1084 TS("E_Update Init");
1085 if (!e_update_init())
1087 e_error_message_show(_("Enlightenment cannot initialize the Update system.\n"));
1088 _e_main_shutdown(-1);
1090 TS("E_Update Init Done");
1091 _e_main_shutdown_push(e_update_shutdown);
1093 if (e_config->show_splash)
1094 e_init_status_set(_("Setup Desktop Environment"));
1095 TS("E_Deskenv Init");
1096 if (!e_deskenv_init())
1098 e_error_message_show(_("Enlightenment cannot initialize its desktop environment.\n"));
1099 _e_main_shutdown(-1);
1101 TS("E_Deskenv Init Done");
1102 _e_main_shutdown_push(e_deskenv_shutdown);
1104 if (e_config->show_splash)
1105 e_init_status_set(_("Setup File Ordering"));
1107 if (!e_order_init())
1109 e_error_message_show(_("Enlightenment cannot set up its order file system.\n"));
1110 _e_main_shutdown(-1);
1112 TS("E_Order Init Done");
1113 _e_main_shutdown_push(e_order_shutdown);
1116 TS("E_Manager Keys Grab");
1117 e_managers_keys_grab();
1118 TS("E_Manager Keys Grab Done");
1120 TS("E_Comp_Canvas Keys Grab");
1121 e_comp_canvas_keys_grab();
1122 TS("E_Comp_Canvas Keys Grab Done");
1125 if (e_config->show_splash)
1126 e_init_status_set(_("Load Modules"));
1128 _e_main_modules_load(safe_mode);
1129 TS("Load Modules Done");
1131 TS("Run Startup Apps");
1135 e_startup(E_STARTUP_RESTART);
1137 e_startup(E_STARTUP_START);
1139 TS("Run Startup Apps Done");
1141 if (e_config->show_splash && (!after_restart))
1142 ecore_timer_add(2.0, _e_main_cb_startup_fake_end, NULL);
1146 TS("E_Comp Thaw Done");
1152 TS("E_Test_Helper Init");
1153 e_test_helper_init();
1154 _e_main_shutdown_push(e_test_helper_shutdown);
1155 TS("E_Test_Helper Done");
1157 TS("E_Info_Server Init");
1158 e_info_server_init();
1159 _e_main_shutdown_push(e_info_server_shutdown);
1160 TS("E_Info_Server Done");
1162 if (e_config->show_splash)
1163 e_init_status_set(_("Setup Shelves"));
1165 if (!e_shelf_init())
1167 e_error_message_show(_("Enlightenment cannot set up its module system.\n"));
1168 _e_main_shutdown(-1);
1170 TS("E_Shelf Init Done");
1172 ecore_idle_enterer_before_add(_e_main_shelf_init_job, NULL);
1174 _idle_before = ecore_idle_enterer_before_add(_e_main_cb_idle_before, NULL);
1176 _xdg_data_dirs_augment();
1178 TS("Ecore_Evas Init");
1179 if (!ecore_evas_init())
1181 e_error_message_show(_("Enlightenment cannot initialize Ecore_Evas!\n"));
1182 _e_main_shutdown(-1);
1184 TS("Ecore_Evas Init Done");
1186 /* e doesn't sync to compositor - it should be one */
1187 ecore_evas_app_comp_sync_set(0);
1189 TS("Ecore_Evas Engine Check");
1190 #ifdef HAVE_WAYLAND_ONLY
1191 if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_WAYLAND_SHM))
1193 e_error_message_show(_("Enlightenment found ecore_evas doesn't support the Wayland SHM\n"
1194 "rendering in Evas. Please check your installation of Evas and\n"
1195 "Ecore and check they support the Wayland SHM rendering engine."));
1196 _e_main_shutdown(-1);
1199 if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_XCB))
1201 if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_XLIB))
1203 e_error_message_show(_("Enlightenment found ecore_evas doesn't support the Software X11\n"
1204 "rendering in Evas. Please check your installation of Evas and\n"
1205 "Ecore and check they support the Software X11 rendering engine."));
1206 _e_main_shutdown(-1);
1210 if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_BUFFER))
1212 e_error_message_show(_("Enlightenment found ecore_evas doesn't support the Software Buffer\n"
1213 "rendering in Evas. Please check your installation of Evas and\n"
1214 "Ecore and check they support the Software Buffer rendering engine."));
1215 _e_main_shutdown(-1);
1217 TS("Ecore_Evas Engine Check Done");
1219 /*** Initialize E Subsystems We Need ***/
1221 TS("E Directories Init");
1222 /* setup directories we will be using for configurations storage etc. */
1223 if (!_e_main_dirs_init())
1225 e_error_message_show(_("Enlightenment cannot create directories in your home directory.\n"
1226 "Perhaps you have no home directory or the disk is full?"));
1227 _e_main_shutdown(-1);
1229 TS("E Directories Init Done");
1230 _e_main_shutdown_push(_e_main_dirs_shutdown);
1232 TS("E_Config Init");
1233 if (!e_config_init())
1235 e_error_message_show(_("Enlightenment cannot set up its config system.\n"));
1236 _e_main_shutdown(-1);
1238 TS("E_Config Init Done");
1239 _e_main_shutdown_push(e_config_shutdown);
1244 e_error_message_show(_("Enlightenment cannot set up its environment.\n"));
1245 _e_main_shutdown(-1);
1247 TS("E_Env Init Done");
1248 _e_main_shutdown_push(e_env_shutdown);
1250 efreet_desktop_environment_set(e_config->desktop_environment);
1251 e_util_env_set("E_ICON_THEME", e_config->icon_theme);
1252 ecore_exe_run_priority_set(e_config->priority);
1253 locked |= e_config->desklock_start_locked;
1256 if (!_e_main_path_init())
1258 e_error_message_show(_("Enlightenment cannot set up paths for finding files.\n"
1259 "Perhaps you are out of memory?"));
1260 _e_main_shutdown(-1);
1262 TS("E Paths Init Done");
1263 _e_main_shutdown_push(_e_main_path_shutdown);
1265 ecore_animator_frametime_set(1.0 / e_config->framerate);
1270 e_error_message_show(_("Enlightenment cannot set up its font system.\n"));
1271 _e_main_shutdown(-1);
1273 TS("E_Font Init Done");
1274 _e_main_shutdown_push(e_font_shutdown);
1278 TS("E_Font Apply Done");
1281 if (!e_theme_init())
1283 e_error_message_show(_("Enlightenment cannot set up its theme system.\n"));
1284 _e_main_shutdown(-1);
1286 TS("E_Theme Init Done");
1287 _e_main_shutdown_push(e_theme_shutdown);
1289 TS("E_Moveresize Init");
1290 e_moveresize_init();
1291 TS("E_Moveresize Init Done");
1292 _e_main_shutdown_push(e_moveresize_shutdown);
1294 e_screensaver_preinit();
1296 if (e_config->show_splash)
1297 e_init_status_set(_("Setup Actions"));
1298 TS("E_Actions Init");
1299 if (!e_actions_init())
1301 e_error_message_show(_("Enlightenment cannot set up its actions system.\n"));
1302 _e_main_shutdown(-1);
1304 TS("E_Actions Init Done");
1305 _e_main_shutdown_push(e_actions_shutdown);
1307 /* these just add event handlers and can't fail
1308 * timestamping them is dumb.
1314 if (e_config->show_splash)
1315 e_init_status_set(_("Setup Powersave Modes"));
1316 TS("E_Powersave Init");
1317 if (!e_powersave_init())
1319 e_error_message_show(_("Enlightenment cannot set up its powersave modes.\n"));
1320 _e_main_shutdown(-1);
1322 TS("E_Powersave Init Done");
1323 _e_main_shutdown_push(e_powersave_shutdown);
1325 if (e_config->show_splash)
1326 e_init_status_set(_("Setup Screensaver"));
1327 TS("E_Screensaver Init");
1328 if (!e_screensaver_init())
1330 e_error_message_show(_("Enlightenment cannot configure the X screensaver.\n"));
1331 _e_main_shutdown(-1);
1333 TS("E_Screensaver Init Done");
1334 _e_main_shutdown_push(e_screensaver_shutdown);
1336 if (e_config->show_splash)
1337 e_init_status_set(_("Setup Screens"));
1339 if (!_e_main_screens_init())
1341 e_error_message_show(_("Enlightenment set up window management for all the screens on your system\n"
1342 "failed. Perhaps another window manager is running?\n"));
1343 _e_main_shutdown(-1);
1345 TS("Screens Init Done");
1346 _e_main_shutdown_push(_e_main_screens_shutdown);
1347 e_screensaver_force_update();
1349 if (e_config->show_splash)
1350 e_init_status_set(_("Setup System Controls"));
1354 e_error_message_show(_("Enlightenment cannot initialize the System Command system.\n"));
1355 _e_main_shutdown(-1);
1357 TS("E_Sys Init Done");
1358 _e_main_shutdown_push(e_sys_shutdown);
1360 TS("E_Comp Freeze");
1361 e_comp_all_freeze();
1362 TS("E_Comp Freeze Done");
1364 if (e_config->show_splash)
1365 e_init_status_set(_("Setup Grab Input Handling"));
1366 TS("E_Grabinput Init");
1367 if (!e_grabinput_init())
1369 e_error_message_show(_("Enlightenment cannot set up its grab input handling system.\n"));
1370 _e_main_shutdown(-1);
1372 TS("E_Grabinput Init Done");
1373 _e_main_shutdown_push(e_grabinput_shutdown);
1375 ecore_event_handler_add(E_EVENT_MODULE_INIT_END, _e_main_deferred_job_schedule, NULL);
1377 if (e_config->show_splash)
1378 e_init_status_set(_("Setup Modules"));
1379 TS("E_Module Init");
1380 if (!e_module_init())
1382 e_error_message_show(_("Enlightenment cannot set up its module system.\n"));
1383 _e_main_shutdown(-1);
1385 TS("E_Module Init Done");
1386 _e_main_shutdown_push(e_module_shutdown);
1388 if (e_config->show_splash)
1389 e_init_status_set(_("Setup Remembers"));
1390 TS("E_Remember Init");
1391 if (!e_remember_init(after_restart ? E_STARTUP_RESTART : E_STARTUP_START))
1393 e_error_message_show(_("Enlightenment cannot setup remember settings.\n"));
1394 _e_main_shutdown(-1);
1396 TS("E_Remember Init Done");
1397 _e_main_shutdown_push(e_remember_shutdown);
1399 if (e_config->show_splash)
1400 e_init_status_set(_("Setup Mouse"));
1402 if (!e_mouse_update())
1404 e_error_message_show(_("Enlightenment cannot configure the mouse settings.\n"));
1405 _e_main_shutdown(-1);
1407 TS("E_Mouse Init Done");
1409 if (e_config->show_splash)
1410 e_init_status_set(_("Setup Bindings"));
1411 TS("E_Bindings Init");
1412 if (!e_bindings_init())
1414 e_error_message_show(_("Enlightenment cannot set up its bindings system.\n"));
1415 _e_main_shutdown(-1);
1417 TS("E_Bindings Init Done");
1418 _e_main_shutdown_push(e_bindings_shutdown);
1423 e_error_message_show(_("Enlightenment cannot initialize the Icon Cache system.\n"));
1424 _e_main_shutdown(-1);
1426 TS("E_Icon Init Done");
1427 _e_main_shutdown_push(e_icon_shutdown);
1429 TS("E_Manager Keys Grab");
1430 e_managers_keys_grab();
1431 TS("E_Manager Keys Grab Done");
1433 if (e_config->show_splash)
1434 e_init_status_set(_("Load Modules"));
1436 _e_main_modules_load(safe_mode);
1437 TS("Load Modules Done");
1439 if (e_config->show_splash && (!after_restart))
1440 ecore_timer_add(2.0, _e_main_cb_startup_fake_end, NULL);
1444 TS("E_Comp Thaw Done");
1447 _idle_after = ecore_idle_enterer_add(_e_main_cb_idle_after, NULL);
1449 if (e_config->show_splash)
1450 e_init_status_set(_("Almost Done"));
1452 starting = EINA_FALSE;
1455 e_util_env_set("E_RESTART", "1");
1457 TS("MAIN LOOP AT LAST");
1458 if (!setjmp(x_fatal_buff))
1459 ecore_main_loop_begin();
1461 CRI("FATAL: X Died. Connection gone. Abbreviated Shutdown\n");
1463 inloop = EINA_FALSE;
1464 stopping = EINA_TRUE;
1466 //if (!x_fatal) e_canvas_idle_flush();
1468 e_config_save_flush();
1469 _e_main_desk_save();
1470 e_remember_internal_save();
1471 e_comp_internal_save();
1473 _e_main_shutdown(0);
1477 e_util_env_set("E_RESTART_OK", "1");
1478 if (getenv("E_START_MTRACK"))
1479 e_util_env_set("MTRACK", "track");
1480 ecore_app_restart();
1483 e_prefix_shutdown();
1489 e_main_ts(const char *str)
1492 t1 = ecore_time_unix_get();
1493 printf("ESTART: %1.5f [%1.5f] - %s\n", t1 - t0, t1 - t2, str);
1499 /* local functions */
1501 _e_main_shutdown(int errcode)
1507 printf("E: Begin Shutdown Procedure!\n");
1509 if (_idle_before) ecore_idle_enterer_del(_idle_before);
1510 _idle_before = NULL;
1511 if (_idle_after) ecore_idle_enterer_del(_idle_after);
1514 dir = getenv("XDG_RUNTIME_DIR");
1517 char buf_env[PATH_MAX];
1518 snprintf(buf_env, sizeof(buf_env), "%s", dir);
1519 snprintf(buf, sizeof(buf), "%s/.e-deleteme", buf_env);
1520 if (ecore_file_exists(buf)) ecore_file_recursive_rm(buf_env);
1522 for (i = (_e_main_lvl - 1); i >= 0; i--)
1523 (*_e_main_shutdown_func[i])();
1524 #ifdef OBJECT_HASH_CHECK
1525 e_object_hash_shutdown();
1527 if (errcode < 0) exit(errcode);
1531 _e_main_shutdown_push(int (*func)(void))
1534 if (_e_main_lvl > MAX_LEVEL)
1537 e_error_message_show("WARNING: too many init levels. MAX = %i\n",
1541 _e_main_shutdown_func[_e_main_lvl - 1] = func;
1545 _e_main_parse_arguments(int argc, char **argv)
1550 /* handle some command-line parameters */
1551 for (i = 1; i < argc; i++)
1553 if ((!strcmp(argv[i], "-display")) && (i < (argc - 1)))
1556 e_util_env_set("DISPLAY", argv[i]);
1558 else if ((!strcmp(argv[i], "-fake-xinerama-screen")) && (i < (argc - 1)))
1563 if (sscanf(argv[i], "%ix%i+%i+%i", &w, &h, &x, &y) == 4)
1564 e_xinerama_fake_screen_add(x, y, w, h);
1566 else if (!strcmp(argv[i], "-good"))
1570 printf("LA LA LA\n");
1572 else if (!strcmp(argv[i], "-evil"))
1576 printf("MUHAHAHAHHAHAHAHAHA\n");
1578 else if (!strcmp(argv[i], "-psychotic"))
1582 printf("MUHAHALALALALALALALA\n");
1584 else if ((!strcmp(argv[i], "-profile")) && (i < (argc - 1)))
1587 if (!getenv("E_CONF_PROFILE"))
1588 e_util_env_set("E_CONF_PROFILE", argv[i]);
1590 else if (!strcmp(argv[i], "-i-really-know-what-i-am-doing-and-accept-full-responsibility-for-it"))
1591 really_know = EINA_TRUE;
1592 else if (!strcmp(argv[i], "-locked"))
1594 else if (!strcmp(argv[i], "-nopause"))
1595 e_nopause = EINA_TRUE;
1596 else if ((!strcmp(argv[i], "-version")) ||
1597 (!strcmp(argv[i], "--version")))
1599 printf(_("Version: %s\n"), PACKAGE_VERSION);
1600 _e_main_shutdown(-1);
1602 else if ((!strcmp(argv[i], "-h")) ||
1603 (!strcmp(argv[i], "-help")) ||
1604 (!strcmp(argv[i], "--help")))
1609 "\t-display DISPLAY\n"
1610 "\t\tConnect to display named DISPLAY.\n"
1611 "\t\tEG: -display :1.0\n"
1612 "\t-fake-xinerama-screen WxH+X+Y\n"
1613 "\t\tAdd a FAKE xinerama screen (instead of the real ones)\n"
1614 "\t\tgiven the geometry. Add as many as you like. They all\n"
1615 "\t\treplace the real xinerama screens, if any. This can\n"
1616 "\t\tbe used to simulate xinerama.\n"
1617 "\t\tEG: -fake-xinerama-screen 800x600+0+0 -fake-xinerama-screen 800x600+800+0\n"
1618 "\t-profile CONF_PROFILE\n"
1619 "\t\tUse the configuration profile CONF_PROFILE instead of the user selected default or just \"default\".\n"
1625 "\t\tBe psychotic.\n"
1627 "\t\tStart with desklock on, so password will be asked.\n"
1628 "\t-i-really-know-what-i-am-doing-and-accept-full-responsibility-for-it\n"
1629 "\t\tIf you need this help, you don't need this option.\n"
1633 _e_main_shutdown(-1);
1637 /* fix up DISPLAY to be :N.0 if no .screen is in it */
1638 s = getenv("DISPLAY");
1641 char *p, buff[4096];
1643 if (!(p = strrchr(s, ':')))
1645 snprintf(buff, sizeof(buff), "%s:0.0", s);
1646 e_util_env_set("DISPLAY", buff);
1650 if (!strrchr(p, '.'))
1652 snprintf(buff, sizeof(buff), "%s.0", s);
1653 e_util_env_set("DISPLAY", buff);
1658 /* we want to have been launched by enlightenment_start. there is a very */
1659 /* good reason we want to have been launched this way, thus check */
1660 if (!getenv("E_START"))
1662 e_error_message_show(_("You are executing enlightenment directly. This is\n"
1663 "bad. Please do not execute the \"enlightenment\"\n"
1664 "binary. Use the \"enlightenment_start\" launcher. It\n"
1665 "will handle setting up environment variables, paths,\n"
1666 "and launching any other required services etc.\n"
1667 "before enlightenment itself begins running.\n"));
1668 _e_main_shutdown(-1);
1673 _e_main_cb_x_fatal(void *data EINA_UNUSED)
1675 e_error_message_show("Lost X Connection.\n");
1676 ecore_main_loop_quit();
1679 x_fatal = EINA_TRUE;
1680 if (inloop) longjmp(x_fatal_buff, -99);
1685 _e_main_cb_signal_exit(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *ev EINA_UNUSED)
1687 /* called on ctrl-c, kill (pid) (also SIGINT, SIGTERM and SIGQIT) */
1688 e_sys_action_do(E_SYS_EXIT, NULL);
1689 return ECORE_CALLBACK_RENEW;
1693 _e_main_cb_signal_hup(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *ev EINA_UNUSED)
1695 e_sys_action_do(E_SYS_RESTART, NULL);
1696 return ECORE_CALLBACK_RENEW;
1700 _e_main_cb_signal_user(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *ev)
1702 Ecore_Event_Signal_User *e = ev;
1706 // E_Action *a = e_action_find("configuration");
1707 // if ((a) && (a->func.go)) a->func.go(NULL, NULL);
1709 else if (e->number == 2)
1711 // comp module has its own handler for this for enabling/disabling fps debug
1713 return ECORE_CALLBACK_RENEW;
1718 _e_main_dirs_init(void)
1721 const char *dirs[] =
1729 "applications/menu",
1730 "applications/menu/favorite",
1731 "applications/menu/all",
1733 "applications/bar/default",
1734 "applications/startup",
1735 "applications/restart",
1736 "applications/trash",
1737 "applications/desk-lock",
1738 "applications/desk-unlock",
1746 base = e_user_dir_get();
1747 if (ecore_file_mksubdirs(base, dirs) != sizeof(dirs) / sizeof(dirs[0]) - 1)
1749 e_error_message_show("Could not create one of the required "
1750 "subdirectories of '%s'\n", base);
1758 _e_main_dirs_shutdown(void)
1764 _e_main_path_init(void)
1768 /* setup data paths */
1769 path_data = e_path_new();
1772 e_error_message_show("Cannot allocate path for path_data\n");
1775 e_prefix_data_concat_static(buf, "data");
1776 e_path_default_path_append(path_data, buf);
1777 e_path_user_path_set(path_data, &(e_config->path_append_data));
1779 /* setup image paths */
1780 path_images = e_path_new();
1783 e_error_message_show("Cannot allocate path for path_images\n");
1786 e_user_dir_concat_static(buf, "/images");
1787 e_path_default_path_append(path_images, buf);
1788 e_prefix_data_concat_static(buf, "data/images");
1789 e_path_default_path_append(path_images, buf);
1790 e_path_user_path_set(path_images, &(e_config->path_append_images));
1792 /* setup font paths */
1793 path_fonts = e_path_new();
1796 e_error_message_show("Cannot allocate path for path_fonts\n");
1799 e_user_dir_concat_static(buf, "/fonts");
1800 e_path_default_path_append(path_fonts, buf);
1801 e_prefix_data_concat_static(buf, "data/fonts");
1802 e_path_default_path_append(path_fonts, buf);
1803 e_path_user_path_set(path_fonts, &(e_config->path_append_fonts));
1805 /* setup icon paths */
1806 path_icons = e_path_new();
1809 e_error_message_show("Cannot allocate path for path_icons\n");
1812 e_user_dir_concat_static(buf, "/icons");
1813 e_path_default_path_append(path_icons, buf);
1814 e_prefix_data_concat_static(buf, "data/icons");
1815 e_path_default_path_append(path_icons, buf);
1816 e_path_user_path_set(path_icons, &(e_config->path_append_icons));
1818 /* setup module paths */
1819 path_modules = e_path_new();
1822 e_error_message_show("Cannot allocate path for path_modules\n");
1825 e_user_dir_concat_static(buf, "/modules");
1826 e_path_default_path_append(path_modules, buf);
1827 snprintf(buf, sizeof(buf), "%s/enlightenment/modules", e_prefix_lib_get());
1828 e_path_default_path_append(path_modules, buf);
1829 /* FIXME: eventually this has to go - moduels should have installers that
1830 * add appropriate install paths (if not installed to user homedir) to
1831 * e's module search dirs
1833 snprintf(buf, sizeof(buf), "%s/enlightenment/modules_extra", e_prefix_lib_get());
1834 e_path_default_path_append(path_modules, buf);
1835 e_path_user_path_set(path_modules, &(e_config->path_append_modules));
1837 /* setup background paths */
1838 path_backgrounds = e_path_new();
1839 if (!path_backgrounds)
1841 e_error_message_show("Cannot allocate path for path_backgrounds\n");
1844 e_user_dir_concat_static(buf, "/backgrounds");
1845 e_path_default_path_append(path_backgrounds, buf);
1846 e_prefix_data_concat_static(buf, "data/backgrounds");
1847 e_path_default_path_append(path_backgrounds, buf);
1848 e_path_user_path_set(path_backgrounds, &(e_config->path_append_backgrounds));
1850 path_messages = e_path_new();
1853 e_error_message_show("Cannot allocate path for path_messages\n");
1856 e_user_dir_concat_static(buf, "/locale");
1857 e_path_default_path_append(path_messages, buf);
1858 e_path_default_path_append(path_messages, e_prefix_locale_get());
1859 e_path_user_path_set(path_messages, &(e_config->path_append_messages));
1865 _e_main_path_shutdown(void)
1869 e_object_del(E_OBJECT(path_data));
1874 e_object_del(E_OBJECT(path_images));
1879 e_object_del(E_OBJECT(path_fonts));
1884 e_object_del(E_OBJECT(path_icons));
1889 e_object_del(E_OBJECT(path_modules));
1890 path_modules = NULL;
1892 if (path_backgrounds)
1894 e_object_del(E_OBJECT(path_backgrounds));
1895 path_backgrounds = NULL;
1899 e_object_del(E_OBJECT(path_messages));
1900 path_messages = NULL;
1905 #ifndef DISABLE_FORMAT_TEST
1907 _e_main_test_formats(void)
1911 Evas_Object *im, *txt;
1913 char buff[PATH_MAX];
1915 if (e_config->show_splash)
1916 e_init_status_set(_("Testing Format Support"));
1918 if (!(ee = ecore_evas_buffer_new(1, 1)))
1920 e_error_message_show(_("Enlightenment found Evas can't create a buffer canvas. Please check\n"
1921 "Evas has Software Buffer engine support.\n"));
1922 _e_main_shutdown(-1);
1924 evas = ecore_evas_get(ee);
1925 im = evas_object_image_add(evas);
1927 e_prefix_data_concat_static(buff, "data/images/test.svg");
1928 evas_object_image_file_set(im, buff, NULL);
1929 if (evas_object_image_load_error_get(im) != EVAS_LOAD_ERROR_NONE)
1931 e_error_message_show(_("Enlightenment found Evas can't load SVG files. "
1932 "Check Evas has SVG loader support.\n"));
1935 efreet_icon_extension_add(".svg");
1937 e_prefix_data_concat_static(buff, "data/images/test.jpg");
1938 evas_object_image_file_set(im, buff, NULL);
1939 if (evas_object_image_load_error_get(im) != EVAS_LOAD_ERROR_NONE)
1941 e_error_message_show(_("Enlightenment found Evas can't load JPEG files. "
1942 "Check Evas has JPEG loader support.\n"));
1943 _e_main_shutdown(-1);
1945 efreet_icon_extension_add(".jpg");
1947 e_prefix_data_concat_static(buff, "data/images/test.png");
1948 evas_object_image_file_set(im, buff, NULL);
1949 if (evas_object_image_load_error_get(im) != EVAS_LOAD_ERROR_NONE)
1951 e_error_message_show(_("Enlightenment found Evas can't load PNG files. "
1952 "Check Evas has PNG loader support.\n"));
1953 _e_main_shutdown(-1);
1955 efreet_icon_extension_add(".png");
1957 e_prefix_data_concat_static(buff, "data/images/test.edj");
1958 evas_object_image_file_set(im, buff, "images/0");
1959 if (evas_object_image_load_error_get(im) != EVAS_LOAD_ERROR_NONE)
1961 e_error_message_show(_("Enlightenment found Evas can't load EET files. "
1962 "Check Evas has EET loader support.\n"));
1963 _e_main_shutdown(-1);
1965 efreet_icon_extension_add(".edj");
1967 evas_object_del(im);
1969 txt = evas_object_text_add(evas);
1970 evas_object_text_font_set(txt, "Sans", 10);
1971 evas_object_text_text_set(txt, "Hello");
1972 evas_object_geometry_get(txt, NULL, NULL, &tw, &th);
1973 if ((tw <= 0) && (th <= 0))
1975 e_error_message_show(_("Enlightenment found Evas can't load the 'Sans' font. Check Evas has fontconfig\n"
1976 "support and system fontconfig defines a 'Sans' font.\n"));
1977 _e_main_shutdown(-1);
1979 evas_object_del(txt);
1980 ecore_evas_free(ee);
1985 _e_main_screens_init(void)
1987 TS("\tscreens: client");
1988 if (!e_client_init()) return 0;
1989 #ifndef ENABLE_QUICK_INIT
1990 TS("\tscreens: win");
1991 if (!e_win_init()) return 0;
1993 #ifndef HAVE_WAYLAND_ONLY
1997 e_error_message_show(_("Enlightenment cannot setup XKB Keyboard layouts.\n"));
1998 _e_main_shutdown(-1);
2000 TS("E_Xkb Init Done");
2003 TS("Compositor Init");
2006 e_error_message_show(_("Enlightenment cannot create a compositor.\n"));
2007 _e_main_shutdown(-1);
2010 _e_main_desk_restore();
2012 #ifndef HAVE_WAYLAND_ONLY
2013 if (e_config->show_splash)
2014 e_init_status_set(_("Setup DND"));
2018 e_error_message_show(_("Enlightenment cannot set up its dnd system.\n"));
2019 _e_main_shutdown(-1);
2021 TS("E_Dnd Init Done");
2022 _e_main_shutdown_push(e_dnd_shutdown);
2029 _e_main_screens_shutdown(void)
2035 e_client_shutdown();
2036 e_exehist_shutdown();
2037 e_backlight_shutdown();
2046 _e_main_desk_save(void)
2049 char env[1024], name[1024];
2052 EINA_LIST_FOREACH(e_comp->zones, l, zone)
2054 snprintf(name, sizeof(name), "DESK_%d_%d", 0, zone->num);
2055 snprintf(env, sizeof(env), "%d,%d", zone->desk_x_current, zone->desk_y_current);
2056 e_util_env_set(name, env);
2061 _e_main_desk_restore(void)
2073 EINA_LIST_FOREACH(e_comp->zones, l, zone)
2079 snprintf(name, sizeof(name), "DESK_%d_%d", 0, zone->num);
2082 snprintf(buf_e, sizeof(buf_e), "%s", env);
2083 if (!sscanf(buf_e, "%d,%d", &desk_x, &desk_y)) continue;
2084 desk = e_desk_at_xy_get(zone, desk_x, desk_y);
2085 if (!desk) continue;
2089 E_CLIENT_REVERSE_FOREACH(ec)
2090 if ((!e_client_util_ignored_get(ec)) && e_client_util_desk_visible(ec, e_desk_current_get(ec->zone)))
2092 ec->want_focus = ec->take_focus = 1;
2098 _e_main_efreet_paths_init(void)
2102 if ((list = efreet_icon_extra_list_get()))
2104 char buff[PATH_MAX];
2106 e_user_dir_concat_static(buff, "icons");
2107 *list = eina_list_prepend(*list, (void *)eina_stringshare_add(buff));
2108 e_prefix_data_concat_static(buff, "data/icons");
2109 *list = eina_list_prepend(*list, (void *)eina_stringshare_add(buff));
2114 _e_main_modules_load_after(void *d EINA_UNUSED, int type EINA_UNUSED, void *ev EINA_UNUSED)
2116 e_int_config_modules(NULL, NULL);
2117 E_FREE_FUNC(mod_init_end, ecore_event_handler_del);
2118 return ECORE_CALLBACK_RENEW;
2122 _e_main_modules_load(Eina_Bool safe_mode)
2125 e_module_all_load();
2131 crashmodule = getenv("E_MODULE_LOAD");
2132 if (crashmodule) m = e_module_new(crashmodule);
2134 if ((crashmodule) && (m))
2136 e_module_disable(m);
2137 e_object_del(E_OBJECT(m));
2139 e_error_message_show
2140 (_("Enlightenment crashed early on start and has<br>"
2141 "been restarted. There was an error loading the<br>"
2142 "module named: %s. This module has been disabled<br>"
2143 "and will not be loaded."), crashmodule);
2145 (_("Enlightenment crashed early on start and has been restarted"),
2146 _("Enlightenment crashed early on start and has been restarted.<br>"
2147 "There was an error loading the module named: %s<br><br>"
2148 "This module has been disabled and will not be loaded."), crashmodule);
2149 e_module_all_load();
2153 e_error_message_show
2154 (_("Enlightenment crashed early on start and has<br>"
2155 "been restarted. All modules have been disabled<br>"
2156 "and will not be loaded to help remove any problem<br>"
2157 "modules from your configuration. The module<br>"
2158 "configuration dialog should let you select your<br>"
2159 "modules again.\n"));
2161 (_("Enlightenment crashed early on start and has been restarted"),
2162 _("Enlightenment crashed early on start and has been restarted.<br>"
2163 "All modules have been disabled and will not be loaded to help<br>"
2164 "remove any problem modules from your configuration.<br><br>"
2165 "The module configuration dialog should let you select your<br>"
2168 mod_init_end = ecore_event_handler_add(E_EVENT_MODULE_INIT_END, _e_main_modules_load_after, NULL);
2173 _e_main_cb_idle_before(void *data EINA_UNUSED)
2175 e_menu_idler_before();
2176 e_client_idler_before();
2177 e_pointer_idler_before();
2179 return ECORE_CALLBACK_RENEW;
2183 _e_main_cb_idle_after(void *data EINA_UNUSED)
2185 static int first_idle = 1;
2190 #ifdef E_RELEASE_BUILD
2195 e_precache_end = EINA_TRUE;
2198 if (first_idle++ < 60)
2202 e_precache_end = EINA_TRUE;
2206 return ECORE_CALLBACK_RENEW;
2211 _e_main_cb_startup_fake_end(void *data __UNUSED__)
2213 _e_main_cb_startup_fake_end(void *data EINA_UNUSED)
2217 return ECORE_CALLBACK_CANCEL;