2 #include "e_actions_intern.h"
3 #include "e_test_helper_intern.h"
4 #include "e_user_intern.h"
5 #include "e_utils_intern.h"
6 #include "e_theme_intern.h"
7 #include "e_signals_intern.h"
8 #include "e_security_intern.h"
9 #include "e_screensaver_intern.h"
10 #include "e_scale_intern.h"
11 #include "e_process_intern.h"
12 #include "e_comp_canvas_intern.h"
13 #include "e_comp_intern.h"
14 #include "e_prefix_intern.h"
15 #include "e_config_intern.h"
16 #include "e_keyrouter_intern.h"
17 #include "e_info_server_intern.h"
18 #include "e_icon_intern.h"
19 #include "e_devicemgr_intern.h"
22 # include <sys/prctl.h>
25 # include <systemd/sd-daemon.h>
34 t1 = ecore_time_unix_get(); \
35 printf("ESTART: %1.5f [%1.5f] - %s\n", t1 - t0, t1 - t2, x); \
41 TRACE_DS_BEGIN(ESTART: %s, x); \
51 TRACE_DS_MARK(ESTART: %s, x); \
54 static double t0, t1, t2;
62 * i need to make more use of these when i'm baffled as to when something is
65 * void *(*__malloc_hook)(size_t size, const void *caller);
67 * void *(*__realloc_hook)(void *ptr, size_t size, const void *caller);
69 * void *(*__memalign_hook)(size_t alignment, size_t size,
70 * const void *caller);
72 * void (*__free_hook)(void *ptr, const void *caller);
74 * void (*__malloc_initialize_hook)(void);
76 * void (*__after_morecore_hook)(void);
79 static void my_init_hook(void);
80 static void my_free_hook(void *p, const void *caller);
82 static void (*old_free_hook)(void *ptr, const void *caller) = NULL;
83 void (*__free_hook)(void *ptr, const void *caller);
85 void (*__malloc_initialize_hook) (void) = my_init_hook;
89 old_free_hook = __free_hook;
90 __free_hook = my_free_hook;
93 //void *magicfree = NULL;
96 my_free_hook(void *p, const void *caller)
98 __free_hook = old_free_hook;
99 // if ((p) && (p == magicfree))
101 // printf("CAUGHT!!!!! %p ...\n", p);
105 __free_hook = my_free_hook;
109 /* local function prototypes */
110 static void _e_main_shutdown(int errcode);
111 static void _e_main_shutdown_push(int (*func)(void));
112 static void _e_main_parse_arguments(int argc, char **argv);
113 static Eina_Bool _e_main_cb_signal_exit(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *ev EINA_UNUSED);
114 static Eina_Bool _e_main_cb_signal_hup(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *ev EINA_UNUSED);
115 static int _e_main_dirs_init(void);
116 static int _e_main_dirs_shutdown(void);
117 static int _e_main_path_init(void);
118 static int _e_main_path_shutdown(void);
119 static int _e_main_screens_init(void);
120 static int _e_main_screens_shutdown(void);
121 static void _e_main_desk_save(void);
122 static void _e_main_desk_restore(void);
123 static Eina_Bool _e_main_cb_idle_before(void *data EINA_UNUSED);
124 static Eina_Bool _e_main_cb_idle_after(void *data EINA_UNUSED);
125 static void _e_main_create_wm_ready(void);
126 static void _e_main_hooks_clean(void);
127 static void _e_main_hook_call(E_Main_Hook_Point hookpoint, void *data EINA_UNUSED);
129 /* local variables */
130 static int _e_main_lvl = 0;
131 static int(*_e_main_shutdown_func[MAX_LEVEL]) (void);
133 static Ecore_Idle_Enterer *_idle_before = NULL;
134 static Ecore_Idle_Enterer *_idle_after = NULL;
136 static Eina_List *hooks = NULL;
138 static int _e_main_hooks_delete = 0;
139 static int _e_main_hooks_walking = 0;
141 static Eina_Inlist *_e_main_hooks[] =
143 [E_MAIN_HOOK_MODULE_LOAD_DONE] = NULL,
144 [E_MAIN_HOOK_E_INFO_READY] = NULL,
145 [E_MAIN_HOOK_POST_CLIENT_IDLER_BEFORE] = NULL
148 /* external variables */
149 E_API Eina_Bool starting = EINA_TRUE;
150 E_API Eina_Bool stopping = EINA_FALSE;
153 _xdg_check_str(const char *env, const char *str)
159 for (p = strstr(env, str); p; p++, p = strstr(p, str))
161 if ((!p[len]) || (p[len] == ':')) return EINA_TRUE;
167 _xdg_data_dirs_augment(void)
170 const char *p = e_prefix_get();
171 char newpath[PATH_MAX], buf[PATH_MAX + PATH_MAX + 200];
175 s = e_util_env_get("XDG_DATA_DIRS");
178 Eina_Bool pfxdata, pfx;
180 pfxdata = !_xdg_check_str(s, e_prefix_data_get());
181 snprintf(newpath, sizeof(newpath), "%s/share", p);
182 pfx = !_xdg_check_str(s, newpath);
185 snprintf(buf, sizeof(buf), "%s%s%s%s%s",
186 pfxdata ? e_prefix_data_get() : "",
191 e_util_env_set("XDG_DATA_DIRS", buf);
197 snprintf(buf, sizeof(buf), "%s:%s/share:/usr/local/share:/usr/share", e_prefix_data_get(), p);
198 e_util_env_set("XDG_DATA_DIRS", buf);
201 s = e_util_env_get("XDG_CONFIG_DIRS");
202 snprintf(newpath, sizeof(newpath), "%s/etc/xdg", p);
205 if (!_xdg_check_str(s, newpath))
207 snprintf(buf, sizeof(buf), "%s:%s", newpath, s);
208 e_util_env_set("XDG_CONFIG_DIRS", buf);
214 snprintf(buf, sizeof(buf), "%s:/etc/xdg", newpath);
215 e_util_env_set("XDG_CONFIG_DIRS", buf);
218 s = e_util_env_get("XDG_RUNTIME_DIR");
225 snprintf(buf, sizeof(buf), "/tmp/xdg-XXXXXX");
227 if (!dir) dir = "/tmp";
230 e_util_env_set("XDG_RUNTIME_DIR", dir);
231 snprintf(buf, sizeof(buf), "%s/.e-deleteme", dir);
232 ecore_file_mkdir(buf);
236 /* set menu prefix so we get our e menu */
237 s = e_util_env_get("XDG_MENU_PREFIX");
241 e_util_env_set("XDG_MENU_PREFIX", "e-");
245 _e_main_subsystem_defer(void *data EINA_UNUSED)
247 TRACE_DS_BEGIN(MAIN:SUBSYSTEMS DEFER);
249 /* try to init delayed subsystems */
251 TRACE_DS_BEGIN(MAIN:DEFERRED INTERNAL SUBSYSTEMS INIT);
253 TSB("[DEFERRED] DPMS Init");
256 e_error_message_show(_("Enlightenment cannot set up dpms.\n"));
259 TSE("[DEFERRED] DPMS Init Done");
260 _e_main_shutdown_push(e_dpms_shutdown);
262 TSB("[DEFERRED] E_Dnd Init");
265 e_error_message_show(_("Enlightenment cannot set up its dnd system.\n"));
268 TSE("[DEFERRED] E_Dnd Init Done");
269 _e_main_shutdown_push(e_dnd_shutdown);
271 TSB("[DEFERRED] E_Scale Init");
274 e_error_message_show(_("Enlightenment cannot set up its scale system.\n"));
277 TSE("[DEFERRED] E_Scale Init Done");
278 _e_main_shutdown_push(e_scale_shutdown);
280 TSB("[DEFERRED] E_Test_Helper Init");
281 e_test_helper_init();
282 _e_main_shutdown_push(e_test_helper_shutdown);
283 TSE("[DEFERRED] E_Test_Helper Done");
285 TSB("[DEFERRED] E_INFO_SERVER Init");
286 e_info_server_init();
287 _e_main_shutdown_push(e_info_server_shutdown);
288 TSE("[DEFERRED] E_INFO_SERVER Done");
291 TRACE_DS_BEGIN(MAIN:DEFERRED COMP JOB);
293 /* try to do deferred job of any subsystems*/
294 TSB("[DEFERRED] Compositor's deferred job");
295 e_comp_deferred_job();
296 TSE("[DEFERRED] Compositor's deferred job Done");
298 if (e_config->use_e_policy)
300 TSB("[DEFERRED] E_Policy's deferred job");
301 e_policy_deferred_job();
302 TSE("[DEFERRED] E_Policy's deferred job Done");
305 TSB("[DEFERRED] E_Module's deferred job");
306 e_module_deferred_job();
307 TSE("[DEFERRED] E_Module's deferred job Done");
311 return ECORE_CALLBACK_DONE;
317 _e_main_shutdown(-1);
318 return ECORE_CALLBACK_DONE;
322 _e_main_deferred_job_schedule(void *d EINA_UNUSED, int type EINA_UNUSED, void *ev EINA_UNUSED)
324 PRCTL("[Winsys] all modules loaded");
325 ecore_idler_add(_e_main_subsystem_defer, NULL);
326 return ECORE_CALLBACK_DONE;
329 /* externally accessible functions */
331 main(int argc, char **argv)
334 struct sigaction action;
337 # ifdef PR_SET_PTRACER
338 # ifdef PR_SET_PTRACER_ANY
339 prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY);
344 #ifdef TIZEN_TEST_GCOV
345 setenv("GCOV_PREFIX", "/tmp", 1);
348 /* for debugging by redirecting stdout & stderr of e to a log file to tail */
349 setvbuf(stdout, NULL, _IONBF, 0);
350 setvbuf(stderr, NULL, _IONBF, 0);
353 t0 = t1 = t2 = ecore_time_unix_get();
354 printf("ESTART(main) %1.5f\n", t0);
356 TRACE_DS_BEGIN(MAIN:BEGIN STARTUP);
357 TSB("Begin Startup");
358 PRCTL("[Winsys] start of main");
360 /* trap deadly bug signals and allow some form of sane recovery */
361 /* or ability to gdb attach and debug at this point - better than your */
362 /* wm/desktop vanishing and not knowing what happened */
364 /* don't install SIGBUS handler */
365 /* Wayland shm sets up a sigbus handler for catching invalid shm region */
366 /* access. If we setup our sigbus handler here, then the wl-shm sigbus */
367 /* handler will not function properly */
368 s = e_util_env_get("NOTIFY_SOCKET");
374 action.sa_sigaction = e_sigseg_act;
375 action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
376 sigemptyset(&action.sa_mask);
377 sigaction(SIGSEGV, &action, NULL);
379 action.sa_sigaction = e_sigill_act;
380 action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
381 sigemptyset(&action.sa_mask);
382 sigaction(SIGILL, &action, NULL);
384 action.sa_sigaction = e_sigfpe_act;
385 action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
386 sigemptyset(&action.sa_mask);
387 sigaction(SIGFPE, &action, NULL);
389 action.sa_sigaction = e_sigabrt_act;
390 action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
391 sigemptyset(&action.sa_mask);
392 sigaction(SIGABRT, &action, NULL);
393 TSE("Signal Trap Done");
399 e_error_message_show(_("Enlightenment cannot initialize Eina!\n"));
402 TSE("Eina Init Done");
403 _e_main_shutdown_push(eina_shutdown);
405 #ifdef OBJECT_HASH_CHECK
406 TSB("E_Object Hash Init");
407 e_object_hash_init();
408 TSE("E_Object Hash Init Done");
414 e_error_message_show(_("Enlightenment could not create a logging domain!\n"));
417 TSE("E_Log Init Done");
418 _e_main_shutdown_push(e_log_shutdown);
420 TSB("Determine Prefix");
421 if (!e_prefix_determine(argv[0]))
424 "ERROR: Enlightenment cannot determine it's installed\n"
425 " prefix from the system or argv[0].\n"
426 " This is because it is not on Linux AND has been\n"
427 " executed strangely. This is unusual.\n");
429 TSE("Determine Prefix Done");
431 TSB("Parse Arguments");
432 _e_main_parse_arguments(argc, argv);
433 TSE("Parse Arguments Done");
435 /*** Initialize Core EFL Libraries We Need ***/
440 e_error_message_show(_("Enlightenment cannot initialize Eet!\n"));
443 TSE("Eet Init Done");
444 _e_main_shutdown_push(eet_shutdown);
446 /* Allow ecore to not load system modules.
447 * Without it ecore_init will block until dbus authentication
448 * and registration are complete.
450 ecore_app_no_system_modules();
455 e_error_message_show(_("Enlightenment cannot initialize Ecore!\n"));
458 TSE("Ecore Init Done");
459 _e_main_shutdown_push(ecore_shutdown);
464 e_error_message_show(_("Enlightenment cannot initialize EIO!\n"));
467 TSE("EIO Init Done");
468 _e_main_shutdown_push(eio_shutdown);
470 TSB("Ecore Event Handlers");
471 if (!ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT,
472 _e_main_cb_signal_exit, NULL))
474 e_error_message_show(_("Enlightenment cannot set up an exit signal handler.\n"
475 "Perhaps you are out of memory?"));
478 if (!ecore_event_handler_add(ECORE_EVENT_SIGNAL_HUP,
479 _e_main_cb_signal_hup, NULL))
481 e_error_message_show(_("Enlightenment cannot set up a HUP signal handler.\n"
482 "Perhaps you are out of memory?"));
485 TSE("Ecore Event Handlers Done");
487 TSB("Ecore_File Init");
488 if (!ecore_file_init())
490 e_error_message_show(_("Enlightenment cannot initialize Ecore_File!\n"));
493 TSE("Ecore_File Init Done");
494 _e_main_shutdown_push(ecore_file_shutdown);
496 TSB("E_Util_File_Monitor Init");
497 e_util_file_monitor_init();
498 TSE("E_Util_File_Monitor Init Done");
499 _e_main_shutdown_push(e_util_file_monitor_shutdown);
501 _idle_before = ecore_idle_enterer_before_add(_e_main_cb_idle_before, NULL);
503 TSB("XDG_DATA_DIRS Init");
504 _xdg_data_dirs_augment();
505 TSE("XDG_DATA_DIRS Init Done");
507 TSB("Ecore_Evas Init");
508 if (!ecore_evas_init())
510 e_error_message_show(_("Enlightenment cannot initialize Ecore_Evas!\n"));
513 TSE("Ecore_Evas Init Done");
518 e_error_message_show(_("Enlightenment cannot initialize Edje!\n"));
521 TSE("Edje Init Done");
522 _e_main_shutdown_push(edje_shutdown);
524 /*** Initialize E Subsystems We Need ***/
529 e_error_message_show(_("Enlightenment cannot set up user home path\n"));
532 TSE("E User Init Done");
533 _e_main_shutdown_push(e_user_shutdown);
535 TSB("E Directories Init");
536 /* setup directories we will be using for configurations storage etc. */
537 if (!_e_main_dirs_init())
539 e_error_message_show(_("Enlightenment cannot create directories in your home directory.\n"
540 "Perhaps you have no home directory or the disk is full?"));
543 TSE("E Directories Init Done");
544 _e_main_shutdown_push(_e_main_dirs_shutdown);
546 TSB("E_Config Init");
547 if (!e_config_init())
549 e_error_message_show(_("Enlightenment cannot set up its config system.\n"));
552 TSE("E_Config Init Done");
553 _e_main_shutdown_push(e_config_shutdown);
558 e_error_message_show(_("Enlightenment cannot set up its environment.\n"));
561 TSE("E_Env Init Done");
562 _e_main_shutdown_push(e_env_shutdown);
564 ecore_exe_run_priority_set(e_config->priority);
567 if (!_e_main_path_init())
569 e_error_message_show(_("Enlightenment cannot set up paths for finding files.\n"
570 "Perhaps you are out of memory?"));
573 TSE("E Paths Init Done");
574 _e_main_shutdown_push(_e_main_path_shutdown);
576 ecore_animator_frametime_set(1.0 / e_config->framerate);
581 e_error_message_show(_("Enlightenment cannot set up its theme system.\n"));
584 TSE("E_Theme Init Done");
585 _e_main_shutdown_push(e_theme_shutdown);
587 TSB("E_Actions Init");
588 if (!e_actions_init())
590 e_error_message_show(_("Enlightenment cannot set up its actions system.\n"));
593 TSE("E_Actions Init Done");
594 _e_main_shutdown_push(e_actions_shutdown);
596 /* these just add event handlers and can't fail
597 * timestamping them is dumb.
599 e_screensaver_preinit();
604 TRACE_DS_BEGIN(MAIN:WAIT /dev/dri/card0);
605 if (e_config->sleep_for_dri)
607 while(access("/dev/dri/card0", F_OK) != 0)
609 struct timespec req, rem;
611 req.tv_nsec = 50000000L;
612 nanosleep(&req, &rem);
620 e_error_message_show(_("Enlightenment cannot set up its msg system."));
623 TSE("E_Msg Init Done");
624 _e_main_shutdown_push(e_msg_shutdown);
626 e_module_event_init();
628 TSB("E_Pointer Init");
629 if (!e_pointer_init())
631 e_error_message_show(_("Enlightenment cannot set up its pointer system.\n"));
634 TSE("E_Pointer Init Done");
635 _e_main_shutdown_push(e_pointer_shutdown);
637 TRACE_DS_BEGIN(MAIN:SCREEN INIT);
639 if (!_e_main_screens_init())
641 e_error_message_show(_("Enlightenment set up window management for all the screens on your system\n"
642 "failed. Perhaps another window manager is running?\n"));
645 TSE("Screens Init Done");
646 _e_main_shutdown_push(_e_main_screens_shutdown);
649 TSB("E_Devicemgr Init");
650 if (!e_devicemgr_init())
652 e_error_message_show(_("Enlightenment cannot set up its device_manager system.\n"));
655 TSE("E_Devicemgr Init Done");
656 _e_main_shutdown_push(e_devicemgr_shutdown);
658 TSB("E_Keyrouter Init");
659 if (!e_keyrouter_init())
661 e_error_message_show(_("Enlightenment cannot set up its keyrouting system.\n"));
664 TSE("E_Keyrouter Init Done");
665 _e_main_shutdown_push(e_keyrouter_shutdown);
667 if (e_config->eom_enable)
672 e_error_message_show(_("Enlightenment cannot set up eom.\n"));
675 TSE("Eom Init Done");
676 _e_main_shutdown_push(e_eom_shutdown);
679 TSB("E_Screensaver Init");
680 if (!e_screensaver_init())
682 e_error_message_show(_("Enlightenment cannot configure the X screensaver.\n"));
685 TSE("E_Screensaver Init Done");
686 _e_main_shutdown_push(e_screensaver_shutdown);
688 TSB("E_Comp Freeze");
690 TSE("E_Comp Freeze Done");
692 TSB("E_Grabinput Init");
693 if (!e_grabinput_init())
695 e_error_message_show(_("Enlightenment cannot set up its grab input handling system.\n"));
698 TSE("E_Grabinput Init Done");
699 _e_main_shutdown_push(e_grabinput_shutdown);
701 TS("E_Gesture Init");
703 _e_main_shutdown_push(e_gesture_shutdown);
705 ecore_event_handler_add(E_EVENT_MODULE_INIT_END, _e_main_deferred_job_schedule, NULL);
707 TSB("E_Module Init");
708 if (!e_module_init())
710 e_error_message_show(_("Enlightenment cannot set up its module system.\n"));
713 TSE("E_Module Init Done");
714 _e_main_shutdown_push(e_module_shutdown);
717 if (!e_mouse_update())
719 e_error_message_show(_("Enlightenment cannot configure the mouse settings.\n"));
722 TSE("E_Mouse Init Done");
727 e_error_message_show(_("Enlightenment cannot initialize the Icon Cache system.\n"));
730 TSE("E_Icon Init Done");
731 _e_main_shutdown_push(e_icon_shutdown);
733 if (e_config->use_e_policy)
735 TSB("E_Policy Init");
736 if (!e_policy_init())
738 e_error_message_show(_("Enlightenment cannot setup policy system!\n"));
741 TSE("E_Policy Init Done");
742 _e_main_shutdown_push(e_policy_shutdown);
745 TSB("E_Process Init");
746 if (!e_process_init())
748 e_error_message_show(_("Enlightenment cannot setup process managing system!\n"));
751 TSE("E_Process Init Done");
752 _e_main_shutdown_push(e_process_shutdown);
754 TSB("E_Security Init");
755 if (!e_security_init())
757 e_error_message_show(_("Enlightenment cannot setup security system!\n"));
760 TSE("E_Security Init Done");
761 _e_main_shutdown_push(e_security_shutdown);
765 TSE("Load Modules Done");
769 TSE("E_Comp Thaw Done");
771 if (e_config->use_thread_max_cpu)
775 cpus = eina_cpu_count();
778 TSM("Set ecore thread max");
779 ecore_thread_max_set(cpus);
783 _idle_after = ecore_idle_enterer_add(_e_main_cb_idle_after, NULL);
785 starting = EINA_FALSE;
787 TSM("MAIN LOOP AT LAST");
789 if (e_config->create_wm_ready)
790 _e_main_create_wm_ready();
795 TSM("[WM] Send start-up completion");
796 sd_notify(0, "READY=1");
798 TSM("[WM] Skip sending start-up completion. (no systemd)");
800 ecore_main_loop_begin();
802 ELOGF("COMP", "STOPPING enlightenment...", NULL);
803 stopping = EINA_TRUE;
806 e_comp_internal_save();
817 _e_main_shutdown(-1);
821 e_main_ts(const char *str)
824 t1 = ecore_time_unix_get();
825 printf("ESTART: %1.5f [%1.5f] - %s\n", t1 - t0, t1 - t2, str);
832 e_main_ts_begin(const char *str)
834 TRACE_DS_BEGIN(ESTART: %s, str);
835 return e_main_ts(str);
839 e_main_ts_end(const char *str)
842 return e_main_ts(str);
845 /* local functions */
847 _e_main_shutdown(int errcode)
853 printf("E: Begin Shutdown Procedure!\n");
855 E_FREE_LIST(hooks, e_main_hook_del);
857 if (_idle_before) ecore_idle_enterer_del(_idle_before);
859 if (_idle_after) ecore_idle_enterer_del(_idle_after);
862 dir = e_util_env_get("XDG_RUNTIME_DIR");
865 char buf_env[PATH_MAX - 12];
866 snprintf(buf_env, sizeof(buf_env), "%s", dir);
867 snprintf(buf, sizeof(buf), "%s/.e-deleteme", buf_env);
868 if (ecore_file_exists(buf)) ecore_file_recursive_rm(buf_env);
871 for (i = (_e_main_lvl - 1); i >= 0; i--)
872 (*_e_main_shutdown_func[i])();
873 #ifdef OBJECT_HASH_CHECK
874 e_object_hash_shutdown();
876 if (errcode < 0) exit(errcode);
880 _e_main_shutdown_push(int (*func)(void))
883 if (_e_main_lvl > MAX_LEVEL)
886 e_error_message_show("WARNING: too many init levels. MAX = %i\n",
890 _e_main_shutdown_func[_e_main_lvl - 1] = func;
894 _e_main_parse_arguments(int argc, char **argv)
898 /* handle some command-line parameters */
899 for (i = 1; i < argc; i++)
901 if ((!strcmp(argv[i], "-profile")) && (i < (argc - 1)))
904 if (!getenv("E_CONF_PROFILE"))
905 e_util_env_set("E_CONF_PROFILE", argv[i]);
907 else if ((!strcmp(argv[i], "-version")) ||
908 (!strcmp(argv[i], "--version")))
910 printf(_("Version: %s\n"), PACKAGE_VERSION);
911 _e_main_shutdown(-1);
913 else if ((!strcmp(argv[i], "-h")) ||
914 (!strcmp(argv[i], "-help")) ||
915 (!strcmp(argv[i], "--help")))
920 "\t-profile CONF_PROFILE\n"
921 "\t\tUse the configuration profile CONF_PROFILE instead of the user selected default or just \"default\".\n"
925 _e_main_shutdown(-1);
931 _e_main_cb_signal_exit(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *ev EINA_UNUSED)
933 /* called on ctrl-c, kill (pid) (also SIGINT, SIGTERM and SIGQIT) */
934 ecore_main_loop_quit();
935 return ECORE_CALLBACK_RENEW;
939 _e_main_cb_signal_hup(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *ev EINA_UNUSED)
941 ecore_main_loop_quit();
942 return ECORE_CALLBACK_RENEW;
946 _e_main_dirs_init(void)
948 if(getenv("E_CONF_RO"))
962 base = e_user_dir_get();
963 if (ecore_file_mksubdirs(base, dirs) != sizeof(dirs) / sizeof(dirs[0]) - 1)
965 e_error_message_show("Could not create one of the required "
966 "subdirectories of '%s'\n", base);
974 _e_main_dirs_shutdown(void)
980 _e_main_path_init(void)
984 /* setup data paths */
985 path_data = e_path_new();
988 e_error_message_show("Cannot allocate path for path_data\n");
991 e_prefix_data_concat_static(buf, "data");
992 e_path_default_path_append(path_data, buf);
994 /* setup image paths */
995 path_images = e_path_new();
998 e_error_message_show("Cannot allocate path for path_images\n");
1001 e_user_dir_concat_static(buf, "/images");
1002 e_path_default_path_append(path_images, buf);
1003 e_prefix_data_concat_static(buf, "data/images");
1004 e_path_default_path_append(path_images, buf);
1006 /* setup font paths */
1007 path_fonts = e_path_new();
1010 e_error_message_show("Cannot allocate path for path_fonts\n");
1013 e_user_dir_concat_static(buf, "/fonts");
1014 e_path_default_path_append(path_fonts, buf);
1015 e_prefix_data_concat_static(buf, "data/fonts");
1016 e_path_default_path_append(path_fonts, buf);
1018 /* setup icon paths */
1019 path_icons = e_path_new();
1022 e_error_message_show("Cannot allocate path for path_icons\n");
1025 e_user_dir_concat_static(buf, "/icons");
1026 e_path_default_path_append(path_icons, buf);
1027 e_prefix_data_concat_static(buf, "data/icons");
1028 e_path_default_path_append(path_icons, buf);
1030 /* setup module paths */
1031 path_modules = e_path_new();
1034 e_error_message_show("Cannot allocate path for path_modules\n");
1037 e_user_dir_concat_static(buf, "/modules");
1038 e_path_default_path_append(path_modules, buf);
1039 snprintf(buf, sizeof(buf), "%s/enlightenment/modules", e_prefix_lib_get());
1040 e_path_default_path_append(path_modules, buf);
1041 /* FIXME: eventually this has to go - moduels should have installers that
1042 * add appropriate install paths (if not installed to user homedir) to
1043 * e's module search dirs
1045 snprintf(buf, sizeof(buf), "%s/enlightenment/modules_extra", e_prefix_lib_get());
1046 e_path_default_path_append(path_modules, buf);
1048 /* setup background paths */
1049 path_backgrounds = e_path_new();
1050 if (!path_backgrounds)
1052 e_error_message_show("Cannot allocate path for path_backgrounds\n");
1055 e_user_dir_concat_static(buf, "/backgrounds");
1056 e_path_default_path_append(path_backgrounds, buf);
1057 e_prefix_data_concat_static(buf, "data/backgrounds");
1058 e_path_default_path_append(path_backgrounds, buf);
1060 path_messages = e_path_new();
1063 e_error_message_show("Cannot allocate path for path_messages\n");
1066 e_user_dir_concat_static(buf, "/locale");
1067 e_path_default_path_append(path_messages, buf);
1068 e_path_default_path_append(path_messages, e_prefix_locale_get());
1074 _e_main_path_shutdown(void)
1078 e_object_del(E_OBJECT(path_data));
1083 e_object_del(E_OBJECT(path_images));
1088 e_object_del(E_OBJECT(path_fonts));
1093 e_object_del(E_OBJECT(path_icons));
1098 e_object_del(E_OBJECT(path_modules));
1099 path_modules = NULL;
1101 if (path_backgrounds)
1103 e_object_del(E_OBJECT(path_backgrounds));
1104 path_backgrounds = NULL;
1108 e_object_del(E_OBJECT(path_messages));
1109 path_messages = NULL;
1115 _e_main_screens_init(void)
1117 TSB("\tscreens: client");
1118 if (!e_client_init()) return 0;
1119 TSE("\tscreens: client Done");
1121 TSB("Compositor Init");
1122 PRCTL("[Winsys] start of compositor init");
1125 e_error_message_show(_("Enlightenment cannot create a compositor.\n"));
1126 _e_main_shutdown(-1);
1128 TSE("Compositor Init Done");
1130 PRCTL("[Winsys] end of compositor init");
1131 _e_main_desk_restore();
1137 _e_main_screens_shutdown(void)
1140 e_client_shutdown();
1142 e_magnifier_shutdown();
1149 _e_main_desk_save(void)
1152 char env[1024], name[1024];
1155 EINA_LIST_FOREACH(e_comp->zones, l, zone)
1157 snprintf(name, sizeof(name), "DESK_%d_%d", 0, zone->num);
1158 snprintf(env, sizeof(env), "%d,%d", zone->desk_x_current, zone->desk_y_current);
1159 e_util_env_set(name, env);
1164 _e_main_desk_restore(void)
1169 E_CLIENT_REVERSE_FOREACH(ec)
1171 zone = e_comp_zone_find_by_ec(ec);
1172 if ((!e_client_util_ignored_get(ec)) && e_desk_has_ec(e_desk_current_get(zone), ec))
1174 ec->want_focus = ec->take_focus = 1;
1181 _e_main_cb_idle_before(void *data EINA_UNUSED)
1183 e_comp_idler_before();
1184 _e_main_hook_call(E_MAIN_HOOK_POST_CLIENT_IDLER_BEFORE, NULL);
1187 return ECORE_CALLBACK_RENEW;
1191 _e_main_cb_idle_after(void *data EINA_UNUSED)
1193 static int first_idle = 1;
1204 return ECORE_CALLBACK_RENEW;
1208 _e_main_create_wm_ready(void)
1210 FILE *_wmready_checker = NULL;
1211 const char *path_wm_ready = "/run/.wm_ready";
1213 if (!e_util_file_realpath_check(path_wm_ready, EINA_TRUE))
1215 WRN("%s is maybe link, so delete it\n", path_wm_ready);
1218 _wmready_checker = fopen(path_wm_ready, "wb");
1219 if (_wmready_checker)
1221 TSM("[WM] WINDOW MANAGER is READY!!!");
1222 PRCTL("[Winsys] WINDOW MANAGER is READY!!!");
1223 fclose(_wmready_checker);
1225 /*TODO: Next lines should be removed. */
1226 FILE *_tmp_wm_ready_checker;
1228 _tmp_wm_ready_checker = fopen(path_wm_ready, "wb");
1230 if (_tmp_wm_ready_checker)
1232 TSM("[WM] temporary wm_ready path is created.");
1233 PRCTL("[Winsys] temporary wm_ready path is created.");
1234 fclose(_tmp_wm_ready_checker);
1238 TSM("[WM] temporary wm_ready path create failed.");
1239 PRCTL("[Winsys] temporary wm_ready path create failed.");
1244 TSM("[WM] WINDOW MANAGER is READY. BUT, failed to create .wm_ready file.");
1245 PRCTL("[Winsys] WINDOW MANAGER is READY. BUT, failed to create .wm_ready file.");
1250 _e_main_hooks_clean(void)
1256 for (x = 0; x < E_MAIN_HOOK_LAST; x++)
1257 EINA_INLIST_FOREACH_SAFE(_e_main_hooks[x], l, mh)
1259 if (!mh->delete_me) continue;
1260 _e_main_hooks[x] = eina_inlist_remove(_e_main_hooks[x],
1261 EINA_INLIST_GET(mh));
1267 _e_main_hook_call(E_Main_Hook_Point hookpoint, void *data EINA_UNUSED)
1271 _e_main_hooks_walking++;
1272 EINA_INLIST_FOREACH(_e_main_hooks[hookpoint], mh)
1274 if (mh->delete_me) continue;
1277 _e_main_hooks_walking--;
1278 if ((_e_main_hooks_walking == 0) && (_e_main_hooks_delete > 0))
1279 _e_main_hooks_clean();
1283 e_main_hook_add(E_Main_Hook_Point hookpoint, E_Main_Hook_Cb func, const void *data)
1287 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_MAIN_HOOK_LAST, NULL);
1288 mh = E_NEW(E_Main_Hook, 1);
1289 EINA_SAFETY_ON_NULL_RETURN_VAL(mh, NULL);
1290 mh->hookpoint = hookpoint;
1292 mh->data = (void*)data;
1293 _e_main_hooks[hookpoint] = eina_inlist_append(_e_main_hooks[hookpoint],
1294 EINA_INLIST_GET(mh));
1299 e_main_hook_del(E_Main_Hook *mh)
1302 if (_e_main_hooks_walking == 0)
1304 _e_main_hooks[mh->hookpoint] = eina_inlist_remove(_e_main_hooks[mh->hookpoint],
1305 EINA_INLIST_GET(mh));
1309 _e_main_hooks_delete++;
1313 e_main_hook_call(E_Main_Hook_Point hookpoint)
1315 if ((hookpoint < 0) || (hookpoint >= E_MAIN_HOOK_LAST)) return;
1317 _e_main_hook_call(hookpoint, NULL);