Enlightenment CVS committal Author : dj2 Project : e17 Module : libs/ewl
Dir : e17/libs/ewl/src/lib Modified Files: ewl_box.c ewl_button.c ewl_button.h ewl_embed.c ewl_entry.c ewl_enums.h ewl_grid.c ewl_label.c ewl_row.c ewl_separator.c ewl_spacer.c ewl_text.c ewl_tree.c ewl_widget.c ewl_widget.h Log Message: - more work on tab focus changing. it actually works now. there are a _lot_ of issues with it, but if you run 'ewl_test entry' and hit tab it will jump from one entry to the next then to the buttons. shift-tab will go back. See the TODO list for a few issues. =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_box.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -3 -r1.15 -r1.16 --- ewl_box.c 10 Nov 2005 20:28:47 -0000 1.15 +++ ewl_box.c 2 Dec 2005 06:19:04 -0000 1.16 @@ -183,6 +183,8 @@ */ b->orientation = EWL_ORIENTATION_HORIZONTAL; + ewl_widget_focusable_set(w, FALSE); + DRETURN_INT(TRUE, DLEVEL_STABLE); } =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_button.c,v retrieving revision 1.18 retrieving revision 1.19 diff -u -3 -r1.18 -r1.19 --- ewl_button.c 21 Nov 2005 05:12:29 -0000 1.18 +++ ewl_button.c 2 Dec 2005 06:19:04 -0000 1.19 @@ -90,6 +90,11 @@ ewl_container_redirect_set(EWL_CONTAINER(b), EWL_CONTAINER(b->body)); ewl_widget_appearance_set(w, "button"); + ewl_widget_focusable_set(w, TRUE); + + ewl_callback_append(w, EWL_CALLBACK_KEY_DOWN, + ewl_button_cb_key_down, NULL); + DRETURN_INT(TRUE, DLEVEL_STABLE); } @@ -245,4 +250,22 @@ DRETURN_PTR(file, DLEVEL_STABLE); } +void +ewl_button_cb_key_down(Ewl_Widget *w, void *ev, void *data __UNUSED__) +{ + Ewl_Event_Key_Down *event; + + DENTER_FUNCTION(DLEVEL_STABLE); + + event = ev; + + if ((!strcmp(event->keyname, "Return")) + || (!strcmp(event->keyname, "KP_Return")) + || (!strcmp(event->keyname, "Enter")) + || (!strcmp(event->keyname, "KP_Enter")) + || (!strcmp(event->keyname, "Space"))) + printf("BUTTON PRESS\n"); + + DLEAVE_FUNCTION(DLEVEL_STABLE); +} =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_button.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -3 -r1.6 -r1.7 --- ewl_button.h 12 Oct 2005 03:53:24 -0000 1.6 +++ ewl_button.h 2 Dec 2005 06:19:04 -0000 1.7 @@ -52,7 +52,12 @@ void ewl_button_image_set(Ewl_Button *b, char *file, char *key); char *ewl_button_image_get(Ewl_Button *b); - + +/* + * Internal + */ +void ewl_button_cb_key_down(Ewl_Widget *w, void *ev, void *data); + /** * @} */ =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_embed.c,v retrieving revision 1.25 retrieving revision 1.26 diff -u -3 -r1.25 -r1.26 --- ewl_embed.c 29 Nov 2005 02:11:50 -0000 1.25 +++ ewl_embed.c 2 Dec 2005 06:19:04 -0000 1.26 @@ -341,6 +341,25 @@ DCHECK_PARAM_PTR("keyname", keyname); DCHECK_TYPE("embed", embed, "embed"); + /* + * check if this is a focus change key press and we are not ignoring + * focus change events + */ + if ((!(embed->last.focused + && ewl_widget_ignore_focus_change_get(embed->last.focused))) + && (!strcmp(keyname, "Tab"))) + { + if (mods & EWL_KEY_MODIFIER_SHIFT) + ewl_embed_tab_order_previous(embed); + else + ewl_embed_tab_order_next(embed); + + DRETURN(DLEVEL_STABLE); + } + + /* + * setup the event struct + */ ev.modifiers = mods; ev.keyname = strdup(keyname); @@ -399,24 +418,11 @@ DCHECK_PARAM_PTR("keyname", keyname); DCHECK_TYPE("embed", embed, "embed"); - /* handle tab focus change - * XXX this should probably be pulled out to a config variable or - * something instead of tab... */ - if ((!strcmp(keyname, "Tab")) - && (!ewl_widget_ignore_focus_change_get(embed->last.focused))) - { - Ewl_Embed *emb; - unsigned int key_modifiers = 0; - - emb = ewl_embed_widget_find(embed->last.focused); - key_modifiers = ewl_ev_modifiers_get(); - if (key_modifiers & EWL_KEY_MODIFIER_SHIFT) - ewl_embed_tab_order_previous(emb); - else - ewl_embed_tab_order_next(emb); - + /* handle tab focus change (we just drop it on the floor as the + * actual focus change was done in key down */ + if ((embed->last.focused && (!ewl_widget_ignore_focus_change_get(embed->last.focused))) + && (!strcmp(keyname, "Tab"))) DRETURN(DLEVEL_STABLE); - } ev.modifiers = mods; ev.keyname = strdup(keyname); @@ -1019,6 +1025,10 @@ if (!ewl_container_parent_of(EWL_WIDGET(e), w)) DRETURN(DLEVEL_STABLE); + /* do nothing if this widget isn't focusable */ + if (!ewl_widget_focusable_get(w)) + DRETURN(DLEVEL_STABLE); + current_idx = ecore_dlist_index(e->tab_order); /* make sure this widget isn't already in the list */ @@ -1144,18 +1154,43 @@ */ void ewl_embed_tab_order_next(Ewl_Embed *e) { - Ewl_Widget *w; + Ewl_Widget *w, *start; DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("e", e); DCHECK_TYPE("e", e, "embed"); /* make sure the list is at the last focused widget */ - ecore_dlist_goto(e->tab_order, e->last.focused); - if (!(w = ecore_dlist_next(e->tab_order))) + if (e->last.focused) + { + ecore_dlist_goto(e->tab_order, e->last.focused); + w = ecore_dlist_next(e->tab_order); + if (!w) ecore_dlist_goto_first(e->tab_order); + } + else ecore_dlist_goto_first(e->tab_order); w = ecore_dlist_current(e->tab_order); + if (!w) DRETURN(DLEVEL_STABLE); + + start = w; + while ((!VISIBLE(w) || (!ewl_widget_focusable_get(w)) + || (ewl_widget_internal_is(w)))) + { + ecore_dlist_next(e->tab_order); + w = ecore_dlist_current(e->tab_order); + + /* check if we hit the end of the list and loop to the start */ + if (!w) + { + ecore_dlist_goto_first(e->tab_order); + w = ecore_dlist_current(e->tab_order); + } + + /* make sure we don't cycle */ + if (w == start) DRETURN(DLEVEL_STABLE); + } + if (w) ewl_embed_focused_widget_set(e, w); DLEAVE_FUNCTION(DLEVEL_STABLE); @@ -1169,18 +1204,43 @@ void ewl_embed_tab_order_previous(Ewl_Embed *e) { - Ewl_Widget *w; + Ewl_Widget *w, *start; DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("e", e); DCHECK_TYPE("e", e, "embed"); /* make sure the list is at the last focused widget */ - ecore_dlist_goto(e->tab_order, e->last.focused); - if (!(w = ecore_dlist_previous(e->tab_order))) - ecore_dlist_goto_last(e->tab_order); + if (e->last.focused) + { + ecore_dlist_goto(e->tab_order, e->last.focused); + w = ecore_dlist_previous(e->tab_order); + if (!w) ecore_dlist_goto_first(e->tab_order); + } + else + ecore_dlist_goto_first(e->tab_order); w = ecore_dlist_current(e->tab_order); + if (!w) DRETURN(DLEVEL_STABLE); + + start = w; + while ((!VISIBLE(w) || (!ewl_widget_focusable_get(w)) + || (ewl_widget_internal_is(w)))) + { + ecore_dlist_previous(e->tab_order); + w = ecore_dlist_current(e->tab_order); + + /* check if we hit the end of the list and loop to the start */ + if (!w) + { + ecore_dlist_goto_last(e->tab_order); + w = ecore_dlist_current(e->tab_order); + } + + /* make sure we don't cycle */ + if (w == start) DRETURN(DLEVEL_STABLE); + } + if (w) ewl_embed_focused_widget_set(e, w); DLEAVE_FUNCTION(DLEVEL_STABLE); @@ -1201,12 +1261,18 @@ DCHECK_TYPE("w", w, "widget"); if (embed->last.focused) + { ewl_widget_state_set(embed->last.focused, "unfocused"); + ewl_callback_call(embed->last.focused, EWL_CALLBACK_DESELECT); + } embed->last.focused = w; if (embed->last.focused) + { ewl_widget_state_set(embed->last.focused, "focused"); + ewl_callback_call(embed->last.focused, EWL_CALLBACK_SELECT); + } DLEAVE_FUNCTION(DLEVEL_STABLE); } =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_entry.c,v retrieving revision 1.41 retrieving revision 1.42 diff -u -3 -r1.41 -r1.42 --- ewl_entry.c 1 Dec 2005 05:35:04 -0000 1.41 +++ ewl_entry.c 2 Dec 2005 06:19:04 -0000 1.42 @@ -50,6 +50,7 @@ ewl_widget_inherit(w, "entry"); ewl_widget_appearance_set(w, "entry"); + ewl_widget_focusable_set(EWL_WIDGET(e), TRUE); ewl_object_fill_policy_set(EWL_OBJECT(e), EWL_FLAG_FILL_HSHRINK | EWL_FLAG_FILL_HFILL); @@ -535,6 +536,8 @@ ewl_widget_inherit(EWL_WIDGET(c), "cursor"); c->parent = parent; + ewl_widget_focusable_set(EWL_WIDGET(c), FALSE); + DRETURN_INT(TRUE, DLEVEL_STABLE); } =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_enums.h,v retrieving revision 1.24 retrieving revision 1.25 diff -u -3 -r1.24 -r1.25 --- ewl_enums.h 21 Nov 2005 04:13:41 -0000 1.24 +++ ewl_enums.h 2 Dec 2005 06:19:04 -0000 1.25 @@ -130,28 +130,29 @@ EWL_FLAG_PROPERTY_TOPLEVEL = 0x2000, EWL_FLAG_PROPERTY_INTERNAL = 0x4000, EWL_FLAG_PROPERTY_BLOCK_TAB_FOCUS = 0x8000, + EWL_FLAG_PROPERTY_FOCUSABLE = 0x10000, /* * Flags to indicate queues this object is on. */ - EWL_FLAG_QUEUED_CSCHEDULED = 0x10000, - EWL_FLAG_QUEUED_RSCHEDULED = 0x20000, - EWL_FLAG_QUEUED_DSCHEDULED = 0x40000, - - EWL_FLAG_QUEUED_CPROCESS = 0x80000, - EWL_FLAG_QUEUED_RPROCESS = 0x100000, - EWL_FLAG_QUEUED_DPROCESS = 0x200000, + EWL_FLAG_QUEUED_CSCHEDULED = 0x20000, + EWL_FLAG_QUEUED_RSCHEDULED = 0x40000, + EWL_FLAG_QUEUED_DSCHEDULED = 0x80000, + + EWL_FLAG_QUEUED_CPROCESS = 0x100000, + EWL_FLAG_QUEUED_RPROCESS = 0x200000, + EWL_FLAG_QUEUED_DPROCESS = 0x400000, /* * The state enum specifies the current state of a widget, ie. has it * been clicked, does it have the keyboard focus, etc. */ EWL_FLAG_STATE_NORMAL = 0, - EWL_FLAG_STATE_HILITED = 0x400000, - EWL_FLAG_STATE_PRESSED = 0x800000, - EWL_FLAG_STATE_SELECTED = 0x10000000, - EWL_FLAG_STATE_DND = 0x2000000, - EWL_FLAG_STATE_DISABLED = 0x4000000, + EWL_FLAG_STATE_HILITED = 0x800000, + EWL_FLAG_STATE_PRESSED = 0x1000000, + EWL_FLAG_STATE_SELECTED = 0x20000000, + EWL_FLAG_STATE_DND = 0x4000000, + EWL_FLAG_STATE_DISABLED = 0x8000000, EWL_FLAG_PROPERTY_DND_AWARE = 0x10000000 }; @@ -169,16 +170,16 @@ EWL_FLAG_VISIBLE_SHOWN | EWL_FLAG_VISIBLE_REALIZED | \ EWL_FLAG_VISIBLE_OBSCURED | EWL_FLAG_VISIBLE_NOCLIP) -#define EWL_FLAGS_PROPERTY_MASK (EWL_FLAG_PROPERTY_RECURSIVE | \ +#define EWL_FLAGS_PROPERTY_MASK (EWL_FLAG_PROPERTY_RECURSIVE | \ EWL_FLAG_PROPERTY_TOPLEVEL | EWL_FLAG_PROPERTY_INTERNAL | \ - EWL_FLAG_PROPERTY_BLOCK_TAB_FOCUS) + EWL_FLAG_PROPERTY_BLOCK_TAB_FOCUS | EWL_FLAG_PROPERTY_FOCUSABLE) -#define EWL_FLAGS_QUEUED_MASK (EWL_FLAG_QUEUED_CSCHEDULED | \ +#define EWL_FLAGS_QUEUED_MASK (EWL_FLAG_QUEUED_CSCHEDULED | \ EWL_FLAG_QUEUED_RSCHEDULED | EWL_FLAG_QUEUED_DSCHEDULED | \ EWL_FLAG_QUEUED_CPROCESS | EWL_FLAG_QUEUED_RPROCESS | \ EWL_FLAG_QUEUED_DPROCESS) -#define EWL_FLAGS_STATE_MASK (EWL_FLAG_STATE_NORMAL | \ +#define EWL_FLAGS_STATE_MASK (EWL_FLAG_STATE_NORMAL | \ EWL_FLAG_STATE_HILITED | EWL_FLAG_STATE_PRESSED | \ EWL_FLAG_STATE_SELECTED | EWL_FLAG_STATE_DND | \ EWL_FLAG_STATE_DISABLED) =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_grid.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -3 -r1.6 -r1.7 --- ewl_grid.c 24 Oct 2005 00:23:57 -0000 1.6 +++ ewl_grid.c 2 Dec 2005 06:19:04 -0000 1.7 @@ -90,6 +90,8 @@ ewl_callback_append(EWL_WIDGET(g), EWL_CALLBACK_CONFIGURE, ewl_grid_configure_cb, NULL); + ewl_widget_focusable_set(EWL_WIDGET(g), FALSE); + DRETURN_INT(TRUE, DLEVEL_STABLE); } =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_label.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -3 -r1.14 -r1.15 --- ewl_label.c 24 Oct 2005 01:09:11 -0000 1.14 +++ ewl_label.c 2 Dec 2005 06:19:04 -0000 1.15 @@ -49,6 +49,7 @@ ewl_widget_appearance_set(w, "label"); ewl_widget_inherit(w, "label"); ewl_object_fill_policy_set(EWL_OBJECT(la), EWL_FLAG_FILL_FILL); + ewl_widget_focusable_set(w, FALSE); ewl_callback_prepend(w, EWL_CALLBACK_DESTROY, ewl_label_destroy_cb, NULL); =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_row.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -3 -r1.11 -r1.12 --- ewl_row.c 13 Nov 2005 06:38:27 -0000 1.11 +++ ewl_row.c 2 Dec 2005 06:19:04 -0000 1.12 @@ -57,6 +57,8 @@ ewl_callback_prepend(EWL_WIDGET(row), EWL_CALLBACK_DESTROY, ewl_row_destroy_cb, NULL); + ewl_widget_focusable_set(EWL_WIDGET(row), FALSE); + DRETURN_INT(TRUE, DLEVEL_STABLE); } =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_separator.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -3 -r1.10 -r1.11 --- ewl_separator.c 25 Oct 2005 04:32:24 -0000 1.10 +++ ewl_separator.c 2 Dec 2005 06:19:04 -0000 1.11 @@ -93,6 +93,8 @@ s->orientation = EWL_ORIENTATION_HORIZONTAL; + ewl_widget_focusable_set(w, FALSE); + DRETURN_INT(TRUE, DLEVEL_STABLE); } =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_spacer.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -3 -r1.5 -r1.6 --- ewl_spacer.c 25 Oct 2005 04:52:22 -0000 1.5 +++ ewl_spacer.c 2 Dec 2005 06:19:04 -0000 1.6 @@ -42,6 +42,7 @@ ewl_widget_init(EWL_WIDGET(s)); ewl_widget_appearance_set(EWL_WIDGET(s), "spacer"); ewl_widget_inherit(EWL_WIDGET(s), "spacer"); + ewl_widget_focusable_set(EWL_WIDGET(s), FALSE); DRETURN_INT(TRUE, DLEVEL_STABLE); } =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_text.c,v retrieving revision 1.71 retrieving revision 1.72 diff -u -3 -r1.71 -r1.72 --- ewl_text.c 2 Dec 2005 04:26:41 -0000 1.71 +++ ewl_text.c 2 Dec 2005 06:19:04 -0000 1.72 @@ -139,7 +139,8 @@ ewl_text_cb_child_del); /* text consumes tabs by default */ - ewl_widget_ignore_focus_change_set(EWL_WIDGET(t), TRUE); +// ewl_widget_ignore_focus_change_set(EWL_WIDGET(t), TRUE); + ewl_widget_focusable_set(EWL_WIDGET(t), FALSE); DRETURN_INT(TRUE, DLEVEL_STABLE); } @@ -2741,6 +2742,8 @@ trigger->areas = ecore_list_new(); trigger->type = type; + ewl_widget_focusable_set(EWL_WIDGET(trigger), FALSE); + DRETURN_INT(TRUE, DLEVEL_STABLE); } @@ -3397,6 +3400,8 @@ if (type == EWL_TEXT_TRIGGER_TYPE_TRIGGER) ewl_widget_color_set(EWL_WIDGET(area), 0, 0, 0, 0); + ewl_widget_focusable_set(EWL_WIDGET(area), FALSE); + DRETURN_INT(TRUE, DLEVEL_STABLE); } =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_tree.c,v retrieving revision 1.17 retrieving revision 1.18 diff -u -3 -r1.17 -r1.18 --- ewl_tree.c 13 Nov 2005 06:38:27 -0000 1.17 +++ ewl_tree.c 2 Dec 2005 06:19:04 -0000 1.18 @@ -106,6 +106,8 @@ ewl_tree_header_configure_cb, tree->scrollarea); ewl_tree_headers_visible_set(tree, 1); + ewl_widget_focusable_set(EWL_WIDGET(tree), FALSE); + DRETURN_INT(TRUE, DLEVEL_STABLE); } @@ -772,6 +774,8 @@ node->expanded = EWL_TREE_NODE_COLLAPSED; + ewl_widget_focusable_set(EWL_WIDGET(node), FALSE); + DRETURN_INT(TRUE, DLEVEL_STABLE); } =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_widget.c,v retrieving revision 1.45 retrieving revision 1.46 diff -u -3 -r1.45 -r1.46 --- ewl_widget.c 29 Nov 2005 17:28:07 -0000 1.45 +++ ewl_widget.c 2 Dec 2005 06:19:04 -0000 1.46 @@ -103,6 +103,9 @@ ewl_callback_append(w, EWL_CALLBACK_MOUSE_MOVE, ewl_widget_mouse_move_cb, NULL); + /* widgets can take focus by default */ + ewl_widget_focusable_set(w, TRUE); + DRETURN_INT(TRUE, DLEVEL_STABLE); } @@ -1172,6 +1175,39 @@ DRETURN_INT(FALSE, DLEVEL_STABLE); } +void +ewl_widget_focusable_set(Ewl_Widget *w, unsigned int val) +{ + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR("w", w); + DCHECK_TYPE("w", w, "widget"); + + if (val) + ewl_object_flags_add(EWL_OBJECT(w), + EWL_FLAG_PROPERTY_FOCUSABLE, + EWL_FLAGS_PROPERTY_MASK); + else + ewl_object_flags_remove(EWL_OBJECT(w), + EWL_FLAG_PROPERTY_FOCUSABLE, + EWL_FLAGS_PROPERTY_MASK); + + DLEAVE_FUNCTION(DLEVEL_STABLE); +} + +unsigned int +ewl_widget_focusable_get(Ewl_Widget *w) +{ + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR_RET("w", w, FALSE); + DCHECK_TYPE("w", w, "widget"); + + if (ewl_object_flags_has(EWL_OBJECT(w), + EWL_FLAG_PROPERTY_FOCUSABLE, + EWL_FLAGS_PROPERTY_MASK)) + DRETURN_INT(TRUE, DLEVEL_STABLE); + DRETURN_INT(FALSE, DLEVEL_STABLE); +} + /** * @param w: the widget to display ancestry tree * @return Returns no value. @@ -1682,6 +1718,8 @@ if (pc) ewl_container_child_show_call(pc, w); + ewl_widget_tab_order_prepend(w); + DLEAVE_FUNCTION(DLEVEL_STABLE); } =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_widget.h,v retrieving revision 1.22 retrieving revision 1.23 diff -u -3 -r1.22 -r1.23 --- ewl_widget.h 30 Nov 2005 04:33:32 -0000 1.22 +++ ewl_widget.h 2 Dec 2005 06:19:04 -0000 1.23 @@ -162,6 +162,9 @@ void ewl_widget_tab_order_insert_after(Ewl_Widget *w, Ewl_Widget *after); void ewl_widget_tab_order_remove(Ewl_Widget *w); +void ewl_widget_focusable_set(Ewl_Widget *w, unsigned int val); +unsigned int ewl_widget_focusable_get(Ewl_Widget *w); + void ewl_widget_ignore_focus_change_set(Ewl_Widget *w, unsigned int val); unsigned int ewl_widget_ignore_focus_change_get(Ewl_Widget *w); ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs