diff options
author | Carsten Haitzler (Rasterman) <raster@rasterman.com> | 2016-08-01 21:12:24 +0900 |
---|---|---|
committer | Carsten Haitzler (Rasterman) <raster@rasterman.com> | 2016-08-01 21:12:24 +0900 |
commit | 37735d8b4fef461d669975bf66d031b6dd5cf184 (patch) | |
tree | 43e67fa6dad84b5007fd6d2f7f508c42dc61ac8d /src | |
parent | 1d0b500fa8ce93ac6cd9211abd35ea8972be74b2 (diff) |
ecore-imf - fix stupidity of loading ALL modules even if not needed
eocre-imf loaded all input modules even though an env var was set to
tell it to use a specific one. this just wastes memory and slows down
startup time. this uses the env var to choose ro auto-guesses wayland
or xim input if the right env vars are set, and if it doesnt know
falls back to "load all" as before. this saves 28kb of dirty pages.
this helps address T4227
@fix
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/ecore_imf/ecore_imf_module.c | 97 |
1 files changed, 75 insertions, 22 deletions
diff --git a/src/lib/ecore_imf/ecore_imf_module.c b/src/lib/ecore_imf/ecore_imf_module.c index 990bb71f21..e4d651cada 100644 --- a/src/lib/ecore_imf/ecore_imf_module.c +++ b/src/lib/ecore_imf/ecore_imf_module.c | |||
@@ -30,6 +30,22 @@ static Eina_Prefix *pfx = NULL; | |||
30 | void | 30 | void |
31 | ecore_imf_module_init(void) | 31 | ecore_imf_module_init(void) |
32 | { | 32 | { |
33 | const char *built_modules[] = { | ||
34 | #ifdef ENABLE_XIM | ||
35 | "xim", | ||
36 | #endif | ||
37 | #ifdef BUILD_ECORE_IMF_IBUS | ||
38 | "ibus", | ||
39 | #endif | ||
40 | #ifdef BUILD_ECORE_IMF_SCIM | ||
41 | "scim", | ||
42 | #endif | ||
43 | #ifdef BUILD_ECORE_IMF_WAYLAND | ||
44 | "wayland", | ||
45 | #endif | ||
46 | NULL | ||
47 | }; | ||
48 | const char *env; | ||
33 | char buf[PATH_MAX] = ""; | 49 | char buf[PATH_MAX] = ""; |
34 | 50 | ||
35 | pfx = eina_prefix_new(NULL, ecore_imf_init, | 51 | pfx = eina_prefix_new(NULL, ecore_imf_init, |
@@ -47,40 +63,77 @@ ecore_imf_module_init(void) | |||
47 | PACKAGE_BUILD_DIR); | 63 | PACKAGE_BUILD_DIR); |
48 | if (stat(buf, &st) == 0) | 64 | if (stat(buf, &st) == 0) |
49 | { | 65 | { |
50 | const char *built_modules[] = { | ||
51 | #ifdef ENABLE_XIM | ||
52 | "xim", | ||
53 | #endif | ||
54 | #ifdef BUILD_ECORE_IMF_IBUS | ||
55 | "ibus", | ||
56 | #endif | ||
57 | #ifdef BUILD_ECORE_IMF_SCIM | ||
58 | "scim", | ||
59 | #endif | ||
60 | #ifdef BUILD_ECORE_IMF_WAYLAND | ||
61 | "wayland", | ||
62 | #endif | ||
63 | NULL | ||
64 | }; | ||
65 | const char **itr; | 66 | const char **itr; |
66 | for (itr = built_modules; *itr != NULL; itr++) | 67 | const char **modules_load; |
68 | const char *env; | ||
69 | const char *modules_one[1] = { NULL }; | ||
70 | |||
71 | modules_load = built_modules; | ||
72 | env = getenv("ECORE_IMF_MODULE"); | ||
73 | if (env) | ||
74 | { | ||
75 | modules_one[0] = env; | ||
76 | modules_load = modules_one; | ||
77 | } | ||
78 | for (itr = modules_load; *itr != NULL; itr++) | ||
67 | { | 79 | { |
68 | snprintf(buf, sizeof(buf), | 80 | snprintf(buf, sizeof(buf), |
69 | "%s/src/modules/ecore_imf/%s/.libs", | 81 | "%s/src/modules/ecore_imf/%s/.libs", |
70 | PACKAGE_BUILD_DIR, *itr); | 82 | PACKAGE_BUILD_DIR, *itr); |
71 | module_list = eina_module_list_get(module_list, buf, | 83 | module_list = eina_module_list_get |
72 | EINA_FALSE, NULL, NULL); | 84 | (module_list, buf, EINA_FALSE, NULL, NULL); |
73 | } | 85 | } |
74 | 86 | ||
75 | if (module_list) | 87 | if (module_list) eina_module_list_load(module_list); |
76 | eina_module_list_load(module_list); | ||
77 | return; | 88 | return; |
78 | } | 89 | } |
79 | } | 90 | } |
80 | } | 91 | } |
81 | 92 | ||
82 | snprintf(buf, sizeof(buf), "%s/ecore_imf/modules", eina_prefix_lib_get(pfx)); | 93 | env = getenv("ECORE_IMF_MODULE"); |
83 | module_list = eina_module_arch_list_get(module_list, buf, MODULE_ARCH); | 94 | #ifdef BUILD_ECORE_IMF_WAYLAND |
95 | // if not set and we are sure we're on wayland.... | ||
96 | if ((!env) && (getenv("WAYLAND_DISPLAY")) && (!getenv("DISPLAY"))) | ||
97 | env = "wayland"; | ||
98 | #endif | ||
99 | #ifdef ENABLE_XIM | ||
100 | if ((!env) && (!getenv("WAYLAND_DISPLAY")) && (getenv("DISPLAY"))) | ||
101 | env = "xim"; | ||
102 | #endif | ||
103 | if (env) | ||
104 | { | ||
105 | const char **itr; | ||
106 | Eina_Bool ok = EINA_FALSE; | ||
107 | |||
108 | for (itr = built_modules; *itr != NULL; itr++) | ||
109 | { | ||
110 | if (!strcmp(env, *itr)) | ||
111 | { | ||
112 | ok = EINA_TRUE; | ||
113 | break; | ||
114 | } | ||
115 | } | ||
116 | if (ok) | ||
117 | { | ||
118 | Eina_Module *m; | ||
119 | |||
120 | snprintf(buf, sizeof(buf), | ||
121 | "%s/ecore_imf/modules/%s/%s/module" SHARED_LIB_SUFFIX, | ||
122 | eina_prefix_lib_get(pfx), env, MODULE_ARCH); | ||
123 | m = eina_module_new(buf); | ||
124 | if (m) | ||
125 | { | ||
126 | module_list = eina_array_new(1); | ||
127 | if (module_list) eina_array_push(module_list, m); | ||
128 | else eina_module_free(m); | ||
129 | } | ||
130 | } | ||
131 | } | ||
132 | else | ||
133 | { | ||
134 | snprintf(buf, sizeof(buf), "%s/ecore_imf/modules", eina_prefix_lib_get(pfx)); | ||
135 | module_list = eina_module_arch_list_get(module_list, buf, MODULE_ARCH); | ||
136 | } | ||
84 | 137 | ||
85 | // XXX: MODFIX: do not list ALL modules and load them ALL! this is | 138 | // XXX: MODFIX: do not list ALL modules and load them ALL! this is |
86 | // is wrong - we end up loading BOTH xim ANd scim (and maybe uim too) | 139 | // is wrong - we end up loading BOTH xim ANd scim (and maybe uim too) |