3 # include <sys/prctl.h>
6 # include <systemd/sd-daemon.h>
15 t1 = ecore_time_unix_get(); \
16 printf("ESTART: %1.5f [%1.5f] - %s\n", t1 - t0, t1 - t2, x); \
22 TRACE_DS_BEGIN(ESTART: %s, x); \
32 TRACE_DS_MARK(ESTART: %s, x); \
35 static double t0, t1, t2;
43 * i need to make more use of these when i'm baffled as to when something is
46 * void *(*__malloc_hook)(size_t size, const void *caller);
48 * void *(*__realloc_hook)(void *ptr, size_t size, const void *caller);
50 * void *(*__memalign_hook)(size_t alignment, size_t size,
51 * const void *caller);
53 * void (*__free_hook)(void *ptr, const void *caller);
55 * void (*__malloc_initialize_hook)(void);
57 * void (*__after_morecore_hook)(void);
60 static void my_init_hook(void);
61 static void my_free_hook(void *p, const void *caller);
63 static void (*old_free_hook)(void *ptr, const void *caller) = NULL;
64 void (*__free_hook)(void *ptr, const void *caller);
66 void (*__malloc_initialize_hook) (void) = my_init_hook;
70 old_free_hook = __free_hook;
71 __free_hook = my_free_hook;
74 //void *magicfree = NULL;
77 my_free_hook(void *p, const void *caller)
79 __free_hook = old_free_hook;
80 // if ((p) && (p == magicfree))
82 // printf("CAUGHT!!!!! %p ...\n", p);
86 __free_hook = my_free_hook;
90 /* local function prototypes */
91 static void _e_main_shutdown(int errcode);
92 static void _e_main_shutdown_push(int (*func)(void));
93 static void _e_main_parse_arguments(int argc, char **argv);
94 static Eina_Bool _e_main_cb_signal_exit(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *ev EINA_UNUSED);
95 static Eina_Bool _e_main_cb_signal_hup(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *ev EINA_UNUSED);
96 static Eina_Bool _e_main_cb_signal_user(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *ev);
97 static int _e_main_dirs_init(void);
98 static int _e_main_dirs_shutdown(void);
99 static int _e_main_path_init(void);
100 static int _e_main_path_shutdown(void);
101 static int _e_main_screens_init(void);
102 static int _e_main_screens_shutdown(void);
103 static void _e_main_desk_save(void);
104 static void _e_main_desk_restore(void);
105 static void _e_main_modules_load(Eina_Bool safe_mode);
106 static Eina_Bool _e_main_cb_idle_before(void *data EINA_UNUSED);
107 static Eina_Bool _e_main_cb_idle_after(void *data EINA_UNUSED);
108 static void _e_main_create_wm_ready(void);
109 static void _e_main_hooks_clean(void);
110 static void _e_main_hook_call(E_Main_Hook_Point hookpoint, void *data EINA_UNUSED);
112 /* local variables */
113 static Eina_Bool really_know = EINA_FALSE;
114 static Eina_Bool inloop = EINA_FALSE;
116 static int _e_main_lvl = 0;
117 static int(*_e_main_shutdown_func[MAX_LEVEL]) (void);
119 static Ecore_Idle_Enterer *_idle_before = NULL;
120 static Ecore_Idle_Enterer *_idle_after = NULL;
122 static Ecore_Event_Handler *mod_init_end = NULL;
124 static Eina_List *hooks = NULL;
126 static int _e_main_hooks_delete = 0;
127 static int _e_main_hooks_walking = 0;
129 static Eina_Inlist *_e_main_hooks[] =
131 [E_MAIN_HOOK_MODULE_LOAD_DONE] = NULL,
132 [E_MAIN_HOOK_E_INFO_READY] = NULL
135 /* external variables */
136 E_API Eina_Bool e_precache_end = EINA_FALSE;
137 E_API Eina_Bool good = EINA_FALSE;
138 E_API Eina_Bool evil = EINA_FALSE;
139 E_API Eina_Bool starting = EINA_TRUE;
140 E_API Eina_Bool stopping = EINA_FALSE;
141 E_API Eina_Bool restart = EINA_FALSE;
142 E_API Eina_Bool e_nopause = EINA_FALSE;
145 _xdg_check_str(const char *env, const char *str)
151 for (p = strstr(env, str); p; p++, p = strstr(p, str))
153 if ((!p[len]) || (p[len] == ':')) return EINA_TRUE;
159 _xdg_data_dirs_augment(void)
162 const char *p = e_prefix_get();
163 char newpath[4096], buf[4096];
167 s = getenv("XDG_DATA_DIRS");
170 Eina_Bool pfxdata, pfx;
172 pfxdata = !_xdg_check_str(s, e_prefix_data_get());
173 snprintf(newpath, sizeof(newpath), "%s/share", p);
174 pfx = !_xdg_check_str(s, newpath);
177 snprintf(buf, sizeof(buf), "%s%s%s%s%s",
178 pfxdata ? e_prefix_data_get() : "",
183 e_util_env_set("XDG_DATA_DIRS", buf);
188 snprintf(buf, sizeof(buf), "%s:%s/share:/usr/local/share:/usr/share", e_prefix_data_get(), p);
189 e_util_env_set("XDG_DATA_DIRS", buf);
192 s = getenv("XDG_CONFIG_DIRS");
193 snprintf(newpath, sizeof(newpath), "%s/etc/xdg", p);
196 if (!_xdg_check_str(s, newpath))
198 snprintf(buf, sizeof(buf), "%s:%s", newpath, s);
199 e_util_env_set("XDG_CONFIG_DIRS", buf);
204 snprintf(buf, sizeof(buf), "%s:/etc/xdg", newpath);
205 e_util_env_set("XDG_CONFIG_DIRS", buf);
208 if (!getenv("XDG_RUNTIME_DIR"))
212 snprintf(buf, sizeof(buf), "/tmp/xdg-XXXXXX");
214 if (!dir) dir = "/tmp";
217 e_util_env_set("XDG_RUNTIME_DIR", dir);
218 snprintf(buf, sizeof(buf), "%s/.e-deleteme", dir);
219 ecore_file_mkdir(buf);
223 /* set menu prefix so we get our e menu */
224 if (!getenv("XDG_MENU_PREFIX"))
226 e_util_env_set("XDG_MENU_PREFIX", "e-");
231 _e_main_subsystem_defer(void *data EINA_UNUSED)
236 TRACE_DS_BEGIN(MAIN:SUBSYSTEMS DEFER);
238 ecore_app_args_get(&argc, &argv);
240 /* try to init delayed subsystems */
242 TRACE_DS_BEGIN(MAIN:DEFERRED INTERNAL SUBSYSTEMS INIT);
244 TSB("[DEFERRED] DPMS Init");
247 e_error_message_show(_("Enlightenment cannot set up dpms.\n"));
250 TSE("[DEFERRED] DPMS Init Done");
251 _e_main_shutdown_push(e_dpms_shutdown);
253 TSB("[DEFERRED] Screens Init: win");
256 e_error_message_show(_("Enlightenment cannot setup elementary trap!\n"));
259 TSE("[DEFERRED] Screens Init: win Done");
261 TSB("[DEFERRED] E_Dnd Init");
264 e_error_message_show(_("Enlightenment cannot set up its dnd system.\n"));
267 TSE("[DEFERRED] E_Dnd Init Done");
268 _e_main_shutdown_push(e_dnd_shutdown);
270 TSB("[DEFERRED] E_Scale Init");
273 e_error_message_show(_("Enlightenment cannot set up its scale system.\n"));
276 TSE("[DEFERRED] E_Scale Init Done");
277 _e_main_shutdown_push(e_scale_shutdown);
279 TSB("[DEFERRED] E_Test_Helper Init");
280 e_test_helper_init();
281 _e_main_shutdown_push(e_test_helper_shutdown);
282 TSE("[DEFERRED] E_Test_Helper Done");
284 TSB("[DEFERRED] E_INFO_SERVER Init");
285 e_info_server_init();
286 _e_main_shutdown_push(e_info_server_shutdown);
287 TSE("[DEFERRED] E_INFO_SERVER Done");
290 TRACE_DS_BEGIN(MAIN:DEFERRED COMP JOB);
292 /* try to do deferred job of any subsystems*/
293 TSB("[DEFERRED] Compositor's deferred job");
294 e_comp_deferred_job();
295 TSE("[DEFERRED] Compositor's deferred job Done");
297 if (e_config->use_e_policy)
299 TSB("[DEFERRED] E_Policy's deferred job");
300 e_policy_deferred_job();
301 TSE("[DEFERRED] E_Policy's deferred job Done");
304 TSB("[DEFERRED] E_Module's deferred job");
305 e_module_deferred_job();
306 TSE("[DEFERRED] E_Module's deferred job Done");
310 return ECORE_CALLBACK_DONE;
316 _e_main_shutdown(-1);
317 return ECORE_CALLBACK_DONE;
321 _e_main_deferred_job_schedule(void *d EINA_UNUSED, int type EINA_UNUSED, void *ev EINA_UNUSED)
323 PRCTL("[Winsys] all modules loaded");
324 ecore_idler_add(_e_main_subsystem_defer, NULL);
325 return ECORE_CALLBACK_DONE;
328 /* externally accessible functions */
330 main(int argc, char **argv)
332 Eina_Bool safe_mode = EINA_FALSE;
333 double t = 0.0, tstart = 0.0;
334 char *s = NULL, buff[32];
335 struct sigaction action;
338 # ifdef PR_SET_PTRACER
339 # ifdef PR_SET_PTRACER_ANY
340 prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY);
345 t0 = t1 = t2 = ecore_time_unix_get();
346 printf("ESTART(main) %1.5f\n", t0);
348 TRACE_DS_BEGIN(MAIN:BEGIN STARTUP);
349 TSB("Begin Startup");
350 PRCTL("[Winsys] start of main");
352 /* trap deadly bug signals and allow some form of sane recovery */
353 /* or ability to gdb attach and debug at this point - better than your */
354 /* wm/desktop vanishing and not knowing what happened */
356 /* don't install SIGBUS handler */
357 /* Wayland shm sets up a sigbus handler for catching invalid shm region */
358 /* access. If we setup our sigbus handler here, then the wl-shm sigbus */
359 /* handler will not function properly */
360 if (!getenv("NOTIFY_SOCKET"))
363 action.sa_sigaction = e_sigseg_act;
364 action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
365 sigemptyset(&action.sa_mask);
366 sigaction(SIGSEGV, &action, NULL);
368 action.sa_sigaction = e_sigill_act;
369 action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
370 sigemptyset(&action.sa_mask);
371 sigaction(SIGILL, &action, NULL);
373 action.sa_sigaction = e_sigfpe_act;
374 action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
375 sigemptyset(&action.sa_mask);
376 sigaction(SIGFPE, &action, NULL);
378 action.sa_sigaction = e_sigabrt_act;
379 action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
380 sigemptyset(&action.sa_mask);
381 sigaction(SIGABRT, &action, NULL);
382 TSE("Signal Trap Done");
385 t = ecore_time_unix_get();
386 s = getenv("E_START_TIME");
387 if ((s) && (!getenv("E_RESTART_OK")))
390 if ((t - tstart) < 5.0) safe_mode = EINA_TRUE;
393 snprintf(buff, sizeof(buff), "%1.1f", tstart);
394 e_util_env_set("E_START_TIME", buff);
396 if (getenv("E_START_MTRACK"))
397 e_util_env_set("MTRACK", NULL);
401 e_error_message_show(_("Enlightenment cannot initialize Eina!\n"));
404 TSE("Eina Init Done");
405 _e_main_shutdown_push(eina_shutdown);
407 #ifdef OBJECT_HASH_CHECK
408 TSB("E_Object Hash Init");
409 e_object_hash_init();
410 TSE("E_Object Hash Init Done");
416 e_error_message_show(_("Enlightenment could not create a logging domain!\n"));
419 TSE("E_Log Init Done");
420 _e_main_shutdown_push(e_log_shutdown);
422 TSB("Determine Prefix");
423 if (!e_prefix_determine(argv[0]))
426 "ERROR: Enlightenment cannot determine it's installed\n"
427 " prefix from the system or argv[0].\n"
428 " This is because it is not on Linux AND has been\n"
429 " executed strangely. This is unusual.\n");
431 TSE("Determine Prefix Done");
433 /* for debugging by redirecting stdout of e to a log file to tail */
434 setvbuf(stdout, NULL, _IONBF, 0);
436 TSB("Parse Arguments");
437 _e_main_parse_arguments(argc, argv);
438 TSE("Parse Arguments Done");
440 /*** Initialize Core EFL Libraries We Need ***/
445 e_error_message_show(_("Enlightenment cannot initialize Eet!\n"));
448 TSE("Eet Init Done");
449 _e_main_shutdown_push(eet_shutdown);
451 /* Allow ecore to not load system modules.
452 * Without it ecore_init will block until dbus authentication
453 * and registration are complete.
455 ecore_app_no_system_modules();
460 e_error_message_show(_("Enlightenment cannot initialize Ecore!\n"));
463 TSE("Ecore Init Done");
464 _e_main_shutdown_push(ecore_shutdown);
469 e_error_message_show(_("Enlightenment cannot initialize EIO!\n"));
472 TSE("EIO Init Done");
473 _e_main_shutdown_push(eio_shutdown);
475 ecore_app_args_set(argc, (const char **)argv);
477 TSB("Ecore Event Handlers");
478 if (!ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT,
479 _e_main_cb_signal_exit, NULL))
481 e_error_message_show(_("Enlightenment cannot set up an exit signal handler.\n"
482 "Perhaps you are out of memory?"));
485 if (!ecore_event_handler_add(ECORE_EVENT_SIGNAL_HUP,
486 _e_main_cb_signal_hup, NULL))
488 e_error_message_show(_("Enlightenment cannot set up a HUP signal handler.\n"
489 "Perhaps you are out of memory?"));
492 if (!ecore_event_handler_add(ECORE_EVENT_SIGNAL_USER,
493 _e_main_cb_signal_user, NULL))
495 e_error_message_show(_("Enlightenment cannot set up a USER signal handler.\n"
496 "Perhaps you are out of memory?"));
499 TSE("Ecore Event Handlers Done");
501 TSB("Ecore_File Init");
502 if (!ecore_file_init())
504 e_error_message_show(_("Enlightenment cannot initialize Ecore_File!\n"));
507 TSE("Ecore_File Init Done");
508 _e_main_shutdown_push(ecore_file_shutdown);
510 _idle_before = ecore_idle_enterer_before_add(_e_main_cb_idle_before, NULL);
512 TSB("XDG_DATA_DIRS Init");
513 _xdg_data_dirs_augment();
514 TSE("XDG_DATA_DIRS Init Done");
516 TSB("Ecore_Evas Init");
517 if (!ecore_evas_init())
519 e_error_message_show(_("Enlightenment cannot initialize Ecore_Evas!\n"));
522 TSE("Ecore_Evas Init Done");
524 /* e doesn't sync to compositor - it should be one */
525 ecore_evas_app_comp_sync_set(0);
530 e_error_message_show(_("Enlightenment cannot initialize Edje!\n"));
533 TSE("Edje Init Done");
534 _e_main_shutdown_push(edje_shutdown);
536 /*** Initialize E Subsystems We Need ***/
538 TSB("E Directories Init");
539 /* setup directories we will be using for configurations storage etc. */
540 if (!_e_main_dirs_init())
542 e_error_message_show(_("Enlightenment cannot create directories in your home directory.\n"
543 "Perhaps you have no home directory or the disk is full?"));
546 TSE("E Directories Init Done");
547 _e_main_shutdown_push(_e_main_dirs_shutdown);
549 TSB("E_Config Init");
550 if (!e_config_init())
552 e_error_message_show(_("Enlightenment cannot set up its config system.\n"));
555 TSE("E_Config Init Done");
556 _e_main_shutdown_push(e_config_shutdown);
561 e_error_message_show(_("Enlightenment cannot set up its environment.\n"));
564 TSE("E_Env Init Done");
565 _e_main_shutdown_push(e_env_shutdown);
567 ecore_exe_run_priority_set(e_config->priority);
570 if (!_e_main_path_init())
572 e_error_message_show(_("Enlightenment cannot set up paths for finding files.\n"
573 "Perhaps you are out of memory?"));
576 TSE("E Paths Init Done");
577 _e_main_shutdown_push(_e_main_path_shutdown);
579 ecore_animator_frametime_set(1.0 / e_config->framerate);
584 e_error_message_show(_("Enlightenment cannot set up its theme system.\n"));
587 TSE("E_Theme Init Done");
588 _e_main_shutdown_push(e_theme_shutdown);
590 TSB("E_Actions Init");
591 if (!e_actions_init())
593 e_error_message_show(_("Enlightenment cannot set up its actions system.\n"));
596 TSE("E_Actions Init Done");
597 _e_main_shutdown_push(e_actions_shutdown);
599 /* these just add event handlers and can't fail
600 * timestamping them is dumb.
602 e_screensaver_preinit();
607 TRACE_DS_BEGIN(MAIN:WAIT /dev/dri/card0);
608 if (e_config->sleep_for_dri)
610 while(access("/dev/dri/card0", F_OK) != 0)
612 struct timespec req, rem;
614 req.tv_nsec = 50000000L;
615 nanosleep(&req, &rem);
620 e_module_event_init();
622 TSB("E_Pointer Init");
623 if (!e_pointer_init())
625 e_error_message_show(_("Enlightenment cannot set up its pointer system.\n"));
628 TSE("E_Pointer Init Done");
629 _e_main_shutdown_push(e_pointer_shutdown);
631 TRACE_DS_BEGIN(MAIN:SCREEN INIT);
633 if (!_e_main_screens_init())
635 e_error_message_show(_("Enlightenment set up window management for all the screens on your system\n"
636 "failed. Perhaps another window manager is running?\n"));
639 TSE("Screens Init Done");
640 _e_main_shutdown_push(_e_main_screens_shutdown);
643 if (e_config->eom_enable)
648 e_error_message_show(_("Enlightenment cannot set up eom.\n"));
651 TSE("Eom Init Done");
652 _e_main_shutdown_push(e_eom_shutdown);
655 TSB("E_Screensaver Init");
656 if (!e_screensaver_init())
658 e_error_message_show(_("Enlightenment cannot configure the X screensaver.\n"));
661 TSE("E_Screensaver Init Done");
662 _e_main_shutdown_push(e_screensaver_shutdown);
664 TSB("E_Comp Freeze");
666 TSE("E_Comp Freeze Done");
668 TSB("E_Grabinput Init");
669 if (!e_grabinput_init())
671 e_error_message_show(_("Enlightenment cannot set up its grab input handling system.\n"));
674 TSE("E_Grabinput Init Done");
675 _e_main_shutdown_push(e_grabinput_shutdown);
677 TS("E_Gesture Init");
679 _e_main_shutdown_push(e_gesture_shutdown);
681 ecore_event_handler_add(E_EVENT_MODULE_INIT_END, _e_main_deferred_job_schedule, NULL);
683 TSB("E_Module Init");
684 if (!e_module_init())
686 e_error_message_show(_("Enlightenment cannot set up its module system.\n"));
689 TSE("E_Module Init Done");
690 _e_main_shutdown_push(e_module_shutdown);
693 if (!e_mouse_update())
695 e_error_message_show(_("Enlightenment cannot configure the mouse settings.\n"));
698 TSE("E_Mouse Init Done");
703 e_error_message_show(_("Enlightenment cannot initialize the Icon Cache system.\n"));
706 TSE("E_Icon Init Done");
707 _e_main_shutdown_push(e_icon_shutdown);
709 if (e_config->use_e_policy)
711 TSB("E_Policy Init");
712 if (!e_policy_init())
714 e_error_message_show(_("Enlightenment cannot setup policy system!\n"));
717 TSE("E_Policy Init Done");
718 _e_main_shutdown_push(e_policy_shutdown);
721 TSB("E_Process Init");
722 if (!e_process_init())
724 e_error_message_show(_("Enlightenment cannot setup process managing system!\n"));
727 TSE("E_Process Init Done");
728 _e_main_shutdown_push(e_process_shutdown);
730 TSB("E_Security Init");
731 if (!e_security_init())
733 e_error_message_show(_("Enlightenment cannot setup security system!\n"));
736 TSE("E_Security Init Done");
737 _e_main_shutdown_push(e_security_shutdown);
740 _e_main_modules_load(safe_mode);
741 TSE("Load Modules Done");
745 TSE("E_Comp Thaw Done");
747 _idle_after = ecore_idle_enterer_add(_e_main_cb_idle_after, NULL);
749 starting = EINA_FALSE;
752 e_util_env_set("E_RESTART", "1");
754 TSM("MAIN LOOP AT LAST");
756 if (e_config->create_wm_ready)
757 _e_main_create_wm_ready();
762 TSM("[WM] Send start-up completion");
763 sd_notify(0, "READY=1");
765 TSM("[WM] Skip sending start-up completion. (no systemd)");
767 ecore_main_loop_begin();
771 ELOGF("COMP", "STOPPING enlightenment...", NULL, NULL);
772 stopping = EINA_TRUE;
775 e_comp_internal_save();
781 e_util_env_set("E_RESTART_OK", "1");
782 if (getenv("E_START_MTRACK"))
783 e_util_env_set("MTRACK", "track");
794 _e_main_shutdown(-1);
798 e_main_ts(const char *str)
801 t1 = ecore_time_unix_get();
802 printf("ESTART: %1.5f [%1.5f] - %s\n", t1 - t0, t1 - t2, str);
809 e_main_ts_begin(const char *str)
811 TRACE_DS_BEGIN(ESTART: %s, str);
812 return e_main_ts(str);
816 e_main_ts_end(const char *str)
819 return e_main_ts(str);
822 /* local functions */
824 _e_main_shutdown(int errcode)
830 printf("E: Begin Shutdown Procedure!\n");
832 E_FREE_LIST(hooks, e_main_hook_del);
834 if (_idle_before) ecore_idle_enterer_del(_idle_before);
836 if (_idle_after) ecore_idle_enterer_del(_idle_after);
839 dir = getenv("XDG_RUNTIME_DIR");
842 char buf_env[PATH_MAX];
843 snprintf(buf_env, sizeof(buf_env), "%s", dir);
844 snprintf(buf, sizeof(buf), "%s/.e-deleteme", buf_env);
845 if (ecore_file_exists(buf)) ecore_file_recursive_rm(buf_env);
847 for (i = (_e_main_lvl - 1); i >= 0; i--)
848 (*_e_main_shutdown_func[i])();
849 #ifdef OBJECT_HASH_CHECK
850 e_object_hash_shutdown();
852 if (errcode < 0) exit(errcode);
856 _e_main_shutdown_push(int (*func)(void))
859 if (_e_main_lvl > MAX_LEVEL)
862 e_error_message_show("WARNING: too many init levels. MAX = %i\n",
866 _e_main_shutdown_func[_e_main_lvl - 1] = func;
870 _e_main_parse_arguments(int argc, char **argv)
874 /* handle some command-line parameters */
875 for (i = 1; i < argc; i++)
877 if (!strcmp(argv[i], "-good"))
881 printf("LA LA LA\n");
883 else if (!strcmp(argv[i], "-evil"))
887 printf("MUHAHAHAHHAHAHAHAHA\n");
889 else if (!strcmp(argv[i], "-psychotic"))
893 printf("MUHAHALALALALALALALA\n");
895 else if ((!strcmp(argv[i], "-profile")) && (i < (argc - 1)))
898 if (!getenv("E_CONF_PROFILE"))
899 e_util_env_set("E_CONF_PROFILE", argv[i]);
901 else if (!strcmp(argv[i], "-i-really-know-what-i-am-doing-and-accept-full-responsibility-for-it"))
902 really_know = EINA_TRUE;
903 else if (!strcmp(argv[i], "-nopause"))
904 e_nopause = EINA_TRUE;
905 else if ((!strcmp(argv[i], "-version")) ||
906 (!strcmp(argv[i], "--version")))
908 printf(_("Version: %s\n"), PACKAGE_VERSION);
909 _e_main_shutdown(-1);
911 else if ((!strcmp(argv[i], "-h")) ||
912 (!strcmp(argv[i], "-help")) ||
913 (!strcmp(argv[i], "--help")))
918 "\t-display DISPLAY\n"
919 "\t\tConnect to display named DISPLAY.\n"
920 "\t\tEG: -display :1.0\n"
921 "\t-fake-xinerama-screen WxH+X+Y\n"
922 "\t\tAdd a FAKE xinerama screen (instead of the real ones)\n"
923 "\t\tgiven the geometry. Add as many as you like. They all\n"
924 "\t\treplace the real xinerama screens, if any. This can\n"
925 "\t\tbe used to simulate xinerama.\n"
926 "\t\tEG: -fake-xinerama-screen 800x600+0+0 -fake-xinerama-screen 800x600+800+0\n"
927 "\t-profile CONF_PROFILE\n"
928 "\t\tUse the configuration profile CONF_PROFILE instead of the user selected default or just \"default\".\n"
934 "\t\tBe psychotic.\n"
935 "\t-i-really-know-what-i-am-doing-and-accept-full-responsibility-for-it\n"
936 "\t\tIf you need this help, you don't need this option.\n"
940 _e_main_shutdown(-1);
946 _e_main_cb_signal_exit(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *ev EINA_UNUSED)
948 /* called on ctrl-c, kill (pid) (also SIGINT, SIGTERM and SIGQIT) */
949 ecore_main_loop_quit();
950 return ECORE_CALLBACK_RENEW;
954 _e_main_cb_signal_hup(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *ev EINA_UNUSED)
957 ecore_main_loop_quit();
958 return ECORE_CALLBACK_RENEW;
962 _e_main_cb_signal_user(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *ev)
964 Ecore_Event_Signal_User *e = ev;
968 // E_Action *a = e_action_find("configuration");
969 // if ((a) && (a->func.go)) a->func.go(NULL, NULL);
971 else if (e->number == 2)
973 // comp module has its own handler for this for enabling/disabling fps debug
975 return ECORE_CALLBACK_RENEW;
980 _e_main_dirs_init(void)
982 if(getenv("E_CONF_RO"))
996 base = e_user_dir_get();
997 if (ecore_file_mksubdirs(base, dirs) != sizeof(dirs) / sizeof(dirs[0]) - 1)
999 e_error_message_show("Could not create one of the required "
1000 "subdirectories of '%s'\n", base);
1008 _e_main_dirs_shutdown(void)
1014 _e_main_path_init(void)
1018 /* setup data paths */
1019 path_data = e_path_new();
1022 e_error_message_show("Cannot allocate path for path_data\n");
1025 e_prefix_data_concat_static(buf, "data");
1026 e_path_default_path_append(path_data, buf);
1028 /* setup image paths */
1029 path_images = e_path_new();
1032 e_error_message_show("Cannot allocate path for path_images\n");
1035 e_user_dir_concat_static(buf, "/images");
1036 e_path_default_path_append(path_images, buf);
1037 e_prefix_data_concat_static(buf, "data/images");
1038 e_path_default_path_append(path_images, buf);
1040 /* setup font paths */
1041 path_fonts = e_path_new();
1044 e_error_message_show("Cannot allocate path for path_fonts\n");
1047 e_user_dir_concat_static(buf, "/fonts");
1048 e_path_default_path_append(path_fonts, buf);
1049 e_prefix_data_concat_static(buf, "data/fonts");
1050 e_path_default_path_append(path_fonts, buf);
1052 /* setup icon paths */
1053 path_icons = e_path_new();
1056 e_error_message_show("Cannot allocate path for path_icons\n");
1059 e_user_dir_concat_static(buf, "/icons");
1060 e_path_default_path_append(path_icons, buf);
1061 e_prefix_data_concat_static(buf, "data/icons");
1062 e_path_default_path_append(path_icons, buf);
1064 /* setup module paths */
1065 path_modules = e_path_new();
1068 e_error_message_show("Cannot allocate path for path_modules\n");
1071 e_user_dir_concat_static(buf, "/modules");
1072 e_path_default_path_append(path_modules, buf);
1073 snprintf(buf, sizeof(buf), "%s/enlightenment/modules", e_prefix_lib_get());
1074 e_path_default_path_append(path_modules, buf);
1075 /* FIXME: eventually this has to go - moduels should have installers that
1076 * add appropriate install paths (if not installed to user homedir) to
1077 * e's module search dirs
1079 snprintf(buf, sizeof(buf), "%s/enlightenment/modules_extra", e_prefix_lib_get());
1080 e_path_default_path_append(path_modules, buf);
1082 /* setup background paths */
1083 path_backgrounds = e_path_new();
1084 if (!path_backgrounds)
1086 e_error_message_show("Cannot allocate path for path_backgrounds\n");
1089 e_user_dir_concat_static(buf, "/backgrounds");
1090 e_path_default_path_append(path_backgrounds, buf);
1091 e_prefix_data_concat_static(buf, "data/backgrounds");
1092 e_path_default_path_append(path_backgrounds, buf);
1094 path_messages = e_path_new();
1097 e_error_message_show("Cannot allocate path for path_messages\n");
1100 e_user_dir_concat_static(buf, "/locale");
1101 e_path_default_path_append(path_messages, buf);
1102 e_path_default_path_append(path_messages, e_prefix_locale_get());
1108 _e_main_path_shutdown(void)
1112 e_object_del(E_OBJECT(path_data));
1117 e_object_del(E_OBJECT(path_images));
1122 e_object_del(E_OBJECT(path_fonts));
1127 e_object_del(E_OBJECT(path_icons));
1132 e_object_del(E_OBJECT(path_modules));
1133 path_modules = NULL;
1135 if (path_backgrounds)
1137 e_object_del(E_OBJECT(path_backgrounds));
1138 path_backgrounds = NULL;
1142 e_object_del(E_OBJECT(path_messages));
1143 path_messages = NULL;
1149 _e_main_screens_init(void)
1151 TSB("\tscreens: client");
1152 if (!e_client_init()) return 0;
1153 TSE("\tscreens: client Done");
1155 TSB("Compositor Init");
1156 PRCTL("[Winsys] start of compositor init");
1159 e_error_message_show(_("Enlightenment cannot create a compositor.\n"));
1160 _e_main_shutdown(-1);
1162 TSE("Compositor Init Done");
1164 PRCTL("[Winsys] end of compositor init");
1165 _e_main_desk_restore();
1171 _e_main_screens_shutdown(void)
1175 e_client_shutdown();
1184 _e_main_desk_save(void)
1187 char env[1024], name[1024];
1190 EINA_LIST_FOREACH(e_comp->zones, l, zone)
1192 snprintf(name, sizeof(name), "DESK_%d_%d", 0, zone->num);
1193 snprintf(env, sizeof(env), "%d,%d", zone->desk_x_current, zone->desk_y_current);
1194 e_util_env_set(name, env);
1199 _e_main_desk_restore(void)
1203 E_CLIENT_REVERSE_FOREACH(ec)
1204 if ((!e_client_util_ignored_get(ec)) && e_client_util_desk_visible(ec, e_desk_current_get(ec->zone)))
1206 ec->want_focus = ec->take_focus = 1;
1212 _e_main_modules_load_after(void *d EINA_UNUSED, int type EINA_UNUSED, void *ev EINA_UNUSED)
1214 E_FREE_FUNC(mod_init_end, ecore_event_handler_del);
1215 return ECORE_CALLBACK_RENEW;
1219 _e_main_modules_load(Eina_Bool safe_mode)
1222 e_module_all_load();
1228 crashmodule = getenv("E_MODULE_LOAD");
1229 if (crashmodule) m = e_module_new(crashmodule);
1231 if ((crashmodule) && (m))
1233 e_module_disable(m);
1234 e_object_del(E_OBJECT(m));
1236 e_error_message_show
1237 (_("Enlightenment crashed early on start and has<br>"
1238 "been restarted. There was an error loading the<br>"
1239 "module named: %s. This module has been disabled<br>"
1240 "and will not be loaded."), crashmodule);
1242 (_("Enlightenment crashed early on start and has been restarted"),
1243 _("Enlightenment crashed early on start and has been restarted.<br>"
1244 "There was an error loading the module named: %s<br><br>"
1245 "This module has been disabled and will not be loaded."), crashmodule);
1246 e_module_all_load();
1250 e_error_message_show
1251 (_("Enlightenment crashed early on start and has<br>"
1252 "been restarted. All modules have been disabled<br>"
1253 "and will not be loaded to help remove any problem<br>"
1254 "modules from your configuration. The module<br>"
1255 "configuration dialog should let you select your<br>"
1256 "modules again.\n"));
1258 (_("Enlightenment crashed early on start and has been restarted"),
1259 _("Enlightenment crashed early on start and has been restarted.<br>"
1260 "All modules have been disabled and will not be loaded to help<br>"
1261 "remove any problem modules from your configuration.<br><br>"
1262 "The module configuration dialog should let you select your<br>"
1265 mod_init_end = ecore_event_handler_add(E_EVENT_MODULE_INIT_END, _e_main_modules_load_after, NULL);
1270 _e_main_cb_idle_before(void *data EINA_UNUSED)
1272 e_client_idler_before();
1274 return ECORE_CALLBACK_RENEW;
1278 _e_main_cb_idle_after(void *data EINA_UNUSED)
1280 static int first_idle = 1;
1285 #ifdef E_RELEASE_BUILD
1290 e_precache_end = EINA_TRUE;
1293 if (first_idle++ < 60)
1297 e_precache_end = EINA_TRUE;
1301 return ECORE_CALLBACK_RENEW;
1305 _e_main_create_wm_ready(void)
1307 FILE *_wmready_checker = NULL;
1308 const char *path_wm_ready = "/run/.wm_ready";
1310 if (!e_util_file_realpath_check(path_wm_ready, EINA_TRUE))
1312 WRN("%s is maybe link, so delete it\n", path_wm_ready);
1315 _wmready_checker = fopen(path_wm_ready, "wb");
1316 if (_wmready_checker)
1318 TSM("[WM] WINDOW MANAGER is READY!!!");
1319 PRCTL("[Winsys] WINDOW MANAGER is READY!!!");
1320 fclose(_wmready_checker);
1322 /*TODO: Next lines should be removed. */
1323 FILE *_tmp_wm_ready_checker;
1325 _tmp_wm_ready_checker = fopen(path_wm_ready, "wb");
1327 if (_tmp_wm_ready_checker)
1329 TSM("[WM] temporary wm_ready path is created.");
1330 PRCTL("[Winsys] temporary wm_ready path is created.");
1331 fclose(_tmp_wm_ready_checker);
1335 TSM("[WM] temporary wm_ready path create failed.");
1336 PRCTL("[Winsys] temporary wm_ready path create failed.");
1341 TSM("[WM] WINDOW MANAGER is READY. BUT, failed to create .wm_ready file.");
1342 PRCTL("[Winsys] WINDOW MANAGER is READY. BUT, failed to create .wm_ready file.");
1347 _e_main_hooks_clean(void)
1353 for (x = 0; x < E_MAIN_HOOK_LAST; x++)
1354 EINA_INLIST_FOREACH_SAFE(_e_main_hooks[x], l, mh)
1356 if (!mh->delete_me) continue;
1357 _e_main_hooks[x] = eina_inlist_remove(_e_main_hooks[x],
1358 EINA_INLIST_GET(mh));
1364 _e_main_hook_call(E_Main_Hook_Point hookpoint, void *data EINA_UNUSED)
1368 _e_main_hooks_walking++;
1369 EINA_INLIST_FOREACH(_e_main_hooks[hookpoint], mh)
1371 if (mh->delete_me) continue;
1374 _e_main_hooks_walking--;
1375 if ((_e_main_hooks_walking == 0) && (_e_main_hooks_delete > 0))
1376 _e_main_hooks_clean();
1380 e_main_hook_add(E_Main_Hook_Point hookpoint, E_Main_Hook_Cb func, const void *data)
1384 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_MAIN_HOOK_LAST, NULL);
1385 mh = E_NEW(E_Main_Hook, 1);
1386 EINA_SAFETY_ON_NULL_RETURN_VAL(mh, NULL);
1387 mh->hookpoint = hookpoint;
1389 mh->data = (void*)data;
1390 _e_main_hooks[hookpoint] = eina_inlist_append(_e_main_hooks[hookpoint],
1391 EINA_INLIST_GET(mh));
1396 e_main_hook_del(E_Main_Hook *mh)
1399 if (_e_main_hooks_walking == 0)
1401 _e_main_hooks[mh->hookpoint] = eina_inlist_remove(_e_main_hooks[mh->hookpoint],
1402 EINA_INLIST_GET(mh));
1406 _e_main_hooks_delete++;
1410 e_main_hook_call(E_Main_Hook_Point hookpoint)
1412 if ((hookpoint < 0) || (hookpoint >= E_MAIN_HOOK_LAST)) return;
1414 _e_main_hook_call(hookpoint, NULL);