3 # include <sys/prctl.h>
12 t1 = ecore_time_unix_get(); \
13 printf("ESTART: %1.5f [%1.5f] - %s\n", t1 - t0, t1 - t2, x); \
16 static double t0, t1, t2;
21 * i need to make more use of these when i'm baffled as to when something is
24 * void *(*__malloc_hook)(size_t size, const void *caller);
26 * void *(*__realloc_hook)(void *ptr, size_t size, const void *caller);
28 * void *(*__memalign_hook)(size_t alignment, size_t size,
29 * const void *caller);
31 * void (*__free_hook)(void *ptr, const void *caller);
33 * void (*__malloc_initialize_hook)(void);
35 * void (*__after_morecore_hook)(void);
38 static void my_init_hook(void);
39 static void my_free_hook(void *p, const void *caller);
41 static void (*old_free_hook)(void *ptr, const void *caller) = NULL;
42 void (*__free_hook)(void *ptr, const void *caller);
44 void (*__malloc_initialize_hook) (void) = my_init_hook;
48 old_free_hook = __free_hook;
49 __free_hook = my_free_hook;
52 //void *magicfree = NULL;
55 my_free_hook(void *p, const void *caller)
57 __free_hook = old_free_hook;
58 // if ((p) && (p == magicfree))
60 // printf("CAUGHT!!!!! %p ...\n", p);
64 __free_hook = my_free_hook;
68 /* local function prototypes */
69 static void _e_main_shutdown(int errcode);
70 static void _e_main_shutdown_push(int (*func)(void));
71 static void _e_main_parse_arguments(int argc, char **argv);
72 static Eina_Bool _e_main_cb_signal_exit(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *ev EINA_UNUSED);
73 static Eina_Bool _e_main_cb_signal_hup(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *ev EINA_UNUSED);
74 static Eina_Bool _e_main_cb_signal_user(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *ev);
75 static int _e_main_dirs_init(void);
76 static int _e_main_dirs_shutdown(void);
77 static int _e_main_path_init(void);
78 static int _e_main_path_shutdown(void);
79 static int _e_main_screens_init(void);
80 static int _e_main_screens_shutdown(void);
81 static void _e_main_desk_save(void);
82 static void _e_main_desk_restore(void);
83 static void _e_main_modules_load(Eina_Bool safe_mode);
84 static Eina_Bool _e_main_cb_idle_before(void *data EINA_UNUSED);
85 static Eina_Bool _e_main_cb_idle_after(void *data EINA_UNUSED);
86 static void _e_main_create_wm_ready(void);
89 static Eina_Bool really_know = EINA_FALSE;
90 static Eina_Bool inloop = EINA_FALSE;
91 static jmp_buf x_fatal_buff;
93 static int _e_main_lvl = 0;
94 static int(*_e_main_shutdown_func[MAX_LEVEL]) (void);
96 static Ecore_Idle_Enterer *_idle_before = NULL;
97 static Ecore_Idle_Enterer *_idle_after = NULL;
99 static Ecore_Event_Handler *mod_init_end = NULL;
101 /* external variables */
102 E_API Eina_Bool e_precache_end = EINA_FALSE;
103 E_API Eina_Bool x_fatal = EINA_FALSE;
104 E_API Eina_Bool good = EINA_FALSE;
105 E_API Eina_Bool evil = EINA_FALSE;
106 E_API Eina_Bool starting = EINA_TRUE;
107 E_API Eina_Bool stopping = EINA_FALSE;
108 E_API Eina_Bool restart = EINA_FALSE;
109 E_API Eina_Bool e_nopause = EINA_FALSE;
110 EINTERN const char *e_first_frame = NULL;
111 EINTERN double e_first_frame_start_time = -1;
114 _xdg_check_str(const char *env, const char *str)
120 for (p = strstr(env, str); p; p++, p = strstr(p, str))
122 if ((!p[len]) || (p[len] == ':')) return EINA_TRUE;
128 _xdg_data_dirs_augment(void)
131 const char *p = e_prefix_get();
132 char newpath[4096], buf[4096];
136 s = getenv("XDG_DATA_DIRS");
139 Eina_Bool pfxdata, pfx;
141 pfxdata = !_xdg_check_str(s, e_prefix_data_get());
142 snprintf(newpath, sizeof(newpath), "%s/share", p);
143 pfx = !_xdg_check_str(s, newpath);
146 snprintf(buf, sizeof(buf), "%s%s%s%s%s",
147 pfxdata ? e_prefix_data_get() : "",
152 e_util_env_set("XDG_DATA_DIRS", buf);
157 snprintf(buf, sizeof(buf), "%s:%s/share:/usr/local/share:/usr/share", e_prefix_data_get(), p);
158 e_util_env_set("XDG_DATA_DIRS", buf);
161 s = getenv("XDG_CONFIG_DIRS");
162 snprintf(newpath, sizeof(newpath), "%s/etc/xdg", p);
165 if (!_xdg_check_str(s, newpath))
167 snprintf(buf, sizeof(buf), "%s:%s", newpath, s);
168 e_util_env_set("XDG_CONFIG_DIRS", buf);
173 snprintf(buf, sizeof(buf), "%s:/etc/xdg", newpath);
174 e_util_env_set("XDG_CONFIG_DIRS", buf);
177 if (!getenv("XDG_RUNTIME_DIR"))
181 snprintf(buf, sizeof(buf), "/tmp/xdg-XXXXXX");
183 if (!dir) dir = "/tmp";
186 e_util_env_set("XDG_RUNTIME_DIR", dir);
187 snprintf(buf, sizeof(buf), "%s/.e-deleteme", dir);
188 ecore_file_mkdir(buf);
192 /* set menu prefix so we get our e menu */
193 if (!getenv("XDG_MENU_PREFIX"))
195 e_util_env_set("XDG_MENU_PREFIX", "e-");
200 _e_main_subsystem_defer(void *data EINA_UNUSED)
205 TRACE_DS_BEGIN(MAIN:SUBSYSTEMS DEFER);
207 ecore_app_args_get(&argc, &argv);
209 /* try to init delayed subsystems */
211 TRACE_DS_BEGIN(MAIN:DEFFERED EFL INIT);
213 TS("[DEFERRED] Edje Init");
216 e_error_message_show(_("Enlightenment cannot initialize Edje!\n"));
218 _e_main_shutdown(-1);
220 TS("[DEFERRED] Edje Init Done");
221 _e_main_shutdown_push(edje_shutdown);
224 TRACE_DS_BEGIN(MAIN:DEFERRED INTERNAL SUBSYSTEMS INIT);
226 TS("[DEFERRED] Screens Init: win");
229 e_error_message_show(_("Enlightenment cannot setup elementary trap!\n"));
231 _e_main_shutdown(-1);
233 TS("[DEFERRED] Screens Init: win Done");
235 TS("[DEFERRED] E_Dnd Init");
238 e_error_message_show(_("Enlightenment cannot set up its dnd system.\n"));
239 _e_main_shutdown(-1);
241 TS("[DEFERRED] E_Dnd Init Done");
242 _e_main_shutdown_push(e_dnd_shutdown);
244 TS("[DEFERRED] E_Pointer Init");
245 if (!e_pointer_init())
247 e_error_message_show(_("Enlightenment cannot set up its pointer system.\n"));
249 _e_main_shutdown(-1);
252 TS("[DEFERRED] E_Pointer Init Done");
253 _e_main_shutdown_push(e_pointer_shutdown);
255 TS("[DEFERRED] E_Scale Init");
258 e_error_message_show(_("Enlightenment cannot set up its scale system.\n"));
260 _e_main_shutdown(-1);
262 TS("[DEFERRED] E_Scale Init Done");
263 _e_main_shutdown_push(e_scale_shutdown);
265 TS("[DEFERRED] E_Test_Helper Init");
266 e_test_helper_init();
267 _e_main_shutdown_push(e_test_helper_shutdown);
268 TS("[DEFERRED] E_Test_Helper Done");
270 TS("[DEFERRED] E_INFO_SERVER Init");
271 e_info_server_init();
272 _e_main_shutdown_push(e_info_server_shutdown);
273 TS("[DEFERRED] E_INFO_SERVER Done");
276 TRACE_DS_BEGIN(MAIN:DEFERRED COMP JOB);
278 /* try to do deferred job of any subsystems*/
279 TS("[DEFERRED] Compositor's deferred job");
280 e_comp_deferred_job();
281 TS("[DEFERRED] Compositor's deferred job Done");
284 TRACE_DS_BEGIN(MAIN:DEFERRED MODULE JOB);
286 TS("[DEFERRED] E_Module's deferred job");
287 e_module_deferred_job();
288 TS("[DEFERRED] E_Module's deferred job Done");
293 return ECORE_CALLBACK_DONE;
297 _e_main_deferred_job_schedule(void *d EINA_UNUSED, int type EINA_UNUSED, void *ev EINA_UNUSED)
299 PRCTL("[Winsys] all modules loaded");
300 ecore_idler_add(_e_main_subsystem_defer, NULL);
301 return ECORE_CALLBACK_DONE;
304 /* externally accessible functions */
306 main(int argc, char **argv)
308 Eina_Bool safe_mode = EINA_FALSE;
309 double t = 0.0, tstart = 0.0;
310 char *s = NULL, buff[32];
311 struct sigaction action;
314 # ifdef PR_SET_PTRACER
315 # ifdef PR_SET_PTRACER_ANY
316 prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY);
321 t0 = t1 = t2 = ecore_time_unix_get();
322 printf("ESTART(main) %1.5f\n", t0);
324 TRACE_DS_BEGIN(MAIN:BEGIN STARTUP);
326 PRCTL("[Winsys] start of main");
328 /* trap deadly bug signals and allow some form of sane recovery */
329 /* or ability to gdb attach and debug at this point - better than your */
330 /* wm/desktop vanishing and not knowing what happened */
332 /* don't install SIGBUS handler */
333 /* Wayland shm sets up a sigbus handler for catching invalid shm region */
334 /* access. If we setup our sigbus handler here, then the wl-shm sigbus */
335 /* handler will not function properly */
336 if (!getenv("NOTIFY_SOCKET"))
339 action.sa_sigaction = e_sigseg_act;
340 action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
341 sigemptyset(&action.sa_mask);
342 sigaction(SIGSEGV, &action, NULL);
344 action.sa_sigaction = e_sigill_act;
345 action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
346 sigemptyset(&action.sa_mask);
347 sigaction(SIGILL, &action, NULL);
349 action.sa_sigaction = e_sigfpe_act;
350 action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
351 sigemptyset(&action.sa_mask);
352 sigaction(SIGFPE, &action, NULL);
354 action.sa_sigaction = e_sigabrt_act;
355 action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
356 sigemptyset(&action.sa_mask);
357 sigaction(SIGABRT, &action, NULL);
358 TS("Signal Trap Done");
361 t = ecore_time_unix_get();
362 s = getenv("E_START_TIME");
363 if ((s) && (!getenv("E_RESTART_OK")))
366 if ((t - tstart) < 5.0) safe_mode = EINA_TRUE;
369 snprintf(buff, sizeof(buff), "%1.1f", tstart);
370 e_util_env_set("E_START_TIME", buff);
372 if (getenv("E_START_MTRACK"))
373 e_util_env_set("MTRACK", NULL);
377 e_error_message_show(_("Enlightenment cannot initialize Eina!\n"));
378 _e_main_shutdown(-1);
380 TS("Eina Init Done");
381 _e_main_shutdown_push(eina_shutdown);
383 #ifdef OBJECT_HASH_CHECK
384 TS("E_Object Hash Init");
385 e_object_hash_init();
386 TS("E_Object Hash Init Done");
392 e_error_message_show(_("Enlightenment could not create a logging domain!\n"));
393 _e_main_shutdown(-1);
395 TS("E_Log Init Done");
396 _e_main_shutdown_push(e_log_shutdown);
398 TS("Determine Prefix");
399 if (!e_prefix_determine(argv[0]))
402 "ERROR: Enlightenment cannot determine it's installed\n"
403 " prefix from the system or argv[0].\n"
404 " This is because it is not on Linux AND has been\n"
405 " executed strangely. This is unusual.\n");
407 TS("Determine Prefix Done");
409 /* for debugging by redirecting stdout of e to a log file to tail */
410 setvbuf(stdout, NULL, _IONBF, 0);
412 TS("Parse Arguments");
413 _e_main_parse_arguments(argc, argv);
414 TS("Parse Arguments Done");
416 /*** Initialize Core EFL Libraries We Need ***/
421 e_error_message_show(_("Enlightenment cannot initialize Eet!\n"));
422 _e_main_shutdown(-1);
425 _e_main_shutdown_push(eet_shutdown);
427 /* Allow ecore to not load system modules.
428 * Without it ecore_init will block until dbus authentication
429 * and registration are complete.
431 ecore_app_no_system_modules();
436 e_error_message_show(_("Enlightenment cannot initialize Ecore!\n"));
437 _e_main_shutdown(-1);
439 TS("Ecore Init Done");
440 _e_main_shutdown_push(ecore_shutdown);
442 e_first_frame = getenv("E_FIRST_FRAME");
443 if (e_first_frame && e_first_frame[0])
444 e_first_frame_start_time = ecore_time_get();
446 e_first_frame = NULL;
451 e_error_message_show(_("Enlightenment cannot initialize EIO!\n"));
452 _e_main_shutdown(-1);
455 _e_main_shutdown_push(eio_shutdown);
457 ecore_app_args_set(argc, (const char **)argv);
459 TS("Ecore Event Handlers");
460 if (!ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT,
461 _e_main_cb_signal_exit, NULL))
463 e_error_message_show(_("Enlightenment cannot set up an exit signal handler.\n"
464 "Perhaps you are out of memory?"));
465 _e_main_shutdown(-1);
467 if (!ecore_event_handler_add(ECORE_EVENT_SIGNAL_HUP,
468 _e_main_cb_signal_hup, NULL))
470 e_error_message_show(_("Enlightenment cannot set up a HUP signal handler.\n"
471 "Perhaps you are out of memory?"));
472 _e_main_shutdown(-1);
474 if (!ecore_event_handler_add(ECORE_EVENT_SIGNAL_USER,
475 _e_main_cb_signal_user, NULL))
477 e_error_message_show(_("Enlightenment cannot set up a USER signal handler.\n"
478 "Perhaps you are out of memory?"));
479 _e_main_shutdown(-1);
481 TS("Ecore Event Handlers Done");
483 TS("Ecore_File Init");
484 if (!ecore_file_init())
486 e_error_message_show(_("Enlightenment cannot initialize Ecore_File!\n"));
487 _e_main_shutdown(-1);
489 TS("Ecore_File Init Done");
490 _e_main_shutdown_push(ecore_file_shutdown);
492 _idle_before = ecore_idle_enterer_before_add(_e_main_cb_idle_before, NULL);
494 TS("XDG_DATA_DIRS Init");
495 _xdg_data_dirs_augment();
496 TS("XDG_DATA_DIRS Init Done");
498 TS("Ecore_Evas Init");
499 if (!ecore_evas_init())
501 e_error_message_show(_("Enlightenment cannot initialize Ecore_Evas!\n"));
502 _e_main_shutdown(-1);
504 TS("Ecore_Evas Init Done");
506 /* e doesn't sync to compositor - it should be one */
507 ecore_evas_app_comp_sync_set(0);
510 /*** Initialize E Subsystems We Need ***/
512 TS("E Directories Init");
513 /* setup directories we will be using for configurations storage etc. */
514 if (!_e_main_dirs_init())
516 e_error_message_show(_("Enlightenment cannot create directories in your home directory.\n"
517 "Perhaps you have no home directory or the disk is full?"));
518 _e_main_shutdown(-1);
520 TS("E Directories Init Done");
521 _e_main_shutdown_push(_e_main_dirs_shutdown);
524 if (!e_config_init())
526 e_error_message_show(_("Enlightenment cannot set up its config system.\n"));
527 _e_main_shutdown(-1);
529 TS("E_Config Init Done");
530 _e_main_shutdown_push(e_config_shutdown);
535 e_error_message_show(_("Enlightenment cannot set up its environment.\n"));
536 _e_main_shutdown(-1);
538 TS("E_Env Init Done");
539 _e_main_shutdown_push(e_env_shutdown);
541 ecore_exe_run_priority_set(e_config->priority);
544 if (!_e_main_path_init())
546 e_error_message_show(_("Enlightenment cannot set up paths for finding files.\n"
547 "Perhaps you are out of memory?"));
548 _e_main_shutdown(-1);
550 TS("E Paths Init Done");
551 _e_main_shutdown_push(_e_main_path_shutdown);
553 ecore_animator_frametime_set(1.0 / e_config->framerate);
558 e_error_message_show(_("Enlightenment cannot set up its theme system.\n"));
559 _e_main_shutdown(-1);
561 TS("E_Theme Init Done");
562 _e_main_shutdown_push(e_theme_shutdown);
564 TS("E_Actions Init");
565 if (!e_actions_init())
567 e_error_message_show(_("Enlightenment cannot set up its actions system.\n"));
568 _e_main_shutdown(-1);
570 TS("E_Actions Init Done");
571 _e_main_shutdown_push(e_actions_shutdown);
573 /* these just add event handlers and can't fail
574 * timestamping them is dumb.
576 e_screensaver_preinit();
580 if (e_config->sleep_for_dri)
582 while(access("/dev/dri/card0", F_OK) != 0)
584 struct timespec req, rem;
586 req.tv_nsec = 50000000L;
587 nanosleep(&req, &rem);
591 TRACE_DS_BEGIN(MAIN:SCREEN INIT);
593 if (!_e_main_screens_init())
595 e_error_message_show(_("Enlightenment set up window management for all the screens on your system\n"
596 "failed. Perhaps another window manager is running?\n"));
597 _e_main_shutdown(-1);
599 TS("Screens Init Done");
600 _e_main_shutdown_push(_e_main_screens_shutdown);
603 TS("E_Screensaver Init");
604 if (!e_screensaver_init())
606 e_error_message_show(_("Enlightenment cannot configure the X screensaver.\n"));
607 _e_main_shutdown(-1);
609 TS("E_Screensaver Init Done");
610 _e_main_shutdown_push(e_screensaver_shutdown);
614 TS("E_Comp Freeze Done");
616 TS("E_Grabinput Init");
617 if (!e_grabinput_init())
619 e_error_message_show(_("Enlightenment cannot set up its grab input handling system.\n"));
620 _e_main_shutdown(-1);
622 TS("E_Grabinput Init Done");
623 _e_main_shutdown_push(e_grabinput_shutdown);
625 ecore_event_handler_add(E_EVENT_MODULE_INIT_END, _e_main_deferred_job_schedule, NULL);
628 if (!e_module_init())
630 e_error_message_show(_("Enlightenment cannot set up its module system.\n"));
631 _e_main_shutdown(-1);
633 TS("E_Module Init Done");
634 _e_main_shutdown_push(e_module_shutdown);
636 TS("E_Remember Init");
637 if (!e_remember_init())
639 e_error_message_show(_("Enlightenment cannot setup remember settings.\n"));
640 _e_main_shutdown(-1);
642 TS("E_Remember Init Done");
643 _e_main_shutdown_push(e_remember_shutdown);
646 if (!e_mouse_update())
648 e_error_message_show(_("Enlightenment cannot configure the mouse settings.\n"));
649 _e_main_shutdown(-1);
651 TS("E_Mouse Init Done");
656 e_error_message_show(_("Enlightenment cannot initialize the Icon Cache system.\n"));
657 _e_main_shutdown(-1);
659 TS("E_Icon Init Done");
660 _e_main_shutdown_push(e_icon_shutdown);
663 _e_main_modules_load(safe_mode);
664 TS("Load Modules Done");
668 TS("E_Comp Thaw Done");
670 _idle_after = ecore_idle_enterer_add(_e_main_cb_idle_after, NULL);
672 starting = EINA_FALSE;
675 e_util_env_set("E_RESTART", "1");
677 TS("MAIN LOOP AT LAST");
679 if (e_config->create_wm_ready)
680 _e_main_create_wm_ready();
683 if (!setjmp(x_fatal_buff))
684 ecore_main_loop_begin();
686 CRI("FATAL: X Died. Connection gone. Abbreviated Shutdown\n");
689 stopping = EINA_TRUE;
692 e_remember_internal_save();
693 e_comp_internal_save();
699 e_util_env_set("E_RESTART_OK", "1");
700 if (getenv("E_START_MTRACK"))
701 e_util_env_set("MTRACK", "track");
711 e_main_ts(const char *str)
714 t1 = ecore_time_unix_get();
715 printf("ESTART: %1.5f [%1.5f] - %s\n", t1 - t0, t1 - t2, str);
721 /* local functions */
723 _e_main_shutdown(int errcode)
729 printf("E: Begin Shutdown Procedure!\n");
731 if (_idle_before) ecore_idle_enterer_del(_idle_before);
733 if (_idle_after) ecore_idle_enterer_del(_idle_after);
736 dir = getenv("XDG_RUNTIME_DIR");
739 char buf_env[PATH_MAX];
740 snprintf(buf_env, sizeof(buf_env), "%s", dir);
741 snprintf(buf, sizeof(buf), "%s/.e-deleteme", buf_env);
742 if (ecore_file_exists(buf)) ecore_file_recursive_rm(buf_env);
744 for (i = (_e_main_lvl - 1); i >= 0; i--)
745 (*_e_main_shutdown_func[i])();
746 #ifdef OBJECT_HASH_CHECK
747 e_object_hash_shutdown();
749 if (errcode < 0) exit(errcode);
753 _e_main_shutdown_push(int (*func)(void))
756 if (_e_main_lvl > MAX_LEVEL)
759 e_error_message_show("WARNING: too many init levels. MAX = %i\n",
763 _e_main_shutdown_func[_e_main_lvl - 1] = func;
767 _e_main_parse_arguments(int argc, char **argv)
771 /* handle some command-line parameters */
772 for (i = 1; i < argc; i++)
774 if (!strcmp(argv[i], "-good"))
778 printf("LA LA LA\n");
780 else if (!strcmp(argv[i], "-evil"))
784 printf("MUHAHAHAHHAHAHAHAHA\n");
786 else if (!strcmp(argv[i], "-psychotic"))
790 printf("MUHAHALALALALALALALA\n");
792 else if ((!strcmp(argv[i], "-profile")) && (i < (argc - 1)))
795 if (!getenv("E_CONF_PROFILE"))
796 e_util_env_set("E_CONF_PROFILE", argv[i]);
798 else if (!strcmp(argv[i], "-i-really-know-what-i-am-doing-and-accept-full-responsibility-for-it"))
799 really_know = EINA_TRUE;
800 else if (!strcmp(argv[i], "-nopause"))
801 e_nopause = EINA_TRUE;
802 else if ((!strcmp(argv[i], "-version")) ||
803 (!strcmp(argv[i], "--version")))
805 printf(_("Version: %s\n"), PACKAGE_VERSION);
806 _e_main_shutdown(-1);
808 else if ((!strcmp(argv[i], "-h")) ||
809 (!strcmp(argv[i], "-help")) ||
810 (!strcmp(argv[i], "--help")))
815 "\t-display DISPLAY\n"
816 "\t\tConnect to display named DISPLAY.\n"
817 "\t\tEG: -display :1.0\n"
818 "\t-fake-xinerama-screen WxH+X+Y\n"
819 "\t\tAdd a FAKE xinerama screen (instead of the real ones)\n"
820 "\t\tgiven the geometry. Add as many as you like. They all\n"
821 "\t\treplace the real xinerama screens, if any. This can\n"
822 "\t\tbe used to simulate xinerama.\n"
823 "\t\tEG: -fake-xinerama-screen 800x600+0+0 -fake-xinerama-screen 800x600+800+0\n"
824 "\t-profile CONF_PROFILE\n"
825 "\t\tUse the configuration profile CONF_PROFILE instead of the user selected default or just \"default\".\n"
831 "\t\tBe psychotic.\n"
832 "\t-i-really-know-what-i-am-doing-and-accept-full-responsibility-for-it\n"
833 "\t\tIf you need this help, you don't need this option.\n"
837 _e_main_shutdown(-1);
843 _e_main_cb_x_fatal(void *data EINA_UNUSED)
845 e_error_message_show("Lost X Connection.\n");
846 ecore_main_loop_quit();
850 if (inloop) longjmp(x_fatal_buff, -99);
855 _e_main_cb_signal_exit(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *ev EINA_UNUSED)
857 /* called on ctrl-c, kill (pid) (also SIGINT, SIGTERM and SIGQIT) */
858 ecore_main_loop_quit();
859 return ECORE_CALLBACK_RENEW;
863 _e_main_cb_signal_hup(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *ev EINA_UNUSED)
866 ecore_main_loop_quit();
867 return ECORE_CALLBACK_RENEW;
871 _e_main_cb_signal_user(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *ev)
873 Ecore_Event_Signal_User *e = ev;
877 // E_Action *a = e_action_find("configuration");
878 // if ((a) && (a->func.go)) a->func.go(NULL, NULL);
880 else if (e->number == 2)
882 // comp module has its own handler for this for enabling/disabling fps debug
884 return ECORE_CALLBACK_RENEW;
889 _e_main_dirs_init(void)
900 base = e_user_dir_get();
901 if (ecore_file_mksubdirs(base, dirs) != sizeof(dirs) / sizeof(dirs[0]) - 1)
903 e_error_message_show("Could not create one of the required "
904 "subdirectories of '%s'\n", base);
912 _e_main_dirs_shutdown(void)
918 _e_main_path_init(void)
922 /* setup data paths */
923 path_data = e_path_new();
926 e_error_message_show("Cannot allocate path for path_data\n");
929 e_prefix_data_concat_static(buf, "data");
930 e_path_default_path_append(path_data, buf);
932 /* setup image paths */
933 path_images = e_path_new();
936 e_error_message_show("Cannot allocate path for path_images\n");
939 e_user_dir_concat_static(buf, "/images");
940 e_path_default_path_append(path_images, buf);
941 e_prefix_data_concat_static(buf, "data/images");
942 e_path_default_path_append(path_images, buf);
944 /* setup font paths */
945 path_fonts = e_path_new();
948 e_error_message_show("Cannot allocate path for path_fonts\n");
951 e_user_dir_concat_static(buf, "/fonts");
952 e_path_default_path_append(path_fonts, buf);
953 e_prefix_data_concat_static(buf, "data/fonts");
954 e_path_default_path_append(path_fonts, buf);
956 /* setup icon paths */
957 path_icons = e_path_new();
960 e_error_message_show("Cannot allocate path for path_icons\n");
963 e_user_dir_concat_static(buf, "/icons");
964 e_path_default_path_append(path_icons, buf);
965 e_prefix_data_concat_static(buf, "data/icons");
966 e_path_default_path_append(path_icons, buf);
968 /* setup module paths */
969 path_modules = e_path_new();
972 e_error_message_show("Cannot allocate path for path_modules\n");
975 e_user_dir_concat_static(buf, "/modules");
976 e_path_default_path_append(path_modules, buf);
977 snprintf(buf, sizeof(buf), "%s/enlightenment/modules", e_prefix_lib_get());
978 e_path_default_path_append(path_modules, buf);
979 /* FIXME: eventually this has to go - moduels should have installers that
980 * add appropriate install paths (if not installed to user homedir) to
981 * e's module search dirs
983 snprintf(buf, sizeof(buf), "%s/enlightenment/modules_extra", e_prefix_lib_get());
984 e_path_default_path_append(path_modules, buf);
986 /* setup background paths */
987 path_backgrounds = e_path_new();
988 if (!path_backgrounds)
990 e_error_message_show("Cannot allocate path for path_backgrounds\n");
993 e_user_dir_concat_static(buf, "/backgrounds");
994 e_path_default_path_append(path_backgrounds, buf);
995 e_prefix_data_concat_static(buf, "data/backgrounds");
996 e_path_default_path_append(path_backgrounds, buf);
998 path_messages = e_path_new();
1001 e_error_message_show("Cannot allocate path for path_messages\n");
1004 e_user_dir_concat_static(buf, "/locale");
1005 e_path_default_path_append(path_messages, buf);
1006 e_path_default_path_append(path_messages, e_prefix_locale_get());
1012 _e_main_path_shutdown(void)
1016 e_object_del(E_OBJECT(path_data));
1021 e_object_del(E_OBJECT(path_images));
1026 e_object_del(E_OBJECT(path_fonts));
1031 e_object_del(E_OBJECT(path_icons));
1036 e_object_del(E_OBJECT(path_modules));
1037 path_modules = NULL;
1039 if (path_backgrounds)
1041 e_object_del(E_OBJECT(path_backgrounds));
1042 path_backgrounds = NULL;
1046 e_object_del(E_OBJECT(path_messages));
1047 path_messages = NULL;
1053 _e_main_screens_init(void)
1055 TS("\tscreens: client");
1056 if (!e_client_init()) return 0;
1058 TS("Compositor Init");
1059 PRCTL("[Winsys] start of compositor init");
1062 e_error_message_show(_("Enlightenment cannot create a compositor.\n"));
1063 _e_main_shutdown(-1);
1066 PRCTL("[Winsys] end of compositor init");
1067 _e_main_desk_restore();
1073 _e_main_screens_shutdown(void)
1077 e_client_shutdown();
1085 _e_main_desk_save(void)
1088 char env[1024], name[1024];
1091 EINA_LIST_FOREACH(e_comp->zones, l, zone)
1093 snprintf(name, sizeof(name), "DESK_%d_%d", 0, zone->num);
1094 snprintf(env, sizeof(env), "%d,%d", zone->desk_x_current, zone->desk_y_current);
1095 e_util_env_set(name, env);
1100 _e_main_desk_restore(void)
1108 EINA_LIST_FOREACH(e_comp->zones, l, zone)
1114 snprintf(name, sizeof(name), "DESK_%d_%d", 0, zone->num);
1117 snprintf(buf_e, sizeof(buf_e), "%s", env);
1118 if (!sscanf(buf_e, "%d,%d", &desk_x, &desk_y)) continue;
1119 desk = e_desk_at_xy_get(zone, desk_x, desk_y);
1120 if (!desk) continue;
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_modules_load_after(void *d EINA_UNUSED, int type EINA_UNUSED, void *ev EINA_UNUSED)
1135 E_FREE_FUNC(mod_init_end, ecore_event_handler_del);
1136 return ECORE_CALLBACK_RENEW;
1140 _e_main_modules_load(Eina_Bool safe_mode)
1143 e_module_all_load();
1149 crashmodule = getenv("E_MODULE_LOAD");
1150 if (crashmodule) m = e_module_new(crashmodule);
1152 if ((crashmodule) && (m))
1154 e_module_disable(m);
1155 e_object_del(E_OBJECT(m));
1157 e_error_message_show
1158 (_("Enlightenment crashed early on start and has<br>"
1159 "been restarted. There was an error loading the<br>"
1160 "module named: %s. This module has been disabled<br>"
1161 "and will not be loaded."), crashmodule);
1163 (_("Enlightenment crashed early on start and has been restarted"),
1164 _("Enlightenment crashed early on start and has been restarted.<br>"
1165 "There was an error loading the module named: %s<br><br>"
1166 "This module has been disabled and will not be loaded."), crashmodule);
1167 e_module_all_load();
1171 e_error_message_show
1172 (_("Enlightenment crashed early on start and has<br>"
1173 "been restarted. All modules have been disabled<br>"
1174 "and will not be loaded to help remove any problem<br>"
1175 "modules from your configuration. The module<br>"
1176 "configuration dialog should let you select your<br>"
1177 "modules again.\n"));
1179 (_("Enlightenment crashed early on start and has been restarted"),
1180 _("Enlightenment crashed early on start and has been restarted.<br>"
1181 "All modules have been disabled and will not be loaded to help<br>"
1182 "remove any problem modules from your configuration.<br><br>"
1183 "The module configuration dialog should let you select your<br>"
1186 mod_init_end = ecore_event_handler_add(E_EVENT_MODULE_INIT_END, _e_main_modules_load_after, NULL);
1191 _e_main_cb_idle_before(void *data EINA_UNUSED)
1193 e_client_idler_before();
1194 e_pointer_idler_before();
1196 return ECORE_CALLBACK_RENEW;
1200 _e_main_cb_idle_after(void *data EINA_UNUSED)
1202 static int first_idle = 1;
1207 #ifdef E_RELEASE_BUILD
1212 e_precache_end = EINA_TRUE;
1215 if (first_idle++ < 60)
1219 e_precache_end = EINA_TRUE;
1223 return ECORE_CALLBACK_RENEW;
1227 _e_main_create_wm_ready(void)
1229 FILE *_wmready_checker = NULL;
1231 _wmready_checker = fopen("/run/.wm_ready", "wb");
1232 if (_wmready_checker)
1234 TS("[WM] WINDOW MANAGER is READY!!!");
1235 PRCTL("[Winsys] WINDOW MANAGER is READY!!!");
1236 fclose(_wmready_checker);
1238 /*TODO: Next lines should be removed. */
1239 FILE *_tmp_wm_ready_checker;
1240 _tmp_wm_ready_checker = fopen("/tmp/.wm_ready", "wb");
1242 if (_tmp_wm_ready_checker)
1244 TS("[WM] temporary wm_ready path is created.");
1245 PRCTL("[Winsys] temporary wm_ready path is created.");
1246 fclose(_tmp_wm_ready_checker);
1250 TS("[WM] temporary wm_ready path create failed.");
1251 PRCTL("[Winsys] temporary wm_ready path create failed.");
1256 TS("[WM] WINDOW MANAGER is READY. BUT, failed to create .wm_ready file.");
1257 PRCTL("[Winsys] WINDOW MANAGER is READY. BUT, failed to create .wm_ready file.");