summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorMarcel Hollerbach <marcel@osg.samsung.com>2017-10-27 10:02:17 +0200
committerMarcel Hollerbach <marcel@osg.samsung.com>2017-10-27 12:06:40 +0200
commitacb469439fdd71607e915747e482ef294a1ab04c (patch)
tree9a2ea369483f059344f5cd4a389b4b6e48f5e234 /src/lib
parent3139b0f7f57a871a7c43474f7a375dc00aa17af2 (diff)
efl_ui_focus_manager: the FOCUSED event now carries the last focused
object This is usefull to react on focused events
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/elementary/efl_ui_focus_manager.eo2
-rw-r--r--src/lib/elementary/efl_ui_focus_manager_calc.c20
-rw-r--r--src/lib/elementary/elm_gengrid.c7
-rw-r--r--src/lib/elementary/elm_scroller.c2
4 files changed, 25 insertions, 6 deletions
diff --git a/src/lib/elementary/efl_ui_focus_manager.eo b/src/lib/elementary/efl_ui_focus_manager.eo
index f382d55975..60d75788fd 100644
--- a/src/lib/elementary/efl_ui_focus_manager.eo
+++ b/src/lib/elementary/efl_ui_focus_manager.eo
@@ -154,6 +154,6 @@ interface Efl.Ui.Focus.Manager {
154 coords,dirty; [[Emitted once the graph is dirty, this means there are 154 coords,dirty; [[Emitted once the graph is dirty, this means there are
155 potential changes in border_elements you want to know about]] 155 potential changes in border_elements you want to know about]]
156 focused : Efl.Ui.Focus.Object; [[Emitted if the manager has focused an 156 focused : Efl.Ui.Focus.Object; [[Emitted if the manager has focused an
157 object]] 157 object, the passed focus object is the last focused object]]
158 } 158 }
159} 159}
diff --git a/src/lib/elementary/efl_ui_focus_manager_calc.c b/src/lib/elementary/efl_ui_focus_manager_calc.c
index 1592ea4919..171bc7993e 100644
--- a/src/lib/elementary/efl_ui_focus_manager_calc.c
+++ b/src/lib/elementary/efl_ui_focus_manager_calc.c
@@ -1311,6 +1311,7 @@ EOLIAN static void
1311_efl_ui_focus_manager_calc_efl_ui_focus_manager_focus_set(Eo *obj, Efl_Ui_Focus_Manager_Calc_Data *pd, Efl_Ui_Focus_Object *focus) 1311_efl_ui_focus_manager_calc_efl_ui_focus_manager_focus_set(Eo *obj, Efl_Ui_Focus_Manager_Calc_Data *pd, Efl_Ui_Focus_Object *focus)
1312{ 1312{
1313 Node *node; 1313 Node *node;
1314 Efl_Ui_Focus_Object *last_focusable;
1314 Efl_Ui_Focus_Manager *redirect_manager; 1315 Efl_Ui_Focus_Manager *redirect_manager;
1315 Eo *focusable; 1316 Eo *focusable;
1316 Node_Type type; 1317 Node_Type type;
@@ -1366,6 +1367,9 @@ _efl_ui_focus_manager_calc_efl_ui_focus_manager_focus_set(Eo *obj, Efl_Ui_Focus_
1366 type = node->type; 1367 type = node->type;
1367 focusable = node->focusable; 1368 focusable = node->focusable;
1368 1369
1370 if (pd->focus_stack)
1371 last_focusable = ((Node*)eina_list_last_data_get(pd->focus_stack))->focusable;
1372
1369 _focus_stack_unfocus_last(pd); 1373 _focus_stack_unfocus_last(pd);
1370 1374
1371 if (node->type == NODE_TYPE_NORMAL) 1375 if (node->type == NODE_TYPE_NORMAL)
@@ -1377,13 +1381,17 @@ _efl_ui_focus_manager_calc_efl_ui_focus_manager_focus_set(Eo *obj, Efl_Ui_Focus_
1377 1381
1378 //populate the new change 1382 //populate the new change
1379 efl_ui_focus_object_focus_set(node->focusable, EINA_TRUE); 1383 efl_ui_focus_object_focus_set(node->focusable, EINA_TRUE);
1380 efl_event_callback_call(obj, EFL_UI_FOCUS_MANAGER_EVENT_FOCUSED, node_focusable);
1381 } 1384 }
1382 1385
1383 //remove the object from the list and add it again 1386 //remove the object from the list and add it again
1384 pd->focus_stack = eina_list_remove(pd->focus_stack, node); 1387 pd->focus_stack = eina_list_remove(pd->focus_stack, node);
1385 pd->focus_stack = eina_list_append(pd->focus_stack, node); 1388 pd->focus_stack = eina_list_append(pd->focus_stack, node);
1386 1389
1390 if (node->type == NODE_TYPE_NORMAL)
1391 {
1392 efl_event_callback_call(obj, EFL_UI_FOCUS_MANAGER_EVENT_FOCUSED, last_focusable);
1393 }
1394
1387 //set to NULL here, from the event earlier this pointer could be dead. 1395 //set to NULL here, from the event earlier this pointer could be dead.
1388 node = NULL; 1396 node = NULL;
1389 1397
@@ -1620,24 +1628,34 @@ _efl_ui_focus_manager_calc_efl_ui_focus_manager_logical_end(Eo *obj EINA_UNUSED,
1620EOLIAN static void 1628EOLIAN static void
1621_efl_ui_focus_manager_calc_efl_ui_focus_manager_reset_history(Eo *obj EINA_UNUSED, Efl_Ui_Focus_Manager_Calc_Data *pd) 1629_efl_ui_focus_manager_calc_efl_ui_focus_manager_reset_history(Eo *obj EINA_UNUSED, Efl_Ui_Focus_Manager_Calc_Data *pd)
1622{ 1630{
1631 Efl_Ui_Focus_Object *last_focusable;
1632
1623 if (!pd->focus_stack) return; 1633 if (!pd->focus_stack) return;
1624 1634
1635 last_focusable = ((Node*)eina_list_last_data_get(pd->focus_stack))->focusable;
1636
1625 _focus_stack_unfocus_last(pd); 1637 _focus_stack_unfocus_last(pd);
1626 1638
1627 pd->focus_stack = eina_list_free(pd->focus_stack); 1639 pd->focus_stack = eina_list_free(pd->focus_stack);
1640
1641 efl_event_callback_call(obj, EFL_UI_FOCUS_MANAGER_EVENT_FOCUSED, last_focusable);
1628} 1642}
1629 1643
1630EOLIAN static void 1644EOLIAN static void
1631_efl_ui_focus_manager_calc_efl_ui_focus_manager_pop_history_stack(Eo *obj EINA_UNUSED, Efl_Ui_Focus_Manager_Calc_Data *pd) 1645_efl_ui_focus_manager_calc_efl_ui_focus_manager_pop_history_stack(Eo *obj EINA_UNUSED, Efl_Ui_Focus_Manager_Calc_Data *pd)
1632{ 1646{
1647 Efl_Ui_Focus_Object *last_focusable;
1633 Node *last; 1648 Node *last;
1634 1649
1635 if (!pd->focus_stack) return; 1650 if (!pd->focus_stack) return;
1636 _focus_stack_unfocus_last(pd); 1651 _focus_stack_unfocus_last(pd);
1637 1652
1653 last_focusable = ((Node*)eina_list_last_data_get(pd->focus_stack))->focusable;
1654
1638 //get now the highest, and unfocus that! 1655 //get now the highest, and unfocus that!
1639 last = eina_list_last_data_get(pd->focus_stack); 1656 last = eina_list_last_data_get(pd->focus_stack);
1640 if (last) efl_ui_focus_object_focus_set(last->focusable, EINA_TRUE); 1657 if (last) efl_ui_focus_object_focus_set(last->focusable, EINA_TRUE);
1658 efl_event_callback_call(obj, EFL_UI_FOCUS_MANAGER_EVENT_FOCUSED, last_focusable);
1641} 1659}
1642 1660
1643EOLIAN static Efl_Ui_Focus_Object* 1661EOLIAN static Efl_Ui_Focus_Object*
diff --git a/src/lib/elementary/elm_gengrid.c b/src/lib/elementary/elm_gengrid.c
index a60cea8c90..a4ae02ac4c 100644
--- a/src/lib/elementary/elm_gengrid.c
+++ b/src/lib/elementary/elm_gengrid.c
@@ -4235,12 +4235,13 @@ static void
4235_gengrid_element_focused(void *data, const Efl_Event *ev) 4235_gengrid_element_focused(void *data, const Efl_Event *ev)
4236{ 4236{
4237 ELM_GENGRID_DATA_GET(data, pd); 4237 ELM_GENGRID_DATA_GET(data, pd);
4238 Elm_Widget *focused = efl_ui_focus_manager_focus_get(ev->object);
4238 Elm_Widget_Item *item; 4239 Elm_Widget_Item *item;
4239 4240
4240 if (efl_isa(ev->info, EFL_UI_FOCUS_COMPOSITION_ADAPTER_CLASS)) 4241 if (efl_isa(focused, EFL_UI_FOCUS_COMPOSITION_ADAPTER_CLASS))
4241 item = efl_parent_get(ev->info); 4242 item = efl_parent_get(focused);
4242 else 4243 else
4243 item = efl_ui_focus_parent_provider_find_logical_parent(pd->provider, ev->info); 4244 item = efl_ui_focus_parent_provider_find_logical_parent(pd->provider, focused);
4244 4245
4245 if (efl_isa(item, ELM_GENGRID_ITEM_CLASS)) 4246 if (efl_isa(item, ELM_GENGRID_ITEM_CLASS))
4246 { 4247 {
diff --git a/src/lib/elementary/elm_scroller.c b/src/lib/elementary/elm_scroller.c
index 833bd7e36b..b365e78101 100644
--- a/src/lib/elementary/elm_scroller.c
+++ b/src/lib/elementary/elm_scroller.c
@@ -856,7 +856,7 @@ _focused_element(void *data, const Efl_Event *event)
856{ 856{
857 Eina_Rect geom; 857 Eina_Rect geom;
858 Efl_Ui_Focus_Object *obj = data; 858 Efl_Ui_Focus_Object *obj = data;
859 Efl_Ui_Focus_Object *focus = event->info; 859 Efl_Ui_Focus_Object *focus = efl_ui_focus_manager_focus_get(event->object);
860 Elm_Scrollable_Smart_Interface_Data *pd; 860 Elm_Scrollable_Smart_Interface_Data *pd;
861 Eina_Position2D pos; 861 Eina_Position2D pos;
862 int pan_x, pan_y; 862 int pan_x, pan_y;