aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/elementary/efl_ui_win.c
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2016-12-07 19:27:05 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2016-12-08 16:13:32 +0900
commitbdb4977dda7024f561abf06201219804c2fa64fb (patch)
treecaf59319c700408017afdfee443141ce88ea8b9d /src/lib/elementary/efl_ui_win.c
parententry: set autocapital mode according to the layout (diff)
downloadefl-bdb4977dda7024f561abf06201219804c2fa64fb.tar.gz
win: Implement stronger theme compatibility for frame_obj
The frame object requires a theme of version 119 or more. In fact I think until we are totally happy with the window API (for EO) we might want to bump that version regularly. That would indeed disallow theme customization for border.edc until it's done. This patch uses a pretty brute force way to set the theme file to the default file from EFL installation. elm_config is not reliable here. This is very custom made and there may be a more generic way to force a widget to use a minimum theme version. Yes that could mean ugly widgets if we change the theme API but at least that would make them work. Note that the border theme contains no visual elements, so the colors of the background, etc... should all depend on the user selected theme. But of course CSD (in Wayland) will have to use the default theme -- and look grey. Fixes https://phab.enlightenment.org/D4976
Diffstat (limited to 'src/lib/elementary/efl_ui_win.c')
-rw-r--r--src/lib/elementary/efl_ui_win.c84
1 files changed, 72 insertions, 12 deletions
diff --git a/src/lib/elementary/efl_ui_win.c b/src/lib/elementary/efl_ui_win.c
index 75aa1d0c7c..1dab8de4c0 100644
--- a/src/lib/elementary/efl_ui_win.c
+++ b/src/lib/elementary/efl_ui_win.c
@@ -28,6 +28,8 @@
#define MY_CLASS_NAME "Efl.Ui.Win"
#define MY_CLASS_NAME_LEGACY "elm_win"
+#define FRAME_OBJ_THEME_MIN_VERSION 119
+
static const Elm_Win_Trap *trap = NULL;
#define TRAP(sd, name, ...) \
@@ -2150,9 +2152,9 @@ static inline Edje_Object *
_elm_win_modal_blocker_edje_get(Efl_Ui_Win_Data *sd)
{
/* Legacy theme compatibility */
- const char *version = edje_object_data_get(sd->legacy.edje, "elm_win_version");
+ const char *version = edje_object_data_get(sd->legacy.edje, "version");
int v = version ? atoi(version) : 0;
- if (v < 119)
+ if (v < FRAME_OBJ_THEME_MIN_VERSION)
{
DBG("Detected legacy theme (<1.19) for modal window blocker.");
return sd->legacy.edje;
@@ -4071,22 +4073,79 @@ _elm_object_part_cursor_set(Evas_Object *obj, Evas_Object *edj,
elm_object_sub_cursor_set(sub, obj, cursor);
}
+static char *
+_efl_system_theme_path_get(void)
+{
+ // Find the default theme from EFL install. Quite ugly.
+ const char *sysdir;
+ char *version;
+ char path[PATH_MAX];
+ int v;
+
+ sysdir = elm_theme_system_dir_get();
+ if (!sysdir) return NULL;
+
+ eina_file_path_join(path, PATH_MAX, sysdir, "default.edj");
+ version = edje_file_data_get(path, "version");
+ v = version ? atoi(version) : 0;
+ free(version);
+ if (v < FRAME_OBJ_THEME_MIN_VERSION)
+ {
+ ERR("Default system theme is too old, something is wrong with your installation of EFL.");
+ return NULL;
+ }
+
+ return strdup(path);
+}
+
static void
_elm_win_frame_add(Efl_Ui_Win_Data *sd, const char *style)
{
Evas_Object *obj = sd->obj;
- int w, h, mw, mh;
- /* short layer; */
+ int w, h, mw, mh, v;
+ const char *version;
if (sd->frame_obj) return;
+
sd->frame_obj = edje_object_add(sd->evas);
- /* layer = evas_object_layer_get(obj); */
- /* evas_object_layer_set(sd->frame_obj, layer + 1); */
- if (!elm_widget_theme_object_set
- (sd->obj, sd->frame_obj, "border", "base", style))
+
+ // Verify theme version. Border requires an exact theme API.
+ version = elm_theme_data_get(elm_widget_theme_get(sd->obj), "version");
+ v = version ? atoi(version) : 0;
+ if (EINA_LIKELY(v >= FRAME_OBJ_THEME_MIN_VERSION))
{
- ELM_SAFE_FREE(sd->frame_obj, evas_object_del);
- return;
+ if (!elm_widget_theme_object_set
+ (sd->obj, sd->frame_obj, "border", "base", style))
+ {
+ ERR("Failed to set main border theme for the window.");
+ ELM_SAFE_FREE(sd->frame_obj, evas_object_del);
+ return;
+ }
+
+ // Verify border.edc version as well
+ version = edje_object_data_get(sd->frame_obj, "version");
+ v = version ? atoi(version) : 0;
+ }
+
+ if (v < FRAME_OBJ_THEME_MIN_VERSION)
+ {
+ // Theme compatibility
+ const char *key = "elm/border/base/default"; // FIXME?
+ char *sys_theme;
+
+ WRN("Selected theme does not support the required border theme API "
+ "(version = %d, requires >= %d).",
+ v, FRAME_OBJ_THEME_MIN_VERSION);
+ sys_theme = _efl_system_theme_path_get();
+ if (!sys_theme ||
+ !edje_object_file_set(sd->frame_obj, sys_theme, key))
+ {
+ ERR("Failed to set main border theme for the window.");
+ ELM_SAFE_FREE(sd->frame_obj, evas_object_del);
+ free(sys_theme);
+ return;
+ }
+ free(sys_theme);
}
/* Small hack: The special value 2 means this is the top frame object.
@@ -6318,9 +6377,10 @@ _elm_win_bg_must_swallow(Efl_Ui_Win_Data *sd)
wd = efl_data_scope_get(bg, ELM_WIDGET_CLASS);
if (wd)
{
- version = edje_object_data_get(wd->resize_obj, "elm_bg_version");
+ version = edje_object_data_get(wd->resize_obj, "version");
v = version ? atoi(version) : 0;
- if (v >= 119) sd->legacy.bg_must_swallow = 0;
+ if (v >= FRAME_OBJ_THEME_MIN_VERSION)
+ sd->legacy.bg_must_swallow = 0;
}
evas_object_del(bg);
}