summaryrefslogtreecommitdiff
path: root/src/lib/elementary/els_cursor.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/elementary/els_cursor.c')
-rw-r--r--src/lib/elementary/els_cursor.c122
1 files changed, 93 insertions, 29 deletions
diff --git a/src/lib/elementary/els_cursor.c b/src/lib/elementary/els_cursor.c
index a90c7daf25..87adefe50e 100644
--- a/src/lib/elementary/els_cursor.c
+++ b/src/lib/elementary/els_cursor.c
@@ -192,6 +192,21 @@ struct _Elm_Cursor
};
static void
+_elm_cursor_obj_hints(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
+{
+ Elm_Cursor *cur = data;
+ int x, y;
+
+ evas_object_size_hint_min_get(cur->obj, &x, &y);
+ if ((x < 8) || (y < 8))
+ {
+ x = 8;
+ y = 8;
+ }
+ evas_object_resize(cur->obj, x, y);
+}
+
+static void
_elm_cursor_obj_del(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
Elm_Cursor *cur = data;
@@ -200,6 +215,8 @@ _elm_cursor_obj_del(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UN
{
evas_object_event_callback_del_full(cur->obj, EVAS_CALLBACK_DEL,
_elm_cursor_obj_del, cur);
+ evas_object_event_callback_del_full(cur->obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
+ _elm_cursor_obj_hints, cur);
cur->obj = NULL;
ELM_SAFE_FREE(cur->hotobj, evas_object_del);
}
@@ -212,6 +229,8 @@ _elm_cursor_set_hot_spots(Elm_Cursor *cur)
Evas_Coord cx, cy, cw, ch, x, y, w, h;
int prev_hot_x, prev_hot_y;
+ if (!cur->visible) return;
+
prev_hot_x = cur->hot_x;
prev_hot_y = cur->hot_y;
@@ -255,8 +274,6 @@ _elm_cursor_hot_change(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA
static Eina_Bool
_elm_cursor_obj_add(Evas_Object *obj, Elm_Cursor *cur)
{
- int x, y;
-
#ifdef HAVE_ELEMENTARY_WL2
const char *engine_name;
@@ -269,6 +286,8 @@ _elm_cursor_obj_add(Evas_Object *obj, Elm_Cursor *cur)
cur->obj = edje_object_add(cur->evas);
if (!cur->obj) return EINA_FALSE;
+ edje_object_freeze(cur->obj);
+ edje_object_update_hints_set(cur->obj, 1);
if (!elm_widget_theme_object_set(obj, cur->obj, "cursor", cur->cursor_name,
cur->style ? cur->style : "default"))
@@ -287,27 +306,40 @@ _elm_cursor_obj_add(Evas_Object *obj, Elm_Cursor *cur)
_elm_cursor_hot_change, cur);
evas_object_event_callback_add(cur->hotobj, EVAS_CALLBACK_RESIZE,
_elm_cursor_hot_change, cur);
- if (edje_object_part_exists(cur->obj, "elm.swallow.hotspot"))
- edje_object_part_swallow(cur->obj, "elm.swallow.hotspot", cur->hotobj);
- else if (edje_object_part_exists(cur->obj, "elm.content.hotspot"))
- edje_object_part_swallow(cur->obj, "elm.content.hotspot", cur->hotobj);
+
+ if (elm_widget_is_legacy(obj))
+ {
+ if (edje_object_part_exists(cur->obj, "elm.swallow.hotspot"))
+ edje_object_part_swallow(cur->obj, "elm.swallow.hotspot", cur->hotobj);
+ else if (edje_object_part_exists(cur->obj, "elm.content.hotspot"))
+ edje_object_part_swallow(cur->obj, "elm.content.hotspot", cur->hotobj);
+ else
+ {
+ ELM_SAFE_FREE(cur->hotobj, evas_object_del);
+ ELM_SAFE_FREE(cur->obj, evas_object_del);
+ return EINA_FALSE;
+ }
+ }
else
{
- ELM_SAFE_FREE(cur->hotobj, evas_object_del);
- ELM_SAFE_FREE(cur->obj, evas_object_del);
- return EINA_FALSE;
+ if (edje_object_part_exists(cur->obj, "efl.hotspot"))
+ edje_object_part_swallow(cur->obj, "efl.hotspot", cur->hotobj);
+ else if (edje_object_part_exists(cur->obj, "efl.content.hotspot"))
+ edje_object_part_swallow(cur->obj, "efl.content.hotspot", cur->hotobj);
+ else
+ {
+ ELM_SAFE_FREE(cur->hotobj, evas_object_del);
+ ELM_SAFE_FREE(cur->obj, evas_object_del);
+ return EINA_FALSE;
+ }
}
evas_object_event_callback_add(cur->obj, EVAS_CALLBACK_DEL,
_elm_cursor_obj_del, cur);
- edje_object_size_min_get(cur->obj, &x, &y);
- edje_object_size_min_restricted_calc(cur->obj, &x, &y, x, y);
- if ((x < 8) || (y < 8))
- {
- x = 8;
- y = 8;
- }
- evas_object_resize(cur->obj, x, y);
+ evas_object_event_callback_add(cur->obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
+ _elm_cursor_obj_hints, cur);
+ edje_object_thaw(cur->obj);
+
return EINA_TRUE;
}
@@ -640,7 +672,7 @@ elm_object_sub_cursor_set(Evas_Object *eventarea, Evas_Object *owner, const char
}
EOLIAN Eina_Bool
-_elm_widget_efl_ui_cursor_cursor_set(Evas_Object *obj, Elm_Widget_Smart_Data *pd EINA_UNUSED,
+_efl_ui_widget_efl_ui_cursor_cursor_set(Evas_Object *obj, Elm_Widget_Smart_Data *pd EINA_UNUSED,
const char *cursor)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
@@ -648,13 +680,19 @@ _elm_widget_efl_ui_cursor_cursor_set(Evas_Object *obj, Elm_Widget_Smart_Data *pd
return EINA_TRUE;
}
-EOLIAN const char *
-_elm_widget_efl_ui_cursor_cursor_get(const Evas_Object *obj, Elm_Widget_Smart_Data *pd EINA_UNUSED)
+const char *
+elm_object_sub_cursor_get(const Evas_Object *obj)
{
ELM_CURSOR_GET_OR_RETURN(cur, obj, NULL);
return cur->cursor_name;
}
+EOLIAN const char *
+_efl_ui_widget_efl_ui_cursor_cursor_get(const Evas_Object *obj, Elm_Widget_Smart_Data *pd EINA_UNUSED)
+{
+ return elm_object_sub_cursor_get(obj);
+}
+
EAPI void
elm_object_cursor_unset(Evas_Object *obj)
{
@@ -675,6 +713,8 @@ elm_object_cursor_unset(Evas_Object *obj)
{
evas_object_event_callback_del_full(cur->obj, EVAS_CALLBACK_DEL,
_elm_cursor_obj_del, cur);
+ evas_object_event_callback_del_full(cur->obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
+ _elm_cursor_obj_hints, cur);
ELM_SAFE_FREE(cur->obj, evas_object_del);
}
@@ -717,9 +757,8 @@ elm_object_cursor_unset(Evas_Object *obj)
free(cur);
}
-EOLIAN Eina_Bool
-_elm_widget_efl_ui_cursor_cursor_style_set(Evas_Object *obj, Elm_Widget_Smart_Data *pd EINA_UNUSED,
- const char *style)
+Eina_Bool
+elm_object_sub_cursor_style_set(Evas_Object *obj, const char *style)
{
ELM_CURSOR_GET_OR_RETURN(cur, obj, EINA_FALSE);
@@ -753,13 +792,26 @@ _elm_widget_efl_ui_cursor_cursor_style_set(Evas_Object *obj, Elm_Widget_Smart_Da
return EINA_TRUE;
}
-EOLIAN const char *
-_elm_widget_efl_ui_cursor_cursor_style_get(const Evas_Object *obj, Elm_Widget_Smart_Data *pd EINA_UNUSED)
+EOLIAN Eina_Bool
+_efl_ui_widget_efl_ui_cursor_cursor_style_set(Evas_Object *obj, Elm_Widget_Smart_Data *pd EINA_UNUSED,
+ const char *style)
+{
+ return elm_object_sub_cursor_style_set(obj, style);
+}
+
+const char *
+elm_object_sub_cursor_style_get(const Evas_Object *obj)
{
ELM_CURSOR_GET_OR_RETURN(cur, obj, NULL);
return cur->style ? cur->style : "default";
}
+EOLIAN const char *
+_efl_ui_widget_efl_ui_cursor_cursor_style_get(const Evas_Object *obj, Elm_Widget_Smart_Data *pd EINA_UNUSED)
+{
+ return elm_object_sub_cursor_style_get(obj);
+}
+
/**
* Notify cursor should recalculate its theme.
* @internal
@@ -775,9 +827,8 @@ elm_cursor_theme(Elm_Cursor *cur)
_elm_cursor_set_hot_spots(cur);
}
-EOLIAN Eina_Bool
-_elm_widget_efl_ui_cursor_cursor_theme_search_enabled_set(Evas_Object *obj, Elm_Widget_Smart_Data *pd EINA_UNUSED,
- Eina_Bool theme_search)
+Eina_Bool
+elm_object_sub_cursor_theme_search_enabled_set(Evas_Object *obj, Eina_Bool theme_search)
{
ELM_CURSOR_GET_OR_RETURN(cur, obj, EINA_FALSE);
cur->theme_search = theme_search;
@@ -787,10 +838,23 @@ _elm_widget_efl_ui_cursor_cursor_theme_search_enabled_set(Evas_Object *obj, Elm_
}
EOLIAN Eina_Bool
-_elm_widget_efl_ui_cursor_cursor_theme_search_enabled_get(const Evas_Object *obj, Elm_Widget_Smart_Data *pd EINA_UNUSED)
+_efl_ui_widget_efl_ui_cursor_cursor_theme_search_enabled_set(Evas_Object *obj, Elm_Widget_Smart_Data *pd EINA_UNUSED,
+ Eina_Bool theme_search)
+{
+ return elm_object_sub_cursor_theme_search_enabled_set(obj, theme_search);
+}
+
+Eina_Bool
+elm_object_sub_cursor_theme_search_enabled_get(const Evas_Object *obj)
{
ELM_CURSOR_GET_OR_RETURN(cur, obj, EINA_FALSE);
return cur->theme_search;
}
+EOLIAN Eina_Bool
+_efl_ui_widget_efl_ui_cursor_cursor_theme_search_enabled_get(const Evas_Object *obj, Elm_Widget_Smart_Data *pd EINA_UNUSED)
+{
+ return elm_object_sub_cursor_theme_search_enabled_get(obj);
+}
+
#include "efl_ui_cursor.eo.c"