evas: focus_set can fail... internally handle that case properly now.

This commit is contained in:
Cedric Bail 2013-09-02 20:28:23 +09:00
parent cafa763817
commit a007a3af13
2 changed files with 17 additions and 6 deletions

View File

@ -5232,7 +5232,7 @@ enum
*
* @see evas_object_focus_set
*/
#define evas_obj_focus_set(focus) EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_FOCUS_SET), EO_TYPECHECK(Eina_Bool, focus)
#define evas_obj_focus_set(focus, succeed) EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_FOCUS_SET), EO_TYPECHECK(Eina_Bool, focus), EO_TYPECHECK(Eina_Bool *, succeed)
/**
* @def evas_obj_focus_get

View File

@ -10,29 +10,36 @@
EAPI void
evas_object_focus_set(Evas_Object *eo_obj, Eina_Bool focus)
{
eo_do(eo_obj, evas_obj_focus_set(focus));
eo_do(eo_obj, evas_obj_focus_set(focus, NULL));
}
void
_focus_set(Eo *eo_obj, void *_pd, va_list *list)
{
Eina_Bool focus = va_arg(*list, int);
Eina_Bool *r = va_arg(*list, Eina_Bool *);
int event_id = 0;
MAGIC_CHECK(eo_obj, Evas_Object, MAGIC_OBJ);
return;
MAGIC_CHECK_END();
Evas_Object_Protected_Data *obj = _pd;
Evas_Object_Protected_Data *obj = _pd;
if (r) *r = EINA_FALSE;
_evas_object_event_new();
event_id = _evas_event_counter;
if (obj->focused == focus) goto end;
if (obj->focused == focus) goto success_end;
if (evas_object_intercept_call_focus_set(eo_obj, obj, focus)) goto end;
if (focus)
{
Eina_Bool success = EINA_TRUE;
if (obj->layer->evas->focused)
evas_object_focus_set(obj->layer->evas->focused, 0);
eo_do(obj->layer->evas->focused,
evas_obj_focus_set(0, &success));
if (!success) goto end;
obj->focused = 1;
obj->layer->evas->focused = eo_obj;
evas_object_event_callback_call(eo_obj, obj, EVAS_CALLBACK_FOCUS_IN, NULL, event_id);
@ -47,7 +54,11 @@ _focus_set(Eo *eo_obj, void *_pd, va_list *list)
evas_event_callback_call(obj->layer->evas->evas,
EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT, eo_obj);
}
end:
success_end:
if (r) *r = EINA_TRUE;
end:
_evas_post_event_callback_call(obj->layer->evas->evas, obj->layer->evas);
}