efl_ui_win: reuse bg which was created for version check

Summary: This is just for not creating bg object twice.

Reviewers: bu5hm4n, zmike, YOhoho

Reviewed By: YOhoho

Subscribers: YOhoho, cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D11936
This commit is contained in:
WooHyun Jung 2020-06-12 16:57:45 +09:00
parent 94ca2d40d0
commit f362e8a93e
1 changed files with 18 additions and 16 deletions

View File

@ -7596,29 +7596,28 @@ _elm_win_bg_set(Efl_Ui_Win_Data *sd, Eo *bg)
/* Legacy theme compatibility */ /* Legacy theme compatibility */
static Eina_Bool static Eina_Bool
_elm_win_bg_must_swallow(Efl_Ui_Win_Data *sd) _elm_win_bg_must_swallow(Efl_Ui_Win_Data *sd, Eo **bg)
{ {
if (EINA_UNLIKELY(!sd->legacy.bg_must_swallow_init)) if (EINA_UNLIKELY(!sd->legacy.bg_must_swallow_init))
{ {
/* Overkill: check which theme version the standard elm_bg uses */ /* Overkill: check which theme version the standard elm_bg uses */
Elm_Widget_Smart_Data *wd; Elm_Widget_Smart_Data *wd;
const char *version; const char *version;
Eo *bg;
int v; int v;
sd->legacy.bg_must_swallow = 1; sd->legacy.bg_must_swallow = 1;
sd->legacy.bg_must_swallow_init = 1; sd->legacy.bg_must_swallow_init = 1;
if (sd->legacy.ctor) if (sd->legacy.ctor)
bg = elm_bg_add(sd->obj); *bg = elm_bg_add(sd->obj);
else else
{ {
// Note: This code path is probably not necessary (custom legacy // Note: This code path is probably not necessary (custom legacy
// theme but efl_add'ed window -- all efl_add'ed widgets would // theme but efl_add'ed window -- all efl_add'ed widgets would
// use default theme) // use default theme)
bg = efl_add(EFL_UI_BG_CLASS, sd->obj); *bg = efl_add(EFL_UI_BG_CLASS, sd->obj);
} }
wd = efl_data_scope_get(bg, EFL_UI_WIDGET_CLASS); wd = efl_data_scope_get(*bg, EFL_UI_WIDGET_CLASS);
if (wd) if (wd)
{ {
version = edje_object_data_get(wd->resize_obj, "version"); version = edje_object_data_get(wd->resize_obj, "version");
@ -7626,7 +7625,6 @@ _elm_win_bg_must_swallow(Efl_Ui_Win_Data *sd)
if (v >= FRAME_OBJ_THEME_MIN_VERSION) if (v >= FRAME_OBJ_THEME_MIN_VERSION)
sd->legacy.bg_must_swallow = 0; sd->legacy.bg_must_swallow = 0;
} }
evas_object_del(bg);
} }
return sd->legacy.bg_must_swallow; return sd->legacy.bg_must_swallow;
@ -7637,21 +7635,24 @@ _elm_win_standard_init(Eo *obj)
{ {
/* Support for elm_util_win_standard_add() and Efl.Ui.Win.Standard */ /* Support for elm_util_win_standard_add() and Efl.Ui.Win.Standard */
Efl_Ui_Win_Data *sd = efl_data_scope_get(obj, MY_CLASS); Efl_Ui_Win_Data *sd = efl_data_scope_get(obj, MY_CLASS);
Eo *bg = NULL;
ELM_SAFE_DEL(sd->bg); ELM_SAFE_DEL(sd->bg);
sd->csd.need_bg_standard = 1; sd->csd.need_bg_standard = 1;
if (!_elm_win_bg_must_swallow(sd)) if (!_elm_win_bg_must_swallow(sd, &bg))
{ {
sd->csd.need_bg_solid = EINA_TRUE; sd->csd.need_bg_solid = EINA_TRUE;
evas_object_del(bg);
} }
else else
{ {
Eo *bg;
/* Legacy theme compatibility */ /* Legacy theme compatibility */
DBG("Detected legacy theme used for elm_bg. Swallowing object."); DBG("Detected legacy theme used for elm_bg. Swallowing object.");
sd->csd.need_bg_solid = EINA_FALSE; sd->csd.need_bg_solid = EINA_FALSE;
if (!bg)
{
if (sd->legacy.ctor) if (sd->legacy.ctor)
bg = elm_bg_add(obj); bg = elm_bg_add(obj);
else else
@ -7661,6 +7662,7 @@ _elm_win_standard_init(Eo *obj)
// use default theme) // use default theme)
bg = efl_add(EFL_UI_BG_CLASS, obj); bg = efl_add(EFL_UI_BG_CLASS, obj);
} }
}
_elm_win_bg_set(sd, bg); _elm_win_bg_set(sd, bg);
} }