e_scale: make an internal header
[platform/upstream/enlightenment.git] / src / bin / e_main.c
index 4c37d22..6b15f81 100644 (file)
@@ -1,7 +1,20 @@
 #include "e.h"
+#include "e_actions_intern.h"
+#include "e_test_helper_intern.h"
+#include "e_user_intern.h"
+#include "e_utils_intern.h"
+#include "e_theme_intern.h"
+#include "e_signals_intern.h"
+#include "e_security_intern.h"
+#include "e_screensaver_intern.h"
+#include "e_scale_intern.h"
+
 #ifdef __linux__
 # include <sys/prctl.h>
 #endif
+#ifdef HAVE_SYSTEMD
+# include <systemd/sd-daemon.h>
+#endif
 
 #define MAX_LEVEL 80
 
      printf("ESTART: %1.5f [%1.5f] - %s\n", t1 - t0, t1 - t2, x); \
      t2 = t1;                                                     \
   }
+
+# define TSB(x)                                                  \
+  do {                                                           \
+     TRACE_DS_BEGIN(ESTART: %s, x);                              \
+     TS(x);                                                      \
+  } while (0)
+# define TSE(x)                                                  \
+  do {                                                           \
+     TRACE_DS_END();                                             \
+     TS(x);                                                      \
+  } while (0)
+# define TSM(x)                                                  \
+  do {                                                           \
+     TRACE_DS_MARK(ESTART: %s, x);                               \
+     TS(x);                                                      \
+  } while (0)
 static double t0, t1, t2;
 #else
 # define TS(x)
+# define TSB(x)
+# define TSE(x)
+# define TSM(x)
 #endif
-
 /*
  * i need to make more use of these when i'm baffled as to when something is
  * up. other hooks:
@@ -72,49 +103,42 @@ static void      _e_main_shutdown_push(int (*func)(void));
 static void      _e_main_parse_arguments(int argc, char **argv);
 static Eina_Bool _e_main_cb_signal_exit(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *ev EINA_UNUSED);
 static Eina_Bool _e_main_cb_signal_hup(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *ev EINA_UNUSED);
-static Eina_Bool _e_main_cb_signal_user(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *ev);
 static int       _e_main_dirs_init(void);
 static int       _e_main_dirs_shutdown(void);
 static int       _e_main_path_init(void);
 static int       _e_main_path_shutdown(void);
-static void      _e_main_test_formats(void);
 static int       _e_main_screens_init(void);
 static int       _e_main_screens_shutdown(void);
 static void      _e_main_desk_save(void);
 static void      _e_main_desk_restore(void);
-static void      _e_main_efreet_paths_init(void);
-static void      _e_main_modules_load(Eina_Bool safe_mode);
-static Eina_Bool _e_main_cb_x_flusher(void *data EINA_UNUSED);
 static Eina_Bool _e_main_cb_idle_before(void *data EINA_UNUSED);
 static Eina_Bool _e_main_cb_idle_after(void *data EINA_UNUSED);
-static Eina_Bool _e_main_cb_startup_fake_end(void *data EINA_UNUSED);
+static void      _e_main_create_wm_ready(void);
+static void      _e_main_hooks_clean(void);
+static void      _e_main_hook_call(E_Main_Hook_Point hookpoint, void *data EINA_UNUSED);
 
 /* local variables */
-static Eina_Bool really_know = EINA_FALSE;
-static Eina_Bool locked = EINA_FALSE;
-static Eina_Bool inloop = EINA_FALSE;
-static jmp_buf x_fatal_buff;
-
 static int _e_main_lvl = 0;
 static int(*_e_main_shutdown_func[MAX_LEVEL]) (void);
 
 static Ecore_Idle_Enterer *_idle_before = NULL;
 static Ecore_Idle_Enterer *_idle_after = NULL;
-static Ecore_Idle_Enterer *_idle_flush = NULL;
 
-static Ecore_Event_Handler *mod_init_end = NULL;
+static Eina_List *hooks = NULL;
+
+static int _e_main_hooks_delete = 0;
+static int _e_main_hooks_walking = 0;
+
+static Eina_Inlist *_e_main_hooks[] =
+{
+   [E_MAIN_HOOK_MODULE_LOAD_DONE] = NULL,
+   [E_MAIN_HOOK_E_INFO_READY] = NULL,
+   [E_MAIN_HOOK_POST_CLIENT_IDLER_BEFORE] = NULL
+};
 
 /* external variables */
-E_API Eina_Bool e_precache_end = EINA_FALSE;
-E_API Eina_Bool x_fatal = EINA_FALSE;
-E_API Eina_Bool good = EINA_FALSE;
-E_API Eina_Bool evil = EINA_FALSE;
 E_API Eina_Bool starting = EINA_TRUE;
 E_API Eina_Bool stopping = EINA_FALSE;
-E_API Eina_Bool restart = EINA_FALSE;
-E_API Eina_Bool e_nopause = EINA_FALSE;
-EINTERN const char *e_first_frame = NULL;
-EINTERN double e_first_frame_start_time = -1;
 
 static Eina_Bool
 _xdg_check_str(const char *env, const char *str)
@@ -133,13 +157,13 @@ _xdg_check_str(const char *env, const char *str)
 static void
 _xdg_data_dirs_augment(void)
 {
-   const char *s;
+   char *s;
    const char *p = e_prefix_get();
-   char newpath[4096], buf[4096];
+   char newpath[PATH_MAX], buf[PATH_MAX + PATH_MAX + 200];
 
    if (!p) return;
 
-   s = getenv("XDG_DATA_DIRS");
+   s = e_util_env_get("XDG_DATA_DIRS");
    if (s)
      {
         Eina_Bool pfxdata, pfx;
@@ -157,6 +181,7 @@ _xdg_data_dirs_augment(void)
                s);
              e_util_env_set("XDG_DATA_DIRS", buf);
           }
+        E_FREE(s);
      }
    else
      {
@@ -164,7 +189,7 @@ _xdg_data_dirs_augment(void)
         e_util_env_set("XDG_DATA_DIRS", buf);
      }
 
-   s = getenv("XDG_CONFIG_DIRS");
+   s = e_util_env_get("XDG_CONFIG_DIRS");
    snprintf(newpath, sizeof(newpath), "%s/etc/xdg", p);
    if (s)
      {
@@ -173,6 +198,7 @@ _xdg_data_dirs_augment(void)
              snprintf(buf, sizeof(buf), "%s:%s", newpath, s);
              e_util_env_set("XDG_CONFIG_DIRS", buf);
           }
+        E_FREE(s);
      }
    else
      {
@@ -180,7 +206,10 @@ _xdg_data_dirs_augment(void)
         e_util_env_set("XDG_CONFIG_DIRS", buf);
      }
 
-   if (!getenv("XDG_RUNTIME_DIR"))
+   s = e_util_env_get("XDG_RUNTIME_DIR");
+   if (s)
+     E_FREE(s);
+   else
      {
         const char *dir;
 
@@ -196,29 +225,103 @@ _xdg_data_dirs_augment(void)
      }
 
    /* set menu prefix so we get our e menu */
-   if (!getenv("XDG_MENU_PREFIX"))
+   s = e_util_env_get("XDG_MENU_PREFIX");
+   if (s)
+     E_FREE(s);
+   else
+     e_util_env_set("XDG_MENU_PREFIX", "e-");
+}
+
+static Eina_Bool
+_e_main_subsystem_defer(void *data EINA_UNUSED)
+{
+   TRACE_DS_BEGIN(MAIN:SUBSYSTEMS DEFER);
+
+   /* try to init delayed subsystems */
+
+   TRACE_DS_BEGIN(MAIN:DEFERRED INTERNAL SUBSYSTEMS INIT);
+
+   TSB("[DEFERRED] DPMS Init");
+   if (!e_dpms_init())
+     {
+        e_error_message_show(_("Enlightenment cannot set up dpms.\n"));
+        goto failed;
+     }
+   TSE("[DEFERRED] DPMS Init Done");
+   _e_main_shutdown_push(e_dpms_shutdown);
+
+   TSB("[DEFERRED] E_Dnd Init");
+   if (!e_dnd_init())
      {
-        e_util_env_set("XDG_MENU_PREFIX", "e-");
+        e_error_message_show(_("Enlightenment cannot set up its dnd system.\n"));
+        goto failed;
      }
+   TSE("[DEFERRED] E_Dnd Init Done");
+   _e_main_shutdown_push(e_dnd_shutdown);
+
+   TSB("[DEFERRED] E_Scale Init");
+   if (!e_scale_init())
+     {
+        e_error_message_show(_("Enlightenment cannot set up its scale system.\n"));
+        goto failed;
+     }
+   TSE("[DEFERRED] E_Scale Init Done");
+   _e_main_shutdown_push(e_scale_shutdown);
+
+   TSB("[DEFERRED] E_Test_Helper Init");
+   e_test_helper_init();
+   _e_main_shutdown_push(e_test_helper_shutdown);
+   TSE("[DEFERRED] E_Test_Helper Done");
+
+   TSB("[DEFERRED] E_INFO_SERVER Init");
+   e_info_server_init();
+   _e_main_shutdown_push(e_info_server_shutdown);
+   TSE("[DEFERRED] E_INFO_SERVER Done");
+
+   TRACE_DS_END();
+   TRACE_DS_BEGIN(MAIN:DEFERRED COMP JOB);
+
+   /* try to do deferred job of any subsystems*/
+   TSB("[DEFERRED] Compositor's deferred job");
+   e_comp_deferred_job();
+   TSE("[DEFERRED] Compositor's deferred job Done");
+
+   if (e_config->use_e_policy)
+     {
+        TSB("[DEFERRED] E_Policy's deferred job");
+        e_policy_deferred_job();
+        TSE("[DEFERRED] E_Policy's deferred job Done");
+     }
+
+   TSB("[DEFERRED] E_Module's deferred job");
+   e_module_deferred_job();
+   TSE("[DEFERRED] E_Module's deferred job Done");
+
+   TRACE_DS_END();
+   TRACE_DS_END();
+   return ECORE_CALLBACK_DONE;
+
+failed:
+   TSE("INIT FAILED");
+   TRACE_DS_END();
+   TRACE_DS_END();
+   _e_main_shutdown(-1);
+   return ECORE_CALLBACK_DONE;
 }
 
 static Eina_Bool
-_e_main_shelf_init_job(void *data EINA_UNUSED)
+_e_main_deferred_job_schedule(void *d EINA_UNUSED, int type EINA_UNUSED, void *ev EINA_UNUSED)
 {
-   e_shelf_config_update();
-   return ECORE_CALLBACK_CANCEL;
+   PRCTL("[Winsys] all modules loaded");
+   ecore_idler_add(_e_main_subsystem_defer, NULL);
+   return ECORE_CALLBACK_DONE;
 }
 
 /* externally accessible functions */
 int
 main(int argc, char **argv)
 {
-   Eina_Bool nostartup = EINA_FALSE;
-   Eina_Bool safe_mode = EINA_FALSE;
-   Eina_Bool after_restart = EINA_FALSE;
-   Eina_Bool waslocked = EINA_FALSE;
-   double t = 0.0, tstart = 0.0;
-   char *s = NULL, buff[32];
+   char *s = NULL;
    struct sigaction action;
 
 #ifdef __linux__
@@ -228,85 +331,84 @@ main(int argc, char **argv)
 #  endif
 # endif
 #endif
-   
+
+#ifdef TIZEN_TEST_GCOV
+   setenv("GCOV_PREFIX", "/tmp", 1);
+#endif
+
+   /* for debugging by redirecting stdout & stderr of e to a log file to tail */
+   setvbuf(stdout, NULL, _IONBF, 0);
+   setvbuf(stderr, NULL, _IONBF, 0);
+
 #ifdef TS_DO
    t0 = t1 = t2 = ecore_time_unix_get();
+   printf("ESTART(main) %1.5f\n", t0);
 #endif
-   TS("Begin Startup");
+   TRACE_DS_BEGIN(MAIN:BEGIN STARTUP);
+   TSB("Begin Startup");
+   PRCTL("[Winsys] start of main");
 
    /* trap deadly bug signals and allow some form of sane recovery */
    /* or ability to gdb attach and debug at this point - better than your */
    /* wm/desktop vanishing and not knowing what happened */
-   if (!getenv("NOTIFY_SOCKET"))
+
+   /* don't install SIGBUS handler */
+   /* Wayland shm sets up a sigbus handler for catching invalid shm region */
+   /* access. If we setup our sigbus handler here, then the wl-shm sigbus */
+   /* handler will not function properly */
+   s = e_util_env_get("NOTIFY_SOCKET");
+   if (s)
+     E_FREE(s);
+   else
      {
-        TS("Signal Trap");
+        TSB("Signal Trap");
         action.sa_sigaction = e_sigseg_act;
-       action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
-       sigemptyset(&action.sa_mask);
-       sigaction(SIGSEGV, &action, NULL);
-
-       action.sa_sigaction = e_sigill_act;
-       action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
-       sigemptyset(&action.sa_mask);
-       sigaction(SIGILL, &action, NULL);
-
-       action.sa_sigaction = e_sigfpe_act;
-       action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
-       sigemptyset(&action.sa_mask);
-       sigaction(SIGFPE, &action, NULL);
-
-#ifndef HAVE_WAYLAND_ONLY
-       action.sa_sigaction = e_sigbus_act;
-       action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
-       sigemptyset(&action.sa_mask);
-       sigaction(SIGBUS, &action, NULL);
-#endif
+        action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
+        sigemptyset(&action.sa_mask);
+        sigaction(SIGSEGV, &action, NULL);
 
-       action.sa_sigaction = e_sigabrt_act;
-       action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
-       sigemptyset(&action.sa_mask);
-       sigaction(SIGABRT, &action, NULL);
-       TS("Signal Trap Done");
-     }
+        action.sa_sigaction = e_sigill_act;
+        action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
+        sigemptyset(&action.sa_mask);
+        sigaction(SIGILL, &action, NULL);
 
-   t = ecore_time_unix_get();
-   s = getenv("E_START_TIME");
-   if ((s) && (!getenv("E_RESTART_OK")))
-     {
-        tstart = atof(s);
-        if ((t - tstart) < 5.0) safe_mode = EINA_TRUE;
+        action.sa_sigaction = e_sigfpe_act;
+        action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
+        sigemptyset(&action.sa_mask);
+        sigaction(SIGFPE, &action, NULL);
+
+        action.sa_sigaction = e_sigabrt_act;
+        action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
+        sigemptyset(&action.sa_mask);
+        sigaction(SIGABRT, &action, NULL);
+        TSE("Signal Trap Done");
      }
-   tstart = t;
-   snprintf(buff, sizeof(buff), "%1.1f", tstart);
-   e_util_env_set("E_START_TIME", buff);
 
-   if (getenv("E_START_MTRACK"))
-     e_util_env_set("MTRACK", NULL);
-   TS("Eina Init");
+   TSB("Eina Init");
    if (!eina_init())
      {
         e_error_message_show(_("Enlightenment cannot initialize Eina!\n"));
-        _e_main_shutdown(-1);
+        goto failed;
      }
+   TSE("Eina Init Done");
    _e_main_shutdown_push(eina_shutdown);
+
+#ifdef OBJECT_HASH_CHECK
+   TSB("E_Object Hash Init");
+   e_object_hash_init();
+   TSE("E_Object Hash Init Done");
+#endif
+
+   TSB("E_Log Init");
    if (!e_log_init())
      {
         e_error_message_show(_("Enlightenment could not create a logging domain!\n"));
-        _e_main_shutdown(-1);
+        goto failed;
      }
-#ifdef TS_DO
-#undef TS
-# define TS(x)                                                    \
-  {                                                               \
-     t1 = ecore_time_unix_get();                                  \
-     printf("ESTART: %1.5f [%1.5f] - %s\n", t1 - t0, t1 - t2, x); \
-     t2 = t1;                                                     \
-  }
-#endif
-   TS("Eina Init Done");
+   TSE("E_Log Init Done");
    _e_main_shutdown_push(e_log_shutdown);
 
-   TS("Determine Prefix");
+   TSB("Determine Prefix");
    if (!e_prefix_determine(argv[0]))
      {
         fprintf(stderr,
@@ -315,754 +417,395 @@ main(int argc, char **argv)
                 "       This is because it is not on Linux AND has been\n"
                 "       executed strangely. This is unusual.\n");
      }
-   TS("Determine Prefix Done");
-
-   /* for debugging by redirecting stdout of e to a log file to tail */
-   setvbuf(stdout, NULL, _IONBF, 0);
+   TSE("Determine Prefix Done");
 
-   TS("Environment Variables");
-   if (getenv("E_RESTART")) after_restart = EINA_TRUE;
-   if (getenv("DESKTOP_STARTUP_ID"))
-     e_util_env_set("DESKTOP_STARTUP_ID", NULL);
-   e_util_env_set("E_RESTART_OK", NULL);
-   e_util_env_set("PANTS", "ON");
-   e_util_env_set("DESKTOP", "Enlightenment");
-   TS("Environment Variables Done");
-
-   TS("Parse Arguments");
+   TSB("Parse Arguments");
    _e_main_parse_arguments(argc, argv);
-   TS("Parse Arguments Done");
+   TSE("Parse Arguments Done");
 
    /*** Initialize Core EFL Libraries We Need ***/
 
-   TS("Eet Init");
+   TSB("Eet Init");
    if (!eet_init())
      {
         e_error_message_show(_("Enlightenment cannot initialize Eet!\n"));
-        _e_main_shutdown(-1);
+        goto failed;
      }
-   TS("Eet Init Done");
+   TSE("Eet Init Done");
    _e_main_shutdown_push(eet_shutdown);
 
-   TS("Ecore Init");
+   /* Allow ecore to not load system modules.
+    * Without it ecore_init will block until dbus authentication
+    * and registration are complete.
+    */
+   ecore_app_no_system_modules();
+
+   TSB("Ecore Init");
    if (!ecore_init())
      {
         e_error_message_show(_("Enlightenment cannot initialize Ecore!\n"));
-        _e_main_shutdown(-1);
+        goto failed;
      }
-   TS("Ecore Init Done");
+   TSE("Ecore Init Done");
    _e_main_shutdown_push(ecore_shutdown);
 
-   e_first_frame = getenv("E_FIRST_FRAME");
-   if (e_first_frame && (!e_first_frame[0]))
-     e_first_frame = NULL;
-   else
-     e_first_frame_start_time = ecore_time_get();
-
-   TS("EIO Init");
+   TSB("EIO Init");
    if (!eio_init())
      {
         e_error_message_show(_("Enlightenment cannot initialize EIO!\n"));
-        _e_main_shutdown(-1);
+        goto failed;
      }
-   TS("EIO Init Done");
+   TSE("EIO Init Done");
    _e_main_shutdown_push(eio_shutdown);
 
-   ecore_app_args_set(argc, (const char **)argv);
-
-   TS("Ecore Event Handlers");
+   TSB("Ecore Event Handlers");
    if (!ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT,
                                 _e_main_cb_signal_exit, NULL))
      {
         e_error_message_show(_("Enlightenment cannot set up an exit signal handler.\n"
                                "Perhaps you are out of memory?"));
-        _e_main_shutdown(-1);
+        goto failed;
      }
    if (!ecore_event_handler_add(ECORE_EVENT_SIGNAL_HUP,
                                 _e_main_cb_signal_hup, NULL))
      {
         e_error_message_show(_("Enlightenment cannot set up a HUP signal handler.\n"
                                "Perhaps you are out of memory?"));
-        _e_main_shutdown(-1);
-     }
-   if (!ecore_event_handler_add(ECORE_EVENT_SIGNAL_USER,
-                                _e_main_cb_signal_user, NULL))
-     {
-        e_error_message_show(_("Enlightenment cannot set up a USER signal handler.\n"
-                               "Perhaps you are out of memory?"));
-        _e_main_shutdown(-1);
+        goto failed;
      }
-   TS("Ecore Event Handlers Done");
+   TSE("Ecore Event Handlers Done");
 
-   TS("Ecore_File Init");
+   TSB("Ecore_File Init");
    if (!ecore_file_init())
      {
         e_error_message_show(_("Enlightenment cannot initialize Ecore_File!\n"));
-        _e_main_shutdown(-1);
+        goto failed;
      }
-   TS("Ecore_File Init Done");
+   TSE("Ecore_File Init Done");
    _e_main_shutdown_push(ecore_file_shutdown);
 
-   TS("Ecore_Con Init");
-   if (!ecore_con_init())
-     {
-        e_error_message_show(_("Enlightenment cannot initialize Ecore_Con!\n"));
-        _e_main_shutdown(-1);
-     }
-   TS("Ecore_Con Init Done");
-   _e_main_shutdown_push(ecore_con_shutdown);
-
-   TS("Ecore_Ipc Init");
-   if (!ecore_ipc_init())
-     {
-        e_error_message_show(_("Enlightenment cannot initialize Ecore_Ipc!\n"));
-        _e_main_shutdown(-1);
-     }
-   TS("Ecore_Ipc Init Done");
-   _e_main_shutdown_push(ecore_ipc_shutdown);
+   TSB("E_Util_File_Monitor Init");
+   e_util_file_monitor_init();
+   TSE("E_Util_File_Monitor Init Done");
+   _e_main_shutdown_push(e_util_file_monitor_shutdown);
 
    _idle_before = ecore_idle_enterer_before_add(_e_main_cb_idle_before, NULL);
 
+   TSB("XDG_DATA_DIRS Init");
    _xdg_data_dirs_augment();
+   TSE("XDG_DATA_DIRS Init Done");
 
-   TS("Ecore_Evas Init");
+   TSB("Ecore_Evas Init");
    if (!ecore_evas_init())
      {
         e_error_message_show(_("Enlightenment cannot initialize Ecore_Evas!\n"));
-        _e_main_shutdown(-1);
-     }
-   TS("Ecore_Evas Init Done");
-//   _e_main_shutdown_push(ecore_evas_shutdown);
-
-   TS("Elementary Init");
-   if (!elm_init(argc, argv))
-     {
-        e_error_message_show(_("Enlightenment cannot initialize Elementary!\n"));
-        _e_main_shutdown(-1);
+        goto failed;
      }
-   TS("Elementary Init Done");
-   //_e_main_shutdown_push(elm_shutdown);
+   TSE("Ecore_Evas Init Done");
 
-   TS("Emotion Init");
-   if (!emotion_init())
-     {
-        e_error_message_show(_("Enlightenment cannot initialize Emotion!\n"));
-        _e_main_shutdown(-1);
-     }
-   TS("Emotion Init Done");
-   _e_main_shutdown_push((void *)emotion_shutdown);
-
-   /* e doesn't sync to compositor - it should be one */
-   ecore_evas_app_comp_sync_set(0);
-
-   TS("Ecore_Evas Engine Check");
-#ifdef HAVE_WAYLAND_ONLY
-   if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_WAYLAND_SHM))
-     {
-        e_error_message_show(_("Enlightenment found ecore_evas doesn't support the Wayland SHM\n"
-                               "rendering in Evas. Please check your installation of Evas and\n"
-                                "Ecore and check they support the Wayland SHM rendering engine."));
-        _e_main_shutdown(-1);
-     }
-#else
-   if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_XCB))
-     {
-        if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_XLIB))
-          {
-             e_error_message_show(_("Enlightenment found ecore_evas doesn't support the Software X11\n"
-                                    "rendering in Evas. Please check your installation of Evas and\n"
-                                    "Ecore and check they support the Software X11 rendering engine."));
-             _e_main_shutdown(-1);
-          }
-     }
-#endif
-   if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_BUFFER))
-     {
-        e_error_message_show(_("Enlightenment found ecore_evas doesn't support the Software Buffer\n"
-                               "rendering in Evas. Please check your installation of Evas and\n"
-                               "Ecore and check they support the Software Buffer rendering engine."));
-        _e_main_shutdown(-1);
-     }
-   TS("Ecore_Evas Engine Check Done");
-
-   TS("Edje Init");
+   TSB("Edje Init");
    if (!edje_init())
      {
         e_error_message_show(_("Enlightenment cannot initialize Edje!\n"));
-        _e_main_shutdown(-1);
+        goto failed;
      }
-   TS("Edje Init Done");
+   TSE("Edje Init Done");
    _e_main_shutdown_push(edje_shutdown);
-   edje_freeze();
 
    /*** Initialize E Subsystems We Need ***/
 
-   TS("E Intl Init");
-   if (!e_intl_init())
+   TSB("E User Init");
+   if (!e_user_init())
      {
-        e_error_message_show(_("Enlightenment cannot initialize E_Intl!\n"));
-        _e_main_shutdown(-1);
+        e_error_message_show(_("Enlightenment cannot set up user home path\n"));
+        goto failed;
      }
-   TS("E Intl Init Done");
-   _e_main_shutdown_push(e_intl_shutdown);
-
-#ifndef HAVE_WAYLAND_ONLY
-   /* init white box of death alert */
-   TS("E_Alert Init");
-   if (!e_alert_init())
-     {
-        e_error_message_show(_("Enlightenment cannot initialize its emergency alert system.\n"
-                               "Have you set your DISPLAY variable?"));
-        _e_main_shutdown(-1);
-     }
-   TS("E_Alert Init Done");
-   _e_main_shutdown_push(e_alert_shutdown);
-#endif
-
-   TS("E_Configure Init");
-   e_configure_init();
-   TS("E_Configure Init Done");
+   TSE("E User Init Done");
+   _e_main_shutdown_push(e_user_shutdown);
 
-   TS("E Directories Init");
+   TSB("E Directories Init");
    /* setup directories we will be using for configurations storage etc. */
    if (!_e_main_dirs_init())
      {
         e_error_message_show(_("Enlightenment cannot create directories in your home directory.\n"
                                "Perhaps you have no home directory or the disk is full?"));
-        _e_main_shutdown(-1);
+        goto failed;
      }
-   TS("E Directories Init Done");
+   TSE("E Directories Init Done");
    _e_main_shutdown_push(_e_main_dirs_shutdown);
 
-   TS("E_Filereg Init");
-   if (!e_filereg_init())
-     {
-        e_error_message_show(_("Enlightenment cannot set up its file registry system.\n"));
-        _e_main_shutdown(-1);
-     }
-   TS("E_Filereg Init Done");
-   _e_main_shutdown_push(e_filereg_shutdown);
-
-   TS("E_Config Init");
+   TSB("E_Config Init");
    if (!e_config_init())
      {
         e_error_message_show(_("Enlightenment cannot set up its config system.\n"));
-        _e_main_shutdown(-1);
+        goto failed;
      }
-   TS("E_Config Init Done");
+   TSE("E_Config Init Done");
    _e_main_shutdown_push(e_config_shutdown);
 
-   TS("E_Env Init");
+   TSB("E_Env Init");
    if (!e_env_init())
      {
         e_error_message_show(_("Enlightenment cannot set up its environment.\n"));
-        _e_main_shutdown(-1);
+        goto failed;
      }
-   TS("E_Env Init Done");
+   TSE("E_Env Init Done");
    _e_main_shutdown_push(e_env_shutdown);
 
-   efreet_desktop_environment_set(e_config->desktop_environment);
-   e_util_env_set("E_ICON_THEME", e_config->icon_theme);
    ecore_exe_run_priority_set(e_config->priority);
-   locked |= e_config->desklock_start_locked;
 
-   s = getenv("E_DESKLOCK_LOCKED");
-   if ((s) && (!strcmp(s, "locked"))) waslocked = EINA_TRUE;
-
-   TS("E Paths Init");
+   TSB("E Paths Init");
    if (!_e_main_path_init())
      {
         e_error_message_show(_("Enlightenment cannot set up paths for finding files.\n"
                                "Perhaps you are out of memory?"));
-        _e_main_shutdown(-1);
+        goto failed;
      }
-   TS("E Paths Init Done");
+   TSE("E Paths Init Done");
    _e_main_shutdown_push(_e_main_path_shutdown);
 
-   TS("E_Ipc Init");
-   if (!e_ipc_init()) _e_main_shutdown(-1);
-   TS("E_Ipc Init Done");
-   _e_main_shutdown_push(e_ipc_shutdown);
-
-   edje_frametime_set(1.0 / e_config->framerate);
-
-   TS("E_Font Init");
-   if (!e_font_init())
-     {
-        e_error_message_show(_("Enlightenment cannot set up its font system.\n"));
-        _e_main_shutdown(-1);
-     }
-   TS("E_Font Init Done");
-   _e_main_shutdown_push(e_font_shutdown);
-
-   TS("E_Font Apply");
-   e_font_apply();
-   TS("E_Font Apply Done");
+   ecore_animator_frametime_set(1.0 / e_config->framerate);
 
-   TS("E_Theme Init");
+   TSB("E_Theme Init");
    if (!e_theme_init())
      {
         e_error_message_show(_("Enlightenment cannot set up its theme system.\n"));
-        _e_main_shutdown(-1);
+        goto failed;
      }
-   TS("E_Theme Init Done");
+   TSE("E_Theme Init Done");
    _e_main_shutdown_push(e_theme_shutdown);
 
-   TS("E_Moveresize Init");
-   e_moveresize_init();
-   TS("E_Moveresize Init Done");
-   _e_main_shutdown_push(e_moveresize_shutdown);
-
-   if (e_config->show_splash)
-     e_init_status_set(_("Setup Message Bus"));
-   TS("E_Msgbus Init");
-   if (e_msgbus_init())
-     _e_main_shutdown_push(e_msgbus_shutdown);
-   TS("E_Msgbus Init Done");
-
-   TS("Efreet Init");
-   if (!efreet_init())
-     {
-        e_error_message_show(_("Enlightenment cannot initialize the FDO desktop system.\n"
-                               "Perhaps you lack permissions on ~/.cache/efreet or are\n"
-                               "out of memory or disk space?"));
-        _e_main_shutdown(-1);
-     }
-   TS("Efreet Init Done");
-   _e_main_shutdown_push(efreet_shutdown);
-
-   if (e_config->show_splash)
-     e_init_status_set(_("Starting International Support"));
-   TS("E_Intl Post Init");
-   if (!e_intl_post_init())
-     {
-        e_error_message_show(_("Enlightenment cannot set up its intl system.\n"));
-        _e_main_shutdown(-1);
-     }
-   TS("E_Intl Post Init Done");
-   _e_main_shutdown_push(e_intl_post_shutdown);
-
-   e_screensaver_preinit();
-
-   if (e_config->show_splash)
-     e_init_status_set(_("Setup Actions"));
-   TS("E_Actions Init");
+   TSB("E_Actions Init");
    if (!e_actions_init())
      {
         e_error_message_show(_("Enlightenment cannot set up its actions system.\n"));
-        _e_main_shutdown(-1);
+        goto failed;
      }
-   TS("E_Actions Init Done");
+   TSE("E_Actions Init Done");
    _e_main_shutdown_push(e_actions_shutdown);
 
    /* these just add event handlers and can't fail
     * timestamping them is dumb.
     */
+   e_screensaver_preinit();
    e_zone_init();
    e_desk_init();
-   e_exehist_init();
+   e_magnifier_init();
 
-   if (e_config->show_splash)
-     e_init_status_set(_("Setup Powersave Modes"));
-   TS("E_Powersave Init");
-   if (!e_powersave_init())
+   TRACE_DS_BEGIN(MAIN:WAIT /dev/dri/card0);
+   if (e_config->sleep_for_dri)
      {
-        e_error_message_show(_("Enlightenment cannot set up its powersave modes.\n"));
-        _e_main_shutdown(-1);
+        while(access("/dev/dri/card0", F_OK) != 0)
+          {
+             struct timespec req, rem;
+             req.tv_sec = 0;
+             req.tv_nsec = 50000000L;
+             nanosleep(&req, &rem);
+          }
      }
-   TS("E_Powersave Init Done");
-   _e_main_shutdown_push(e_powersave_shutdown);
+   TRACE_DS_END();
 
-   if (e_config->show_splash)
-     e_init_status_set(_("Setup Screensaver"));
-   TS("E_Screensaver Init");
-   if (!e_screensaver_init())
+   TSB("E_Msg Init");
+   if (!e_msg_init())
      {
-        e_error_message_show(_("Enlightenment cannot configure the X screensaver.\n"));
-        _e_main_shutdown(-1);
+        e_error_message_show(_("Enlightenment cannot set up its msg system."));
+        goto failed;
      }
-   TS("E_Screensaver Init Done");
-   _e_main_shutdown_push(e_screensaver_shutdown);
+   TSE("E_Msg Init Done");
+   _e_main_shutdown_push(e_msg_shutdown);
 
-   if (e_config->show_splash)
-     e_init_status_set(_("Setup Screens"));
-   TS("Screens Init");
-   if (!_e_main_screens_init())
-     {
-        e_error_message_show(_("Enlightenment set up window management for all the screens on your system\n"
-                               "failed. Perhaps another window manager is running?\n"));
-        _e_main_shutdown(-1);
-     }
-   TS("Screens Init Done");
-   _e_main_shutdown_push(_e_main_screens_shutdown);
-   e_screensaver_force_update();
+   e_module_event_init();
 
-   TS("E_Pointer Init");
+   TSB("E_Pointer Init");
    if (!e_pointer_init())
      {
         e_error_message_show(_("Enlightenment cannot set up its pointer system.\n"));
-        _e_main_shutdown(-1);
+        goto failed;
      }
-   TS("E_Pointer Init Done");
+   TSE("E_Pointer Init Done");
    _e_main_shutdown_push(e_pointer_shutdown);
-   e_menu_init();
-
-   TS("E_Scale Init");
-   if (!e_scale_init())
-     {
-        e_error_message_show(_("Enlightenment cannot set up its scale system.\n"));
-        _e_main_shutdown(-1);
-     }
-   TS("E_Scale Init Done");
-   _e_main_shutdown_push(e_scale_shutdown);
-
-   if (e_config->show_splash)
-     {
-        TS("E_Splash Init");
-        if (!e_init_init())
-          {
-             e_error_message_show(_("Enlightenment cannot set up its init screen.\n"));
-             _e_main_shutdown(-1);
-          }
-        TS("E_Splash Init Done");
-        _e_main_shutdown_push(e_init_shutdown);
-     }
-   if (!((!e_config->show_splash) || (after_restart)))
-     e_init_show();
-
-   if (!really_know)
-     {
-        TS("Test File Format Support");
-        _e_main_test_formats();
-        TS("Test File Format Support Done");
-     }
-   else
-     {
-        efreet_icon_extension_add(".svg");
-        efreet_icon_extension_add(".jpg");
-        efreet_icon_extension_add(".png");
-        efreet_icon_extension_add(".edj");
-     }
-
-   if (e_config->show_splash)
-     e_init_status_set(_("Setup ACPI"));
-   TS("E_Acpi Init");
-   e_acpi_init();
-   TS("E_Acpi Init Done");
-   _e_main_shutdown_push(e_acpi_shutdown);
 
-   if (e_config->show_splash)
-     e_init_status_set(_("Setup Backlight"));
-   TS("E_Backlight Init");
-   if (!e_backlight_init())
+   TRACE_DS_BEGIN(MAIN:SCREEN INIT);
+   TSB("Screens Init");
+   if (!_e_main_screens_init())
      {
-        e_error_message_show(_("Enlightenment cannot configure the backlight.\n"));
-        _e_main_shutdown(-1);
+        e_error_message_show(_("Enlightenment set up window management for all the screens on your system\n"
+                               "failed. Perhaps another window manager is running?\n"));
+        goto failed;
      }
-   TS("E_Backlight Init Done");
+   TSE("Screens Init Done");
+   _e_main_shutdown_push(_e_main_screens_shutdown);
+   TRACE_DS_END();
 
-   if (e_config->show_splash)
-     e_init_status_set(_("Setup DPMS"));
-   TS("E_Dpms Init");
-   if (!e_dpms_init())
+   TSB("E_Devicemgr Init");
+   if (!e_devicemgr_init())
      {
-        e_error_message_show(_("Enlightenment cannot configure the DPMS settings.\n"));
-        _e_main_shutdown(-1);
+        e_error_message_show(_("Enlightenment cannot set up its device_manager system.\n"));
+        goto failed;
      }
-   TS("E_Dpms Init Done");
-   _e_main_shutdown_push(e_dpms_shutdown);
+   TSE("E_Devicemgr Init Done");
+   _e_main_shutdown_push(e_devicemgr_shutdown);
 
-   if (e_config->show_splash)
-     e_init_status_set(_("Setup Desklock"));
-   TS("E_Desklock Init");
-   if (!e_desklock_init())
+   TSB("E_Keyrouter Init");
+   if (!e_keyrouter_init())
      {
-        e_error_message_show(_("Enlightenment cannot set up its desk locking system.\n"));
-        _e_main_shutdown(-1);
+        e_error_message_show(_("Enlightenment cannot set up its keyrouting system.\n"));
+        goto failed;
      }
-   TS("E_Desklock Init Done");
-   _e_main_shutdown_push(e_desklock_shutdown);
-
-   if (waslocked || (locked && ((!after_restart) || (!getenv("E_DESKLOCK_UNLOCKED")))))
-     e_desklock_show(EINA_TRUE);
+   TSE("E_Keyrouter Init Done");
+   _e_main_shutdown_push(e_keyrouter_shutdown);
 
-   if (e_config->show_splash)
-     e_init_status_set(_("Setup Paths"));
-   TS("Efreet Paths");
-   _e_main_efreet_paths_init();
-   TS("Efreet Paths Done");
-
-   if (e_config->show_splash)
-     e_init_status_set(_("Setup System Controls"));
-   TS("E_Sys Init");
-   if (!e_sys_init())
+   if (e_config->eom_enable)
      {
-        e_error_message_show(_("Enlightenment cannot initialize the System Command system.\n"));
-        _e_main_shutdown(-1);
+        TSB("Eom Init");
+        if (!e_eom_init())
+          {
+             e_error_message_show(_("Enlightenment cannot set up eom.\n"));
+             goto failed;
+          }
+        TSE("Eom Init Done");
+        _e_main_shutdown_push(e_eom_shutdown);
      }
-   TS("E_Sys Init Done");
-   _e_main_shutdown_push(e_sys_shutdown);
 
-   if (e_config->show_splash)
-     e_init_status_set(_("Setup Execution System"));
-   TS("E_Exec Init");
-   if (!e_exec_init())
+   TSB("E_Screensaver Init");
+   if (!e_screensaver_init())
      {
-        e_error_message_show(_("Enlightenment cannot set up its exec system.\n"));
-        _e_main_shutdown(-1);
+        e_error_message_show(_("Enlightenment cannot configure the X screensaver.\n"));
+        goto failed;
      }
-   TS("E_Exec Init Done");
+   TSE("E_Screensaver Init Done");
+   _e_main_shutdown_push(e_screensaver_shutdown);
 
-   TS("E_Comp Freeze");
+   TSB("E_Comp Freeze");
    e_comp_all_freeze();
-   TS("E_Comp Freeze Done");
-
-   if (e_config->show_splash)
-     e_init_status_set(_("Setup Filemanager"));
-   TS("E_Fm2 Init");
-   if (!e_fm2_init())
-     {
-        e_error_message_show(_("Enlightenment cannot initialize the File manager.\n"));
-        _e_main_shutdown(-1);
-     }
-   TS("E_Fm2 Init Done");
-   _e_main_shutdown_push(e_fm2_shutdown);
-
-   if (e_config->show_splash)
-     e_init_status_set(_("Setup Message System"));
-   TS("E_Msg Init");
-   if (!e_msg_init())
-     {
-        e_error_message_show(_("Enlightenment cannot set up its msg system.\n"));
-        _e_main_shutdown(-1);
-     }
-   TS("E_Msg Init Done");
-   _e_main_shutdown_push(e_msg_shutdown);
+   TSE("E_Comp Freeze Done");
 
-   if (e_config->show_splash)
-     e_init_status_set(_("Setup Grab Input Handling"));
-   TS("E_Grabinput Init");
+   TSB("E_Grabinput Init");
    if (!e_grabinput_init())
      {
         e_error_message_show(_("Enlightenment cannot set up its grab input handling system.\n"));
-        _e_main_shutdown(-1);
+        goto failed;
      }
-   TS("E_Grabinput Init Done");
+   TSE("E_Grabinput Init Done");
    _e_main_shutdown_push(e_grabinput_shutdown);
 
-   if (e_config->show_splash)
-     e_init_status_set(_("Setup Modules"));
-   TS("E_Module Init");
+   TS("E_Gesture Init");
+   e_gesture_init();
+   _e_main_shutdown_push(e_gesture_shutdown);
+
+   ecore_event_handler_add(E_EVENT_MODULE_INIT_END, _e_main_deferred_job_schedule, NULL);
+
+   TSB("E_Module Init");
    if (!e_module_init())
      {
         e_error_message_show(_("Enlightenment cannot set up its module system.\n"));
-        _e_main_shutdown(-1);
+        goto failed;
      }
-   TS("E_Module Init Done");
+   TSE("E_Module Init Done");
    _e_main_shutdown_push(e_module_shutdown);
 
-   if (e_config->show_splash)
-     e_init_status_set(_("Setup Remembers"));
-   TS("E_Remember Init");
-   if (!e_remember_init(after_restart ? E_STARTUP_RESTART : E_STARTUP_START))
-     {
-        e_error_message_show(_("Enlightenment cannot setup remember settings.\n"));
-        _e_main_shutdown(-1);
-     }
-   TS("E_Remember Init Done");
-   _e_main_shutdown_push(e_remember_shutdown);
-
-   if (e_config->show_splash)
-     e_init_status_set(_("Setup Gadcon"));
-   TS("E_Gadcon Init");
-   if (!e_gadcon_init())
-     {
-        e_error_message_show(_("Enlightenment cannot set up its gadget control system.\n"));
-        _e_main_shutdown(-1);
-     }
-   TS("E_Gadcon Init Done");
-   _e_main_shutdown_push(e_gadcon_shutdown);
-
-   if (e_config->show_splash)
-     e_init_status_set(_("Setup Toolbars"));
-   TS("E_Toolbar Init");
-   if (!e_toolbar_init())
-     {
-        e_error_message_show(_("Enlightenment cannot set up its toolbars.\n"));
-        _e_main_shutdown(-1);
-     }
-   TS("E_Toolbar Init Done");
-   _e_main_shutdown_push(e_toolbar_shutdown);
-
-   if (e_config->show_splash)
-     e_init_status_set(_("Setup Wallpaper"));
-   TS("E_Bg Init");
-   if (!e_bg_init())
-     {
-        e_error_message_show(_("Enlightenment cannot set up its desktop background system.\n"));
-        _e_main_shutdown(-1);
-     }
-   TS("E_Bg Init Done");
-   _e_main_shutdown_push(e_bg_shutdown);
-
-   if (e_config->show_splash)
-     e_init_status_set(_("Setup Mouse"));
-   TS("E_Mouse Init");
+   TSB("E_Mouse Init");
    if (!e_mouse_update())
      {
         e_error_message_show(_("Enlightenment cannot configure the mouse settings.\n"));
-        _e_main_shutdown(-1);
-     }
-   TS("E_Mouse Init Done");
-
-   if (e_config->show_splash)
-     e_init_status_set(_("Setup Bindings"));
-   TS("E_Bindings Init");
-   if (!e_bindings_init())
-     {
-        e_error_message_show(_("Enlightenment cannot set up its bindings system.\n"));
-        _e_main_shutdown(-1);
+        goto failed;
      }
-   TS("E_Bindings Init Done");
-   _e_main_shutdown_push(e_bindings_shutdown);
+   TSE("E_Mouse Init Done");
 
-   if (e_config->show_splash)
-     e_init_status_set(_("Setup Thumbnailer"));
-   TS("E_Thumb Init");
-   if (!e_thumb_init())
-     {
-        e_error_message_show(_("Enlightenment cannot initialize the Thumbnailing system.\n"));
-        _e_main_shutdown(-1);
-     }
-   TS("E_Thumb Init Done");
-   _e_main_shutdown_push(e_thumb_shutdown);
-
-   TS("E_Icon Init");
+   TSB("E_Icon Init");
    if (!e_icon_init())
      {
         e_error_message_show(_("Enlightenment cannot initialize the Icon Cache system.\n"));
-        _e_main_shutdown(-1);
+        goto failed;
      }
-   TS("E_Icon Init Done");
+   TSE("E_Icon Init Done");
    _e_main_shutdown_push(e_icon_shutdown);
 
-   TS("E_Update Init");
-   if (!e_update_init())
+   if (e_config->use_e_policy)
      {
-        e_error_message_show(_("Enlightenment cannot initialize the Update system.\n"));
-        _e_main_shutdown(-1);
-     }
-   TS("E_Update Init Done");
-   _e_main_shutdown_push(e_update_shutdown);
-
-   if (e_config->show_splash)
-     e_init_status_set(_("Setup Desktop Environment"));
-   TS("E_Deskenv Init");
-   if (!e_deskenv_init())
-     {
-        e_error_message_show(_("Enlightenment cannot initialize its desktop environment.\n"));
-        _e_main_shutdown(-1);
+        TSB("E_Policy Init");
+        if (!e_policy_init())
+          {
+             e_error_message_show(_("Enlightenment cannot setup policy system!\n"));
+             goto failed;
+          }
+        TSE("E_Policy Init Done");
+        _e_main_shutdown_push(e_policy_shutdown);
      }
-   TS("E_Deskenv Init Done");
-   _e_main_shutdown_push(e_deskenv_shutdown);
 
-   if (e_config->show_splash)
-     e_init_status_set(_("Setup File Ordering"));
-   TS("E_Order Init");
-   if (!e_order_init())
+   TSB("E_Process Init");
+   if (!e_process_init())
      {
-        e_error_message_show(_("Enlightenment cannot set up its order file system.\n"));
-        _e_main_shutdown(-1);
+        e_error_message_show(_("Enlightenment cannot setup process managing system!\n"));
+        goto failed;
      }
-   TS("E_Order Init Done");
-   _e_main_shutdown_push(e_order_shutdown);
-
-   TS("Add Idler For X Flush");
-   _idle_flush = ecore_idle_enterer_add(_e_main_cb_x_flusher, NULL);
-   TS("Add Idler For X Flush Done");
+   TSE("E_Process Init Done");
+   _e_main_shutdown_push(e_process_shutdown);
 
-   TS("E_Comp_Canvas Keys Grab");
-   e_comp_canvas_keys_grab();
-   TS("E_Comp_Canvas Keys Grab Done");
-
-   if (e_config->show_splash)
-     e_init_status_set(_("Load Modules"));
-   TS("Load Modules");
-   _e_main_modules_load(safe_mode);
-   TS("Load Modules Done");
-
-   TS("Run Startup Apps");
-   if (!nostartup)
+   TSB("E_Security Init");
+   if (!e_security_init())
      {
-        if (after_restart)
-          e_startup(E_STARTUP_RESTART);
-        else
-          e_startup(E_STARTUP_START);
+        e_error_message_show(_("Enlightenment cannot setup security system!\n"));
+        goto failed;
      }
-   TS("Run Startup Apps Done");
+   TSE("E_Security Init Done");
+   _e_main_shutdown_push(e_security_shutdown);
 
-   if (e_config->show_splash && (!after_restart))
-     ecore_timer_add(2.0, _e_main_cb_startup_fake_end, NULL);
+   TSB("Load Modules");
+   e_module_all_load();
+   TSE("Load Modules Done");
 
-   TS("E_Comp Thaw");
+   TSB("E_Comp Thaw");
    e_comp_all_thaw();
-   TS("E_Comp Thaw Done");
-
-   TS("E_Test Init");
-   e_test();
-   TS("E_Test Done");
+   TSE("E_Comp Thaw Done");
 
-   if (e_config->show_splash)
-     e_init_status_set(_("Setup Shelves"));
-   TS("E_Shelf Init");
-   if (!e_shelf_init())
+   if (e_config->use_thread_max_cpu)
      {
-        e_error_message_show(_("Enlightenment cannot set up its module system.\n"));
-        _e_main_shutdown(-1);
-     }
-   TS("E_Shelf Init Done");
+        int cpus;
 
-   ecore_idle_enterer_before_add(_e_main_shelf_init_job, NULL);
+        cpus = eina_cpu_count();
+        if (cpus >= 1)
+          {
+             TSM("Set ecore thread max");
+             ecore_thread_max_set(cpus);
+          }
+     }
 
    _idle_after = ecore_idle_enterer_add(_e_main_cb_idle_after, NULL);
 
-   if (e_config->show_splash)
-     e_init_status_set(_("Almost Done"));
-
    starting = EINA_FALSE;
-   inloop = EINA_TRUE;
 
-   e_util_env_set("E_RESTART", "1");
+   TSM("MAIN LOOP AT LAST");
 
-   TS("MAIN LOOP AT LAST");
-   if (!setjmp(x_fatal_buff))
-     ecore_main_loop_begin();
-   else
-     CRI("FATAL: X Died. Connection gone. Abbreviated Shutdown\n");
+   if (e_config->create_wm_ready)
+     _e_main_create_wm_ready();
 
-   inloop = EINA_FALSE;
-   stopping = EINA_TRUE;
+   TRACE_DS_END();
+
+#ifdef HAVE_SYSTEMD
+   TSM("[WM] Send start-up completion");
+   sd_notify(0, "READY=1");
+#else
+   TSM("[WM] Skip sending start-up completion. (no systemd)");
+#endif
+   ecore_main_loop_begin();
 
-   //if (!x_fatal) e_canvas_idle_flush();
+   ELOGF("COMP", "STOPPING enlightenment...", NULL);
+   stopping = EINA_TRUE;
 
-   e_config_save_flush();
    _e_main_desk_save();
-   e_remember_internal_save();
    e_comp_internal_save();
 
    _e_main_shutdown(0);
 
-   if (restart)
-     {
-        e_util_env_set("E_RESTART_OK", "1");
-        if (getenv("E_START_MTRACK"))
-          e_util_env_set("MTRACK", "track");
-        ecore_app_restart();
-     }
-
    e_prefix_shutdown();
 
    return 0;
+
+failed:
+   TSE("INIT FAILED");
+   TRACE_DS_END();
+   _e_main_shutdown(-1);
 }
 
 E_API double
@@ -1076,31 +819,51 @@ e_main_ts(const char *str)
    return ret;
 }
 
+E_API double
+e_main_ts_begin(const char *str)
+{
+   TRACE_DS_BEGIN(ESTART: %s, str);
+   return e_main_ts(str);
+}
+
+E_API double
+e_main_ts_end(const char *str)
+{
+   TRACE_DS_END();
+   return e_main_ts(str);
+}
+
 /* local functions */
 static void
 _e_main_shutdown(int errcode)
 {
    int i = 0;
    char buf[PATH_MAX];
-   const char *dir;
+   char *dir;
 
    printf("E: Begin Shutdown Procedure!\n");
 
+   E_FREE_LIST(hooks, e_main_hook_del);
+
    if (_idle_before) ecore_idle_enterer_del(_idle_before);
    _idle_before = NULL;
    if (_idle_after) ecore_idle_enterer_del(_idle_after);
    _idle_after = NULL;
-   if (_idle_flush) ecore_idle_enterer_del(_idle_flush);
-   _idle_flush = NULL;
 
-   dir = getenv("XDG_RUNTIME_DIR");
+   dir = e_util_env_get("XDG_RUNTIME_DIR");
    if (dir)
      {
-        snprintf(buf, sizeof(buf), "%s/.e-deleteme", dir);
-        if (ecore_file_exists(buf)) ecore_file_recursive_rm(dir);
+        char buf_env[PATH_MAX - 12];
+        snprintf(buf_env, sizeof(buf_env), "%s", dir);
+        snprintf(buf, sizeof(buf), "%s/.e-deleteme", buf_env);
+        if (ecore_file_exists(buf)) ecore_file_recursive_rm(buf_env);
+        E_FREE(dir);
      }
    for (i = (_e_main_lvl - 1); i >= 0; i--)
      (*_e_main_shutdown_func[i])();
+#ifdef OBJECT_HASH_CHECK
+   e_object_hash_shutdown();
+#endif
    if (errcode < 0) exit(errcode);
 }
 
@@ -1121,196 +884,69 @@ _e_main_shutdown_push(int (*func)(void))
 static void
 _e_main_parse_arguments(int argc, char **argv)
 {
-   char *s = NULL;
    int i = 0;
 
    /* handle some command-line parameters */
    for (i = 1; i < argc; i++)
      {
-        if ((!strcmp(argv[i], "-display")) && (i < (argc - 1)))
-          {
-             i++;
-             e_util_env_set("DISPLAY", argv[i]);
-          }
-        else if ((!strcmp(argv[i], "-fake-xinerama-screen")) && (i < (argc - 1)))
-          {
-             int x, y, w, h;
-
-             i++;
-             if (sscanf(argv[i], "%ix%i+%i+%i", &w, &h, &x, &y) == 4)
-               e_xinerama_fake_screen_add(x, y, w, h);
-          }
-        else if (!strcmp(argv[i], "-good"))
-          {
-             good = EINA_TRUE;
-             evil = EINA_FALSE;
-             printf("LA LA LA\n");
-          }
-        else if (!strcmp(argv[i], "-evil"))
-          {
-             good = EINA_FALSE;
-             evil = EINA_TRUE;
-             printf("MUHAHAHAHHAHAHAHAHA\n");
-          }
-        else if (!strcmp(argv[i], "-psychotic"))
-          {
-             good = EINA_TRUE;
-             evil = EINA_TRUE;
-             printf("MUHAHALALALALALALALA\n");
-          }
-        else if ((!strcmp(argv[i], "-profile")) && (i < (argc - 1)))
+        if ((!strcmp(argv[i], "-profile")) && (i < (argc - 1)))
           {
              i++;
              if (!getenv("E_CONF_PROFILE"))
                e_util_env_set("E_CONF_PROFILE", argv[i]);
           }
-        else if (!strcmp(argv[i], "-i-really-know-what-i-am-doing-and-accept-full-responsibility-for-it"))
-          really_know = EINA_TRUE;
-        else if (!strcmp(argv[i], "-locked"))
-          locked = EINA_TRUE;
-        else if (!strcmp(argv[i], "-nopause"))
-          e_nopause = EINA_TRUE;
+        else if ((!strcmp(argv[i], "-version")) ||
+                 (!strcmp(argv[i], "--version")))
+          {
+             printf(_("Version: %s\n"), PACKAGE_VERSION);
+             _e_main_shutdown(-1);
+          }
         else if ((!strcmp(argv[i], "-h")) ||
                  (!strcmp(argv[i], "-help")) ||
-                 (!strcmp(argv[i], "--help")) ||
-                 argv[i][0])
+                 (!strcmp(argv[i], "--help")))
           {
              printf
                (_(
                  "Options:\n"
-                 "\t-display DISPLAY\n"
-                 "\t\tConnect to display named DISPLAY.\n"
-                 "\t\tEG: -display :1.0\n"
-                 "\t-fake-xinerama-screen WxH+X+Y\n"
-                 "\t\tAdd a FAKE xinerama screen (instead of the real ones)\n"
-                 "\t\tgiven the geometry. Add as many as you like. They all\n"
-                 "\t\treplace the real xinerama screens, if any. This can\n"
-                 "\t\tbe used to simulate xinerama.\n"
-                 "\t\tEG: -fake-xinerama-screen 800x600+0+0 -fake-xinerama-screen 800x600+800+0\n"
                  "\t-profile CONF_PROFILE\n"
                  "\t\tUse the configuration profile CONF_PROFILE instead of the user selected default or just \"default\".\n"
-                 "\t-good\n"
-                 "\t\tBe good.\n"
-                 "\t-evil\n"
-                 "\t\tBe evil.\n"
-                 "\t-psychotic\n"
-                 "\t\tBe psychotic.\n"
-                 "\t-locked\n"
-                 "\t\tStart with desklock on, so password will be asked.\n"
-                 "\t-i-really-know-what-i-am-doing-and-accept-full-responsibility-for-it\n"
-                 "\t\tIf you need this help, you don't need this option.\n"
+                 "\t-version\n"
                  )
                );
              _e_main_shutdown(-1);
           }
      }
-
-   /* fix up DISPLAY to be :N.0 if no .screen is in it */
-   s = getenv("DISPLAY");
-   if (s)
-     {
-        char *p, buff[4096];
-
-        if (!(p = strrchr(s, ':')))
-          {
-             snprintf(buff, sizeof(buff), "%s:0.0", s);
-             e_util_env_set("DISPLAY", buff);
-          }
-        else
-          {
-             if (!strrchr(p, '.'))
-               {
-                  snprintf(buff, sizeof(buff), "%s.0", s);
-                  e_util_env_set("DISPLAY", buff);
-               }
-          }
-     }
-
-   /* we want to have been launched by enlightenment_start. there is a very */
-   /* good reason we want to have been launched this way, thus check */
-   if (!getenv("E_START"))
-     {
-        e_error_message_show(_("You are executing enlightenment directly. This is\n"
-                               "bad. Please do not execute the \"enlightenment\"\n"
-                               "binary. Use the \"enlightenment_start\" launcher. It\n"
-                               "will handle setting up environment variables, paths,\n"
-                               "and launching any other required services etc.\n"
-                               "before enlightenment itself begins running.\n"));
-        _e_main_shutdown(-1);
-     }
-}
-
-EINTERN void
-_e_main_cb_x_fatal(void *data EINA_UNUSED)
-{
-   e_error_message_show("Lost X Connection.\n");
-   ecore_main_loop_quit();
-   if (!x_fatal)
-     {
-        x_fatal = EINA_TRUE;
-        if (inloop) longjmp(x_fatal_buff, -99);
-     }
 }
 
 static Eina_Bool
 _e_main_cb_signal_exit(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *ev EINA_UNUSED)
 {
    /* called on ctrl-c, kill (pid) (also SIGINT, SIGTERM and SIGQIT) */
-   e_sys_action_do(E_SYS_EXIT, NULL);
+   ecore_main_loop_quit();
    return ECORE_CALLBACK_RENEW;
 }
 
 static Eina_Bool
 _e_main_cb_signal_hup(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *ev EINA_UNUSED)
 {
-   e_sys_action_do(E_SYS_RESTART, NULL);
+   ecore_main_loop_quit();
    return ECORE_CALLBACK_RENEW;
 }
 
-static Eina_Bool
-_e_main_cb_signal_user(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *ev)
+static int
+_e_main_dirs_init(void)
 {
-   Ecore_Event_Signal_User *e = ev;
-
-   if (e->number == 1)
+   if(getenv("E_CONF_RO"))
      {
-//        E_Action *a = e_action_find("configuration");
-//        if ((a) && (a->func.go)) a->func.go(NULL, NULL);
+        return 1;
      }
-   else if (e->number == 2)
-     {
-        // comp module has its own handler for this for enabling/disabling fps debug
-     }
-   return ECORE_CALLBACK_RENEW;
 
-}
-
-static int
-_e_main_dirs_init(void)
-{
    const char *base;
    const char *dirs[] =
    {
-      "images",
-      "fonts",
-      "themes",
-      "icons",
       "backgrounds",
-      "applications",
-      "applications/menu",
-      "applications/menu/favorite",
-      "applications/menu/all",
-      "applications/bar",
-      "applications/bar/default",
-      "applications/startup",
-      "applications/restart",
-      "applications/trash",
-      "applications/desk-lock",
-      "applications/desk-unlock",
-      "modules",
       "config",
-      "locale",
-      "input_methods",
+      "themes",
       NULL
    };
 
@@ -1345,7 +981,6 @@ _e_main_path_init(void)
      }
    e_prefix_data_concat_static(buf, "data");
    e_path_default_path_append(path_data, buf);
-   e_path_user_path_set(path_data, &(e_config->path_append_data));
 
    /* setup image paths */
    path_images = e_path_new();
@@ -1358,7 +993,6 @@ _e_main_path_init(void)
    e_path_default_path_append(path_images, buf);
    e_prefix_data_concat_static(buf, "data/images");
    e_path_default_path_append(path_images, buf);
-   e_path_user_path_set(path_images, &(e_config->path_append_images));
 
    /* setup font paths */
    path_fonts = e_path_new();
@@ -1371,7 +1005,6 @@ _e_main_path_init(void)
    e_path_default_path_append(path_fonts, buf);
    e_prefix_data_concat_static(buf, "data/fonts");
    e_path_default_path_append(path_fonts, buf);
-   e_path_user_path_set(path_fonts, &(e_config->path_append_fonts));
 
    /* setup icon paths */
    path_icons = e_path_new();
@@ -1384,7 +1017,6 @@ _e_main_path_init(void)
    e_path_default_path_append(path_icons, buf);
    e_prefix_data_concat_static(buf, "data/icons");
    e_path_default_path_append(path_icons, buf);
-   e_path_user_path_set(path_icons, &(e_config->path_append_icons));
 
    /* setup module paths */
    path_modules = e_path_new();
@@ -1403,7 +1035,6 @@ _e_main_path_init(void)
     */
    snprintf(buf, sizeof(buf), "%s/enlightenment/modules_extra", e_prefix_lib_get());
    e_path_default_path_append(path_modules, buf);
-   e_path_user_path_set(path_modules, &(e_config->path_append_modules));
 
    /* setup background paths */
    path_backgrounds = e_path_new();
@@ -1416,7 +1047,6 @@ _e_main_path_init(void)
    e_path_default_path_append(path_backgrounds, buf);
    e_prefix_data_concat_static(buf, "data/backgrounds");
    e_path_default_path_append(path_backgrounds, buf);
-   e_path_user_path_set(path_backgrounds, &(e_config->path_append_backgrounds));
 
    path_messages = e_path_new();
    if (!path_messages)
@@ -1427,7 +1057,6 @@ _e_main_path_init(void)
    e_user_dir_concat_static(buf, "/locale");
    e_path_default_path_append(path_messages, buf);
    e_path_default_path_append(path_messages, e_prefix_locale_get());
-   e_path_user_path_set(path_messages, &(e_config->path_append_messages));
 
    return 1;
 }
@@ -1473,137 +1102,35 @@ _e_main_path_shutdown(void)
    return 1;
 }
 
-static void
-_e_main_test_formats(void)
-{
-   Evas *evas;
-   Ecore_Evas *ee;
-   Evas_Object *im, *txt;
-   Evas_Coord tw, th;
-   char buff[PATH_MAX];
-
-   if (e_config->show_splash)
-     e_init_status_set(_("Testing Format Support"));
-
-   if (!(ee = ecore_evas_buffer_new(1, 1)))
-     {
-        e_error_message_show(_("Enlightenment found Evas can't create a buffer canvas. Please check\n"
-                               "Evas has Software Buffer engine support.\n"));
-        _e_main_shutdown(-1);
-     }
-   evas = ecore_evas_get(ee);
-   im = evas_object_image_add(evas);
-
-   e_prefix_data_concat_static(buff, "data/images/test.svg");
-   evas_object_image_file_set(im, buff, NULL);
-   if (evas_object_image_load_error_get(im) != EVAS_LOAD_ERROR_NONE)
-     {
-        e_error_message_show(_("Enlightenment found Evas can't load SVG files. "
-                               "Check Evas has SVG loader support.\n"));
-     }
-   else
-     efreet_icon_extension_add(".svg");
-
-   e_prefix_data_concat_static(buff, "data/images/test.jpg");
-   evas_object_image_file_set(im, buff, NULL);
-   if (evas_object_image_load_error_get(im) != EVAS_LOAD_ERROR_NONE)
-     {
-        e_error_message_show(_("Enlightenment found Evas can't load JPEG files. "
-                               "Check Evas has JPEG loader support.\n"));
-        _e_main_shutdown(-1);
-     }
-   efreet_icon_extension_add(".jpg");
-
-   e_prefix_data_concat_static(buff, "data/images/test.png");
-   evas_object_image_file_set(im, buff, NULL);
-   if (evas_object_image_load_error_get(im) != EVAS_LOAD_ERROR_NONE)
-     {
-        e_error_message_show(_("Enlightenment found Evas can't load PNG files. "
-                               "Check Evas has PNG loader support.\n"));
-        _e_main_shutdown(-1);
-     }
-   efreet_icon_extension_add(".png");
-
-   e_prefix_data_concat_static(buff, "data/images/test.edj");
-   evas_object_image_file_set(im, buff, "images/0");
-   if (evas_object_image_load_error_get(im) != EVAS_LOAD_ERROR_NONE)
-     {
-        e_error_message_show(_("Enlightenment found Evas can't load EET files. "
-                               "Check Evas has EET loader support.\n"));
-        _e_main_shutdown(-1);
-     }
-   efreet_icon_extension_add(".edj");
-
-   evas_object_del(im);
-
-   txt = evas_object_text_add(evas);
-   evas_object_text_font_set(txt, "Sans", 10);
-   evas_object_text_text_set(txt, "Hello");
-   evas_object_geometry_get(txt, NULL, NULL, &tw, &th);
-   if ((tw <= 0) && (th <= 0))
-     {
-        e_error_message_show(_("Enlightenment found Evas can't load the 'Sans' font. Check Evas has fontconfig\n"
-                               "support and system fontconfig defines a 'Sans' font.\n"));
-        _e_main_shutdown(-1);
-     }
-   evas_object_del(txt);
-   ecore_evas_free(ee);
-}
-
 static int
 _e_main_screens_init(void)
 {
-   TS("\tscreens: client");
+   TSB("\tscreens: client");
    if (!e_client_init()) return 0;
-   TS("\tscreens: win");
-   if (!e_win_init()) return 0;
-#ifndef HAVE_WAYLAND_ONLY
-   TS("E_Xkb Init");
-   if (!e_xkb_init())
-     {
-        e_error_message_show(_("Enlightenment cannot setup XKB Keyboard layouts.\n"));
-        _e_main_shutdown(-1);
-     }
-   TS("E_Xkb Init Done");
-#endif
+   TSE("\tscreens: client Done");
 
-   TS("Compositor Init");
+   TSB("Compositor Init");
+   PRCTL("[Winsys] start of compositor init");
    if (!e_comp_init())
      {
         e_error_message_show(_("Enlightenment cannot create a compositor.\n"));
         _e_main_shutdown(-1);
      }
+   TSE("Compositor Init Done");
 
+   PRCTL("[Winsys] end of compositor init");
    _e_main_desk_restore();
 
-#ifndef HAVE_WAYLAND_ONLY
-   if (e_config->show_splash)
-     e_init_status_set(_("Setup DND"));
-   TS("E_Dnd Init");
-   if (!e_dnd_init())
-     {
-        e_error_message_show(_("Enlightenment cannot set up its dnd system.\n"));
-        _e_main_shutdown(-1);
-     }
-   TS("E_Dnd Init Done");
-   _e_main_shutdown_push(e_dnd_shutdown);
-#endif
-
    return 1;
 }
 
 static int
 _e_main_screens_shutdown(void)
 {
-   e_win_shutdown();
-   e_menu_shutdown();
-   e_shelf_shutdown();
    e_comp_shutdown();
    e_client_shutdown();
-   e_exehist_shutdown();
-   e_backlight_shutdown();
-   e_exec_shutdown();
 
+   e_magnifier_shutdown();
    e_desk_shutdown();
    e_zone_shutdown();
    return 1;
@@ -1627,151 +1154,156 @@ _e_main_desk_save(void)
 static void
 _e_main_desk_restore(void)
 {
-   const Eina_List *l;
+   E_Client *ec;
    E_Zone *zone;
-   char *env;
-   char name[1024];
 
-   EINA_LIST_FOREACH(e_comp->zones, l, zone)
+   E_CLIENT_REVERSE_FOREACH(ec)
      {
-        E_Desk *desk;
-        int desk_x, desk_y;
-
-        snprintf(name, sizeof(name), "DESK_%d_%d", 0, zone->num);
-        env = getenv(name);
-        if (!env) continue;
-        if (!sscanf(env, "%d,%d", &desk_x, &desk_y)) continue;
-        desk = e_desk_at_xy_get(zone, desk_x, desk_y);
-        if (!desk) continue;
-        e_desk_show(desk);
+        zone = e_comp_zone_find_by_ec(ec);
+        if ((!e_client_util_ignored_get(ec)) && e_desk_has_ec(e_desk_current_get(zone), ec))
+          {
+             ec->want_focus = ec->take_focus = 1;
+             break;
+          }
      }
 }
 
-static void
-_e_main_efreet_paths_init(void)
+static Eina_Bool
+_e_main_cb_idle_before(void *data EINA_UNUSED)
 {
-   Eina_List **list;
-
-   if ((list = efreet_icon_extra_list_get()))
-     {
-        char buff[PATH_MAX];
+   e_comp_idler_before();
+   _e_main_hook_call(E_MAIN_HOOK_POST_CLIENT_IDLER_BEFORE, NULL);
+   edje_thaw();
 
-        e_user_dir_concat_static(buff, "icons");
-        *list = eina_list_prepend(*list, (void *)eina_stringshare_add(buff));
-        e_prefix_data_concat_static(buff, "data/icons");
-        *list = eina_list_prepend(*list, (void *)eina_stringshare_add(buff));
-     }
+   return ECORE_CALLBACK_RENEW;
 }
 
 static Eina_Bool
-_e_main_modules_load_after(void *d EINA_UNUSED, int type EINA_UNUSED, void *ev EINA_UNUSED)
+_e_main_cb_idle_after(void *data EINA_UNUSED)
 {
-   e_int_config_modules(NULL, NULL);
-   E_FREE_FUNC(mod_init_end, ecore_event_handler_del);
+   static int first_idle = 1;
+
+   eet_clearcache();
+   edje_freeze();
+
+   if (first_idle)
+     {
+        TSM("SLEEP");
+        first_idle = 0;
+     }
+
    return ECORE_CALLBACK_RENEW;
 }
 
 static void
-_e_main_modules_load(Eina_Bool safe_mode)
+_e_main_create_wm_ready(void)
 {
-   if (!safe_mode)
-     e_module_all_load();
-   else
+   FILE *_wmready_checker = NULL;
+   const char *path_wm_ready = "/run/.wm_ready";
+
+   if (!e_util_file_realpath_check(path_wm_ready, EINA_TRUE))
+     {
+        WRN("%s is maybe link, so delete it\n", path_wm_ready);
+     }
+
+   _wmready_checker = fopen(path_wm_ready, "wb");
+   if (_wmready_checker)
      {
-        E_Module *m;
-        char *crashmodule;
+        TSM("[WM] WINDOW MANAGER is READY!!!");
+        PRCTL("[Winsys] WINDOW MANAGER is READY!!!");
+        fclose(_wmready_checker);
 
-        crashmodule = getenv("E_MODULE_LOAD");
-        if (crashmodule) m = e_module_new(crashmodule);
+        /*TODO: Next lines should be removed. */
+        FILE *_tmp_wm_ready_checker;
 
-        if ((crashmodule) && (m))
+        _tmp_wm_ready_checker = fopen(path_wm_ready, "wb");
+
+        if (_tmp_wm_ready_checker)
           {
-             e_module_disable(m);
-             e_object_del(E_OBJECT(m));
-
-             e_error_message_show
-               (_("Enlightenment crashed early on start and has<br>"
-                  "been restarted. There was an error loading the<br>"
-                  "module named: %s. This module has been disabled<br>"
-                  "and will not be loaded."), crashmodule);
-             e_util_dialog_show
-               (_("Enlightenment crashed early on start and has been restarted"),
-               _("Enlightenment crashed early on start and has been restarted.<br>"
-                 "There was an error loading the module named: %s<br><br>"
-                 "This module has been disabled and will not be loaded."), crashmodule);
-             e_module_all_load();
+             TSM("[WM] temporary wm_ready path is created.");
+             PRCTL("[Winsys] temporary wm_ready path is created.");
+             fclose(_tmp_wm_ready_checker);
           }
         else
           {
-             e_error_message_show
-               (_("Enlightenment crashed early on start and has<br>"
-                  "been restarted. All modules have been disabled<br>"
-                  "and will not be loaded to help remove any problem<br>"
-                  "modules from your configuration. The module<br>"
-                  "configuration dialog should let you select your<br>"
-                  "modules again.\n"));
-             e_util_dialog_show
-               (_("Enlightenment crashed early on start and has been restarted"),
-               _("Enlightenment crashed early on start and has been restarted.<br>"
-                 "All modules have been disabled and will not be loaded to help<br>"
-                 "remove any problem modules from your configuration.<br><br>"
-                 "The module configuration dialog should let you select your<br>"
-                 "modules again."));
+             TSM("[WM] temporary wm_ready path create failed.");
+             PRCTL("[Winsys] temporary wm_ready path create failed.");
           }
-        mod_init_end = ecore_event_handler_add(E_EVENT_MODULE_INIT_END, _e_main_modules_load_after, NULL);
+     }
+   else
+     {
+        TSM("[WM] WINDOW MANAGER is READY. BUT, failed to create .wm_ready file.");
+        PRCTL("[Winsys] WINDOW MANAGER is READY. BUT, failed to create .wm_ready file.");
      }
 }
 
-static Eina_Bool
-_e_main_cb_idle_before(void *data EINA_UNUSED)
+static void
+_e_main_hooks_clean(void)
 {
-   e_menu_idler_before();
-   e_client_idler_before();
-   e_pointer_idler_before();
-   edje_thaw();
-   return ECORE_CALLBACK_RENEW;
+   Eina_Inlist *l;
+   E_Main_Hook *mh;
+   unsigned int x;
+
+   for (x = 0; x < E_MAIN_HOOK_LAST; x++)
+     EINA_INLIST_FOREACH_SAFE(_e_main_hooks[x], l, mh)
+       {
+          if (!mh->delete_me) continue;
+          _e_main_hooks[x] = eina_inlist_remove(_e_main_hooks[x],
+                                                EINA_INLIST_GET(mh));
+          free(mh);
+       }
 }
 
-static Eina_Bool
-_e_main_cb_idle_after(void *data EINA_UNUSED)
+static void
+_e_main_hook_call(E_Main_Hook_Point hookpoint, void *data EINA_UNUSED)
 {
-   static int first_idle = 1;
-
-   edje_freeze();
+   E_Main_Hook *mh;
 
-#ifdef E_RELEASE_BUILD
-   if (first_idle)
-     {
-        TS("SLEEP");
-        first_idle = 0;
-        e_precache_end = EINA_TRUE;
-     }
-#else
-   if (first_idle++ < 60)
+   _e_main_hooks_walking++;
+   EINA_INLIST_FOREACH(_e_main_hooks[hookpoint], mh)
      {
-        TS("SLEEP");
-        if (!first_idle)
-          e_precache_end = EINA_TRUE;
+        if (mh->delete_me) continue;
+        mh->func(mh->data);
      }
-#endif
+   _e_main_hooks_walking--;
+   if ((_e_main_hooks_walking == 0) && (_e_main_hooks_delete > 0))
+     _e_main_hooks_clean();
+}
 
-   return ECORE_CALLBACK_RENEW;
+E_API E_Main_Hook *
+e_main_hook_add(E_Main_Hook_Point hookpoint, E_Main_Hook_Cb func, const void *data)
+{
+   E_Main_Hook *mh;
+
+   EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_MAIN_HOOK_LAST, NULL);
+   mh = E_NEW(E_Main_Hook, 1);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(mh, NULL);
+   mh->hookpoint = hookpoint;
+   mh->func = func;
+   mh->data = (void*)data;
+   _e_main_hooks[hookpoint] = eina_inlist_append(_e_main_hooks[hookpoint],
+                                                 EINA_INLIST_GET(mh));
+   return mh;
 }
 
-static Eina_Bool
-_e_main_cb_x_flusher(void *data EINA_UNUSED)
+E_API void
+e_main_hook_del(E_Main_Hook *mh)
 {
-   eet_clearcache();
-#ifndef HAVE_WAYLAND_ONLY
-   if (e_comp->comp_type == E_PIXMAP_TYPE_X)
-     ecore_x_flush();
-#endif
-   return ECORE_CALLBACK_RENEW;
+   mh->delete_me = 1;
+   if (_e_main_hooks_walking == 0)
+     {
+        _e_main_hooks[mh->hookpoint] = eina_inlist_remove(_e_main_hooks[mh->hookpoint],
+                                                          EINA_INLIST_GET(mh));
+        free(mh);
+     }
+   else
+     _e_main_hooks_delete++;
 }
 
-static Eina_Bool
-_e_main_cb_startup_fake_end(void *data EINA_UNUSED)
+E_API void
+e_main_hook_call(E_Main_Hook_Point hookpoint)
 {
-   e_init_hide();
-   return ECORE_CALLBACK_CANCEL;
+   if ((hookpoint < 0) || (hookpoint >= E_MAIN_HOOK_LAST)) return;
+
+   _e_main_hook_call(hookpoint, NULL);
 }