diff --git a/legacy/elementary/src/lib/elm_config.c b/legacy/elementary/src/lib/elm_config.c index 109d2f873d..ade5796afc 100644 --- a/legacy/elementary/src/lib/elm_config.c +++ b/legacy/elementary/src/lib/elm_config.c @@ -15,6 +15,7 @@ Elm_Config *_elm_config = NULL; char *_elm_profile = NULL; static Eet_Data_Descriptor *_config_edd = NULL; static Eet_Data_Descriptor *_config_font_overlay_edd = NULL; +const char *_elm_preferred_engine = NULL; static Ecore_Poller *_elm_cache_flush_poller = NULL; @@ -1419,7 +1420,6 @@ elm_config_all_flush(void) #endif } - static void _translation_init() { @@ -1448,6 +1448,11 @@ _elm_config_init(void) _desc_init(); _profile_fetch_from_conf(); _config_load(); + if (_elm_preferred_engine) eina_stringshare_del(_elm_preferred_engine); + if (_elm_config->engine) + _elm_preferred_engine = eina_stringshare_add(_elm_config->engine); + else + _elm_preferred_engine = NULL; _translation_init(); _env_get(); _config_apply(); @@ -1543,6 +1548,18 @@ _elm_config_engine_set(const char *engine) _elm_config->engine = eina_stringshare_add(engine); } +EAPI const char * +elm_preferred_engine_get(void) +{ + return _elm_preferred_engine; +} + +EAPI void +elm_preferred_engine_set(const char *engine) +{ + eina_stringshare_replace(&(_elm_preferred_engine), engine); +} + void _elm_config_profile_set(const char *profile) { @@ -1595,6 +1612,11 @@ _elm_config_shutdown(void) #endif } _config_free(); + if (_elm_preferred_engine) + { + eina_stringshare_del(_elm_preferred_engine); + _elm_preferred_engine = NULL; + } if (_elm_profile) { free(_elm_profile); diff --git a/legacy/elementary/src/lib/elm_engine.h b/legacy/elementary/src/lib/elm_engine.h index 89ce74f176..4dcf2ac008 100644 --- a/legacy/elementary/src/lib/elm_engine.h +++ b/legacy/elementary/src/lib/elm_engine.h @@ -50,6 +50,33 @@ EAPI const char *elm_engine_get(void); */ EAPI void elm_engine_set(const char *engine); +/** + * @brief Get Elementary's preferred engine to use. + * + * @return The rendering engine's name + * @note there's no need to free the returned string, here. + * + * This gets the global rendering engine that is applied to all Elementary + * applications and is PREFERRED by the application. This can (and will) + * override the engine configured for all applications which. + * + * @see elm_preferred_engine_set() + */ +EAPI const char *elm_preferred_engine_get(void); + +/** + * @brief Set Elementary's preferred rendering engine for use. + * + * @param engine The rendering engine's name + * + * Note that it will take effect only to Elementary windows created after + * this is called. This overrides the engine set by configuration at + * application startup. Note that it is a hint and may not be honored. + * + * @see elm_win_add() + */ +EAPI void elm_preferred_engine_set(const char *engine); + /** * @} */ diff --git a/legacy/elementary/src/lib/elm_priv.h b/legacy/elementary/src/lib/elm_priv.h index dfc25779aa..ce266f4f11 100644 --- a/legacy/elementary/src/lib/elm_priv.h +++ b/legacy/elementary/src/lib/elm_priv.h @@ -273,6 +273,7 @@ extern const char *_elm_lib_dir; extern int _elm_log_dom; extern Eina_List *_elm_win_list; extern int _elm_win_deferred_free; +extern const char *_elm_preferred_engine; #ifdef ENABLE_NLS /* Our gettext wrapper, used to disable translation of elm if the app diff --git a/legacy/elementary/src/lib/elm_win.c b/legacy/elementary/src/lib/elm_win.c index dfbb5fe547..044d48d9e5 100644 --- a/legacy/elementary/src/lib/elm_win.c +++ b/legacy/elementary/src/lib/elm_win.c @@ -867,7 +867,7 @@ _elm_win_xwindow_get(Elm_Win *win) { win->xwin = 0; -#define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name)) +#define ENGINE_COMPARE(name) (!strcmp(_elm_preferred_engine, name)) if (ENGINE_COMPARE(ELM_SOFTWARE_X11)) { if (win->ee) win->xwin = ecore_evas_software_x11_window_get(win->ee); @@ -1745,7 +1745,7 @@ elm_win_add(Evas_Object *parent, const char *name, Elm_Win_Type type) if (win->ee) \ elm_engine_set(ecore_evas_engine_name_get(win->ee)); \ } while (0) -#define ENGINE_COMPARE(name) (_elm_config->engine && !strcmp(_elm_config->engine, name)) +#define ENGINE_COMPARE(name) (_elm_preferred_engine && !strcmp(_elm_preferred_engine, name)) win->kbdmode = ELM_WIN_KEYBOARD_UNKNOWN; win->indmode = ELM_WIN_INDICATOR_UNKNOWN; @@ -1907,11 +1907,11 @@ elm_win_add(Evas_Object *parent, const char *name, Elm_Win_Type type) _elm_win_frame_add(win, "default"); // _elm_win_pointer_add(win, "default"); } - else if (!strncmp(_elm_config->engine, "shot:", 5)) + else if (!strncmp(_elm_preferred_engine, "shot:", 5)) { win->ee = ecore_evas_buffer_new(1, 1); ecore_evas_manual_render_set(win->ee, EINA_TRUE); - win->shot.info = eina_stringshare_add(_elm_config->engine + 5); + win->shot.info = eina_stringshare_add(_elm_preferred_engine + 5); _shot_init(win); } #undef FALLBACK_TRY @@ -2433,7 +2433,7 @@ elm_win_fullscreen_set(Evas_Object *obj, Eina_Bool fullscreen) win = elm_widget_data_get(obj); if (!win) return; // YYY: handle if win->img_obj -#define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name)) +#define ENGINE_COMPARE(name) (!strcmp(_elm_preferred_engine, name)) if (ENGINE_COMPARE(ELM_SOFTWARE_FB) || ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE)) { @@ -2458,7 +2458,7 @@ elm_win_fullscreen_get(const Evas_Object *obj) ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE; win = elm_widget_data_get(obj); if (!win) return EINA_FALSE; -#define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name)) +#define ENGINE_COMPARE(name) (!strcmp(_elm_preferred_engine, name)) if (ENGINE_COMPARE(ELM_SOFTWARE_FB) || ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE)) {