summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBruno Dilly <bdilly@profusion.mobi>2016-12-14 17:47:18 -0200
committerBruno Dilly <bdilly@profusion.mobi>2016-12-19 14:58:35 -0200
commit4449ec869888ff21c46d54ab2baaa1f209986819 (patch)
treedebe4b09a8aaf52bfcd875b3746bf9ae9e67ae31 /src
parent60b160f47ce22f30eb62917d4d43628c6c04861e (diff)
edje/examples: add example of use_custom_seat_names flag
Since seat names defined on evas will depend on evas backends, maybe udev rules, etc, we aren't able to demonstrate it without manually setting another name for such seats with efl_input_devices_name_set(). Otherwise we wouldn't have guarantees it would match names on EDC.
Diffstat (limited to 'src')
-rw-r--r--src/examples/edje/.gitignore1
-rw-r--r--src/examples/edje/Makefile.am3
-rw-r--r--src/examples/edje/edje-multiseat-custom-names.c150
-rw-r--r--src/examples/edje/multiseat_custom_names.edc175
4 files changed, 329 insertions, 0 deletions
diff --git a/src/examples/edje/.gitignore b/src/examples/edje/.gitignore
index d3d18389ac..73b171ab35 100644
--- a/src/examples/edje/.gitignore
+++ b/src/examples/edje/.gitignore
@@ -14,6 +14,7 @@
14/edje-entry 14/edje-entry
15/edje-focus 15/edje-focus
16/edje-multiseat 16/edje-multiseat
17/edje-multiseat-custom-names
17/edje-multisense 18/edje-multisense
18/edje-perspective 19/edje-perspective
19/edje-signals-messages 20/edje-signals-messages
diff --git a/src/examples/edje/Makefile.am b/src/examples/edje/Makefile.am
index 78365a4618..2afacfc6fc 100644
--- a/src/examples/edje/Makefile.am
+++ b/src/examples/edje/Makefile.am
@@ -46,6 +46,7 @@ focus.edc \
46lua_script.edc \ 46lua_script.edc \
47messages_echo.edc \ 47messages_echo.edc \
48multiseat.edc \ 48multiseat.edc \
49multiseat_custom_names.edc \
49perspective.edc \ 50perspective.edc \
50signals-messages.edc \ 51signals-messages.edc \
51signalsBubble.edc \ 52signalsBubble.edc \
@@ -146,6 +147,7 @@ edje-edit-part-box.c \
146edje-entry.c \ 147edje-entry.c \
147edje-focus.c \ 148edje-focus.c \
148edje-multiseat.c \ 149edje-multiseat.c \
150edje-multiseat-custom-names.c \
149edje-multisense.c \ 151edje-multisense.c \
150edje-perspective.c \ 152edje-perspective.c \
151edje-signals-messages.c \ 153edje-signals-messages.c \
@@ -222,6 +224,7 @@ edje-edit-part-box \
222edje-entry \ 224edje-entry \
223edje-focus \ 225edje-focus \
224edje-multiseat \ 226edje-multiseat \
227edje-multiseat-custom-names \
225edje-perspective \ 228edje-perspective \
226edje-signals-messages \ 229edje-signals-messages \
227edje-swallow \ 230edje-swallow \
diff --git a/src/examples/edje/edje-multiseat-custom-names.c b/src/examples/edje/edje-multiseat-custom-names.c
new file mode 100644
index 0000000000..7182d0c1ea
--- /dev/null
+++ b/src/examples/edje/edje-multiseat-custom-names.c
@@ -0,0 +1,150 @@
1/**
2 * Edje example demonstrating how to deal with part and objects focus.
3 *
4 * @verbatim
5 * edje_cc focus.edc && gcc -o edje-focus edje-focus.c `pkg-config --libs --cflags evas ecore ecore-evas edje`
6 * @endverbatim
7 */
8
9#ifdef HAVE_CONFIG_H
10# include "config.h"
11#else
12# define EINA_UNUSED
13#endif
14
15#ifndef PACKAGE_DATA_DIR
16#define PACKAGE_DATA_DIR "."
17#endif
18
19#include <Ecore.h>
20#include <Ecore_Evas.h>
21#include <Edje.h>
22
23#define WIDTH 400
24#define HEIGHT 400
25
26static const char *GROUPNAME = "example/main";
27static const char *EDJE_FILE = PACKAGE_DATA_DIR"/multiseat_custom_names.edj";
28
29static Efl_Input_Device *default_seat = NULL;
30static Efl_Input_Device *secondary_seat = NULL;
31
32static void
33_on_destroy(Ecore_Evas *ee EINA_UNUSED)
34{
35 ecore_main_loop_quit();
36}
37
38static void
39_on_canvas_resize(Ecore_Evas *ee)
40{
41 Evas_Object *edje_obj;
42 int w, h;
43
44 edje_obj = ecore_evas_data_get(ee, "edje_obj");
45
46 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
47 evas_object_resize(edje_obj, w, h);
48}
49
50static void
51_device_rename(Efl_Input_Device *dev)
52{
53 if (!default_seat) {
54 default_seat = dev;
55 efl_input_device_name_set(dev, "default");
56 return;
57 }
58
59 if (!secondary_seat) {
60 secondary_seat = dev;
61 efl_input_device_name_set(dev, "secondary");
62 }
63}
64
65static void
66_device_added(void *data EINA_UNUSED, const Efl_Event *event)
67{
68 Efl_Input_Device *dev = event->info;
69
70 if (efl_input_device_type_get(dev) != EFL_INPUT_DEVICE_CLASS_SEAT)
71 return;
72 _device_rename(dev);
73}
74
75static void
76_device_changed(void *data EINA_UNUSED, const Efl_Event *event)
77{
78 Efl_Input_Device *dev = event->info;
79
80 if (dev == default_seat)
81 efl_input_device_name_set(dev, "default");
82 else if (dev == secondary_seat)
83 efl_input_device_name_set(dev, "secondary");
84}
85
86int
87main(int argc EINA_UNUSED, char *argv[] EINA_UNUSED)
88{
89 const Eina_List *devices, *l;
90 Efl_Input_Device *dev;
91 Evas_Object *edje_obj;
92 Ecore_Evas *ee;
93 Evas *evas;
94
95 if (!ecore_evas_init())
96 return EXIT_FAILURE;
97
98 if (!edje_init())
99 goto shutdown_ecore_evas;
100
101 ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
102 if (!ee) goto shutdown_edje;
103
104 ecore_evas_callback_destroy_set(ee, _on_destroy);
105 ecore_evas_callback_resize_set(ee, _on_canvas_resize);
106 ecore_evas_title_set(ee, "Edje Focus Example");
107
108 evas = ecore_evas_get(ee);
109
110 edje_obj = edje_object_add(evas);
111
112 if (!edje_object_file_set(edje_obj, EDJE_FILE, GROUPNAME))
113 printf("failed to set file %s.\n", EDJE_FILE);
114
115 evas_object_move(edje_obj, 0, 0);
116 evas_object_resize(edje_obj, WIDTH, HEIGHT);
117 evas_object_show(edje_obj);
118 ecore_evas_data_set(ee, "edje_obj", edje_obj);
119
120 devices = evas_device_list(evas, NULL);
121 EINA_LIST_FOREACH(devices, l, dev)
122 {
123 if (efl_input_device_type_get(dev) == EFL_INPUT_DEVICE_CLASS_SEAT)
124 _device_rename(dev);
125 }
126 efl_event_callback_add(evas, EFL_CANVAS_EVENT_DEVICE_ADDED,
127 _device_added, NULL);
128 efl_event_callback_add(evas, EFL_CANVAS_EVENT_DEVICE_CHANGED,
129 _device_changed, NULL);
130
131 printf("Running example on evas engine %s\n",
132 ecore_evas_engine_name_get(ee));
133
134 ecore_evas_show(ee);
135
136 ecore_main_loop_begin();
137
138 ecore_evas_free(ee);
139 ecore_evas_shutdown();
140 edje_shutdown();
141
142 return EXIT_SUCCESS;
143
144shutdown_edje:
145 edje_shutdown();
146shutdown_ecore_evas:
147 ecore_evas_shutdown();
148
149 return EXIT_FAILURE;
150}
diff --git a/src/examples/edje/multiseat_custom_names.edc b/src/examples/edje/multiseat_custom_names.edc
new file mode 100644
index 0000000000..eb5c493ad0
--- /dev/null
+++ b/src/examples/edje/multiseat_custom_names.edc
@@ -0,0 +1,175 @@
1collections {
2
3 group {
4 name: "example/main";
5 min: 400 400;
6 use_custom_seat_names: 1;
7
8 parts {
9 part {
10 name: "bg";
11 type: RECT;
12 mouse_events: 0;
13 description {
14 state: "default" 0.0;
15 }
16 }
17
18 part {
19 name: "title";
20 type: TEXT;
21 mouse_events: 0;
22 description {
23 state: "default" 0.0;
24 color: 0 0 0 255;
25 rel1 {
26 relative: 0.0 0.0;
27 offset: 0 0;
28 to: "bg";
29 }
30 rel2 {
31 relative: 1.0 0.2;
32 offset: -1 -1;
33 to: "bg";
34 }
35 text {
36 text: "Multiseat System Names Example";
37 size: 16;
38 font: "sans";
39 min: 1 1;
40 }
41 }
42 }
43
44 part {
45 name: "button_bg,1";
46 type: RECT;
47 mouse_events: 1;
48 description {
49 state: "default" 0.0;
50 rel1.relative: 0.1 0.25;
51 rel2.relative: 0.45 0.8;
52 color: 200 200 200 255;
53 }
54 description {
55 state: "over,default" 0.0;
56 inherit: "default" 0.0;
57 color: 200 120 120 255;
58 }
59 description {
60 state: "over,secondary" 0.0;
61 inherit: "default" 0.0;
62 color: 120 120 200 255;
63 }
64 }
65
66 part {
67 name: "button,1";
68 type: RECT;
69 mouse_events: 0;
70 description {
71 state: "default" 0.0;
72 rel1 {
73 to: "button_bg,1";
74 offset: 10 10;
75 }
76 rel2 {
77 to: "button_bg,1";
78 offset: -11 -11;
79 }
80 color: 200 200 200 255;
81 }
82 }
83
84 part {
85 name: "button_bg,2";
86 type: RECT;
87 mouse_events: 1;
88 description {
89 state: "default" 0.0;
90 rel1.relative: 0.55 0.25;
91 rel2.relative: 0.9 0.8;
92 color: 200 200 200 255;
93 }
94 description {
95 state: "over,default" 0.0;
96 inherit: "default" 0.0;
97 color: 200 120 120 255;
98 }
99 description {
100 state: "over,secondary" 0.0;
101 inherit: "default" 0.0;
102 color: 120 120 200 255;
103 }
104 }
105
106 part {
107 name: "button,2";
108 type: RECT;
109 mouse_events: 0;
110 description {
111 state: "default" 0.0;
112 rel1 {
113 to: "button_bg,2";
114 offset: 10 10;
115 }
116 rel2 {
117 to: "button_bg,2";
118 offset: -11 -11;
119 }
120 color: 200 200 200 255;
121 }
122 }
123 }
124
125 programs {
126 program {
127 name: "button,1,over,default";
128 signal: "mouse,in,default";
129 source: "button_bg,1";
130 action: STATE_SET "over,default" 0.0;
131 target: "button_bg,1";
132 }
133
134 program {
135 name: "button,1,over,secondary";
136 signal: "mouse,in,secondary";
137 source: "button_bg,1";
138 action: STATE_SET "over,secondary" 0.0;
139 target: "button_bg,1";
140 }
141
142 program {
143 name: "button,1,out";
144 signal: "mouse,out";
145 source: "button_bg,1";
146 action: STATE_SET "default" 0.0;
147 target: "button_bg,1";
148 }
149
150 program {
151 name: "button,2,over,default";
152 signal: "mouse,in,default";
153 source: "button_bg,2";
154 action: STATE_SET "over,default" 0.0;
155 target: "button_bg,2";
156 }
157
158 program {
159 name: "button,2,over,secondary";
160 signal: "mouse,in,secondary";
161 source: "button_bg,2";
162 action: STATE_SET "over,secondary" 0.0;
163 target: "button_bg,2";
164 }
165
166 program {
167 name: "button,2,out";
168 signal: "mouse,out";
169 source: "button_bg,2";
170 action: STATE_SET "default" 0.0;
171 target: "button_bg,2";
172 }
173 }
174 }
175}