summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <marcel-hollerbach@t-online.de>2017-05-25 16:37:01 +0200
committerMarcel Hollerbach <marcel-hollerbach@t-online.de>2017-05-26 21:34:24 +0200
commita7fb6e92b27c01a9b68ea8bfd0b46ff82398395b (patch)
treec21fae13dd97452b886563f688be6bdd39cb5697
parent66fd9839a0ac147b1925793303eef6c3bafbd23c (diff)
introduce efl_ui_focus_manager_root_focus
add a class that fills a dummy element for the case of no element added at all.
-rw-r--r--src/Makefile_Elementary.am2
-rw-r--r--src/lib/elementary/Elementary.h2
-rw-r--r--src/lib/elementary/efl_ui_focus_manager_root_focus.c138
-rw-r--r--src/lib/elementary/efl_ui_focus_manager_root_focus.eo15
4 files changed, 157 insertions, 0 deletions
diff --git a/src/Makefile_Elementary.am b/src/Makefile_Elementary.am
index b9a89a81f4..e83ea8857c 100644
--- a/src/Makefile_Elementary.am
+++ b/src/Makefile_Elementary.am
@@ -119,6 +119,7 @@ elm_public_eolian_files = \
119 lib/elementary/efl_ui_image_factory.eo \ 119 lib/elementary/efl_ui_image_factory.eo \
120 lib/elementary/efl_ui_focus_manager.eo \ 120 lib/elementary/efl_ui_focus_manager.eo \
121 lib/elementary/efl_ui_focus_manager_sub.eo \ 121 lib/elementary/efl_ui_focus_manager_sub.eo \
122 lib/elementary/efl_ui_focus_manager_root_focus.eo \
122 lib/elementary/efl_ui_focus_object.eo \ 123 lib/elementary/efl_ui_focus_object.eo \
123 lib/elementary/efl_ui_focus_user.eo \ 124 lib/elementary/efl_ui_focus_user.eo \
124 $(NULL) 125 $(NULL)
@@ -675,6 +676,7 @@ lib_elementary_libelementary_la_SOURCES = \
675 lib/elementary/efl_ui_focus_manager.c \ 676 lib/elementary/efl_ui_focus_manager.c \
676 lib/elementary/efl_ui_focus_manager_sub.c \ 677 lib/elementary/efl_ui_focus_manager_sub.c \
677 lib/elementary/efl_ui_focus_object.c \ 678 lib/elementary/efl_ui_focus_object.c \
679 lib/elementary/efl_ui_focus_manager_root_focus.c \
678 $(NULL) 680 $(NULL)
679 681
680 682
diff --git a/src/lib/elementary/Elementary.h b/src/lib/elementary/Elementary.h
index 2b840cf77d..4ec11f3c2c 100644
--- a/src/lib/elementary/Elementary.h
+++ b/src/lib/elementary/Elementary.h
@@ -147,11 +147,13 @@ EAPI extern Elm_Version *elm_version;
147# include "efl_ui_focus_object.eo.h" 147# include "efl_ui_focus_object.eo.h"
148# include "efl_ui_focus_manager.eo.h" 148# include "efl_ui_focus_manager.eo.h"
149# include "efl_ui_focus_manager_sub.eo.h" 149# include "efl_ui_focus_manager_sub.eo.h"
150# include "efl_ui_focus_manager_root_focus.eo.h"
150# include "efl_ui_focus_user.eo.h" 151# include "efl_ui_focus_user.eo.h"
151#else 152#else
152# include "efl_ui_focus_object.eo.legacy.h" 153# include "efl_ui_focus_object.eo.legacy.h"
153# include "efl_ui_focus_manager.eo.legacy.h" 154# include "efl_ui_focus_manager.eo.legacy.h"
154# include "efl_ui_focus_manager_sub.eo.legacy.h" 155# include "efl_ui_focus_manager_sub.eo.legacy.h"
156# include "efl_ui_focus_manager_root_focus.eo.legacy.h"
155# include "efl_ui_focus_user.eo.legacy.h" 157# include "efl_ui_focus_user.eo.legacy.h"
156#endif 158#endif
157 159
diff --git a/src/lib/elementary/efl_ui_focus_manager_root_focus.c b/src/lib/elementary/efl_ui_focus_manager_root_focus.c
new file mode 100644
index 0000000000..fcfbd9047c
--- /dev/null
+++ b/src/lib/elementary/efl_ui_focus_manager_root_focus.c
@@ -0,0 +1,138 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4
5#include <Elementary.h>
6#include "elm_priv.h"
7
8#define MY_CLASS EFL_UI_FOCUS_MANAGER_ROOT_FOCUS_CLASS
9
10typedef struct {
11 Efl_Ui_Focus_Object *root;
12 Eina_List *none_logicals;
13
14 Evas_Object *rect;
15 Eina_Bool rect_registered;
16
17 Eina_List *iterator_list;
18} Efl_Ui_Focus_Manager_Root_Focus_Data;
19
20static Efl_Ui_Focus_Object*
21_trap(Efl_Ui_Focus_Manager_Root_Focus_Data *pd, Efl_Ui_Focus_Object *obj)
22{
23 if (pd->rect == obj) return pd->root;
24 return obj;
25}
26
27static void
28_state_eval(Eo *obj, Efl_Ui_Focus_Manager_Root_Focus_Data *pd)
29{
30 if (!pd->none_logicals && pd->rect_registered)
31 {
32 efl_ui_focus_manager_unregister(obj, pd->rect);
33 pd->rect_registered = EINA_FALSE;
34 }
35 else if (pd->none_logicals && !pd->rect_registered)
36 {
37 efl_ui_focus_manager_register(obj, pd->rect, pd->root, NULL);
38 pd->rect_registered = EINA_TRUE;
39 }
40}
41
42EOLIAN static Eina_Bool
43_efl_ui_focus_manager_root_focus_efl_ui_focus_manager_register(Eo *obj, Efl_Ui_Focus_Manager_Root_Focus_Data *pd, Efl_Ui_Focus_Object *child, Efl_Ui_Focus_Object *parent, Efl_Ui_Focus_Manager *redirect)
44{
45 if (efl_ui_focus_manager_register(efl_super(obj, MY_CLASS), child, parent, redirect))
46 {
47 pd->none_logicals = eina_list_append(pd->none_logicals, child);
48 return EINA_TRUE;
49 }
50 if (child != pd->rect)
51 _state_eval(obj, pd);
52 return EINA_FALSE;
53}
54
55EOLIAN static void
56_efl_ui_focus_manager_root_focus_efl_ui_focus_manager_unregister(Eo *obj, Efl_Ui_Focus_Manager_Root_Focus_Data *pd, Efl_Ui_Focus_Object *child)
57{
58 efl_ui_focus_manager_unregister(efl_super(obj, MY_CLASS), child);
59
60 pd->none_logicals = eina_list_remove(pd->none_logicals, child);
61
62 if (child != pd->rect)
63 _state_eval(obj, pd);
64}
65
66
67EOLIAN static void
68_efl_ui_focus_manager_root_focus_efl_ui_focus_manager_focus(Eo *obj, Efl_Ui_Focus_Manager_Root_Focus_Data *pd, Efl_Ui_Focus_Object *focus)
69{
70 efl_ui_focus_manager_focus(efl_super(obj, MY_CLASS), _trap(pd, focus));
71}
72
73
74EOLIAN static Efl_Ui_Focus_Object*
75_efl_ui_focus_manager_root_focus_efl_ui_focus_manager_focused(Eo *obj, Efl_Ui_Focus_Manager_Root_Focus_Data *pd)
76{
77 return _trap(pd, efl_ui_focus_manager_focused(efl_super(obj, MY_CLASS)));
78}
79
80
81EOLIAN static Efl_Ui_Focus_Relations *
82_efl_ui_focus_manager_root_focus_efl_ui_focus_manager_fetch(Eo *obj, Efl_Ui_Focus_Manager_Root_Focus_Data *pd, Efl_Ui_Focus_Object *child)
83{
84 return efl_ui_focus_manager_fetch(efl_super(obj, MY_CLASS), _trap(pd, child));
85}
86
87
88EOLIAN static Efl_Ui_Focus_Object *
89_efl_ui_focus_manager_root_focus_efl_ui_focus_manager_logical_end(Eo *obj, Efl_Ui_Focus_Manager_Root_Focus_Data *pd)
90{
91 return _trap(pd, efl_ui_focus_manager_logical_end(efl_super(obj, MY_CLASS)));
92}
93
94EOLIAN static Eina_Iterator *
95_efl_ui_focus_manager_root_focus_efl_ui_focus_manager_border_elements_get(Eo *obj, Efl_Ui_Focus_Manager_Root_Focus_Data *pd)
96{
97 if (!!pd->none_logicals)
98 {
99 return efl_ui_focus_manager_border_elements_get(efl_super(obj, MY_CLASS));;
100 }
101 else
102 {
103 return eina_list_iterator_new(pd->iterator_list);
104 }
105}
106
107
108EOLIAN static Efl_Ui_Focus_Object*
109_efl_ui_focus_manager_root_focus_efl_ui_focus_manager_request_move(Eo *obj, Efl_Ui_Focus_Manager_Root_Focus_Data *pd, Efl_Ui_Focus_Direction direction)
110{
111 return _trap(pd, efl_ui_focus_manager_request_move(efl_super(obj, MY_CLASS), direction));
112}
113
114
115EOLIAN static Efl_Ui_Focus_Object*
116_efl_ui_focus_manager_root_focus_efl_ui_focus_manager_move(Eo *obj, Efl_Ui_Focus_Manager_Root_Focus_Data *pd, Efl_Ui_Focus_Direction direction)
117{
118 return _trap(pd, efl_ui_focus_manager_move(efl_super(obj, MY_CLASS), direction));
119}
120
121EOLIAN static Efl_Object*
122_efl_ui_focus_manager_root_focus_efl_object_finalize(Eo *obj, Efl_Ui_Focus_Manager_Root_Focus_Data *pd)
123{
124 Efl_Object *ret;
125
126 ret = efl_finalize(efl_super(obj, MY_CLASS));
127
128 pd->root = efl_ui_focus_manager_root_get(obj);
129 pd->rect = evas_object_rectangle_add(evas_object_evas_get(pd->root));
130 pd->iterator_list = eina_list_append(pd->iterator_list, pd->root);
131
132 _state_eval(obj, pd);
133
134 return ret;
135}
136
137
138#include "efl_ui_focus_manager_root_focus.eo.c"
diff --git a/src/lib/elementary/efl_ui_focus_manager_root_focus.eo b/src/lib/elementary/efl_ui_focus_manager_root_focus.eo
new file mode 100644
index 0000000000..3a3dd46ff8
--- /dev/null
+++ b/src/lib/elementary/efl_ui_focus_manager_root_focus.eo
@@ -0,0 +1,15 @@
1class Efl.Ui.Focus.Manager.Root_Focus(Efl.Ui.Focus.Manager) {
2 [[ This class ensures that the root is at least focusable, if nothing else is focusable]]
3 implements {
4 Efl.Ui.Focus.Manager.register;
5 Efl.Ui.Focus.Manager.unregister;
6 Efl.Ui.Focus.Manager.focus;
7 Efl.Ui.Focus.Manager.focused;
8 Efl.Ui.Focus.Manager.fetch;
9 Efl.Ui.Focus.Manager.logical_end;
10 Efl.Ui.Focus.Manager.border_elements {get;}
11 Efl.Ui.Focus.Manager.request_move;
12 Efl.Ui.Focus.Manager.move;
13 Efl.Object.finalize;
14 }
15}