summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <marcel-hollerbach@t-online.de>2017-05-25 23:01:51 +0200
committerMarcel Hollerbach <marcel-hollerbach@t-online.de>2017-05-26 21:34:24 +0200
commit94dad4c37a324e67d2e8344748a0927c72c05f6c (patch)
treec68d19512b87f4632fd818530b22dfedfcae7961
parenta7fb6e92b27c01a9b68ea8bfd0b46ff82398395b (diff)
elm_inwin: set this widget as a redirect
once this widget is visible, It should handle the focus of its children and leave no option to the underlaying widgets to gain focus. This is implemented by making it a redirect when it gets visible.
-rw-r--r--src/lib/elementary/elm_inwin.c62
-rw-r--r--src/lib/elementary/elm_inwin.eo5
2 files changed, 57 insertions, 10 deletions
diff --git a/src/lib/elementary/elm_inwin.c b/src/lib/elementary/elm_inwin.c
index c910b1f671..6e9e34b5fe 100644
--- a/src/lib/elementary/elm_inwin.c
+++ b/src/lib/elementary/elm_inwin.c
@@ -24,8 +24,13 @@ static const Elm_Layout_Part_Alias_Description _content_aliases[] =
24 {NULL, NULL} 24 {NULL, NULL}
25}; 25};
26 26
27typedef struct {
28 Efl_Ui_Focus_Manager *manager;
29 Eina_Bool registered;
30} Elm_Inwin_Data;
31
27EOLIAN static void 32EOLIAN static void
28_elm_inwin_elm_layout_sizing_eval(Eo *obj, void *_pd EINA_UNUSED) 33_elm_inwin_elm_layout_sizing_eval(Eo *obj, Elm_Inwin_Data *pd EINA_UNUSED)
29{ 34{
30 Evas_Object *content; 35 Evas_Object *content;
31 Evas_Coord minw = -1, minh = -1; 36 Evas_Coord minw = -1, minh = -1;
@@ -42,13 +47,13 @@ _elm_inwin_elm_layout_sizing_eval(Eo *obj, void *_pd EINA_UNUSED)
42} 47}
43 48
44EOLIAN static Eina_Bool 49EOLIAN static Eina_Bool
45_elm_inwin_elm_widget_focus_next_manager_is(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED) 50_elm_inwin_elm_widget_focus_next_manager_is(Eo *obj EINA_UNUSED, Elm_Inwin_Data *pd EINA_UNUSED)
46{ 51{
47 return EINA_TRUE; 52 return EINA_TRUE;
48} 53}
49 54
50EOLIAN static Eina_Bool 55EOLIAN static Eina_Bool
51_elm_inwin_elm_widget_focus_next(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, Elm_Focus_Direction dir, Evas_Object **next, Elm_Object_Item **next_item) 56_elm_inwin_elm_widget_focus_next(Eo *obj EINA_UNUSED, Elm_Inwin_Data *pd EINA_UNUSED, Elm_Focus_Direction dir, Evas_Object **next, Elm_Object_Item **next_item)
52{ 57{
53 Evas_Object *content; 58 Evas_Object *content;
54 59
@@ -67,7 +72,7 @@ _elm_inwin_elm_widget_focus_next(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, Elm
67} 72}
68 73
69EOLIAN static void 74EOLIAN static void
70_elm_inwin_efl_canvas_group_group_add(Eo *obj, void *_pd EINA_UNUSED) 75_elm_inwin_efl_canvas_group_group_add(Eo *obj, Elm_Inwin_Data *pd EINA_UNUSED)
71{ 76{
72 efl_canvas_group_add(efl_super(obj, MY_CLASS)); 77 efl_canvas_group_add(efl_super(obj, MY_CLASS));
73 elm_widget_sub_object_parent_add(obj); 78 elm_widget_sub_object_parent_add(obj);
@@ -82,7 +87,7 @@ _elm_inwin_efl_canvas_group_group_add(Eo *obj, void *_pd EINA_UNUSED)
82} 87}
83 88
84EOLIAN static void 89EOLIAN static void
85_elm_inwin_elm_widget_widget_parent_set(Eo *obj, void *_pd EINA_UNUSED, Evas_Object *parent) 90_elm_inwin_elm_widget_widget_parent_set(Eo *obj, Elm_Inwin_Data *pd EINA_UNUSED, Evas_Object *parent)
86{ 91{
87 elm_win_resize_object_add(parent, obj); 92 elm_win_resize_object_add(parent, obj);
88 93
@@ -90,7 +95,7 @@ _elm_inwin_elm_widget_widget_parent_set(Eo *obj, void *_pd EINA_UNUSED, Evas_Obj
90} 95}
91 96
92EOLIAN static const Elm_Layout_Part_Alias_Description* 97EOLIAN static const Elm_Layout_Part_Alias_Description*
93_elm_inwin_elm_layout_content_aliases_get(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED) 98_elm_inwin_elm_layout_content_aliases_get(Eo *obj EINA_UNUSED, Elm_Inwin_Data *pd EINA_UNUSED)
94{ 99{
95 return _content_aliases; 100 return _content_aliases;
96} 101}
@@ -104,7 +109,7 @@ elm_win_inwin_add(Evas_Object *parent)
104} 109}
105 110
106EOLIAN static Eo * 111EOLIAN static Eo *
107_elm_inwin_efl_object_constructor(Eo *obj, void *_pd EINA_UNUSED) 112_elm_inwin_efl_object_constructor(Eo *obj, Elm_Inwin_Data *pd EINA_UNUSED)
108{ 113{
109 Evas_Object *parent = NULL; 114 Evas_Object *parent = NULL;
110 115
@@ -120,11 +125,17 @@ _elm_inwin_efl_object_constructor(Eo *obj, void *_pd EINA_UNUSED)
120 efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY); 125 efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY);
121 elm_interface_atspi_accessible_role_set(obj, ELM_ATSPI_ROLE_GLASS_PANE); 126 elm_interface_atspi_accessible_role_set(obj, ELM_ATSPI_ROLE_GLASS_PANE);
122 127
128 pd->manager = efl_add(EFL_UI_FOCUS_MANAGER_ROOT_FOCUS_CLASS, NULL,
129 efl_ui_focus_manager_root_set(efl_added, obj)
130 );
131
132 efl_composite_attach(obj, pd->manager);
133
123 return obj; 134 return obj;
124} 135}
125 136
126EOLIAN static void 137EOLIAN static void
127_elm_inwin_activate(Eo *obj, void *_pd EINA_UNUSED) 138_elm_inwin_activate(Eo *obj, Elm_Inwin_Data *pd EINA_UNUSED)
128{ 139{
129 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); 140 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
130 141
@@ -137,6 +148,41 @@ _elm_inwin_activate(Eo *obj, void *_pd EINA_UNUSED)
137 elm_object_focus_set(obj, EINA_TRUE); 148 elm_object_focus_set(obj, EINA_TRUE);
138} 149}
139 150
151EOLIAN static void
152_elm_inwin_efl_gfx_visible_set(Eo *obj, Elm_Inwin_Data *pd, Eina_Bool v)
153{
154 efl_gfx_visible_set(efl_super(obj, MY_CLASS), v);
155 Elm_Win *win;
156
157 win = elm_win_get(obj);
158
159 if (v && !pd->registered)
160 {
161 efl_ui_focus_manager_redirect_set(pd->manager, obj);
162 pd->registered = EINA_TRUE;
163 }
164 else if (!v && pd->registered)
165 {
166 efl_ui_focus_manager_redirect_set(pd->manager, NULL);
167 pd->registered = EINA_FALSE;
168 }
169}
170
171EOLIAN static Efl_Ui_Focus_Object*
172_elm_inwin_efl_ui_focus_manager_move(Eo *obj, Elm_Inwin_Data *pd, Efl_Ui_Focus_Direction direction)
173{
174 Eo *ret = efl_ui_focus_manager_move(pd->manager , direction);
175
176 if (ret)
177 return ret;
178
179 if ((direction == EFL_UI_FOCUS_DIRECTION_PREV) || (direction == EFL_UI_FOCUS_DIRECTION_NEXT))
180 efl_ui_focus_manager_focus(pd->manager, obj);
181
182 return efl_ui_focus_manager_focused(obj);
183}
184
185
140EAPI void 186EAPI void
141elm_win_inwin_content_set(Evas_Object *obj, Evas_Object *content) 187elm_win_inwin_content_set(Evas_Object *obj, Evas_Object *content)
142{ 188{
diff --git a/src/lib/elementary/elm_inwin.eo b/src/lib/elementary/elm_inwin.eo
index 08238be83c..dd831a9aa3 100644
--- a/src/lib/elementary/elm_inwin.eo
+++ b/src/lib/elementary/elm_inwin.eo
@@ -1,9 +1,8 @@
1class Elm.Inwin (Elm.Layout) 1class Elm.Inwin (Elm.Layout, Efl.Ui.Focus.Manager)
2{ 2{
3 [[Elementary inwin class]] 3 [[Elementary inwin class]]
4 legacy_prefix: elm_inwin; 4 legacy_prefix: elm_inwin;
5 eo_prefix: elm_obj_win_inwin; 5 eo_prefix: elm_obj_win_inwin;
6 data: null;
7 methods { 6 methods {
8 activate { 7 activate {
9 [[Activates an inwin object, ensuring its visibility 8 [[Activates an inwin object, ensuring its visibility
@@ -27,5 +26,7 @@ class Elm.Inwin (Elm.Layout)
27 Elm.Widget.focus_next; 26 Elm.Widget.focus_next;
28 Elm.Layout.content_aliases { get; } 27 Elm.Layout.content_aliases { get; }
29 Elm.Layout.sizing_eval; 28 Elm.Layout.sizing_eval;
29 Efl.Gfx.visible { set; }
30 Efl.Ui.Focus.Manager.move;
30 } 31 }
31} 32}