test focus brokenness.

Raster, if possible give it a try as it seems that most of the focus
steal and clear is your code and maybe you have a clue of what is
happening. For instance I have no clue why that global focus_order
counter that always grows.

This test is now exposing various problems, some of them is what bug
us in Editje, some is what eve's url bar, etc:

  - press "Give focus to scrolled entry", then press it again. See
    that the scrolled entry looses its focus, although we're giving it
    focus? This is related to the object loosing focus but not
    detecting it, thus the next elm_widget_focus_steal() will just
    ignore it and say "you already have focus, do nothing!"

  - start pressing "TAB", after a full iteration, the next iteration
    just goes up to the last item. If you keep doing that, at some
    point the TAB will just not work anymore.  If you change PARENT
    from "bx" to "win", then it does not happen. But adding to "bx"
    would be the correct thing to do (more logical structure)




SVN revision: 52709
This commit is contained in:
Gustavo Sverzut Barbieri 2010-09-25 00:06:32 +00:00
parent 42fab88a0e
commit 09a19aaa68
3 changed files with 152 additions and 1 deletions

View File

@ -85,7 +85,8 @@ test_anim.c \
test_calendar.c \
test_tooltip.c \
test_cursor.c \
test_focus.c
test_focus.c \
test_focus2.c
elementary_test_LDADD = $(top_builddir)/src/lib/libelementary.la @ELEMENTARY_EWEATHER_LIBS@
elementary_test_LDFLAGS =

View File

@ -85,6 +85,7 @@ void test_tooltip(void *data, Evas_Object *obj, void *event_info);
void test_cursor(void *data, Evas_Object *obj, void *event_info);
void test_cursor2(void *data, Evas_Object *obj, void *event_info);
void test_focus(void *data, Evas_Object *obj, void *event_info);
void test_focus2(void *data, Evas_Object *obj, void *event_info);
struct elm_test
{
@ -290,6 +291,7 @@ my_win_main(char *autorun)
ADD_TEST("Cursor", test_cursor);
ADD_TEST("Cursor 2", test_cursor2);
ADD_TEST("Focus", test_focus);
ADD_TEST("Focus 2", test_focus2);
#undef ADD_TEST
if (autorun)

View File

@ -0,0 +1,148 @@
#include <Elementary.h>
#ifndef ELM_LIB_QUICKLAUNCH
static void
_focus_in(void *data, Evas *e, void *event_info)
{
const char *type = evas_object_type_get(event_info);
if (type && strcmp(type, "elm_widget") == 0)
type = elm_object_widget_type_get(event_info);
printf("Evas_Object focus in: %p %s\n", event_info, type);
}
static void
_focus_out(void *data, Evas *e, void *event_info)
{
const char *type = evas_object_type_get(event_info);
if (type && strcmp(type, "elm_widget") == 0)
type = elm_object_widget_type_get(event_info);
printf("Evas_Object focus out: %p %s\n", event_info, type);
}
static void
_focus_obj(void *data, Evas_Object *o, void *event_info)
{
Evas_Object *newfocus = data;
const char *type = evas_object_type_get(newfocus);
if (type && strcmp(type, "elm_widget") == 0)
type = elm_object_widget_type_get(newfocus);
printf("elm_object_focus(%p) %s\n", newfocus, type);
elm_object_focus(newfocus);
}
static void
_focus_layout_part(void *data, Evas_Object *o, void *event_info)
{
Evas_Object *ed = elm_layout_edje_get(data);
Evas_Object *newfocus = (Evas_Object *)edje_object_part_object_get(ed, "sky");
const char *type = evas_object_type_get(newfocus);
printf("evas_object_focus_set(%p, 1) %s\n", newfocus, type);
evas_object_focus_set(newfocus, EINA_TRUE);;
}
void
test_focus2(void *data, Evas_Object *obj, void *event_info)
{
Evas_Object *win, *bg, *bx, *ly, *bt, *en, *bt1;
win = elm_win_add(NULL, "focus2", ELM_WIN_BASIC);
elm_win_title_set(win, "Focus2");
elm_win_autodel_set(win, 1);
elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
evas_event_callback_add
(evas_object_evas_get(win), EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN,
_focus_in, NULL);
evas_event_callback_add
(evas_object_evas_get(win), EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT,
_focus_out, NULL);
bg = elm_bg_add(win);
elm_win_resize_object_add(win, bg);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(bg);
bx = elm_box_add(win);
elm_win_resize_object_add(win, bx);
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(bx);
#define PARENT bx /* this is broken, but should work */
//#define PARENT win
en = elm_scrolled_entry_add(PARENT);
evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(en, EVAS_HINT_FILL, 0.5);
elm_scrolled_entry_scrollbar_policy_set(en, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
elm_scrolled_entry_entry_set(en, "Scrolled Entry that should get focus");
elm_scrolled_entry_single_line_set(en, 1);
evas_object_show(en);
elm_box_pack_end(bx, en);
bt = elm_button_add(PARENT);
elm_button_label_set(bt, "Give focus to scrolled entry");
evas_object_smart_callback_add(bt, "clicked", _focus_obj, en);
elm_box_pack_end(bx, bt);
evas_object_show(bt);
ly = elm_layout_add(PARENT);
elm_layout_file_set(ly, PACKAGE_DATA_DIR"/objects/test.edj", "layout");
evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(en, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(bx, ly);
evas_object_show(ly);
bt1 = bt = elm_button_add(ly);
elm_button_label_set(bt, "Button 1");
elm_layout_content_set(ly, "element1", bt);
en = elm_scrolled_entry_add(ly);
evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(en, EVAS_HINT_FILL, 0.5);
elm_scrolled_entry_scrollbar_policy_set(en, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
elm_scrolled_entry_entry_set(en, "Scrolled Entry that should get focus");
elm_scrolled_entry_single_line_set(en, 1);
elm_layout_content_set(ly, "element2", en);
bt = elm_button_add(ly);
elm_button_label_set(bt, "Button 2");
elm_layout_content_set(ly, "element3", bt);
bt = elm_button_add(PARENT);
elm_button_label_set(bt, "Give focus to layout");
evas_object_smart_callback_add(bt, "clicked", _focus_obj, ly);
evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(en, EVAS_HINT_FILL, 0.5);
elm_box_pack_end(bx, bt);
evas_object_show(bt);
bt = elm_button_add(PARENT);
elm_button_label_set(bt, "Give focus to layout part");
evas_object_smart_callback_add(bt, "clicked", _focus_layout_part, ly);
evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(en, EVAS_HINT_FILL, 0.5);
elm_box_pack_end(bx, bt);
evas_object_show(bt);
bt = elm_button_add(PARENT);
elm_button_label_set(bt, "Give focus to layout 'Button 1'");
evas_object_smart_callback_add(bt, "clicked", _focus_obj, bt1);
evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(en, EVAS_HINT_FILL, 0.5);
elm_box_pack_end(bx, bt);
evas_object_show(bt);
bt = elm_button_add(PARENT);
elm_button_label_set(bt, "Give focus to layout 'Entry'");
evas_object_smart_callback_add(bt, "clicked", _focus_obj, en);
evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(en, EVAS_HINT_FILL, 0.5);
elm_box_pack_end(bx, bt);
evas_object_show(bt);
evas_object_resize(win, 400, 400);
evas_object_show(win);
}
#endif