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[4096], buf[4096];
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 t0 = t1 = t2 = ecore_time_unix_get();
333 printf("ESTART(main) %1.5f\n", t0);
335 TRACE_DS_BEGIN(MAIN:BEGIN STARTUP);
336 TSB("Begin Startup");
337 PRCTL("[Winsys] start of main");
339 /* trap deadly bug signals and allow some form of sane recovery */
340 /* or ability to gdb attach and debug at this point - better than your */
341 /* wm/desktop vanishing and not knowing what happened */
343 /* don't install SIGBUS handler */
344 /* Wayland shm sets up a sigbus handler for catching invalid shm region */
345 /* access. If we setup our sigbus handler here, then the wl-shm sigbus */
346 /* handler will not function properly */
347 s = e_util_env_get("NOTIFY_SOCKET");
353 action.sa_sigaction = e_sigseg_act;
354 action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
355 sigemptyset(&action.sa_mask);
356 sigaction(SIGSEGV, &action, NULL);
358 action.sa_sigaction = e_sigill_act;
359 action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
360 sigemptyset(&action.sa_mask);
361 sigaction(SIGILL, &action, NULL);
363 action.sa_sigaction = e_sigfpe_act;
364 action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
365 sigemptyset(&action.sa_mask);
366 sigaction(SIGFPE, &action, NULL);
368 action.sa_sigaction = e_sigabrt_act;
369 action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
370 sigemptyset(&action.sa_mask);
371 sigaction(SIGABRT, &action, NULL);
372 TSE("Signal Trap Done");
378 e_error_message_show(_("Enlightenment cannot initialize Eina!\n"));
381 TSE("Eina Init Done");
382 _e_main_shutdown_push(eina_shutdown);
384 #ifdef OBJECT_HASH_CHECK
385 TSB("E_Object Hash Init");
386 e_object_hash_init();
387 TSE("E_Object Hash Init Done");
393 e_error_message_show(_("Enlightenment could not create a logging domain!\n"));
396 TSE("E_Log Init Done");
397 _e_main_shutdown_push(e_log_shutdown);
399 TSB("Determine Prefix");
400 if (!e_prefix_determine(argv[0]))
403 "ERROR: Enlightenment cannot determine it's installed\n"
404 " prefix from the system or argv[0].\n"
405 " This is because it is not on Linux AND has been\n"
406 " executed strangely. This is unusual.\n");
408 TSE("Determine Prefix Done");
410 /* for debugging by redirecting stdout of e to a log file to tail */
411 setvbuf(stdout, NULL, _IONBF, 0);
413 TSB("Parse Arguments");
414 _e_main_parse_arguments(argc, argv);
415 TSE("Parse Arguments Done");
417 /*** Initialize Core EFL Libraries We Need ***/
422 e_error_message_show(_("Enlightenment cannot initialize Eet!\n"));
425 TSE("Eet Init Done");
426 _e_main_shutdown_push(eet_shutdown);
428 /* Allow ecore to not load system modules.
429 * Without it ecore_init will block until dbus authentication
430 * and registration are complete.
432 ecore_app_no_system_modules();
437 e_error_message_show(_("Enlightenment cannot initialize Ecore!\n"));
440 TSE("Ecore Init Done");
441 _e_main_shutdown_push(ecore_shutdown);
446 e_error_message_show(_("Enlightenment cannot initialize EIO!\n"));
449 TSE("EIO Init Done");
450 _e_main_shutdown_push(eio_shutdown);
452 TSB("Ecore Event Handlers");
453 if (!ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT,
454 _e_main_cb_signal_exit, NULL))
456 e_error_message_show(_("Enlightenment cannot set up an exit signal handler.\n"
457 "Perhaps you are out of memory?"));
460 if (!ecore_event_handler_add(ECORE_EVENT_SIGNAL_HUP,
461 _e_main_cb_signal_hup, NULL))
463 e_error_message_show(_("Enlightenment cannot set up a HUP signal handler.\n"
464 "Perhaps you are out of memory?"));
467 TSE("Ecore Event Handlers Done");
469 TSB("Ecore_File Init");
470 if (!ecore_file_init())
472 e_error_message_show(_("Enlightenment cannot initialize Ecore_File!\n"));
475 TSE("Ecore_File Init Done");
476 _e_main_shutdown_push(ecore_file_shutdown);
478 TSB("E_Util_File_Monitor Init");
479 e_util_file_monitor_init();
480 TSE("E_Util_File_Monitor Init Done");
481 _e_main_shutdown_push(e_util_file_monitor_shutdown);
483 _idle_before = ecore_idle_enterer_before_add(_e_main_cb_idle_before, NULL);
485 TSB("XDG_DATA_DIRS Init");
486 _xdg_data_dirs_augment();
487 TSE("XDG_DATA_DIRS Init Done");
489 TSB("Ecore_Evas Init");
490 if (!ecore_evas_init())
492 e_error_message_show(_("Enlightenment cannot initialize Ecore_Evas!\n"));
495 TSE("Ecore_Evas Init Done");
497 /* e doesn't sync to compositor - it should be one */
498 ecore_evas_app_comp_sync_set(0);
503 e_error_message_show(_("Enlightenment cannot initialize Edje!\n"));
506 TSE("Edje Init Done");
507 _e_main_shutdown_push(edje_shutdown);
509 /*** Initialize E Subsystems We Need ***/
514 e_error_message_show(_("Enlightenment cannot set up user home path\n"));
517 TSE("E User Init Done");
518 _e_main_shutdown_push(e_user_shutdown);
520 TSB("E Directories Init");
521 /* setup directories we will be using for configurations storage etc. */
522 if (!_e_main_dirs_init())
524 e_error_message_show(_("Enlightenment cannot create directories in your home directory.\n"
525 "Perhaps you have no home directory or the disk is full?"));
528 TSE("E Directories Init Done");
529 _e_main_shutdown_push(_e_main_dirs_shutdown);
531 TSB("E_Config Init");
532 if (!e_config_init())
534 e_error_message_show(_("Enlightenment cannot set up its config system.\n"));
537 TSE("E_Config Init Done");
538 _e_main_shutdown_push(e_config_shutdown);
543 e_error_message_show(_("Enlightenment cannot set up its environment.\n"));
546 TSE("E_Env Init Done");
547 _e_main_shutdown_push(e_env_shutdown);
549 ecore_exe_run_priority_set(e_config->priority);
552 if (!_e_main_path_init())
554 e_error_message_show(_("Enlightenment cannot set up paths for finding files.\n"
555 "Perhaps you are out of memory?"));
558 TSE("E Paths Init Done");
559 _e_main_shutdown_push(_e_main_path_shutdown);
561 ecore_animator_frametime_set(1.0 / e_config->framerate);
566 e_error_message_show(_("Enlightenment cannot set up its theme system.\n"));
569 TSE("E_Theme Init Done");
570 _e_main_shutdown_push(e_theme_shutdown);
572 TSB("E_Actions Init");
573 if (!e_actions_init())
575 e_error_message_show(_("Enlightenment cannot set up its actions system.\n"));
578 TSE("E_Actions Init Done");
579 _e_main_shutdown_push(e_actions_shutdown);
581 /* these just add event handlers and can't fail
582 * timestamping them is dumb.
584 e_screensaver_preinit();
589 TRACE_DS_BEGIN(MAIN:WAIT /dev/dri/card0);
590 if (e_config->sleep_for_dri)
592 while(access("/dev/dri/card0", F_OK) != 0)
594 struct timespec req, rem;
596 req.tv_nsec = 50000000L;
597 nanosleep(&req, &rem);
602 e_module_event_init();
604 TSB("E_Pointer Init");
605 if (!e_pointer_init())
607 e_error_message_show(_("Enlightenment cannot set up its pointer system.\n"));
610 TSE("E_Pointer Init Done");
611 _e_main_shutdown_push(e_pointer_shutdown);
613 TRACE_DS_BEGIN(MAIN:SCREEN INIT);
615 if (!_e_main_screens_init())
617 e_error_message_show(_("Enlightenment set up window management for all the screens on your system\n"
618 "failed. Perhaps another window manager is running?\n"));
621 TSE("Screens Init Done");
622 _e_main_shutdown_push(_e_main_screens_shutdown);
625 TSB("E_Keyrouter Init");
626 if (!e_keyrouter_init())
628 e_error_message_show(_("Enlightenment cannot set up its keyrouting system.\n"));
631 TSE("E_Keyrouter Init Done");
632 _e_main_shutdown_push(e_keyrouter_shutdown);
634 if (e_config->eom_enable)
639 e_error_message_show(_("Enlightenment cannot set up eom.\n"));
642 TSE("Eom Init Done");
643 _e_main_shutdown_push(e_eom_shutdown);
646 TSB("E_Screensaver Init");
647 if (!e_screensaver_init())
649 e_error_message_show(_("Enlightenment cannot configure the X screensaver.\n"));
652 TSE("E_Screensaver Init Done");
653 _e_main_shutdown_push(e_screensaver_shutdown);
655 TSB("E_Comp Freeze");
657 TSE("E_Comp Freeze Done");
659 TSB("E_Grabinput Init");
660 if (!e_grabinput_init())
662 e_error_message_show(_("Enlightenment cannot set up its grab input handling system.\n"));
665 TSE("E_Grabinput Init Done");
666 _e_main_shutdown_push(e_grabinput_shutdown);
668 TS("E_Gesture Init");
670 _e_main_shutdown_push(e_gesture_shutdown);
672 ecore_event_handler_add(E_EVENT_MODULE_INIT_END, _e_main_deferred_job_schedule, NULL);
674 TSB("E_Module Init");
675 if (!e_module_init())
677 e_error_message_show(_("Enlightenment cannot set up its module system.\n"));
680 TSE("E_Module Init Done");
681 _e_main_shutdown_push(e_module_shutdown);
684 if (!e_mouse_update())
686 e_error_message_show(_("Enlightenment cannot configure the mouse settings.\n"));
689 TSE("E_Mouse Init Done");
694 e_error_message_show(_("Enlightenment cannot initialize the Icon Cache system.\n"));
697 TSE("E_Icon Init Done");
698 _e_main_shutdown_push(e_icon_shutdown);
700 if (e_config->use_e_policy)
702 TSB("E_Policy Init");
703 if (!e_policy_init())
705 e_error_message_show(_("Enlightenment cannot setup policy system!\n"));
708 TSE("E_Policy Init Done");
709 _e_main_shutdown_push(e_policy_shutdown);
712 TSB("E_Process Init");
713 if (!e_process_init())
715 e_error_message_show(_("Enlightenment cannot setup process managing system!\n"));
718 TSE("E_Process Init Done");
719 _e_main_shutdown_push(e_process_shutdown);
721 TSB("E_Security Init");
722 if (!e_security_init())
724 e_error_message_show(_("Enlightenment cannot setup security system!\n"));
727 TSE("E_Security Init Done");
728 _e_main_shutdown_push(e_security_shutdown);
732 TSE("Load Modules Done");
736 TSE("E_Comp Thaw Done");
738 _idle_after = ecore_idle_enterer_add(_e_main_cb_idle_after, NULL);
740 starting = EINA_FALSE;
742 TSM("MAIN LOOP AT LAST");
744 if (e_config->create_wm_ready)
745 _e_main_create_wm_ready();
750 TSM("[WM] Send start-up completion");
751 sd_notify(0, "READY=1");
753 TSM("[WM] Skip sending start-up completion. (no systemd)");
755 ecore_main_loop_begin();
757 ELOGF("COMP", "STOPPING enlightenment...", NULL, NULL);
758 stopping = EINA_TRUE;
761 e_comp_internal_save();
772 _e_main_shutdown(-1);
776 e_main_ts(const char *str)
779 t1 = ecore_time_unix_get();
780 printf("ESTART: %1.5f [%1.5f] - %s\n", t1 - t0, t1 - t2, str);
787 e_main_ts_begin(const char *str)
789 TRACE_DS_BEGIN(ESTART: %s, str);
790 return e_main_ts(str);
794 e_main_ts_end(const char *str)
797 return e_main_ts(str);
800 /* local functions */
802 _e_main_shutdown(int errcode)
808 printf("E: Begin Shutdown Procedure!\n");
810 E_FREE_LIST(hooks, e_main_hook_del);
812 if (_idle_before) ecore_idle_enterer_del(_idle_before);
814 if (_idle_after) ecore_idle_enterer_del(_idle_after);
817 dir = e_util_env_get("XDG_RUNTIME_DIR");
820 char buf_env[PATH_MAX];
821 snprintf(buf_env, sizeof(buf_env), "%s", dir);
822 snprintf(buf, sizeof(buf), "%s/.e-deleteme", buf_env);
823 if (ecore_file_exists(buf)) ecore_file_recursive_rm(buf_env);
826 for (i = (_e_main_lvl - 1); i >= 0; i--)
827 (*_e_main_shutdown_func[i])();
828 #ifdef OBJECT_HASH_CHECK
829 e_object_hash_shutdown();
831 if (errcode < 0) exit(errcode);
835 _e_main_shutdown_push(int (*func)(void))
838 if (_e_main_lvl > MAX_LEVEL)
841 e_error_message_show("WARNING: too many init levels. MAX = %i\n",
845 _e_main_shutdown_func[_e_main_lvl - 1] = func;
849 _e_main_parse_arguments(int argc, char **argv)
853 /* handle some command-line parameters */
854 for (i = 1; i < argc; i++)
856 if ((!strcmp(argv[i], "-profile")) && (i < (argc - 1)))
859 if (!getenv("E_CONF_PROFILE"))
860 e_util_env_set("E_CONF_PROFILE", argv[i]);
862 else if ((!strcmp(argv[i], "-version")) ||
863 (!strcmp(argv[i], "--version")))
865 printf(_("Version: %s\n"), PACKAGE_VERSION);
866 _e_main_shutdown(-1);
868 else if ((!strcmp(argv[i], "-h")) ||
869 (!strcmp(argv[i], "-help")) ||
870 (!strcmp(argv[i], "--help")))
875 "\t-profile CONF_PROFILE\n"
876 "\t\tUse the configuration profile CONF_PROFILE instead of the user selected default or just \"default\".\n"
880 _e_main_shutdown(-1);
886 _e_main_cb_signal_exit(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *ev EINA_UNUSED)
888 /* called on ctrl-c, kill (pid) (also SIGINT, SIGTERM and SIGQIT) */
889 ecore_main_loop_quit();
890 return ECORE_CALLBACK_RENEW;
894 _e_main_cb_signal_hup(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *ev EINA_UNUSED)
896 ecore_main_loop_quit();
897 return ECORE_CALLBACK_RENEW;
901 _e_main_dirs_init(void)
903 if(getenv("E_CONF_RO"))
917 base = e_user_dir_get();
918 if (ecore_file_mksubdirs(base, dirs) != sizeof(dirs) / sizeof(dirs[0]) - 1)
920 e_error_message_show("Could not create one of the required "
921 "subdirectories of '%s'\n", base);
929 _e_main_dirs_shutdown(void)
935 _e_main_path_init(void)
939 /* setup data paths */
940 path_data = e_path_new();
943 e_error_message_show("Cannot allocate path for path_data\n");
946 e_prefix_data_concat_static(buf, "data");
947 e_path_default_path_append(path_data, buf);
949 /* setup image paths */
950 path_images = e_path_new();
953 e_error_message_show("Cannot allocate path for path_images\n");
956 e_user_dir_concat_static(buf, "/images");
957 e_path_default_path_append(path_images, buf);
958 e_prefix_data_concat_static(buf, "data/images");
959 e_path_default_path_append(path_images, buf);
961 /* setup font paths */
962 path_fonts = e_path_new();
965 e_error_message_show("Cannot allocate path for path_fonts\n");
968 e_user_dir_concat_static(buf, "/fonts");
969 e_path_default_path_append(path_fonts, buf);
970 e_prefix_data_concat_static(buf, "data/fonts");
971 e_path_default_path_append(path_fonts, buf);
973 /* setup icon paths */
974 path_icons = e_path_new();
977 e_error_message_show("Cannot allocate path for path_icons\n");
980 e_user_dir_concat_static(buf, "/icons");
981 e_path_default_path_append(path_icons, buf);
982 e_prefix_data_concat_static(buf, "data/icons");
983 e_path_default_path_append(path_icons, buf);
985 /* setup module paths */
986 path_modules = e_path_new();
989 e_error_message_show("Cannot allocate path for path_modules\n");
992 e_user_dir_concat_static(buf, "/modules");
993 e_path_default_path_append(path_modules, buf);
994 snprintf(buf, sizeof(buf), "%s/enlightenment/modules", e_prefix_lib_get());
995 e_path_default_path_append(path_modules, buf);
996 /* FIXME: eventually this has to go - moduels should have installers that
997 * add appropriate install paths (if not installed to user homedir) to
998 * e's module search dirs
1000 snprintf(buf, sizeof(buf), "%s/enlightenment/modules_extra", e_prefix_lib_get());
1001 e_path_default_path_append(path_modules, buf);
1003 /* setup background paths */
1004 path_backgrounds = e_path_new();
1005 if (!path_backgrounds)
1007 e_error_message_show("Cannot allocate path for path_backgrounds\n");
1010 e_user_dir_concat_static(buf, "/backgrounds");
1011 e_path_default_path_append(path_backgrounds, buf);
1012 e_prefix_data_concat_static(buf, "data/backgrounds");
1013 e_path_default_path_append(path_backgrounds, buf);
1015 path_messages = e_path_new();
1018 e_error_message_show("Cannot allocate path for path_messages\n");
1021 e_user_dir_concat_static(buf, "/locale");
1022 e_path_default_path_append(path_messages, buf);
1023 e_path_default_path_append(path_messages, e_prefix_locale_get());
1029 _e_main_path_shutdown(void)
1033 e_object_del(E_OBJECT(path_data));
1038 e_object_del(E_OBJECT(path_images));
1043 e_object_del(E_OBJECT(path_fonts));
1048 e_object_del(E_OBJECT(path_icons));
1053 e_object_del(E_OBJECT(path_modules));
1054 path_modules = NULL;
1056 if (path_backgrounds)
1058 e_object_del(E_OBJECT(path_backgrounds));
1059 path_backgrounds = NULL;
1063 e_object_del(E_OBJECT(path_messages));
1064 path_messages = NULL;
1070 _e_main_screens_init(void)
1072 TSB("\tscreens: client");
1073 if (!e_client_init()) return 0;
1074 TSE("\tscreens: client Done");
1076 TSB("Compositor Init");
1077 PRCTL("[Winsys] start of compositor init");
1080 e_error_message_show(_("Enlightenment cannot create a compositor.\n"));
1081 _e_main_shutdown(-1);
1083 TSE("Compositor Init Done");
1085 PRCTL("[Winsys] end of compositor init");
1086 _e_main_desk_restore();
1092 _e_main_screens_shutdown(void)
1096 e_client_shutdown();
1105 _e_main_desk_save(void)
1108 char env[1024], name[1024];
1111 EINA_LIST_FOREACH(e_comp->zones, l, zone)
1113 snprintf(name, sizeof(name), "DESK_%d_%d", 0, zone->num);
1114 snprintf(env, sizeof(env), "%d,%d", zone->desk_x_current, zone->desk_y_current);
1115 e_util_env_set(name, env);
1120 _e_main_desk_restore(void)
1124 E_CLIENT_REVERSE_FOREACH(ec)
1125 if ((!e_client_util_ignored_get(ec)) && e_client_util_desk_visible(ec, e_desk_current_get(ec->zone)))
1127 ec->want_focus = ec->take_focus = 1;
1133 _e_main_cb_idle_before(void *data EINA_UNUSED)
1135 e_client_idler_before();
1137 return ECORE_CALLBACK_RENEW;
1141 _e_main_cb_idle_after(void *data EINA_UNUSED)
1143 static int first_idle = 1;
1154 return ECORE_CALLBACK_RENEW;
1158 _e_main_create_wm_ready(void)
1160 FILE *_wmready_checker = NULL;
1161 const char *path_wm_ready = "/run/.wm_ready";
1163 if (!e_util_file_realpath_check(path_wm_ready, EINA_TRUE))
1165 WRN("%s is maybe link, so delete it\n", path_wm_ready);
1168 _wmready_checker = fopen(path_wm_ready, "wb");
1169 if (_wmready_checker)
1171 TSM("[WM] WINDOW MANAGER is READY!!!");
1172 PRCTL("[Winsys] WINDOW MANAGER is READY!!!");
1173 fclose(_wmready_checker);
1175 /*TODO: Next lines should be removed. */
1176 FILE *_tmp_wm_ready_checker;
1178 _tmp_wm_ready_checker = fopen(path_wm_ready, "wb");
1180 if (_tmp_wm_ready_checker)
1182 TSM("[WM] temporary wm_ready path is created.");
1183 PRCTL("[Winsys] temporary wm_ready path is created.");
1184 fclose(_tmp_wm_ready_checker);
1188 TSM("[WM] temporary wm_ready path create failed.");
1189 PRCTL("[Winsys] temporary wm_ready path create failed.");
1194 TSM("[WM] WINDOW MANAGER is READY. BUT, failed to create .wm_ready file.");
1195 PRCTL("[Winsys] WINDOW MANAGER is READY. BUT, failed to create .wm_ready file.");
1200 _e_main_hooks_clean(void)
1206 for (x = 0; x < E_MAIN_HOOK_LAST; x++)
1207 EINA_INLIST_FOREACH_SAFE(_e_main_hooks[x], l, mh)
1209 if (!mh->delete_me) continue;
1210 _e_main_hooks[x] = eina_inlist_remove(_e_main_hooks[x],
1211 EINA_INLIST_GET(mh));
1217 _e_main_hook_call(E_Main_Hook_Point hookpoint, void *data EINA_UNUSED)
1221 _e_main_hooks_walking++;
1222 EINA_INLIST_FOREACH(_e_main_hooks[hookpoint], mh)
1224 if (mh->delete_me) continue;
1227 _e_main_hooks_walking--;
1228 if ((_e_main_hooks_walking == 0) && (_e_main_hooks_delete > 0))
1229 _e_main_hooks_clean();
1233 e_main_hook_add(E_Main_Hook_Point hookpoint, E_Main_Hook_Cb func, const void *data)
1237 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_MAIN_HOOK_LAST, NULL);
1238 mh = E_NEW(E_Main_Hook, 1);
1239 EINA_SAFETY_ON_NULL_RETURN_VAL(mh, NULL);
1240 mh->hookpoint = hookpoint;
1242 mh->data = (void*)data;
1243 _e_main_hooks[hookpoint] = eina_inlist_append(_e_main_hooks[hookpoint],
1244 EINA_INLIST_GET(mh));
1249 e_main_hook_del(E_Main_Hook *mh)
1252 if (_e_main_hooks_walking == 0)
1254 _e_main_hooks[mh->hookpoint] = eina_inlist_remove(_e_main_hooks[mh->hookpoint],
1255 EINA_INLIST_GET(mh));
1259 _e_main_hooks_delete++;
1263 e_main_hook_call(E_Main_Hook_Point hookpoint)
1265 if ((hookpoint < 0) || (hookpoint >= E_MAIN_HOOK_LAST)) return;
1267 _e_main_hook_call(hookpoint, NULL);