summaryrefslogtreecommitdiff
path: root/src/lib/evas/canvas/evas_device.c
diff options
context:
space:
mode:
authorVincent Torri <vincent.torri@gmail.com>2012-11-04 11:51:42 +0000
committerVincent Torri <vincent.torri@gmail.com>2012-11-04 11:51:42 +0000
commitc15e9c6575c3b5f39ded167dda5259de3de96151 (patch)
tree5115d7ae3620af24c2bc094cd062575af7adeda9 /src/lib/evas/canvas/evas_device.c
parenta5ac6a987caec5a7f7596a25d0a065b9cc94c50c (diff)
merge: and now Evas
I've tested make -j 3 install and it works nicely I've tested expedite with software and opengl xlib, and it works. Not tested other engines, so please report any problems (engines or other) on the ML. TODO: examples and tests, I'll add them later ISSUE: Eina_Unicode size check. It indirectly depends on eina_config.h, which is created at the end of the configure script. So its size is always 0. I don't know how that size is used, so I can't do a lot, for now. SVN revision: 78895
Diffstat (limited to 'src/lib/evas/canvas/evas_device.c')
-rw-r--r--src/lib/evas/canvas/evas_device.c259
1 files changed, 259 insertions, 0 deletions
diff --git a/src/lib/evas/canvas/evas_device.c b/src/lib/evas/canvas/evas_device.c
new file mode 100644
index 0000000..8569bd5
--- /dev/null
+++ b/src/lib/evas/canvas/evas_device.c
@@ -0,0 +1,259 @@
1#include "evas_common.h"
2#include "evas_private.h"
3
4EAPI Evas_Device *
5evas_device_new(Evas *eo_e)
6{
7 Evas_Device *dev;
8
9 MAGIC_CHECK(eo_e, Evas, MAGIC_EVAS);
10 return NULL;
11 MAGIC_CHECK_END();
12 dev = calloc(1, sizeof(Evas_Device));
13 if (!dev) return NULL;
14 dev->magic = MAGIC_DEV;
15 dev->evas = eo_e;
16 dev->ref = 1;
17 Evas_Public_Data *e = eo_data_get(eo_e, EVAS_CLASS);
18 e->devices = eina_list_append(e->devices, dev);
19 evas_event_callback_call(eo_e, EVAS_CALLBACK_DEVICE_CHANGED, dev);
20 return dev;
21}
22
23EAPI void
24evas_device_free(Evas_Device *dev)
25{
26 MAGIC_CHECK(dev, Evas_Device, MAGIC_DEV);
27 return;
28 MAGIC_CHECK_END();
29 if (dev->ref == 1)
30 {
31 Evas_Device *dev2;
32
33 EINA_LIST_FREE(dev->children, dev2)
34 {
35 dev2->parent = NULL;
36 evas_device_free(dev2);
37 }
38 if (dev->src)
39 {
40 _evas_device_unref(dev->src);
41 dev->src = NULL;
42 }
43 dev->parent = NULL;
44 }
45 _evas_device_unref(dev);
46}
47
48EAPI void
49evas_device_push(Evas *eo_e, Evas_Device *dev)
50{
51 MAGIC_CHECK(eo_e, Evas, MAGIC_EVAS);
52 return;
53 MAGIC_CHECK_END();
54 MAGIC_CHECK(dev, Evas_Device, MAGIC_DEV);
55 return;
56 MAGIC_CHECK_END();
57 Evas_Public_Data *e = eo_data_get(eo_e, EVAS_CLASS);
58 if (!e->cur_device)
59 {
60 e->cur_device = eina_array_new(4);
61 if (!e->cur_device) return;
62 }
63 dev->ref++;
64 eina_array_push(e->cur_device, dev);
65}
66
67EAPI void
68evas_device_pop(Evas *eo_e)
69{
70 Evas_Device *dev;
71
72 MAGIC_CHECK(eo_e, Evas, MAGIC_EVAS);
73 return;
74 MAGIC_CHECK_END();
75 Evas_Public_Data *e = eo_data_get(eo_e, EVAS_CLASS);
76 dev = eina_array_pop(e->cur_device);
77 if (dev) _evas_device_unref(dev);
78}
79
80EAPI const Eina_List *
81evas_device_list(Evas *eo_e, const Evas_Device *dev)
82{
83 MAGIC_CHECK(eo_e, Evas, MAGIC_EVAS);
84 return NULL;
85 MAGIC_CHECK_END();
86 if (dev)
87 {
88 MAGIC_CHECK(dev, Evas_Device, MAGIC_DEV);
89 return NULL;
90 MAGIC_CHECK_END();
91 }
92 if (dev) return dev->children;
93 Evas_Public_Data *e = eo_data_get(eo_e, EVAS_CLASS);
94 return e->devices;
95}
96
97EAPI void
98evas_device_name_set(Evas_Device *dev, const char *name)
99{
100 MAGIC_CHECK(dev, Evas_Device, MAGIC_DEV);
101 return;
102 MAGIC_CHECK_END();
103 eina_stringshare_replace(&(dev->name), name);
104 evas_event_callback_call(dev->evas, EVAS_CALLBACK_DEVICE_CHANGED, dev);
105}
106
107EAPI const char *
108evas_device_name_get(const Evas_Device *dev)
109{
110 MAGIC_CHECK(dev, Evas_Device, MAGIC_DEV);
111 return NULL;
112 MAGIC_CHECK_END();
113 return dev->name;
114}
115
116EAPI void
117evas_device_description_set(Evas_Device *dev, const char *desc)
118{
119 MAGIC_CHECK(dev, Evas_Device, MAGIC_DEV);
120 return;
121 MAGIC_CHECK_END();
122 eina_stringshare_replace(&(dev->desc), desc);
123 evas_event_callback_call(dev->evas, EVAS_CALLBACK_DEVICE_CHANGED, dev);
124}
125
126EAPI const char *
127evas_device_description_get(const Evas_Device *dev)
128{
129 MAGIC_CHECK(dev, Evas_Device, MAGIC_DEV);
130 return NULL;
131 MAGIC_CHECK_END();
132 return dev->desc;
133}
134
135EAPI void
136evas_device_parent_set(Evas_Device *dev, Evas_Device *parent)
137{
138 MAGIC_CHECK(dev, Evas_Device, MAGIC_DEV);
139 return;
140 MAGIC_CHECK_END();
141 if (parent)
142 {
143 MAGIC_CHECK(parent, Evas_Device, MAGIC_DEV);
144 return;
145 MAGIC_CHECK_END();
146 }
147 if (dev->parent == parent) return;
148 if (dev->parent)
149 dev->parent->children = eina_list_remove(dev->parent->children, dev);
150 dev->parent = parent;
151 if (parent)
152 parent->children = eina_list_append(parent->children, dev);
153 evas_event_callback_call(dev->evas, EVAS_CALLBACK_DEVICE_CHANGED, dev);
154}
155
156EAPI const Evas_Device *
157evas_device_parent_get(const Evas_Device *dev)
158{
159 MAGIC_CHECK(dev, Evas_Device, MAGIC_DEV);
160 return NULL;
161 MAGIC_CHECK_END();
162 return dev->parent;
163}
164
165EAPI void
166evas_device_class_set(Evas_Device *dev, Evas_Device_Class clas)
167{
168 MAGIC_CHECK(dev, Evas_Device, MAGIC_DEV);
169 return;
170 MAGIC_CHECK_END();
171 dev->clas = clas;
172 evas_event_callback_call(dev->evas, EVAS_CALLBACK_DEVICE_CHANGED, dev);
173}
174
175EAPI Evas_Device_Class
176evas_device_class_get(const Evas_Device *dev)
177{
178 MAGIC_CHECK(dev, Evas_Device, MAGIC_DEV);
179 return EVAS_DEVICE_CLASS_NONE;
180 MAGIC_CHECK_END();
181 return dev->clas;
182}
183
184EAPI void
185evas_device_emulation_source_set(Evas_Device *dev, Evas_Device *src)
186{
187 MAGIC_CHECK(dev, Evas_Device, MAGIC_DEV);
188 return;
189 MAGIC_CHECK_END();
190 if (src)
191 {
192 MAGIC_CHECK(src, Evas_Device, MAGIC_DEV);
193 return;
194 MAGIC_CHECK_END();
195 }
196 if (dev->src == src) return;
197 if (dev->src) _evas_device_unref(dev->src);
198 dev->src = src;
199 if (dev->src) dev->src->ref++;
200 evas_event_callback_call(dev->evas, EVAS_CALLBACK_DEVICE_CHANGED, dev);
201}
202
203EAPI const Evas_Device *
204evas_device_emulation_source_get(const Evas_Device *dev)
205{
206 MAGIC_CHECK(dev, Evas_Device, MAGIC_DEV);
207 return NULL;
208 MAGIC_CHECK_END();
209 return dev->src;
210}
211
212void
213_evas_device_cleanup(Evas *eo_e)
214{
215 Evas_Device *dev;
216
217 Evas_Public_Data *e = eo_data_get(eo_e, EVAS_CLASS);
218 if (e->cur_device)
219 {
220 while ((dev = eina_array_pop(e->cur_device)))
221 _evas_device_unref(dev);
222 eina_array_free(e->cur_device);
223 e->cur_device = NULL;
224 }
225 EINA_LIST_FREE(e->devices, dev)
226 {
227 evas_device_free(dev);
228 }
229}
230
231Evas_Device *
232_evas_device_top_get(const Evas *eo_e)
233{
234 int num;
235
236 Evas_Public_Data *e = eo_data_get(eo_e, EVAS_CLASS);
237 if (!e->cur_device) return NULL;
238 num = eina_array_count(e->cur_device);
239 if (num < 1) return NULL;
240 return eina_array_data_get(e->cur_device, num - 1);
241}
242
243void
244_evas_device_ref(Evas_Device *dev)
245{
246 dev->ref++;
247}
248
249void
250_evas_device_unref(Evas_Device *dev)
251{
252 dev->ref--;
253 if (dev->ref > 0) return;
254 if (dev->name) eina_stringshare_del(dev->name);
255 if (dev->desc) eina_stringshare_del(dev->desc);
256 dev->magic = 0;
257 free(dev);
258}
259