win: Fix support for legacy themes (elm_bg)

For standard windows, we want to create an elm_bg object if
the theme is a legacy one. Otherwise the default theme
doesn't require an extra object, just a rectangle.
This commit is contained in:
Jean-Philippe Andre 2016-11-22 17:34:17 +09:00
parent 8c505e3191
commit 0de72b44c1
4 changed files with 53 additions and 3 deletions

View File

@ -4,7 +4,7 @@ externals.external: "elm";
// theme api version. from 1.10 on we will check version to avoid
// compat issues
data.item: "version" "110";
data.item: "version" "119";
collections {
#include "fonts.edc"

View File

@ -7,6 +7,7 @@
*/
group { name: "elm/bg/base/default";
data.item: "elm_bg_version" "119";
images.image: "bevel_dark_out.png" COMP;
parts {
part { name: "base"; type: RECT;

View File

@ -260,6 +260,8 @@ struct _Efl_Ui_Win_Data
struct {
Evas_Object *box, *edje;
Eina_Bool forbidden : 1; /**< Marks some legacy APIs as not allowed. */
Eina_Bool bg_must_swallow : 1; /**< Legacy theme compatibility (elm_bg for standard window) */
Eina_Bool bg_must_swallow_init : 1;
} legacy;
Eina_Bool urgent : 1;
@ -6223,6 +6225,35 @@ _elm_win_bg_set(Efl_Ui_Win_Data *sd, Eo *bg)
return EINA_TRUE;
}
/* Legacy theme compatibility */
static Eina_Bool
_elm_win_bg_must_swallow(Efl_Ui_Win_Data *sd)
{
if (EINA_UNLIKELY(!sd->legacy.bg_must_swallow_init))
{
/* Overkill: check which theme version the standard elm_bg uses */
Elm_Widget_Smart_Data *wd;
const char *version;
Eo *bg;
int v;
sd->legacy.bg_must_swallow = 1;
sd->legacy.bg_must_swallow_init = 1;
bg = elm_bg_add(sd->obj);
wd = efl_data_scope_get(bg, ELM_WIDGET_CLASS);
if (wd)
{
version = edje_object_data_get(wd->resize_obj, "elm_bg_version");
v = version ? atoi(version) : 0;
if (v >= 119) sd->legacy.bg_must_swallow = 0;
}
evas_object_del(bg);
}
return sd->legacy.bg_must_swallow;
}
void
_elm_win_standard_init(Eo *obj)
{
@ -6230,9 +6261,19 @@ _elm_win_standard_init(Eo *obj)
Efl_Ui_Win_Data *sd = efl_data_scope_get(obj, MY_CLASS);
ELM_SAFE_DEL(sd->bg);
sd->csd.need_bg_solid = EINA_TRUE;
/* FIXME: We should swallow a legacy elm_bg if not using the default theme */
if (!_elm_win_bg_must_swallow(sd))
{
sd->csd.need_bg_solid = EINA_TRUE;
}
else
{
/* Legacy theme compatibility */
DBG("Detected legacy theme used for elm_bg. Swallowing object.");
sd->csd.need_bg_solid = EINA_FALSE;
_elm_win_bg_set(sd, efl_add(ELM_BG_CLASS, obj));
}
_elm_win_frame_style_update(sd, 0, 1);
}

View File

@ -33,6 +33,14 @@ _elm_theme_item_finalize(Elm_Theme_Files *files,
Eina_Bool prepend,
Eina_Bool istheme)
{
/* Theme version history:
* <110: legacy, had no version tag
* 110: first supported version
* 119: switched windows to always use border
* win group has no menu, no blocker
* border group has all required swallows (conformant, bg, win)
* data: "elm_bg_version" matches "version" ("119")
*/
if (!f) return;
if (istheme)
{