e_scale: make an internal header
[platform/upstream/enlightenment.git] / src / bin / e_main.c
index 90f158d..6b15f81 100644 (file)
@@ -1,4 +1,14 @@
 #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
@@ -93,7 +103,6 @@ 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);
@@ -109,8 +118,6 @@ 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 inloop = EINA_FALSE;
-
 static int _e_main_lvl = 0;
 static int(*_e_main_shutdown_func[MAX_LEVEL]) (void);
 
@@ -125,16 +132,13 @@ 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_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 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 e_nopause = EINA_FALSE;
 
 static Eina_Bool
 _xdg_check_str(const char *env, const char *str)
@@ -155,7 +159,7 @@ _xdg_data_dirs_augment(void)
 {
    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;
 
@@ -231,13 +235,8 @@ _xdg_data_dirs_augment(void)
 static Eina_Bool
 _e_main_subsystem_defer(void *data EINA_UNUSED)
 {
-   int argc;
-   char **argv;
-
    TRACE_DS_BEGIN(MAIN:SUBSYSTEMS DEFER);
 
-   ecore_app_args_get(&argc, &argv);
-
    /* try to init delayed subsystems */
 
    TRACE_DS_BEGIN(MAIN:DEFERRED INTERNAL SUBSYSTEMS INIT);
@@ -251,14 +250,6 @@ _e_main_subsystem_defer(void *data EINA_UNUSED)
    TSE("[DEFERRED] DPMS Init Done");
    _e_main_shutdown_push(e_dpms_shutdown);
 
-   TSB("[DEFERRED] Screens Init: win");
-   if (!e_win_init())
-     {
-        e_error_message_show(_("Enlightenment cannot setup elementary trap!\n"));
-        goto failed;
-     }
-   TSE("[DEFERRED] Screens Init: win Done");
-
    TSB("[DEFERRED] E_Dnd Init");
    if (!e_dnd_init())
      {
@@ -340,6 +331,15 @@ 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);
@@ -419,9 +419,6 @@ main(int argc, char **argv)
      }
    TSE("Determine Prefix Done");
 
-   /* for debugging by redirecting stdout of e to a log file to tail */
-   setvbuf(stdout, NULL, _IONBF, 0);
-
    TSB("Parse Arguments");
    _e_main_parse_arguments(argc, argv);
    TSE("Parse Arguments Done");
@@ -461,8 +458,6 @@ main(int argc, char **argv)
    TSE("EIO Init Done");
    _e_main_shutdown_push(eio_shutdown);
 
-   ecore_app_args_set(argc, (const char **)argv);
-
    TSB("Ecore Event Handlers");
    if (!ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT,
                                 _e_main_cb_signal_exit, NULL))
@@ -478,13 +473,6 @@ main(int argc, char **argv)
                                "Perhaps you are out of memory?"));
         goto failed;
      }
-   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?"));
-        goto failed;
-     }
    TSE("Ecore Event Handlers Done");
 
    TSB("Ecore_File Init");
@@ -496,6 +484,11 @@ main(int argc, char **argv)
    TSE("Ecore_File Init Done");
    _e_main_shutdown_push(ecore_file_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");
@@ -510,9 +503,6 @@ main(int argc, char **argv)
      }
    TSE("Ecore_Evas Init Done");
 
-   /* e doesn't sync to compositor - it should be one */
-   ecore_evas_app_comp_sync_set(0);
-
    TSB("Edje Init");
    if (!edje_init())
      {
@@ -600,7 +590,7 @@ main(int argc, char **argv)
    e_screensaver_preinit();
    e_zone_init();
    e_desk_init();
-   e_slot_init();
+   e_magnifier_init();
 
    TRACE_DS_BEGIN(MAIN:WAIT /dev/dri/card0);
    if (e_config->sleep_for_dri)
@@ -615,6 +605,15 @@ main(int argc, char **argv)
      }
    TRACE_DS_END();
 
+   TSB("E_Msg Init");
+   if (!e_msg_init())
+     {
+        e_error_message_show(_("Enlightenment cannot set up its msg system."));
+        goto failed;
+     }
+   TSE("E_Msg Init Done");
+   _e_main_shutdown_push(e_msg_shutdown);
+
    e_module_event_init();
 
    TSB("E_Pointer Init");
@@ -638,6 +637,15 @@ main(int argc, char **argv)
    _e_main_shutdown_push(_e_main_screens_shutdown);
    TRACE_DS_END();
 
+   TSB("E_Devicemgr Init");
+   if (!e_devicemgr_init())
+     {
+        e_error_message_show(_("Enlightenment cannot set up its device_manager system.\n"));
+        goto failed;
+     }
+   TSE("E_Devicemgr Init Done");
+   _e_main_shutdown_push(e_devicemgr_shutdown);
+
    TSB("E_Keyrouter Init");
    if (!e_keyrouter_init())
      {
@@ -751,12 +759,21 @@ main(int argc, char **argv)
    e_comp_all_thaw();
    TSE("E_Comp Thaw Done");
 
+   if (e_config->use_thread_max_cpu)
+     {
+        int cpus;
+
+        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);
 
    starting = EINA_FALSE;
-   inloop = EINA_TRUE;
-
-   e_util_env_set("E_RESTART", "1");
 
    TSM("MAIN LOOP AT LAST");
 
@@ -773,9 +790,7 @@ main(int argc, char **argv)
 #endif
    ecore_main_loop_begin();
 
-   inloop = EINA_FALSE;
-
-   ELOGF("COMP", "STOPPING enlightenment...", NULL, NULL);
+   ELOGF("COMP", "STOPPING enlightenment...", NULL);
    stopping = EINA_TRUE;
 
    _e_main_desk_save();
@@ -838,7 +853,7 @@ _e_main_shutdown(int errcode)
    dir = e_util_env_get("XDG_RUNTIME_DIR");
    if (dir)
      {
-        char buf_env[PATH_MAX];
+        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);
@@ -874,32 +889,12 @@ _e_main_parse_arguments(int argc, char **argv)
    /* handle some command-line parameters */
    for (i = 1; i < argc; i++)
      {
-        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], "-nopause"))
-          e_nopause = EINA_TRUE;
         else if ((!strcmp(argv[i], "-version")) ||
                  (!strcmp(argv[i], "--version")))
           {
@@ -913,25 +908,8 @@ _e_main_parse_arguments(int argc, char **argv)
              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-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"
                  )
                );
@@ -955,24 +933,6 @@ _e_main_cb_signal_hup(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *ev
    return ECORE_CALLBACK_RENEW;
 }
 
-static Eina_Bool
-_e_main_cb_signal_user(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *ev)
-{
-   Ecore_Event_Signal_User *e = ev;
-
-   if (e->number == 1)
-     {
-//        E_Action *a = e_action_find("configuration");
-//        if ((a) && (a->func.go)) a->func.go(NULL, NULL);
-     }
-   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)
 {
@@ -1167,11 +1127,10 @@ _e_main_screens_init(void)
 static int
 _e_main_screens_shutdown(void)
 {
-   e_win_shutdown();
    e_comp_shutdown();
    e_client_shutdown();
 
-   e_slot_shutdown();
+   e_magnifier_shutdown();
    e_desk_shutdown();
    e_zone_shutdown();
    return 1;
@@ -1196,20 +1155,26 @@ static void
 _e_main_desk_restore(void)
 {
    E_Client *ec;
+   E_Zone *zone;
 
    E_CLIENT_REVERSE_FOREACH(ec)
-     if ((!e_client_util_ignored_get(ec)) && e_client_util_desk_visible(ec, e_desk_current_get(ec->zone)))
-       {
-          ec->want_focus = ec->take_focus = 1;
-          break;
-       }
+     {
+        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 Eina_Bool
 _e_main_cb_idle_before(void *data EINA_UNUSED)
 {
-   e_client_idler_before();
+   e_comp_idler_before();
+   _e_main_hook_call(E_MAIN_HOOK_POST_CLIENT_IDLER_BEFORE, NULL);
    edje_thaw();
+
    return ECORE_CALLBACK_RENEW;
 }
 
@@ -1221,21 +1186,11 @@ _e_main_cb_idle_after(void *data EINA_UNUSED)
    eet_clearcache();
    edje_freeze();
 
-#ifdef E_RELEASE_BUILD
    if (first_idle)
      {
         TSM("SLEEP");
         first_idle = 0;
-        e_precache_end = EINA_TRUE;
-     }
-#else
-   if (first_idle++ < 60)
-     {
-        TSM("SLEEP");
-        if (!first_idle)
-          e_precache_end = EINA_TRUE;
      }
-#endif
 
    return ECORE_CALLBACK_RENEW;
 }