Initialize Tizen 2.3
[framework/uifw/elementary.git] / wearable / src / lib / els_cursor.c
1 #include <Elementary.h>
2 #include <Elementary_Cursor.h>
3 #include "elm_priv.h"
4
5 #ifdef HAVE_ELEMENTARY_X
6 #include <Ecore_X.h>
7 #include <Ecore_X_Cursor.h>
8 #endif
9
10 #define _cursor_key "_elm_cursor"
11
12 struct _Cursor_Id
13 {
14    const char *name;
15 #ifdef HAVE_ELEMENTARY_X
16    int id;
17 #endif
18 };
19
20 #ifdef HAVE_ELEMENTARY_X
21 #define CURSOR(_name, _xid) \
22    {_name , _xid}
23 # else
24 #define CURSOR(_name, _xid) \
25    {_name}
26 #endif
27
28 /* Please keep order in sync with Ecore_X_Cursor.h values! */
29 struct _Cursor_Id _cursors[] =
30 {
31    CURSOR(ELM_CURSOR_X                  , ECORE_X_CURSOR_X                  ),
32    CURSOR(ELM_CURSOR_ARROW              , ECORE_X_CURSOR_ARROW              ),
33    CURSOR(ELM_CURSOR_BASED_ARROW_DOWN   , ECORE_X_CURSOR_BASED_ARROW_DOWN   ),
34    CURSOR(ELM_CURSOR_BASED_ARROW_UP     , ECORE_X_CURSOR_UP                 ),
35    CURSOR(ELM_CURSOR_BOAT               , ECORE_X_CURSOR_BOAT               ),
36    CURSOR(ELM_CURSOR_BOGOSITY           , ECORE_X_CURSOR_BOGOSITY           ),
37    CURSOR(ELM_CURSOR_BOTTOM_LEFT_CORNER , ECORE_X_CURSOR_BOTTOM_LEFT_CORNER ),
38    CURSOR(ELM_CURSOR_BOTTOM_RIGHT_CORNER, ECORE_X_CURSOR_BOTTOM_RIGHT_CORNER),
39    CURSOR(ELM_CURSOR_BOTTOM_SIDE        , ECORE_X_CURSOR_BOTTOM_SIDE        ),
40    CURSOR(ELM_CURSOR_BOTTOM_TEE         , ECORE_X_CURSOR_BOTTOM_TEE         ),
41    CURSOR(ELM_CURSOR_BOX_SPIRAL         , ECORE_X_CURSOR_BOX_SPIRAL         ),
42    CURSOR(ELM_CURSOR_CENTER_PTR         , ECORE_X_CURSOR_CENTER_PTR         ),
43    CURSOR(ELM_CURSOR_CIRCLE             , ECORE_X_CURSOR_CIRCLE             ),
44    CURSOR(ELM_CURSOR_CLOCK              , ECORE_X_CURSOR_CLOCK              ),
45    CURSOR(ELM_CURSOR_COFFEE_MUG         , ECORE_X_CURSOR_COFFEE_MUG         ),
46    CURSOR(ELM_CURSOR_CROSS              , ECORE_X_CURSOR_CROSS              ),
47    CURSOR(ELM_CURSOR_CROSS_REVERSE      , ECORE_X_CURSOR_CROSS_REVERSE      ),
48    CURSOR(ELM_CURSOR_CROSSHAIR          , ECORE_X_CURSOR_CROSSHAIR          ),
49    CURSOR(ELM_CURSOR_DIAMOND_CROSS      , ECORE_X_CURSOR_DIAMOND_CROSS      ),
50    CURSOR(ELM_CURSOR_DOT                , ECORE_X_CURSOR_DOT                ),
51    CURSOR(ELM_CURSOR_DOT_BOX_MASK       , ECORE_X_CURSOR_DOT_BOX_MASK       ),
52    CURSOR(ELM_CURSOR_DOUBLE_ARROW       , ECORE_X_CURSOR_DOUBLE_ARROW       ),
53    CURSOR(ELM_CURSOR_DRAFT_LARGE        , ECORE_X_CURSOR_DRAFT_LARGE        ),
54    CURSOR(ELM_CURSOR_DRAFT_SMALL        , ECORE_X_CURSOR_DRAFT_SMALL        ),
55    CURSOR(ELM_CURSOR_DRAPED_BOX         , ECORE_X_CURSOR_DRAPED_BOX         ),
56    CURSOR(ELM_CURSOR_EXCHANGE           , ECORE_X_CURSOR_EXCHANGE           ),
57    CURSOR(ELM_CURSOR_FLEUR              , ECORE_X_CURSOR_FLEUR              ),
58    CURSOR(ELM_CURSOR_GOBBLER            , ECORE_X_CURSOR_GOBBLER            ),
59    CURSOR(ELM_CURSOR_GUMBY              , ECORE_X_CURSOR_GUMBY              ),
60    CURSOR(ELM_CURSOR_HAND1              , ECORE_X_CURSOR_HAND1              ),
61    CURSOR(ELM_CURSOR_HAND2              , ECORE_X_CURSOR_HAND2              ),
62    CURSOR(ELM_CURSOR_HEART              , ECORE_X_CURSOR_HEART              ),
63    CURSOR(ELM_CURSOR_ICON               , ECORE_X_CURSOR_ICON               ),
64    CURSOR(ELM_CURSOR_IRON_CROSS         , ECORE_X_CURSOR_IRON_CROSS         ),
65    CURSOR(ELM_CURSOR_LEFT_PTR           , ECORE_X_CURSOR_LEFT_PTR           ),
66    CURSOR(ELM_CURSOR_LEFT_SIDE          , ECORE_X_CURSOR_LEFT_SIDE          ),
67    CURSOR(ELM_CURSOR_LEFT_TEE           , ECORE_X_CURSOR_LEFT_TEE           ),
68    CURSOR(ELM_CURSOR_LEFTBUTTON         , ECORE_X_CURSOR_LEFTBUTTON         ),
69    CURSOR(ELM_CURSOR_LL_ANGLE           , ECORE_X_CURSOR_LL_ANGLE           ),
70    CURSOR(ELM_CURSOR_LR_ANGLE           , ECORE_X_CURSOR_LR_ANGLE           ),
71    CURSOR(ELM_CURSOR_MAN                , ECORE_X_CURSOR_MAN                ),
72    CURSOR(ELM_CURSOR_MIDDLEBUTTON       , ECORE_X_CURSOR_MIDDLEBUTTON       ),
73    CURSOR(ELM_CURSOR_MOUSE              , ECORE_X_CURSOR_MOUSE              ),
74    CURSOR(ELM_CURSOR_PENCIL             , ECORE_X_CURSOR_PENCIL             ),
75    CURSOR(ELM_CURSOR_PIRATE             , ECORE_X_CURSOR_PIRATE             ),
76    CURSOR(ELM_CURSOR_PLUS               , ECORE_X_CURSOR_PLUS               ),
77    CURSOR(ELM_CURSOR_QUESTION_ARROW     , ECORE_X_CURSOR_QUESTION_ARROW     ),
78    CURSOR(ELM_CURSOR_RIGHT_PTR          , ECORE_X_CURSOR_RIGHT_PTR          ),
79    CURSOR(ELM_CURSOR_RIGHT_SIDE         , ECORE_X_CURSOR_RIGHT_SIDE         ),
80    CURSOR(ELM_CURSOR_RIGHT_TEE          , ECORE_X_CURSOR_RIGHT_TEE          ),
81    CURSOR(ELM_CURSOR_RIGHTBUTTON        , ECORE_X_CURSOR_RIGHTBUTTON        ),
82    CURSOR(ELM_CURSOR_RTL_LOGO           , ECORE_X_CURSOR_RTL_LOGO           ),
83    CURSOR(ELM_CURSOR_SAILBOAT           , ECORE_X_CURSOR_SAILBOAT           ),
84    CURSOR(ELM_CURSOR_SB_DOWN_ARROW      , ECORE_X_CURSOR_SB_DOWN_ARROW      ),
85    CURSOR(ELM_CURSOR_SB_H_DOUBLE_ARROW  , ECORE_X_CURSOR_SB_H_DOUBLE_ARROW  ),
86    CURSOR(ELM_CURSOR_SB_LEFT_ARROW      , ECORE_X_CURSOR_SB_LEFT_ARROW      ),
87    CURSOR(ELM_CURSOR_SB_RIGHT_ARROW     , ECORE_X_CURSOR_SB_RIGHT_ARROW     ),
88    CURSOR(ELM_CURSOR_SB_UP_ARROW        , ECORE_X_CURSOR_SB_UP_ARROW        ),
89    CURSOR(ELM_CURSOR_SB_V_DOUBLE_ARROW  , ECORE_X_CURSOR_SB_V_DOUBLE_ARROW  ),
90    CURSOR(ELM_CURSOR_SHUTTLE            , ECORE_X_CURSOR_SHUTTLE            ),
91    CURSOR(ELM_CURSOR_SIZING             , ECORE_X_CURSOR_SIZING             ),
92    CURSOR(ELM_CURSOR_SPIDER             , ECORE_X_CURSOR_SPIDER             ),
93    CURSOR(ELM_CURSOR_SPRAYCAN           , ECORE_X_CURSOR_SPRAYCAN           ),
94    CURSOR(ELM_CURSOR_STAR               , ECORE_X_CURSOR_STAR               ),
95    CURSOR(ELM_CURSOR_TARGET             , ECORE_X_CURSOR_TARGET             ),
96    CURSOR(ELM_CURSOR_TCROSS             , ECORE_X_CURSOR_TCROSS             ),
97    CURSOR(ELM_CURSOR_TOP_LEFT_ARROW     , ECORE_X_CURSOR_TOP_LEFT_ARROW     ),
98    CURSOR(ELM_CURSOR_TOP_LEFT_CORNER    , ECORE_X_CURSOR_TOP_LEFT_CORNER    ),
99    CURSOR(ELM_CURSOR_TOP_RIGHT_CORNER   , ECORE_X_CURSOR_TOP_RIGHT_CORNER   ),
100    CURSOR(ELM_CURSOR_TOP_SIDE           , ECORE_X_CURSOR_TOP_SIDE           ),
101    CURSOR(ELM_CURSOR_TOP_TEE            , ECORE_X_CURSOR_TOP_TEE            ),
102    CURSOR(ELM_CURSOR_TREK               , ECORE_X_CURSOR_TREK               ),
103    CURSOR(ELM_CURSOR_UL_ANGLE           , ECORE_X_CURSOR_UL_ANGLE           ),
104    CURSOR(ELM_CURSOR_UMBRELLA           , ECORE_X_CURSOR_UMBRELLA           ),
105    CURSOR(ELM_CURSOR_UR_ANGLE           , ECORE_X_CURSOR_UR_ANGLE           ),
106    CURSOR(ELM_CURSOR_WATCH              , ECORE_X_CURSOR_WATCH              ),
107    CURSOR(ELM_CURSOR_XTERM              , ECORE_X_CURSOR_XTERM              )
108 };
109 static const int _cursors_count = sizeof(_cursors)/sizeof(struct _Cursor_Id);
110
111 #define ELM_CURSOR_GET_OR_RETURN(cur, obj, ...)         \
112   Elm_Cursor *cur;                                      \
113   do                                                    \
114     {                                                   \
115        if (!(obj))                                      \
116          {                                              \
117             CRITICAL("Null pointer: " #obj);            \
118             return __VA_ARGS__;                         \
119          }                                              \
120        cur = evas_object_data_get((obj), _cursor_key);  \
121        if (!cur)                                        \
122          {                                              \
123             ERR("Object does not have cursor: " #obj);  \
124             return __VA_ARGS__;                         \
125          }                                              \
126     }                                                   \
127   while (0)
128
129 struct _Elm_Cursor
130 {
131    Evas_Object *obj;
132    Evas_Object *eventarea, *owner;
133    const char *style, *cursor_name;
134    int hot_x, hot_y;
135    Ecore_Evas *ee;
136    Evas *evas;
137 #ifdef HAVE_ELEMENTARY_X
138    struct {
139      Ecore_X_Cursor cursor;
140      Ecore_X_Window win;
141    } x;
142 #endif
143 #ifdef HAVE_ELEMENTARY_WAYLAND
144    struct {
145      Ecore_Wl_Window *win;
146    } wl;
147 #endif
148
149    Eina_Bool visible:1;
150    Eina_Bool use_engine:1;
151    Eina_Bool engine_only:1;
152 };
153
154 static void
155 _elm_cursor_obj_del(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
156 {
157    Elm_Cursor *cur = data;
158    
159    if (cur)
160      {
161         evas_object_event_callback_del_full(cur->obj, EVAS_CALLBACK_DEL,
162                                             _elm_cursor_obj_del, cur);
163         cur->obj = NULL;
164      }
165 }
166
167 static Eina_Bool
168 _elm_cursor_obj_add(Evas_Object *obj, Elm_Cursor *cur)
169 {
170    int x, y;
171
172    cur->obj = edje_object_add(cur->evas);
173
174    if (!cur->obj)
175      return EINA_FALSE;
176
177    if (!_elm_theme_object_set(obj, cur->obj, "cursor", cur->cursor_name,
178                              cur->style ? cur->style : "default"))
179      {
180         evas_object_del(cur->obj);
181         cur->obj = NULL;
182         return EINA_FALSE;
183      }
184
185    evas_object_event_callback_add(cur->obj, EVAS_CALLBACK_DEL,
186                                   _elm_cursor_obj_del, cur);
187
188    edje_object_size_min_get(cur->obj, &x, &y);
189    evas_object_resize(cur->obj, x, y);
190    return EINA_TRUE;
191 }
192
193 static void
194 _elm_cursor_set_hot_spots(Elm_Cursor *cur)
195 {
196    const char *str;
197
198    str = edje_object_data_get(cur->obj, "hot_x");
199    if (str) cur->hot_x = atoi(str);
200    else cur->hot_x = 0;
201
202    str = edje_object_data_get(cur->obj, "hot_y");
203    if (str) cur->hot_y = atoi(str);
204    else cur->hot_y = 0;
205 }
206
207 static void
208 _elm_cursor_mouse_in(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
209 {
210    Elm_Cursor *cur = data;
211
212    if (cur->visible) return;
213    evas_event_freeze(cur->evas);
214    cur->visible = EINA_TRUE;
215    if ((!cur->engine_only) && (!cur->use_engine))
216      {
217         if (!cur->obj)
218           _elm_cursor_obj_add(cur->eventarea, cur);
219         ecore_evas_object_cursor_set(cur->ee, cur->obj,
220                                      ELM_OBJECT_LAYER_CURSOR, cur->hot_x,
221                                      cur->hot_y);
222      }
223    else
224      {
225 #ifdef HAVE_ELEMENTARY_X
226         if (cur->x.win)
227           ecore_x_window_cursor_set(cur->x.win, cur->x.cursor);
228 #endif
229 #ifdef HAVE_ELEMENTARY_WAYLAND
230         if (cur->wl.win)
231           ecore_wl_window_cursor_from_name_set(cur->wl.win, cur->cursor_name);
232 #endif
233      }
234    evas_event_thaw(cur->evas);
235 }
236
237 static void
238 _elm_cursor_mouse_out(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
239 {
240    Evas_Object *sobj_parent;
241    Elm_Cursor *pcur = NULL;
242    Elm_Cursor *cur = data;
243
244    if (!cur->visible) return;
245    evas_event_freeze(cur->evas);
246    cur->visible = EINA_FALSE;
247
248    sobj_parent = evas_object_data_get(cur->eventarea, "elm-parent");
249    while (sobj_parent)
250      {
251         pcur = evas_object_data_get((sobj_parent), _cursor_key);
252         if ((pcur) && (pcur->visible)) break;
253         sobj_parent = evas_object_data_get(sobj_parent, "elm-parent");
254      }
255
256    if (pcur)
257      {
258         pcur->visible = EINA_FALSE;
259         evas_event_thaw(cur->evas);
260         _elm_cursor_mouse_in(pcur, NULL, NULL, NULL);
261         return;
262      }
263
264    if ((!cur->engine_only) || (!cur->use_engine))
265      ecore_evas_object_cursor_set(cur->ee, NULL, ELM_OBJECT_LAYER_CURSOR,
266                                   cur->hot_x, cur->hot_y);
267    else
268      {
269 #ifdef HAVE_ELEMENTARY_X
270         if (cur->x.win)
271           ecore_x_window_cursor_set(cur->x.win, ECORE_X_CURSOR_X);
272 #endif
273 #ifdef HAVE_ELEMENTARY_WAYLAND
274         if (cur->wl.win)
275           ecore_wl_window_cursor_default_restore(cur->wl.win);
276 #endif
277      }
278    evas_event_thaw(cur->evas);
279 }
280
281 static void
282 _elm_cursor_del(void *data __UNUSED__, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
283 {
284    elm_object_cursor_unset(obj);
285 }
286
287 #ifdef HAVE_ELEMENTARY_X
288 static int
289 _elm_cursor_strcmp(const void *data1, const void *data2)
290 {
291    const struct _Cursor_Id *c1 = data1;
292    const struct _Cursor_Id *c2 = data2;
293    return strcmp (c1->name, c2->name);
294 }
295 #endif
296
297 static void
298 _elm_cursor_cur_set(Elm_Cursor *cur)
299 {
300    if (cur->engine_only)
301      {
302         INF("Using only engine cursors");
303         cur->use_engine = EINA_TRUE;
304      }
305    else if (_elm_cursor_obj_add(cur->eventarea, cur))
306      {
307         _elm_cursor_set_hot_spots(cur);
308         cur->use_engine = EINA_FALSE;
309         elm_widget_cursor_add(cur->owner, cur);
310      }
311    else
312      {
313         INF("Cursor couldn't be found on theme: %s", cur->cursor_name);
314         cur->use_engine = EINA_TRUE;
315      }
316
317    if (cur->use_engine)
318      {
319 #ifdef HAVE_ELEMENTARY_X
320         cur->x.win = elm_win_xwindow_get(cur->eventarea);
321         if (cur->x.win)
322           {
323              struct _Cursor_Id *cur_id;
324
325              cur_id = bsearch(&(cur->cursor_name), _cursors, _cursors_count,
326                               sizeof(struct _Cursor_Id), _elm_cursor_strcmp);
327
328              if (!cur_id)
329                {
330                   INF("X cursor couldn't be found: %s. Using default.",
331                       cur->cursor_name);
332                   cur->x.cursor = ecore_x_cursor_shape_get(ECORE_X_CURSOR_X);
333                }
334              else
335                 cur->x.cursor = ecore_x_cursor_shape_get(cur_id->id);
336           }
337 #endif
338 #ifdef HAVE_ELEMENTARY_WAYLAND
339         cur->wl.win = elm_win_wl_window_get(cur->eventarea);
340 #endif
341      }
342 }
343
344 /**
345  * Set the cursor to be shown when mouse is over the object
346  *
347  * Set the cursor that will be displayed when mouse is over the
348  * object. The object can have only one cursor set to it, so if
349  * this function is called twice for an object, the previous set
350  * will be unset.
351  * If using X cursors, a definition of all the valid cursor names
352  * is listed on Elementary_Cursors.h. If an invalid name is set
353  * the default cursor will be used.
354  *
355  * This is an internal function that is used by objects with sub-items
356  * that want to provide different cursors for each of them. The @a
357  * owner object should be an elm_widget and will be used to track
358  * theme changes and to feed @a func and @a del_cb. The @a eventarea
359  * may be any object and is the one that should be used later on with
360  * elm_object_cursor apis, such as elm_object_cursor_unset().
361  *
362  * @param eventarea the object being attached a cursor.
363  * @param owner the elm_widget that owns this object, will be used to
364  *        track theme changes and to be used in @a func or @a del_cb.
365  * @param cursor the cursor name to be used.
366  *
367  * @internal
368  * @ingroup Cursors
369  */
370 void
371 elm_object_sub_cursor_set(Evas_Object *eventarea, Evas_Object *owner, const char *cursor)
372 {
373    Elm_Cursor *cur = NULL;
374
375    cur = evas_object_data_get(eventarea, _cursor_key);
376    if (cur)
377      elm_object_cursor_unset(eventarea);
378
379    if (!cursor) return;
380
381    cur = ELM_NEW(Elm_Cursor);
382    if (!cur) return;
383
384    cur->owner = owner;
385    cur->eventarea = eventarea;
386    cur->engine_only = _elm_config->cursor_engine_only;
387    cur->visible = EINA_FALSE;
388
389    cur->cursor_name = eina_stringshare_add(cursor);
390    if (!cur->cursor_name)
391      ERR("Could not store cursor name %s", cursor);
392
393    cur->evas = evas_object_evas_get(eventarea);
394    cur->ee = ecore_evas_ecore_evas_get(cur->evas);
395
396    _elm_cursor_cur_set(cur);
397
398    evas_object_data_set(eventarea, _cursor_key, cur);
399
400    evas_object_event_callback_add(eventarea, EVAS_CALLBACK_MOUSE_IN,
401                                   _elm_cursor_mouse_in, cur);
402    evas_object_event_callback_add(eventarea, EVAS_CALLBACK_MOUSE_OUT,
403                                   _elm_cursor_mouse_out, cur);
404    evas_object_event_callback_add(eventarea, EVAS_CALLBACK_DEL,
405                                   _elm_cursor_del, cur);
406 }
407
408 EAPI void
409 elm_object_cursor_set(Evas_Object *obj, const char *cursor)
410 {
411    EINA_SAFETY_ON_NULL_RETURN(obj);
412    elm_object_sub_cursor_set(obj, obj, cursor);
413 }
414
415 EAPI const char *
416 elm_object_cursor_get(const Evas_Object *obj)
417 {
418    ELM_CURSOR_GET_OR_RETURN(cur, obj, NULL);
419    return cur->cursor_name;
420 }
421
422 EAPI void
423 elm_object_cursor_unset(Evas_Object *obj)
424 {
425    ELM_CURSOR_GET_OR_RETURN(cur, obj);
426
427    eina_stringshare_del(cur->cursor_name);
428    eina_stringshare_del(cur->style);
429
430    if (cur->owner)
431      elm_widget_cursor_del(cur->owner, cur);
432
433    if (cur->obj)
434      {
435         evas_object_event_callback_del_full(cur->obj, EVAS_CALLBACK_DEL,
436                                             _elm_cursor_obj_del, cur);
437         evas_object_del(cur->obj);
438         cur->obj = NULL;
439      }
440
441    if (cur->visible)
442      {
443         if (!cur->use_engine)
444           ecore_evas_object_cursor_set(cur->ee, NULL, ELM_OBJECT_LAYER_CURSOR,
445                                        cur->hot_x, cur->hot_y);
446 #ifdef HAVE_ELEMENTARY_X
447         else if (cur->x.win)
448           ecore_x_window_cursor_set(cur->x.win, ECORE_X_CURSOR_X);
449 #endif
450      }
451
452    evas_object_event_callback_del_full(obj, EVAS_CALLBACK_MOUSE_IN,
453                                   _elm_cursor_mouse_in, cur);
454    evas_object_event_callback_del_full(obj, EVAS_CALLBACK_MOUSE_OUT,
455                                   _elm_cursor_mouse_out, cur);
456    evas_object_event_callback_del_full(obj, EVAS_CALLBACK_DEL,
457                                        _elm_cursor_del, cur);
458    evas_object_data_del(obj, _cursor_key);
459    free(cur);
460 }
461
462 EAPI void
463 elm_object_cursor_style_set(Evas_Object *obj, const char *style)
464 {
465    ELM_CURSOR_GET_OR_RETURN(cur, obj);
466
467    if (!eina_stringshare_replace(&cur->style, style))
468      ERR("Could not set current style=%s", style);
469
470    if (cur->use_engine) return;
471
472    if (!cur->obj)
473      {
474         if (!_elm_cursor_obj_add(obj, cur))
475           ERR("Could not create cursor object");
476         else
477           _elm_cursor_set_hot_spots(cur);
478      }
479    else
480      {
481         if (!_elm_theme_object_set(obj, cur->obj, "cursor", cur->cursor_name,
482                                    style))
483           ERR("Could not apply the theme to the cursor style=%s", style);
484         else
485           _elm_cursor_set_hot_spots(cur);
486      }
487 }
488
489 EAPI const char *
490 elm_object_cursor_style_get(const Evas_Object *obj)
491 {
492    ELM_CURSOR_GET_OR_RETURN(cur, obj, NULL);
493    return cur->style ? cur->style : "default";
494 }
495
496 /**
497  * Notify cursor should recalculate its theme.
498  * @internal
499  */
500 void
501 elm_cursor_theme(Elm_Cursor *cur)
502 {
503    if ((!cur) || (!cur->obj)) return;
504    if (!_elm_theme_object_set(cur->eventarea, cur->obj, "cursor",
505                              cur->cursor_name, cur->style))
506      ERR("Could not apply the theme to the cursor style=%s", cur->style);
507    else
508      _elm_cursor_set_hot_spots(cur);
509 }
510
511 EAPI void
512 elm_object_cursor_theme_search_enabled_set(Evas_Object *obj, Eina_Bool theme_search)
513 {
514    ELM_CURSOR_GET_OR_RETURN(cur, obj);
515    cur->engine_only = theme_search;
516    if (cur->obj)
517      {
518         evas_object_del(cur->obj);
519         cur->obj = NULL;
520      }
521    _elm_cursor_cur_set(cur);
522 }
523
524
525 EAPI Eina_Bool
526 elm_object_cursor_theme_search_enabled_get(const Evas_Object *obj)
527 {
528    ELM_CURSOR_GET_OR_RETURN(cur, obj, EINA_FALSE);
529    return cur->engine_only;
530 }