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 int _e_main_dirs_init(void);
97 static int _e_main_dirs_shutdown(void);
98 static int _e_main_path_init(void);
99 static int _e_main_path_shutdown(void);
100 static int _e_main_screens_init(void);
101 static int _e_main_screens_shutdown(void);
102 static void _e_main_desk_save(void);
103 static void _e_main_desk_restore(void);
104 static Eina_Bool _e_main_cb_idle_before(void *data EINA_UNUSED);
105 static Eina_Bool _e_main_cb_idle_after(void *data EINA_UNUSED);
106 static void _e_main_create_wm_ready(void);
107 static void _e_main_hooks_clean(void);
108 static void _e_main_hook_call(E_Main_Hook_Point hookpoint, void *data EINA_UNUSED);
110 /* local variables */
111 static int _e_main_lvl = 0;
112 static int(*_e_main_shutdown_func[MAX_LEVEL]) (void);
114 static Ecore_Idle_Enterer *_idle_before = NULL;
115 static Ecore_Idle_Enterer *_idle_after = NULL;
117 static Eina_List *hooks = NULL;
119 static int _e_main_hooks_delete = 0;
120 static int _e_main_hooks_walking = 0;
122 static Eina_Inlist *_e_main_hooks[] =
124 [E_MAIN_HOOK_MODULE_LOAD_DONE] = NULL,
125 [E_MAIN_HOOK_E_INFO_READY] = NULL
128 /* external variables */
129 E_API Eina_Bool starting = EINA_TRUE;
130 E_API Eina_Bool stopping = EINA_FALSE;
133 _xdg_check_str(const char *env, const char *str)
139 for (p = strstr(env, str); p; p++, p = strstr(p, str))
141 if ((!p[len]) || (p[len] == ':')) return EINA_TRUE;
147 _xdg_data_dirs_augment(void)
150 const char *p = e_prefix_get();
151 char newpath[PATH_MAX], buf[PATH_MAX + PATH_MAX + 200];
155 s = e_util_env_get("XDG_DATA_DIRS");
158 Eina_Bool pfxdata, pfx;
160 pfxdata = !_xdg_check_str(s, e_prefix_data_get());
161 snprintf(newpath, sizeof(newpath), "%s/share", p);
162 pfx = !_xdg_check_str(s, newpath);
165 snprintf(buf, sizeof(buf), "%s%s%s%s%s",
166 pfxdata ? e_prefix_data_get() : "",
171 e_util_env_set("XDG_DATA_DIRS", buf);
177 snprintf(buf, sizeof(buf), "%s:%s/share:/usr/local/share:/usr/share", e_prefix_data_get(), p);
178 e_util_env_set("XDG_DATA_DIRS", buf);
181 s = e_util_env_get("XDG_CONFIG_DIRS");
182 snprintf(newpath, sizeof(newpath), "%s/etc/xdg", p);
185 if (!_xdg_check_str(s, newpath))
187 snprintf(buf, sizeof(buf), "%s:%s", newpath, s);
188 e_util_env_set("XDG_CONFIG_DIRS", buf);
194 snprintf(buf, sizeof(buf), "%s:/etc/xdg", newpath);
195 e_util_env_set("XDG_CONFIG_DIRS", buf);
198 s = e_util_env_get("XDG_RUNTIME_DIR");
205 snprintf(buf, sizeof(buf), "/tmp/xdg-XXXXXX");
207 if (!dir) dir = "/tmp";
210 e_util_env_set("XDG_RUNTIME_DIR", dir);
211 snprintf(buf, sizeof(buf), "%s/.e-deleteme", dir);
212 ecore_file_mkdir(buf);
216 /* set menu prefix so we get our e menu */
217 s = e_util_env_get("XDG_MENU_PREFIX");
221 e_util_env_set("XDG_MENU_PREFIX", "e-");
225 _e_main_subsystem_defer(void *data EINA_UNUSED)
227 TRACE_DS_BEGIN(MAIN:SUBSYSTEMS DEFER);
229 /* try to init delayed subsystems */
231 TRACE_DS_BEGIN(MAIN:DEFERRED INTERNAL SUBSYSTEMS INIT);
233 TSB("[DEFERRED] DPMS Init");
236 e_error_message_show(_("Enlightenment cannot set up dpms.\n"));
239 TSE("[DEFERRED] DPMS Init Done");
240 _e_main_shutdown_push(e_dpms_shutdown);
242 TSB("[DEFERRED] Screens Init: win");
245 e_error_message_show(_("Enlightenment cannot setup elementary trap!\n"));
248 TSE("[DEFERRED] Screens Init: win Done");
250 TSB("[DEFERRED] E_Dnd Init");
253 e_error_message_show(_("Enlightenment cannot set up its dnd system.\n"));
256 TSE("[DEFERRED] E_Dnd Init Done");
257 _e_main_shutdown_push(e_dnd_shutdown);
259 TSB("[DEFERRED] E_Scale Init");
262 e_error_message_show(_("Enlightenment cannot set up its scale system.\n"));
265 TSE("[DEFERRED] E_Scale Init Done");
266 _e_main_shutdown_push(e_scale_shutdown);
268 TSB("[DEFERRED] E_Test_Helper Init");
269 e_test_helper_init();
270 _e_main_shutdown_push(e_test_helper_shutdown);
271 TSE("[DEFERRED] E_Test_Helper Done");
273 TSB("[DEFERRED] E_INFO_SERVER Init");
274 e_info_server_init();
275 _e_main_shutdown_push(e_info_server_shutdown);
276 TSE("[DEFERRED] E_INFO_SERVER Done");
279 TRACE_DS_BEGIN(MAIN:DEFERRED COMP JOB);
281 /* try to do deferred job of any subsystems*/
282 TSB("[DEFERRED] Compositor's deferred job");
283 e_comp_deferred_job();
284 TSE("[DEFERRED] Compositor's deferred job Done");
286 if (e_config->use_e_policy)
288 TSB("[DEFERRED] E_Policy's deferred job");
289 e_policy_deferred_job();
290 TSE("[DEFERRED] E_Policy's deferred job Done");
293 TSB("[DEFERRED] E_Module's deferred job");
294 e_module_deferred_job();
295 TSE("[DEFERRED] E_Module's deferred job Done");
299 return ECORE_CALLBACK_DONE;
305 _e_main_shutdown(-1);
306 return ECORE_CALLBACK_DONE;
310 _e_main_deferred_job_schedule(void *d EINA_UNUSED, int type EINA_UNUSED, void *ev EINA_UNUSED)
312 PRCTL("[Winsys] all modules loaded");
313 ecore_idler_add(_e_main_subsystem_defer, NULL);
314 return ECORE_CALLBACK_DONE;
317 /* externally accessible functions */
319 main(int argc, char **argv)
322 struct sigaction action;
325 # ifdef PR_SET_PTRACER
326 # ifdef PR_SET_PTRACER_ANY
327 prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY);
332 #ifdef TIZEN_TEST_GCOV
333 setenv("GCOV_PREFIX", "/tmp", 1);
336 /* for debugging by redirecting stdout & stderr of e to a log file to tail */
337 setvbuf(stdout, NULL, _IONBF, 0);
338 setvbuf(stderr, NULL, _IONBF, 0);
341 t0 = t1 = t2 = ecore_time_unix_get();
342 printf("ESTART(main) %1.5f\n", t0);
344 TRACE_DS_BEGIN(MAIN:BEGIN STARTUP);
345 TSB("Begin Startup");
346 PRCTL("[Winsys] start of main");
348 /* trap deadly bug signals and allow some form of sane recovery */
349 /* or ability to gdb attach and debug at this point - better than your */
350 /* wm/desktop vanishing and not knowing what happened */
352 /* don't install SIGBUS handler */
353 /* Wayland shm sets up a sigbus handler for catching invalid shm region */
354 /* access. If we setup our sigbus handler here, then the wl-shm sigbus */
355 /* handler will not function properly */
356 s = e_util_env_get("NOTIFY_SOCKET");
362 action.sa_sigaction = e_sigseg_act;
363 action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
364 sigemptyset(&action.sa_mask);
365 sigaction(SIGSEGV, &action, NULL);
367 action.sa_sigaction = e_sigill_act;
368 action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
369 sigemptyset(&action.sa_mask);
370 sigaction(SIGILL, &action, NULL);
372 action.sa_sigaction = e_sigfpe_act;
373 action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
374 sigemptyset(&action.sa_mask);
375 sigaction(SIGFPE, &action, NULL);
377 action.sa_sigaction = e_sigabrt_act;
378 action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
379 sigemptyset(&action.sa_mask);
380 sigaction(SIGABRT, &action, NULL);
381 TSE("Signal Trap Done");
387 e_error_message_show(_("Enlightenment cannot initialize Eina!\n"));
390 TSE("Eina Init Done");
391 _e_main_shutdown_push(eina_shutdown);
393 #ifdef OBJECT_HASH_CHECK
394 TSB("E_Object Hash Init");
395 e_object_hash_init();
396 TSE("E_Object Hash Init Done");
402 e_error_message_show(_("Enlightenment could not create a logging domain!\n"));
405 TSE("E_Log Init Done");
406 _e_main_shutdown_push(e_log_shutdown);
408 TSB("Determine Prefix");
409 if (!e_prefix_determine(argv[0]))
412 "ERROR: Enlightenment cannot determine it's installed\n"
413 " prefix from the system or argv[0].\n"
414 " This is because it is not on Linux AND has been\n"
415 " executed strangely. This is unusual.\n");
417 TSE("Determine Prefix Done");
419 TSB("Parse Arguments");
420 _e_main_parse_arguments(argc, argv);
421 TSE("Parse Arguments Done");
423 /*** Initialize Core EFL Libraries We Need ***/
428 e_error_message_show(_("Enlightenment cannot initialize Eet!\n"));
431 TSE("Eet Init Done");
432 _e_main_shutdown_push(eet_shutdown);
434 /* Allow ecore to not load system modules.
435 * Without it ecore_init will block until dbus authentication
436 * and registration are complete.
438 ecore_app_no_system_modules();
443 e_error_message_show(_("Enlightenment cannot initialize Ecore!\n"));
446 TSE("Ecore Init Done");
447 _e_main_shutdown_push(ecore_shutdown);
452 e_error_message_show(_("Enlightenment cannot initialize EIO!\n"));
455 TSE("EIO Init Done");
456 _e_main_shutdown_push(eio_shutdown);
458 TSB("Ecore Event Handlers");
459 if (!ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT,
460 _e_main_cb_signal_exit, NULL))
462 e_error_message_show(_("Enlightenment cannot set up an exit signal handler.\n"
463 "Perhaps you are out of memory?"));
466 if (!ecore_event_handler_add(ECORE_EVENT_SIGNAL_HUP,
467 _e_main_cb_signal_hup, NULL))
469 e_error_message_show(_("Enlightenment cannot set up a HUP signal handler.\n"
470 "Perhaps you are out of memory?"));
473 TSE("Ecore Event Handlers Done");
475 TSB("Ecore_File Init");
476 if (!ecore_file_init())
478 e_error_message_show(_("Enlightenment cannot initialize Ecore_File!\n"));
481 TSE("Ecore_File Init Done");
482 _e_main_shutdown_push(ecore_file_shutdown);
484 TSB("E_Util_File_Monitor Init");
485 e_util_file_monitor_init();
486 TSE("E_Util_File_Monitor Init Done");
487 _e_main_shutdown_push(e_util_file_monitor_shutdown);
489 _idle_before = ecore_idle_enterer_before_add(_e_main_cb_idle_before, NULL);
491 TSB("XDG_DATA_DIRS Init");
492 _xdg_data_dirs_augment();
493 TSE("XDG_DATA_DIRS Init Done");
495 TSB("Ecore_Evas Init");
496 if (!ecore_evas_init())
498 e_error_message_show(_("Enlightenment cannot initialize Ecore_Evas!\n"));
501 TSE("Ecore_Evas Init Done");
506 e_error_message_show(_("Enlightenment cannot initialize Edje!\n"));
509 TSE("Edje Init Done");
510 _e_main_shutdown_push(edje_shutdown);
512 /*** Initialize E Subsystems We Need ***/
517 e_error_message_show(_("Enlightenment cannot set up user home path\n"));
520 TSE("E User Init Done");
521 _e_main_shutdown_push(e_user_shutdown);
523 TSB("E Directories Init");
524 /* setup directories we will be using for configurations storage etc. */
525 if (!_e_main_dirs_init())
527 e_error_message_show(_("Enlightenment cannot create directories in your home directory.\n"
528 "Perhaps you have no home directory or the disk is full?"));
531 TSE("E Directories Init Done");
532 _e_main_shutdown_push(_e_main_dirs_shutdown);
534 TSB("E_Config Init");
535 if (!e_config_init())
537 e_error_message_show(_("Enlightenment cannot set up its config system.\n"));
540 TSE("E_Config Init Done");
541 _e_main_shutdown_push(e_config_shutdown);
546 e_error_message_show(_("Enlightenment cannot set up its environment.\n"));
549 TSE("E_Env Init Done");
550 _e_main_shutdown_push(e_env_shutdown);
552 ecore_exe_run_priority_set(e_config->priority);
555 if (!_e_main_path_init())
557 e_error_message_show(_("Enlightenment cannot set up paths for finding files.\n"
558 "Perhaps you are out of memory?"));
561 TSE("E Paths Init Done");
562 _e_main_shutdown_push(_e_main_path_shutdown);
564 ecore_animator_frametime_set(1.0 / e_config->framerate);
569 e_error_message_show(_("Enlightenment cannot set up its theme system.\n"));
572 TSE("E_Theme Init Done");
573 _e_main_shutdown_push(e_theme_shutdown);
575 TSB("E_Actions Init");
576 if (!e_actions_init())
578 e_error_message_show(_("Enlightenment cannot set up its actions system.\n"));
581 TSE("E_Actions Init Done");
582 _e_main_shutdown_push(e_actions_shutdown);
584 /* these just add event handlers and can't fail
585 * timestamping them is dumb.
587 e_screensaver_preinit();
593 TRACE_DS_BEGIN(MAIN:WAIT /dev/dri/card0);
594 if (e_config->sleep_for_dri)
596 while(access("/dev/dri/card0", F_OK) != 0)
598 struct timespec req, rem;
600 req.tv_nsec = 50000000L;
601 nanosleep(&req, &rem);
609 e_error_message_show(_("Enlightenment cannot set up its msg system."));
612 TSE("E_Msg Init Done");
613 _e_main_shutdown_push(e_msg_shutdown);
615 e_module_event_init();
617 TSB("E_Pointer Init");
618 if (!e_pointer_init())
620 e_error_message_show(_("Enlightenment cannot set up its pointer system.\n"));
623 TSE("E_Pointer Init Done");
624 _e_main_shutdown_push(e_pointer_shutdown);
626 TRACE_DS_BEGIN(MAIN:SCREEN INIT);
628 if (!_e_main_screens_init())
630 e_error_message_show(_("Enlightenment set up window management for all the screens on your system\n"
631 "failed. Perhaps another window manager is running?\n"));
634 TSE("Screens Init Done");
635 _e_main_shutdown_push(_e_main_screens_shutdown);
638 TSB("E_Devicemgr Init");
639 if (!e_devicemgr_init())
641 e_error_message_show(_("Enlightenment cannot set up its device_manager system.\n"));
644 TSE("E_Devicemgr Init Done");
645 _e_main_shutdown_push(e_devicemgr_shutdown);
647 TSB("E_Keyrouter Init");
648 if (!e_keyrouter_init())
650 e_error_message_show(_("Enlightenment cannot set up its keyrouting system.\n"));
653 TSE("E_Keyrouter Init Done");
654 _e_main_shutdown_push(e_keyrouter_shutdown);
656 if (e_config->eom_enable)
661 e_error_message_show(_("Enlightenment cannot set up eom.\n"));
664 TSE("Eom Init Done");
665 _e_main_shutdown_push(e_eom_shutdown);
668 TSB("E_Screensaver Init");
669 if (!e_screensaver_init())
671 e_error_message_show(_("Enlightenment cannot configure the X screensaver.\n"));
674 TSE("E_Screensaver Init Done");
675 _e_main_shutdown_push(e_screensaver_shutdown);
677 TSB("E_Comp Freeze");
679 TSE("E_Comp Freeze Done");
681 TSB("E_Grabinput Init");
682 if (!e_grabinput_init())
684 e_error_message_show(_("Enlightenment cannot set up its grab input handling system.\n"));
687 TSE("E_Grabinput Init Done");
688 _e_main_shutdown_push(e_grabinput_shutdown);
690 TS("E_Gesture Init");
692 _e_main_shutdown_push(e_gesture_shutdown);
694 ecore_event_handler_add(E_EVENT_MODULE_INIT_END, _e_main_deferred_job_schedule, NULL);
696 TSB("E_Module Init");
697 if (!e_module_init())
699 e_error_message_show(_("Enlightenment cannot set up its module system.\n"));
702 TSE("E_Module Init Done");
703 _e_main_shutdown_push(e_module_shutdown);
706 if (!e_mouse_update())
708 e_error_message_show(_("Enlightenment cannot configure the mouse settings.\n"));
711 TSE("E_Mouse Init Done");
716 e_error_message_show(_("Enlightenment cannot initialize the Icon Cache system.\n"));
719 TSE("E_Icon Init Done");
720 _e_main_shutdown_push(e_icon_shutdown);
722 if (e_config->use_e_policy)
724 TSB("E_Policy Init");
725 if (!e_policy_init())
727 e_error_message_show(_("Enlightenment cannot setup policy system!\n"));
730 TSE("E_Policy Init Done");
731 _e_main_shutdown_push(e_policy_shutdown);
734 TSB("E_Process Init");
735 if (!e_process_init())
737 e_error_message_show(_("Enlightenment cannot setup process managing system!\n"));
740 TSE("E_Process Init Done");
741 _e_main_shutdown_push(e_process_shutdown);
743 TSB("E_Security Init");
744 if (!e_security_init())
746 e_error_message_show(_("Enlightenment cannot setup security system!\n"));
749 TSE("E_Security Init Done");
750 _e_main_shutdown_push(e_security_shutdown);
754 TSE("Load Modules Done");
758 TSE("E_Comp Thaw Done");
760 if (e_config->use_thread_max_cpu)
764 cpus = eina_cpu_count();
767 TSM("Set ecore thread max");
768 ecore_thread_max_set(cpus);
772 _idle_after = ecore_idle_enterer_add(_e_main_cb_idle_after, NULL);
774 starting = EINA_FALSE;
776 TSM("MAIN LOOP AT LAST");
778 if (e_config->create_wm_ready)
779 _e_main_create_wm_ready();
784 TSM("[WM] Send start-up completion");
785 sd_notify(0, "READY=1");
787 TSM("[WM] Skip sending start-up completion. (no systemd)");
789 ecore_main_loop_begin();
791 ELOGF("COMP", "STOPPING enlightenment...", NULL);
792 stopping = EINA_TRUE;
795 e_comp_internal_save();
806 _e_main_shutdown(-1);
810 e_main_ts(const char *str)
813 t1 = ecore_time_unix_get();
814 printf("ESTART: %1.5f [%1.5f] - %s\n", t1 - t0, t1 - t2, str);
821 e_main_ts_begin(const char *str)
823 TRACE_DS_BEGIN(ESTART: %s, str);
824 return e_main_ts(str);
828 e_main_ts_end(const char *str)
831 return e_main_ts(str);
834 /* local functions */
836 _e_main_shutdown(int errcode)
842 printf("E: Begin Shutdown Procedure!\n");
844 E_FREE_LIST(hooks, e_main_hook_del);
846 if (_idle_before) ecore_idle_enterer_del(_idle_before);
848 if (_idle_after) ecore_idle_enterer_del(_idle_after);
851 dir = e_util_env_get("XDG_RUNTIME_DIR");
854 char buf_env[PATH_MAX - 12];
855 snprintf(buf_env, sizeof(buf_env), "%s", dir);
856 snprintf(buf, sizeof(buf), "%s/.e-deleteme", buf_env);
857 if (ecore_file_exists(buf)) ecore_file_recursive_rm(buf_env);
860 for (i = (_e_main_lvl - 1); i >= 0; i--)
861 (*_e_main_shutdown_func[i])();
862 #ifdef OBJECT_HASH_CHECK
863 e_object_hash_shutdown();
865 if (errcode < 0) exit(errcode);
869 _e_main_shutdown_push(int (*func)(void))
872 if (_e_main_lvl > MAX_LEVEL)
875 e_error_message_show("WARNING: too many init levels. MAX = %i\n",
879 _e_main_shutdown_func[_e_main_lvl - 1] = func;
883 _e_main_parse_arguments(int argc, char **argv)
887 /* handle some command-line parameters */
888 for (i = 1; i < argc; i++)
890 if ((!strcmp(argv[i], "-profile")) && (i < (argc - 1)))
893 if (!getenv("E_CONF_PROFILE"))
894 e_util_env_set("E_CONF_PROFILE", argv[i]);
896 else if ((!strcmp(argv[i], "-version")) ||
897 (!strcmp(argv[i], "--version")))
899 printf(_("Version: %s\n"), PACKAGE_VERSION);
900 _e_main_shutdown(-1);
902 else if ((!strcmp(argv[i], "-h")) ||
903 (!strcmp(argv[i], "-help")) ||
904 (!strcmp(argv[i], "--help")))
909 "\t-profile CONF_PROFILE\n"
910 "\t\tUse the configuration profile CONF_PROFILE instead of the user selected default or just \"default\".\n"
914 _e_main_shutdown(-1);
920 _e_main_cb_signal_exit(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *ev EINA_UNUSED)
922 /* called on ctrl-c, kill (pid) (also SIGINT, SIGTERM and SIGQIT) */
923 ecore_main_loop_quit();
924 return ECORE_CALLBACK_RENEW;
928 _e_main_cb_signal_hup(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *ev EINA_UNUSED)
930 ecore_main_loop_quit();
931 return ECORE_CALLBACK_RENEW;
935 _e_main_dirs_init(void)
937 if(getenv("E_CONF_RO"))
951 base = e_user_dir_get();
952 if (ecore_file_mksubdirs(base, dirs) != sizeof(dirs) / sizeof(dirs[0]) - 1)
954 e_error_message_show("Could not create one of the required "
955 "subdirectories of '%s'\n", base);
963 _e_main_dirs_shutdown(void)
969 _e_main_path_init(void)
973 /* setup data paths */
974 path_data = e_path_new();
977 e_error_message_show("Cannot allocate path for path_data\n");
980 e_prefix_data_concat_static(buf, "data");
981 e_path_default_path_append(path_data, buf);
983 /* setup image paths */
984 path_images = e_path_new();
987 e_error_message_show("Cannot allocate path for path_images\n");
990 e_user_dir_concat_static(buf, "/images");
991 e_path_default_path_append(path_images, buf);
992 e_prefix_data_concat_static(buf, "data/images");
993 e_path_default_path_append(path_images, buf);
995 /* setup font paths */
996 path_fonts = e_path_new();
999 e_error_message_show("Cannot allocate path for path_fonts\n");
1002 e_user_dir_concat_static(buf, "/fonts");
1003 e_path_default_path_append(path_fonts, buf);
1004 e_prefix_data_concat_static(buf, "data/fonts");
1005 e_path_default_path_append(path_fonts, buf);
1007 /* setup icon paths */
1008 path_icons = e_path_new();
1011 e_error_message_show("Cannot allocate path for path_icons\n");
1014 e_user_dir_concat_static(buf, "/icons");
1015 e_path_default_path_append(path_icons, buf);
1016 e_prefix_data_concat_static(buf, "data/icons");
1017 e_path_default_path_append(path_icons, buf);
1019 /* setup module paths */
1020 path_modules = e_path_new();
1023 e_error_message_show("Cannot allocate path for path_modules\n");
1026 e_user_dir_concat_static(buf, "/modules");
1027 e_path_default_path_append(path_modules, buf);
1028 snprintf(buf, sizeof(buf), "%s/enlightenment/modules", e_prefix_lib_get());
1029 e_path_default_path_append(path_modules, buf);
1030 /* FIXME: eventually this has to go - moduels should have installers that
1031 * add appropriate install paths (if not installed to user homedir) to
1032 * e's module search dirs
1034 snprintf(buf, sizeof(buf), "%s/enlightenment/modules_extra", e_prefix_lib_get());
1035 e_path_default_path_append(path_modules, buf);
1037 /* setup background paths */
1038 path_backgrounds = e_path_new();
1039 if (!path_backgrounds)
1041 e_error_message_show("Cannot allocate path for path_backgrounds\n");
1044 e_user_dir_concat_static(buf, "/backgrounds");
1045 e_path_default_path_append(path_backgrounds, buf);
1046 e_prefix_data_concat_static(buf, "data/backgrounds");
1047 e_path_default_path_append(path_backgrounds, buf);
1049 path_messages = e_path_new();
1052 e_error_message_show("Cannot allocate path for path_messages\n");
1055 e_user_dir_concat_static(buf, "/locale");
1056 e_path_default_path_append(path_messages, buf);
1057 e_path_default_path_append(path_messages, e_prefix_locale_get());
1063 _e_main_path_shutdown(void)
1067 e_object_del(E_OBJECT(path_data));
1072 e_object_del(E_OBJECT(path_images));
1077 e_object_del(E_OBJECT(path_fonts));
1082 e_object_del(E_OBJECT(path_icons));
1087 e_object_del(E_OBJECT(path_modules));
1088 path_modules = NULL;
1090 if (path_backgrounds)
1092 e_object_del(E_OBJECT(path_backgrounds));
1093 path_backgrounds = NULL;
1097 e_object_del(E_OBJECT(path_messages));
1098 path_messages = NULL;
1104 _e_main_screens_init(void)
1106 TSB("\tscreens: client");
1107 if (!e_client_init()) return 0;
1108 TSE("\tscreens: client Done");
1110 TSB("Compositor Init");
1111 PRCTL("[Winsys] start of compositor init");
1114 e_error_message_show(_("Enlightenment cannot create a compositor.\n"));
1115 _e_main_shutdown(-1);
1117 TSE("Compositor Init Done");
1119 PRCTL("[Winsys] end of compositor init");
1120 _e_main_desk_restore();
1126 _e_main_screens_shutdown(void)
1130 e_client_shutdown();
1132 e_magnifier_shutdown();
1140 _e_main_desk_save(void)
1143 char env[1024], name[1024];
1146 EINA_LIST_FOREACH(e_comp->zones, l, zone)
1148 snprintf(name, sizeof(name), "DESK_%d_%d", 0, zone->num);
1149 snprintf(env, sizeof(env), "%d,%d", zone->desk_x_current, zone->desk_y_current);
1150 e_util_env_set(name, env);
1155 _e_main_desk_restore(void)
1159 E_CLIENT_REVERSE_FOREACH(ec)
1160 if ((!e_client_util_ignored_get(ec)) && e_client_util_desk_visible(ec, e_desk_current_get(ec->zone)))
1162 ec->want_focus = ec->take_focus = 1;
1168 _e_main_cb_idle_before(void *data EINA_UNUSED)
1170 e_client_idler_before();
1172 return ECORE_CALLBACK_RENEW;
1176 _e_main_cb_idle_after(void *data EINA_UNUSED)
1178 static int first_idle = 1;
1189 return ECORE_CALLBACK_RENEW;
1193 _e_main_create_wm_ready(void)
1195 FILE *_wmready_checker = NULL;
1196 const char *path_wm_ready = "/run/.wm_ready";
1198 if (!e_util_file_realpath_check(path_wm_ready, EINA_TRUE))
1200 WRN("%s is maybe link, so delete it\n", path_wm_ready);
1203 _wmready_checker = fopen(path_wm_ready, "wb");
1204 if (_wmready_checker)
1206 TSM("[WM] WINDOW MANAGER is READY!!!");
1207 PRCTL("[Winsys] WINDOW MANAGER is READY!!!");
1208 fclose(_wmready_checker);
1210 /*TODO: Next lines should be removed. */
1211 FILE *_tmp_wm_ready_checker;
1213 _tmp_wm_ready_checker = fopen(path_wm_ready, "wb");
1215 if (_tmp_wm_ready_checker)
1217 TSM("[WM] temporary wm_ready path is created.");
1218 PRCTL("[Winsys] temporary wm_ready path is created.");
1219 fclose(_tmp_wm_ready_checker);
1223 TSM("[WM] temporary wm_ready path create failed.");
1224 PRCTL("[Winsys] temporary wm_ready path create failed.");
1229 TSM("[WM] WINDOW MANAGER is READY. BUT, failed to create .wm_ready file.");
1230 PRCTL("[Winsys] WINDOW MANAGER is READY. BUT, failed to create .wm_ready file.");
1235 _e_main_hooks_clean(void)
1241 for (x = 0; x < E_MAIN_HOOK_LAST; x++)
1242 EINA_INLIST_FOREACH_SAFE(_e_main_hooks[x], l, mh)
1244 if (!mh->delete_me) continue;
1245 _e_main_hooks[x] = eina_inlist_remove(_e_main_hooks[x],
1246 EINA_INLIST_GET(mh));
1252 _e_main_hook_call(E_Main_Hook_Point hookpoint, void *data EINA_UNUSED)
1256 _e_main_hooks_walking++;
1257 EINA_INLIST_FOREACH(_e_main_hooks[hookpoint], mh)
1259 if (mh->delete_me) continue;
1262 _e_main_hooks_walking--;
1263 if ((_e_main_hooks_walking == 0) && (_e_main_hooks_delete > 0))
1264 _e_main_hooks_clean();
1268 e_main_hook_add(E_Main_Hook_Point hookpoint, E_Main_Hook_Cb func, const void *data)
1272 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_MAIN_HOOK_LAST, NULL);
1273 mh = E_NEW(E_Main_Hook, 1);
1274 EINA_SAFETY_ON_NULL_RETURN_VAL(mh, NULL);
1275 mh->hookpoint = hookpoint;
1277 mh->data = (void*)data;
1278 _e_main_hooks[hookpoint] = eina_inlist_append(_e_main_hooks[hookpoint],
1279 EINA_INLIST_GET(mh));
1284 e_main_hook_del(E_Main_Hook *mh)
1287 if (_e_main_hooks_walking == 0)
1289 _e_main_hooks[mh->hookpoint] = eina_inlist_remove(_e_main_hooks[mh->hookpoint],
1290 EINA_INLIST_GET(mh));
1294 _e_main_hooks_delete++;
1298 e_main_hook_call(E_Main_Hook_Point hookpoint)
1300 if ((hookpoint < 0) || (hookpoint >= E_MAIN_HOOK_LAST)) return;
1302 _e_main_hook_call(hookpoint, NULL);