summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaehwan Kim <jae.hwan.kim@samsung.com>2015-06-16 13:52:23 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2015-06-16 13:52:24 +0900
commitaa7f859da10ce007a7b945a8703e70161c96146d (patch)
tree2bf0463f3d8b255d444b3404c9577cc8f0d034a4
parent67eb9db938ca1d05502f96a66f70cd1160d3cb05 (diff)
elm_config: remove X dependency.
Summary: In wayland, elm_config_all_flush doesn't work. It has X dependency totally. It uses ecore_file_monitor instead of X property. Reviewers: Hermet, devilhorns, raster, cedric Differential Revision: https://phab.enlightenment.org/D2502
-rw-r--r--src/lib/elm_config.c225
1 files changed, 94 insertions, 131 deletions
diff --git a/src/lib/elm_config.c b/src/lib/elm_config.c
index 9e90f59cb..92dd8aa73 100644
--- a/src/lib/elm_config.c
+++ b/src/lib/elm_config.c
@@ -30,6 +30,8 @@ Eina_List *_color_overlays_del = NULL;
30 30
31static Ecore_Poller *_elm_cache_flush_poller = NULL; 31static Ecore_Poller *_elm_cache_flush_poller = NULL;
32static void _elm_config_key_binding_hash(void); 32static void _elm_config_key_binding_hash(void);
33static Ecore_Timer *_config_change_delay_timer = NULL;
34Eio_Monitor *_eio_monitor = NULL;
33 35
34Eina_Hash *_elm_key_bindings = NULL; 36Eina_Hash *_elm_key_bindings = NULL;
35 37
@@ -114,6 +116,7 @@ static void _config_free(Elm_Config *cfg);
114static void _config_apply(void); 116static void _config_apply(void);
115static void _config_sub_apply(void); 117static void _config_sub_apply(void);
116static void _config_update(void); 118static void _config_update(void);
119static void _config_get(void);
117static void _env_get(void); 120static void _env_get(void);
118static void _color_overlays_cancel(void); 121static void _color_overlays_cancel(void);
119 122
@@ -128,7 +131,6 @@ static Ecore_Timer *_prop_change_delay_timer = NULL;
128static Ecore_X_Window _config_win = 0; 131static Ecore_X_Window _config_win = 0;
129#define ATOM_COUNT 3 132#define ATOM_COUNT 3
130static Ecore_X_Atom _atom[ATOM_COUNT]; 133static Ecore_X_Atom _atom[ATOM_COUNT];
131static Ecore_X_Atom _atom_config = 0;
132static const char *_atom_names[ATOM_COUNT] = 134static const char *_atom_names[ATOM_COUNT] =
133{ 135{
134 "ELM_PROFILE", 136 "ELM_PROFILE",
@@ -139,120 +141,6 @@ static const char *_atom_names[ATOM_COUNT] =
139#define ATOM_E_CONFIG 1 141#define ATOM_E_CONFIG 1
140#define ATOM_E_CONFIG_WIN 2 142#define ATOM_E_CONFIG_WIN 2
141 143
142static Eina_Bool _prop_config_get(void);
143static void _prop_config_set(void);
144static Eina_Bool _prop_change(void *data EINA_UNUSED,
145 int ev_type EINA_UNUSED,
146 void *ev);
147
148static void
149_elm_font_overlays_del_free(void)
150{
151 char *text_class;
152 Eina_List *l;
153 EINA_LIST_FOREACH(_font_overlays_del, l, text_class)
154 eina_stringshare_del(text_class);
155 _font_overlays_del = eina_list_free(_font_overlays_del);
156}
157
158static void
159_elm_config_font_overlays_cancel(void)
160{
161 Elm_Font_Overlay *efd;
162 Eina_List *l;
163 EINA_LIST_FOREACH(_elm_config->font_overlays, l, efd)
164 edje_text_class_del(efd->text_class);
165}
166
167static Eina_Bool
168_prop_config_get(void)
169{
170 int size = 0;
171 Ecore_X_Atom atom;
172 char buf[512];
173 unsigned char *data = NULL;
174 Elm_Config *config_data;
175
176 snprintf(buf, sizeof(buf), "ELM_CONFIG_%s", _elm_profile);
177 atom = ecore_x_atom_get(buf);
178 _atom_config = atom;
179 if (!ecore_x_window_prop_property_get(_config_win,
180 atom, _atom[ATOM_E_CONFIG],
181 8, &data, &size))
182 {
183 if (!ecore_x_window_prop_property_get(_config_win,
184 _atom[ATOM_E_CONFIG],
185 _atom[ATOM_E_CONFIG],
186 8, &data, &size))
187 return EINA_FALSE;
188 else
189 _atom_config = _atom[ATOM_E_CONFIG];
190 }
191 else
192 _atom_config = atom;
193 if (size < 1)
194 {
195 free(data);
196 return EINA_FALSE;
197 }
198 config_data = eet_data_descriptor_decode(_config_edd, data, size);
199 free(data);
200 if (!config_data) return EINA_FALSE;
201
202 /* What do we do on version mismatch when someone changes the
203 * config in the rootwindow? */
204 /* Most obvious case, new version and we are still linked to
205 * whatever was there before, we just ignore until user restarts us */
206 if (config_data->config_version > ELM_CONFIG_VERSION)
207 {
208 _config_free(config_data);
209 return EINA_TRUE;
210 }
211 /* What in the case the version is older? Do we even support those
212 * cases or we only check for equality above? */
213
214 _elm_config_font_overlays_cancel();
215 _color_overlays_cancel();
216 _config_free(_elm_config);
217 _elm_config = config_data;
218 _env_get();
219 _config_apply();
220 _config_sub_apply();
221 evas_font_reinit();
222 _elm_config_font_overlay_apply();
223 _elm_config_color_overlay_apply();
224 _elm_rescale();
225 _elm_recache();
226 _elm_clouseau_reload();
227 _elm_config_key_binding_hash();
228 _elm_win_access(_elm_config->access_mode);
229 ecore_event_add(ELM_EVENT_CONFIG_ALL_CHANGED, NULL, NULL, NULL);
230 return EINA_TRUE;
231}
232
233static void
234_prop_config_set(void)
235{
236 unsigned char *config_data = NULL;
237 int size = 0;
238
239 config_data = eet_data_descriptor_encode(_config_edd, _elm_config, &size);
240 if (config_data)
241 {
242 Ecore_X_Atom atom;
243 char buf[512];
244
245 snprintf(buf, sizeof(buf), "ELM_CONFIG_%s", _elm_profile);
246 atom = ecore_x_atom_get(buf);
247 _atom_config = atom;
248
249 ecore_x_window_prop_property_set(_config_win, _atom_config,
250 _atom[ATOM_E_CONFIG], 8,
251 config_data, size);
252 free(config_data);
253 }
254}
255
256static Eina_Bool 144static Eina_Bool
257_prop_change_delay_cb(void *data EINA_UNUSED) 145_prop_change_delay_cb(void *data EINA_UNUSED)
258{ 146{
@@ -267,7 +155,7 @@ _prop_change_delay_cb(void *data EINA_UNUSED)
267 _elm_profile = s; 155 _elm_profile = s;
268 } 156 }
269 } 157 }
270 _prop_config_get(); 158 _config_get();
271 _prop_change_delay_timer = NULL; 159 _prop_change_delay_timer = NULL;
272 160
273 return ECORE_CALLBACK_CANCEL; 161 return ECORE_CALLBACK_CANCEL;
@@ -287,19 +175,31 @@ _prop_change(void *data EINA_UNUSED,
287 ecore_timer_del(_prop_change_delay_timer); 175 ecore_timer_del(_prop_change_delay_timer);
288 _prop_change_delay_timer = ecore_timer_add(0.1, _prop_change_delay_cb, NULL); 176 _prop_change_delay_timer = ecore_timer_add(0.1, _prop_change_delay_cb, NULL);
289 } 177 }
290 else if (((_atom_config > 0) && (event->atom == _atom_config)) ||
291 (event->atom == _atom[ATOM_E_CONFIG]))
292 {
293 ecore_timer_del(_prop_change_delay_timer);
294 _prop_change_delay_timer = ecore_timer_add(0.1, _prop_change_delay_cb, NULL);
295 }
296 } 178 }
297 return ECORE_CALLBACK_PASS_ON; 179 return ECORE_CALLBACK_PASS_ON;
298} 180}
299
300#endif 181#endif
301 182
302static void 183static void
184_elm_font_overlays_del_free(void)
185{
186 char *text_class;
187 Eina_List *l;
188 EINA_LIST_FOREACH(_font_overlays_del, l, text_class)
189 eina_stringshare_del(text_class);
190 _font_overlays_del = eina_list_free(_font_overlays_del);
191}
192
193static void
194_elm_config_font_overlays_cancel(void)
195{
196 Elm_Font_Overlay *efd;
197 Eina_List *l;
198 EINA_LIST_FOREACH(_elm_config->font_overlays, l, efd)
199 edje_text_class_del(efd->text_class);
200}
201
202static void
303_desc_init(void) 203_desc_init(void)
304{ 204{
305 Eet_Data_Descriptor_Class eddc; 205 Eet_Data_Descriptor_Class eddc;
@@ -1622,6 +1522,28 @@ _config_load(void)
1622 _elm_config->gl_stencil = 0; 1522 _elm_config->gl_stencil = 0;
1623} 1523}
1624 1524
1525static void
1526_config_get(void)
1527{
1528 _elm_config_font_overlays_cancel();
1529 _color_overlays_cancel();
1530 _config_free(_elm_config);
1531 _elm_config = NULL;
1532 _config_load();
1533 _env_get();
1534 _config_apply();
1535 _config_sub_apply();
1536 evas_font_reinit();
1537 _elm_config_font_overlay_apply();
1538 _elm_config_color_overlay_apply();
1539 _elm_rescale();
1540 _elm_recache();
1541 _elm_clouseau_reload();
1542 _elm_config_key_binding_hash();
1543 _elm_win_access(_elm_config->access_mode);
1544 ecore_event_add(ELM_EVENT_CONFIG_ALL_CHANGED, NULL, NULL, NULL);
1545}
1546
1625static const char * 1547static const char *
1626_elm_config_eet_close_error_get(Eet_File *ef, 1548_elm_config_eet_close_error_get(Eet_File *ef,
1627 char *file) 1549 char *file)
@@ -3197,12 +3119,16 @@ elm_config_all_flush(void)
3197{ 3119{
3198#ifdef HAVE_ELEMENTARY_X 3120#ifdef HAVE_ELEMENTARY_X
3199 if (ecore_x_display_get()) 3121 if (ecore_x_display_get())
3200 { 3122 ecore_x_window_prop_string_set(_config_win, _atom[ATOM_E_PROFILE],
3201 _prop_config_set(); 3123 _elm_profile);
3202 ecore_x_window_prop_string_set(_config_win, _atom[ATOM_E_PROFILE],
3203 _elm_profile);
3204 }
3205#endif 3124#endif
3125 char buf[PATH_MAX];
3126
3127 _elm_config_user_dir_snprintf(buf, sizeof(buf), "config/%s/flush",
3128 _elm_profile);
3129 FILE *fp = fopen(buf, "w+");
3130 fprintf(fp, "flush");
3131 fclose(fp);
3206} 3132}
3207 3133
3208static void 3134static void
@@ -3259,6 +3185,32 @@ _elm_config_sub_shutdown(void)
3259 ELM_SAFE_FREE(_prop_change_delay_timer, ecore_timer_del); 3185 ELM_SAFE_FREE(_prop_change_delay_timer, ecore_timer_del);
3260 if (ecore_x_display_get()) ecore_x_shutdown(); 3186 if (ecore_x_display_get()) ecore_x_shutdown();
3261#endif 3187#endif
3188 ELM_SAFE_FREE(_eio_monitor, eio_monitor_del);
3189 ELM_SAFE_FREE(_config_change_delay_timer, ecore_timer_del);
3190}
3191
3192static Eina_Bool
3193_config_change_delay_cb(void *data EINA_UNUSED)
3194{
3195 _config_get();
3196 _config_change_delay_timer = NULL;
3197
3198 return ECORE_CALLBACK_CANCEL;
3199}
3200
3201static Eina_Bool
3202_elm_config_file_monitor_cb(void *data EINA_UNUSED,
3203 int type EINA_UNUSED,
3204 void *event)
3205{
3206 Eio_Monitor_Event *ev = event;
3207
3208 if (ev->monitor != _eio_monitor) return ECORE_CALLBACK_PASS_ON;
3209
3210 ecore_timer_del(_config_change_delay_timer);
3211 _config_change_delay_timer = ecore_timer_add(0.1, _config_change_delay_cb, NULL);
3212
3213 return ECORE_CALLBACK_PASS_ON;
3262} 3214}
3263 3215
3264void 3216void
@@ -3340,7 +3292,7 @@ _elm_config_sub_init(void)
3340 free(_elm_profile); 3292 free(_elm_profile);
3341 } 3293 }
3342 _elm_profile = s; 3294 _elm_profile = s;
3343 if (changed) _prop_config_get(); 3295 if (changed) _config_get();
3344 s = strchr(_elm_profile, '/'); 3296 s = strchr(_elm_profile, '/');
3345 if (s) *s = 0; 3297 if (s) *s = 0;
3346 } 3298 }
@@ -3380,6 +3332,19 @@ _elm_config_sub_init(void)
3380 ecore_wl_init(NULL); 3332 ecore_wl_init(NULL);
3381 } 3333 }
3382#endif 3334#endif
3335 char buf[PATH_MAX];
3336
3337 _elm_config_user_dir_snprintf(buf, sizeof(buf), "config/%s/flush",
3338 _elm_profile);
3339 if (!ecore_file_exists(buf))
3340 {
3341 FILE *fp = fopen(buf, "w+");
3342 fprintf(fp, "flush");
3343 fclose(fp);
3344 }
3345 _eio_monitor = eio_monitor_add(buf);
3346 ecore_event_handler_add(EIO_MONITOR_FILE_MODIFIED, _elm_config_file_monitor_cb, NULL);
3347
3383 _config_sub_apply(); 3348 _config_sub_apply();
3384} 3349}
3385 3350
@@ -3576,9 +3541,7 @@ _elm_config_shutdown(void)
3576 ELM_SAFE_FREE(_elm_preferred_engine, eina_stringshare_del); 3541 ELM_SAFE_FREE(_elm_preferred_engine, eina_stringshare_del);
3577 ELM_SAFE_FREE(_elm_accel_preference, eina_stringshare_del); 3542 ELM_SAFE_FREE(_elm_accel_preference, eina_stringshare_del);
3578 ELM_SAFE_FREE(_elm_profile, free); 3543 ELM_SAFE_FREE(_elm_profile, free);
3579#ifdef HAVE_ELEMENTARY_X
3580 _elm_font_overlays_del_free(); 3544 _elm_font_overlays_del_free();
3581#endif
3582 3545
3583 _desc_shutdown(); 3546 _desc_shutdown();
3584 3547