diff options
author | David Walter Seikel | 2012-01-23 23:30:42 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-01-23 23:30:42 +1000 |
commit | 825a3d837a33f226c879cd02ad15c3fba57e8b2c (patch) | |
tree | 75f57bd9c4253508d338dc79ba8e57a7abc42255 /libraries/ecore/src/lib/ecore_evas/ecore_evas_extn.c | |
parent | Add ability to disable the test harness, or the Lua compile test. (diff) | |
download | SledjHamr-825a3d837a33f226c879cd02ad15c3fba57e8b2c.zip SledjHamr-825a3d837a33f226c879cd02ad15c3fba57e8b2c.tar.gz SledjHamr-825a3d837a33f226c879cd02ad15c3fba57e8b2c.tar.bz2 SledjHamr-825a3d837a33f226c879cd02ad15c3fba57e8b2c.tar.xz |
Update the EFL to what I'm actually using, coz I'm using some stuff not yet released.
Diffstat (limited to 'libraries/ecore/src/lib/ecore_evas/ecore_evas_extn.c')
-rw-r--r-- | libraries/ecore/src/lib/ecore_evas/ecore_evas_extn.c | 2152 |
1 files changed, 2152 insertions, 0 deletions
diff --git a/libraries/ecore/src/lib/ecore_evas/ecore_evas_extn.c b/libraries/ecore/src/lib/ecore_evas/ecore_evas_extn.c new file mode 100644 index 0000000..e46ab4a --- /dev/null +++ b/libraries/ecore/src/lib/ecore_evas/ecore_evas_extn.c | |||
@@ -0,0 +1,2152 @@ | |||
1 | #ifdef HAVE_CONFIG_H | ||
2 | # include <config.h> | ||
3 | #endif | ||
4 | |||
5 | #include <stdlib.h> | ||
6 | #include <unistd.h> | ||
7 | |||
8 | #include <Ecore.h> | ||
9 | #include "ecore_private.h" | ||
10 | #include <Ecore_Input.h> | ||
11 | |||
12 | #ifdef BUILD_ECORE_IPC | ||
13 | # ifdef BUILD_ECORE_EVAS_SOFTWARE_BUFFER | ||
14 | # define EXTN_ENABLED 1 | ||
15 | # endif | ||
16 | #endif | ||
17 | |||
18 | #include "ecore_evas_private.h" | ||
19 | #include "Ecore_Evas.h" | ||
20 | #ifdef EXTN_ENABLED | ||
21 | #include "Ecore_Ipc.h" | ||
22 | |||
23 | #include <stdio.h> | ||
24 | #include <stdlib.h> | ||
25 | #include <sys/types.h> | ||
26 | #include <unistd.h> | ||
27 | #include <math.h> | ||
28 | #include <time.h> | ||
29 | #include <sys/mman.h> | ||
30 | #include <sys/stat.h> | ||
31 | #include <fcntl.h> | ||
32 | #include <string.h> | ||
33 | #include <sys/file.h> | ||
34 | |||
35 | typedef struct _Shmfile Shmfile; | ||
36 | |||
37 | struct _Shmfile | ||
38 | { | ||
39 | int fd; | ||
40 | int size; | ||
41 | void *addr; | ||
42 | const char *file; | ||
43 | }; | ||
44 | |||
45 | static int blank = 0x00000000; | ||
46 | |||
47 | static Shmfile * | ||
48 | shmfile_new(const char *base, int id, int size, Eina_Bool sys) | ||
49 | { | ||
50 | Shmfile *sf; | ||
51 | char file[PATH_MAX]; | ||
52 | |||
53 | sf = calloc(1, sizeof(Shmfile)); | ||
54 | do | ||
55 | { | ||
56 | mode_t mode; | ||
57 | |||
58 | snprintf(file, sizeof(file), "/%s-%i-%i.%i.%i", | ||
59 | base, id, (int)time(NULL), (int)getpid(), (int)rand()); | ||
60 | mode = S_IRUSR | S_IWUSR; | ||
61 | if (sys) mode |= S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; | ||
62 | sf->fd = shm_open(file, O_RDWR | O_CREAT | O_EXCL, mode); | ||
63 | } | ||
64 | while (sf->fd < 0); | ||
65 | |||
66 | sf->file = eina_stringshare_add(file); | ||
67 | if (!sf->file) | ||
68 | { | ||
69 | close(sf->fd); | ||
70 | shm_unlink(sf->file); | ||
71 | eina_stringshare_del(sf->file); | ||
72 | free(sf); | ||
73 | return NULL; | ||
74 | } | ||
75 | sf->size = size; | ||
76 | if (ftruncate(sf->fd, size) < 0) | ||
77 | { | ||
78 | close(sf->fd); | ||
79 | shm_unlink(sf->file); | ||
80 | eina_stringshare_del(sf->file); | ||
81 | free(sf); | ||
82 | return NULL; | ||
83 | } | ||
84 | sf->addr = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, sf->fd, 0); | ||
85 | if (sf->addr == MAP_FAILED) | ||
86 | { | ||
87 | close(sf->fd); | ||
88 | shm_unlink(sf->file); | ||
89 | eina_stringshare_del(sf->file); | ||
90 | free(sf); | ||
91 | return NULL; | ||
92 | } | ||
93 | return sf; | ||
94 | } | ||
95 | |||
96 | void | ||
97 | shmfile_free(Shmfile *sf) | ||
98 | { | ||
99 | munmap(sf->addr, sf->size); | ||
100 | close(sf->fd); | ||
101 | shm_unlink(sf->file); | ||
102 | eina_stringshare_del(sf->file); | ||
103 | free(sf); | ||
104 | } | ||
105 | |||
106 | static Shmfile * | ||
107 | shmfile_open(const char *ref, int size, Eina_Bool sys) | ||
108 | { | ||
109 | Shmfile *sf; | ||
110 | mode_t mode; | ||
111 | |||
112 | sf = calloc(1, sizeof(Shmfile)); | ||
113 | mode = S_IRUSR | S_IWUSR; | ||
114 | if (sys) mode |= S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; | ||
115 | sf->fd = shm_open(ref, O_RDWR, mode); | ||
116 | if (sf->fd < 0) | ||
117 | { | ||
118 | free(sf); | ||
119 | return NULL; | ||
120 | } | ||
121 | sf->file = eina_stringshare_add(ref); | ||
122 | if (!sf->file) | ||
123 | { | ||
124 | close(sf->fd); | ||
125 | eina_stringshare_del(sf->file); | ||
126 | free(sf); | ||
127 | return NULL; | ||
128 | } | ||
129 | sf->size = size; | ||
130 | sf->addr = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, sf->fd, 0); | ||
131 | if (sf->addr == MAP_FAILED) | ||
132 | { | ||
133 | close(sf->fd); | ||
134 | eina_stringshare_del(sf->file); | ||
135 | free(sf); | ||
136 | return NULL; | ||
137 | } | ||
138 | return sf; | ||
139 | } | ||
140 | |||
141 | void | ||
142 | shmfile_close(Shmfile *sf) | ||
143 | { | ||
144 | munmap(sf->addr, sf->size); | ||
145 | close(sf->fd); | ||
146 | eina_stringshare_del(sf->file); | ||
147 | free(sf); | ||
148 | } | ||
149 | |||
150 | // procotol version - change this as needed | ||
151 | #define MAJOR 0x1011 | ||
152 | |||
153 | enum // opcodes | ||
154 | { | ||
155 | OP_RESIZE, | ||
156 | OP_SHOW, | ||
157 | OP_HIDE, | ||
158 | OP_FOCUS, | ||
159 | OP_UNFOCUS, | ||
160 | OP_UPDATE, | ||
161 | OP_UPDATE_DONE, | ||
162 | OP_LOCK_FILE, | ||
163 | OP_SHM_REF, | ||
164 | OP_EV_MOUSE_IN, | ||
165 | OP_EV_MOUSE_OUT, | ||
166 | OP_EV_MOUSE_UP, | ||
167 | OP_EV_MOUSE_DOWN, | ||
168 | OP_EV_MOUSE_MOVE, | ||
169 | OP_EV_MOUSE_WHEEL, | ||
170 | OP_EV_MULTI_UP, | ||
171 | OP_EV_MULTI_DOWN, | ||
172 | OP_EV_MULTI_MOVE, | ||
173 | OP_EV_KEY_UP, | ||
174 | OP_EV_KEY_DOWN, | ||
175 | OP_EV_HOLD | ||
176 | }; | ||
177 | |||
178 | enum | ||
179 | { | ||
180 | MOD_SHIFT = (1 << 0), | ||
181 | MOD_CTRL = (1 << 1), | ||
182 | MOD_ALT = (1 << 2), | ||
183 | MOD_META = (1 << 3), | ||
184 | MOD_HYPER = (1 << 4), | ||
185 | MOD_SUPER = (1 << 5), | ||
186 | MOD_CAPS = (1 << 6), | ||
187 | MOD_NUM = (1 << 7), | ||
188 | MOD_SCROLL = (1 << 8), | ||
189 | }; | ||
190 | |||
191 | typedef struct _Ipc_Data_Resize Ipc_Data_Resize; | ||
192 | typedef struct _Ipc_Data_Update Ipc_Data_Update; | ||
193 | typedef struct _Ipc_Data_Ev_Mouse_In Ipc_Data_Ev_Mouse_In; | ||
194 | typedef struct _Ipc_Data_Ev_Mouse_Out Ipc_Data_Ev_Mouse_Out; | ||
195 | typedef struct _Ipc_Data_Ev_Mouse_Up Ipc_Data_Ev_Mouse_Up; | ||
196 | typedef struct _Ipc_Data_Ev_Mouse_Down Ipc_Data_Ev_Mouse_Down; | ||
197 | typedef struct _Ipc_Data_Ev_Mouse_Move Ipc_Data_Ev_Mouse_Move; | ||
198 | typedef struct _Ipc_Data_Ev_Mouse_Wheel Ipc_Data_Ev_Mouse_Wheel; | ||
199 | typedef struct _Ipc_Data_Ev_Hold Ipc_Data_Ev_Hold; | ||
200 | typedef struct _Ipc_Data_Ev_Multi_Up Ipc_Data_Ev_Multi_Up; | ||
201 | typedef struct _Ipc_Data_Ev_Multi_Down Ipc_Data_Ev_Multi_Down; | ||
202 | typedef struct _Ipc_Data_Ev_Multi_Move Ipc_Data_Ev_Multi_Move; | ||
203 | typedef struct _Ipc_Data_Ev_Key_Up Ipc_Data_Ev_Key_Up; | ||
204 | typedef struct _Ipc_Data_Ev_Key_Down Ipc_Data_Ev_Key_Down; | ||
205 | |||
206 | struct _Ipc_Data_Resize | ||
207 | { | ||
208 | int w, h; | ||
209 | }; | ||
210 | |||
211 | struct _Ipc_Data_Update | ||
212 | { | ||
213 | int x, w, y, h; | ||
214 | }; | ||
215 | |||
216 | struct _Ipc_Data_Ev_Mouse_In | ||
217 | { | ||
218 | unsigned int timestamp; | ||
219 | int mask; | ||
220 | Evas_Event_Flags event_flags; | ||
221 | }; | ||
222 | |||
223 | struct _Ipc_Data_Ev_Mouse_Out | ||
224 | { | ||
225 | unsigned int timestamp; | ||
226 | int mask; | ||
227 | Evas_Event_Flags event_flags; | ||
228 | }; | ||
229 | |||
230 | struct _Ipc_Data_Ev_Mouse_Up | ||
231 | { | ||
232 | int b; | ||
233 | Evas_Button_Flags flags; | ||
234 | int mask; | ||
235 | unsigned int timestamp; | ||
236 | Evas_Event_Flags event_flags; | ||
237 | }; | ||
238 | |||
239 | struct _Ipc_Data_Ev_Mouse_Down | ||
240 | { | ||
241 | int b; | ||
242 | Evas_Button_Flags flags; | ||
243 | int mask; | ||
244 | unsigned int timestamp; | ||
245 | Evas_Event_Flags event_flags; | ||
246 | }; | ||
247 | |||
248 | struct _Ipc_Data_Ev_Mouse_Move | ||
249 | { | ||
250 | int x, y; | ||
251 | Evas_Button_Flags flags; | ||
252 | int mask; | ||
253 | unsigned int timestamp; | ||
254 | Evas_Event_Flags event_flags; | ||
255 | }; | ||
256 | |||
257 | struct _Ipc_Data_Ev_Mouse_Wheel | ||
258 | { | ||
259 | int direction, z; | ||
260 | Evas_Button_Flags flags; | ||
261 | int mask; | ||
262 | unsigned int timestamp; | ||
263 | Evas_Event_Flags event_flags; | ||
264 | }; | ||
265 | |||
266 | struct _Ipc_Data_Ev_Hold | ||
267 | { | ||
268 | int hold; | ||
269 | unsigned int timestamp; | ||
270 | Evas_Event_Flags event_flags; | ||
271 | }; | ||
272 | |||
273 | struct _Ipc_Data_Ev_Multi_Up | ||
274 | { | ||
275 | Evas_Button_Flags flags; | ||
276 | int d, x, y; | ||
277 | double rad, radx, rady, pres, ang, fx, fy; | ||
278 | int mask; | ||
279 | unsigned int timestamp; | ||
280 | Evas_Event_Flags event_flags; | ||
281 | }; | ||
282 | |||
283 | struct _Ipc_Data_Ev_Multi_Down | ||
284 | { | ||
285 | Evas_Button_Flags flags; | ||
286 | int d, x, y; | ||
287 | double rad, radx, rady, pres, ang, fx, fy; | ||
288 | int mask; | ||
289 | unsigned int timestamp; | ||
290 | Evas_Event_Flags event_flags; | ||
291 | }; | ||
292 | |||
293 | struct _Ipc_Data_Ev_Multi_Move | ||
294 | { | ||
295 | int d, x, y; | ||
296 | double rad, radx, rady, pres, ang, fx, fy; | ||
297 | int mask; | ||
298 | unsigned int timestamp; | ||
299 | Evas_Event_Flags event_flags; | ||
300 | }; | ||
301 | |||
302 | struct _Ipc_Data_Ev_Key_Up | ||
303 | { | ||
304 | const char *keyname, *key, *string, *compose; | ||
305 | int mask; | ||
306 | unsigned int timestamp; | ||
307 | Evas_Event_Flags event_flags; | ||
308 | }; | ||
309 | |||
310 | struct _Ipc_Data_Ev_Key_Down | ||
311 | { | ||
312 | const char *keyname, *key, *string, *compose; | ||
313 | int mask; | ||
314 | unsigned int timestamp; | ||
315 | Evas_Event_Flags event_flags; | ||
316 | }; | ||
317 | |||
318 | typedef struct _Extn Extn; | ||
319 | |||
320 | struct _Extn | ||
321 | { | ||
322 | struct { | ||
323 | Ecore_Ipc_Server *server; | ||
324 | Eina_List *clients; | ||
325 | Eina_List *handlers; | ||
326 | Eina_Bool am_server : 1; | ||
327 | } ipc; | ||
328 | struct { | ||
329 | const char *name; | ||
330 | int num; | ||
331 | Eina_Bool sys : 1; | ||
332 | } svc; | ||
333 | struct { | ||
334 | const char *lock; | ||
335 | int lockfd; | ||
336 | const char *shm; | ||
337 | int w, h; | ||
338 | Shmfile *shmfile; | ||
339 | Eina_List *updates; | ||
340 | Eina_Bool have_lock : 1; | ||
341 | } file; | ||
342 | }; | ||
343 | |||
344 | static Eina_List *extn_ee_list = NULL; | ||
345 | |||
346 | EAPI int ECORE_EVAS_EXTN_CLIENT_ADD = 0; | ||
347 | EAPI int ECORE_EVAS_EXTN_CLIENT_DEL = 0; | ||
348 | |||
349 | void | ||
350 | _ecore_evas_extn_init(void) | ||
351 | { | ||
352 | if (ECORE_EVAS_EXTN_CLIENT_ADD) return; | ||
353 | ECORE_EVAS_EXTN_CLIENT_ADD = ecore_event_type_new(); | ||
354 | ECORE_EVAS_EXTN_CLIENT_DEL = ecore_event_type_new(); | ||
355 | } | ||
356 | |||
357 | void | ||
358 | _ecore_evas_extn_shutdown(void) | ||
359 | { | ||
360 | } | ||
361 | |||
362 | static void | ||
363 | _ecore_evas_extn_event_free(void *data, void *ev __UNUSED__) | ||
364 | { | ||
365 | Ecore_Evas *ee = data; | ||
366 | if (ee->engine.buffer.image) | ||
367 | evas_object_unref(ee->engine.buffer.image); | ||
368 | _ecore_evas_unref(ee); | ||
369 | } | ||
370 | |||
371 | static void | ||
372 | _ecore_evas_extn_event(Ecore_Evas *ee, int event) | ||
373 | { | ||
374 | _ecore_evas_ref(ee); | ||
375 | if (ee->engine.buffer.image) | ||
376 | evas_object_ref(ee->engine.buffer.image); | ||
377 | ecore_event_add(event, ee->engine.buffer.image, | ||
378 | _ecore_evas_extn_event_free, ee); | ||
379 | } | ||
380 | |||
381 | static void | ||
382 | _ecore_evas_socket_lock(Ecore_Evas *ee) | ||
383 | { | ||
384 | Extn *extn; | ||
385 | |||
386 | extn = ee->engine.buffer.data; | ||
387 | if (!extn) return; | ||
388 | if (extn->file.lockfd < 0) return; | ||
389 | if (extn->file.have_lock) return; | ||
390 | flock(extn->file.lockfd, LOCK_EX); | ||
391 | extn->file.have_lock = EINA_TRUE; | ||
392 | } | ||
393 | |||
394 | static void | ||
395 | _ecore_evas_socket_unlock(Ecore_Evas *ee) | ||
396 | { | ||
397 | Extn *extn; | ||
398 | |||
399 | extn = ee->engine.buffer.data; | ||
400 | if (!extn) return; | ||
401 | if (extn->file.lockfd < 0) return; | ||
402 | if (!extn->file.have_lock) return; | ||
403 | flock(extn->file.lockfd, LOCK_UN); | ||
404 | extn->file.have_lock = EINA_FALSE; | ||
405 | } | ||
406 | |||
407 | static void | ||
408 | _ecore_evas_extn_plug_targer_render_pre(void *data, Evas *e __UNUSED__, void *event_info __UNUSED__) | ||
409 | { | ||
410 | Ecore_Evas *ee = data; | ||
411 | if (ee) _ecore_evas_socket_lock(ee); | ||
412 | } | ||
413 | |||
414 | static void | ||
415 | _ecore_evas_extn_plug_targer_render_post(void *data, Evas *e __UNUSED__, void *event_info __UNUSED__) | ||
416 | { | ||
417 | Ecore_Evas *ee = data; | ||
418 | if (ee) _ecore_evas_socket_unlock(ee); | ||
419 | } | ||
420 | |||
421 | static void | ||
422 | _ecore_evas_extn_plug_image_obj_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) | ||
423 | { | ||
424 | Ecore_Evas *ee = data; | ||
425 | if (ee) ecore_evas_free(ee); | ||
426 | } | ||
427 | |||
428 | static void | ||
429 | _ecore_evas_extn_coord_translate(Ecore_Evas *ee, Evas_Coord *x, Evas_Coord *y) | ||
430 | { | ||
431 | Evas_Coord xx, yy, ww, hh, fx, fy, fw, fh; | ||
432 | |||
433 | evas_object_geometry_get(ee->engine.buffer.image, &xx, &yy, &ww, &hh); | ||
434 | evas_object_image_fill_get(ee->engine.buffer.image, &fx, &fy, &fw, &fh); | ||
435 | |||
436 | if (fw < 1) fw = 1; | ||
437 | if (fh < 1) fh = 1; | ||
438 | |||
439 | if (evas_object_map_get(ee->engine.buffer.image) && | ||
440 | evas_object_map_enable_get(ee->engine.buffer.image)) | ||
441 | { | ||
442 | fx = 0; fy = 0; | ||
443 | fw = ee->w; fh = ee->h; | ||
444 | ww = ee->w; hh = ee->h; | ||
445 | } | ||
446 | |||
447 | if ((fx == 0) && (fy == 0) && (fw == ww) && (fh == hh)) | ||
448 | { | ||
449 | *x = (ee->w * (*x - xx)) / fw; | ||
450 | *y = (ee->h * (*y - yy)) / fh; | ||
451 | } | ||
452 | else | ||
453 | { | ||
454 | xx = (*x - xx) - fx; | ||
455 | while (xx < 0) xx += fw; | ||
456 | while (xx > fw) xx -= fw; | ||
457 | *x = (ee->w * xx) / fw; | ||
458 | |||
459 | yy = (*y - yy) - fy; | ||
460 | while (yy < 0) yy += fh; | ||
461 | while (yy > fh) yy -= fh; | ||
462 | *y = (ee->h * yy) / fh; | ||
463 | } | ||
464 | } | ||
465 | |||
466 | static void | ||
467 | _ecore_evas_extn_free(Ecore_Evas *ee) | ||
468 | { | ||
469 | Extn *extn; | ||
470 | Ecore_Ipc_Client *client; | ||
471 | |||
472 | extn = ee->engine.buffer.data; | ||
473 | if (extn) | ||
474 | { | ||
475 | Ecore_Event_Handler *hdl; | ||
476 | |||
477 | if (extn->file.have_lock) | ||
478 | _ecore_evas_socket_unlock(ee); | ||
479 | if (extn->file.lockfd) | ||
480 | { | ||
481 | close(extn->file.lockfd); | ||
482 | if (extn->ipc.am_server) | ||
483 | { | ||
484 | if (extn->file.lock) unlink(extn->file.lock); | ||
485 | } | ||
486 | } | ||
487 | if (extn->svc.name) eina_stringshare_del(extn->svc.name); | ||
488 | if (extn->ipc.clients) | ||
489 | { | ||
490 | EINA_LIST_FREE(extn->ipc.clients, client) | ||
491 | ecore_ipc_client_del(client); | ||
492 | } | ||
493 | if (extn->ipc.server) ecore_ipc_server_del(extn->ipc.server); | ||
494 | if (extn->file.lock) eina_stringshare_del(extn->file.lock); | ||
495 | if (extn->file.shm) eina_stringshare_del(extn->file.shm); | ||
496 | if (extn->file.shmfile) | ||
497 | { | ||
498 | if (extn->ipc.am_server) | ||
499 | shmfile_free(extn->file.shmfile); | ||
500 | else | ||
501 | shmfile_close(extn->file.shmfile); | ||
502 | } | ||
503 | |||
504 | EINA_LIST_FREE(extn->ipc.handlers, hdl) | ||
505 | ecore_event_handler_del(hdl); | ||
506 | free(extn); | ||
507 | ecore_ipc_shutdown(); | ||
508 | ee->engine.buffer.data = NULL; | ||
509 | } | ||
510 | if (ee->engine.buffer.image) | ||
511 | { | ||
512 | Ecore_Evas *ee2; | ||
513 | |||
514 | evas_object_event_callback_del_full(ee->engine.buffer.image, | ||
515 | EVAS_CALLBACK_DEL, | ||
516 | _ecore_evas_extn_plug_image_obj_del, | ||
517 | ee); | ||
518 | evas_event_callback_del_full(evas_object_evas_get(ee->engine.buffer.image), | ||
519 | EVAS_CALLBACK_RENDER_PRE, | ||
520 | _ecore_evas_extn_plug_targer_render_pre, | ||
521 | ee); | ||
522 | evas_event_callback_del_full(evas_object_evas_get(ee->engine.buffer.image), | ||
523 | EVAS_CALLBACK_RENDER_POST, | ||
524 | _ecore_evas_extn_plug_targer_render_post, | ||
525 | ee); | ||
526 | evas_object_del(ee->engine.buffer.image); | ||
527 | ee2 = evas_object_data_get(ee->engine.buffer.image, "Ecore_Evas_Parent"); | ||
528 | if (ee2) | ||
529 | { | ||
530 | ee2->sub_ecore_evas = eina_list_remove(ee2->sub_ecore_evas, ee); | ||
531 | } | ||
532 | } | ||
533 | extn_ee_list = eina_list_remove(extn_ee_list, ee); | ||
534 | } | ||
535 | |||
536 | static void | ||
537 | _ecore_evas_resize(Ecore_Evas *ee, int w, int h) | ||
538 | { | ||
539 | if (w < 1) w = 1; | ||
540 | if (h < 1) h = 1; | ||
541 | ee->req.w = w; | ||
542 | ee->req.h = h; | ||
543 | if ((w == ee->w) && (h == ee->h)) return; | ||
544 | ee->w = w; | ||
545 | ee->h = h; | ||
546 | |||
547 | /* | ||
548 | * No need for it if not used later. | ||
549 | Extn *extn; | ||
550 | |||
551 | extn = ee->engine.buffer.data; | ||
552 | */ | ||
553 | if (ee->engine.buffer.image) | ||
554 | evas_object_image_size_set(ee->engine.buffer.image, ee->w, ee->h); | ||
555 | /* Server can have many plugs, so I block resize comand from client to server * | ||
556 | if ((extn) && (extn->ipc.server)) | ||
557 | { | ||
558 | Ipc_Data_Resize ipc; | ||
559 | |||
560 | ipc.w = ee->w; | ||
561 | ipc.h = ee->h; | ||
562 | ecore_ipc_server_send(extn->ipc.server, MAJOR, OP_RESIZE, 0, 0, 0, &ipc, sizeof(ipc)); | ||
563 | }*/ | ||
564 | if (ee->func.fn_resize) ee->func.fn_resize(ee); | ||
565 | } | ||
566 | |||
567 | static void | ||
568 | _ecore_evas_move_resize(Ecore_Evas *ee, int x __UNUSED__, int y __UNUSED__, int w, int h) | ||
569 | { | ||
570 | _ecore_evas_resize(ee, w, h); | ||
571 | } | ||
572 | |||
573 | static int | ||
574 | _ecore_evas_modifiers_locks_mask_get(Evas *e) | ||
575 | { | ||
576 | int mask = 0; | ||
577 | |||
578 | if (evas_key_modifier_is_set(evas_key_modifier_get(e), "Shift")) | ||
579 | mask |= MOD_SHIFT; | ||
580 | if (evas_key_modifier_is_set(evas_key_modifier_get(e), "Control")) | ||
581 | mask |= MOD_CTRL; | ||
582 | if (evas_key_modifier_is_set(evas_key_modifier_get(e), "Alt")) | ||
583 | mask |= MOD_ALT; | ||
584 | if (evas_key_modifier_is_set(evas_key_modifier_get(e), "Meta")) | ||
585 | mask |= MOD_META; | ||
586 | if (evas_key_modifier_is_set(evas_key_modifier_get(e), "Hyper")) | ||
587 | mask |= MOD_HYPER; | ||
588 | if (evas_key_modifier_is_set(evas_key_modifier_get(e), "Super")) | ||
589 | mask |= MOD_SUPER; | ||
590 | if (evas_key_lock_is_set(evas_key_lock_get(e), "Scroll_Lock")) | ||
591 | mask |= MOD_SCROLL; | ||
592 | if (evas_key_lock_is_set(evas_key_lock_get(e), "Num_Lock")) | ||
593 | mask |= MOD_NUM; | ||
594 | if (evas_key_lock_is_set(evas_key_lock_get(e), "Caps_Lock")) | ||
595 | mask |= MOD_CAPS; | ||
596 | return mask; | ||
597 | } | ||
598 | |||
599 | static void | ||
600 | _ecore_evas_modifiers_locks_mask_set(Evas *e, int mask) | ||
601 | { | ||
602 | if (mask & MOD_SHIFT) evas_key_modifier_on (e, "Shift"); | ||
603 | else evas_key_modifier_off(e, "Shift"); | ||
604 | if (mask & MOD_CTRL) evas_key_modifier_on (e, "Control"); | ||
605 | else evas_key_modifier_off(e, "Control"); | ||
606 | if (mask & MOD_ALT) evas_key_modifier_on (e, "Alt"); | ||
607 | else evas_key_modifier_off(e, "Alt"); | ||
608 | if (mask & MOD_META) evas_key_modifier_on (e, "Meta"); | ||
609 | else evas_key_modifier_off(e, "Meta"); | ||
610 | if (mask & MOD_HYPER) evas_key_modifier_on (e, "Hyper"); | ||
611 | else evas_key_modifier_off(e, "Hyper"); | ||
612 | if (mask & MOD_SUPER) evas_key_modifier_on (e, "Super"); | ||
613 | else evas_key_modifier_off(e, "Super"); | ||
614 | if (mask & MOD_SCROLL) evas_key_lock_on (e, "Scroll_Lock"); | ||
615 | else evas_key_lock_off(e, "Scroll_Lock"); | ||
616 | if (mask & MOD_NUM) evas_key_lock_on (e, "Num_Lock"); | ||
617 | else evas_key_lock_off(e, "Num_Lock"); | ||
618 | if (mask & MOD_CAPS) evas_key_lock_on (e, "Caps_Lock"); | ||
619 | else evas_key_lock_off(e, "Caps_Lock"); | ||
620 | } | ||
621 | |||
622 | static void | ||
623 | _ecore_evas_extn_cb_mouse_in(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) | ||
624 | { | ||
625 | Ecore_Evas *ee = data; | ||
626 | Evas_Event_Mouse_In *ev = event_info; | ||
627 | Extn *extn; | ||
628 | |||
629 | extn = ee->engine.buffer.data; | ||
630 | if (!extn) return; | ||
631 | if (extn->ipc.server) | ||
632 | { | ||
633 | Ipc_Data_Ev_Mouse_In ipc; | ||
634 | |||
635 | ipc.timestamp = ev->timestamp; | ||
636 | ipc.mask = _ecore_evas_modifiers_locks_mask_get(ee->evas); | ||
637 | ipc.event_flags = ev->event_flags; | ||
638 | ecore_ipc_server_send(extn->ipc.server, MAJOR, OP_EV_MOUSE_IN, 0, 0, 0, &ipc, sizeof(ipc)); | ||
639 | } | ||
640 | } | ||
641 | |||
642 | static void | ||
643 | _ecore_evas_extn_cb_mouse_out(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) | ||
644 | { | ||
645 | Ecore_Evas *ee = data; | ||
646 | Evas_Event_Mouse_Out *ev = event_info; | ||
647 | Extn *extn; | ||
648 | |||
649 | extn = ee->engine.buffer.data; | ||
650 | if (!extn) return; | ||
651 | if (extn->ipc.server) | ||
652 | { | ||
653 | Ipc_Data_Ev_Mouse_Out ipc; | ||
654 | |||
655 | ipc.timestamp = ev->timestamp; | ||
656 | ipc.mask = _ecore_evas_modifiers_locks_mask_get(ee->evas); | ||
657 | ipc.event_flags = ev->event_flags; | ||
658 | ecore_ipc_server_send(extn->ipc.server, MAJOR, OP_EV_MOUSE_OUT, 0, 0, 0, &ipc, sizeof(ipc)); | ||
659 | } | ||
660 | } | ||
661 | |||
662 | static void | ||
663 | _ecore_evas_extn_cb_mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) | ||
664 | { | ||
665 | Ecore_Evas *ee = data; | ||
666 | Evas_Event_Mouse_Down *ev = event_info; | ||
667 | Extn *extn; | ||
668 | |||
669 | extn = ee->engine.buffer.data; | ||
670 | if (!extn) return; | ||
671 | if (extn->ipc.server) | ||
672 | { | ||
673 | Ipc_Data_Ev_Mouse_Down ipc; | ||
674 | |||
675 | ipc.b = ev->button; | ||
676 | ipc.flags = ev->flags; | ||
677 | ipc.timestamp = ev->timestamp; | ||
678 | ipc.mask = _ecore_evas_modifiers_locks_mask_get(ee->evas); | ||
679 | ipc.event_flags = ev->event_flags; | ||
680 | ecore_ipc_server_send(extn->ipc.server, MAJOR, OP_EV_MOUSE_DOWN, 0, 0, 0, &ipc, sizeof(ipc)); | ||
681 | } | ||
682 | } | ||
683 | |||
684 | static void | ||
685 | _ecore_evas_extn_cb_mouse_up(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) | ||
686 | { | ||
687 | Ecore_Evas *ee = data; | ||
688 | Evas_Event_Mouse_Up *ev = event_info; | ||
689 | Extn *extn; | ||
690 | |||
691 | extn = ee->engine.buffer.data; | ||
692 | if (!extn) return; | ||
693 | if (extn->ipc.server) | ||
694 | { | ||
695 | Ipc_Data_Ev_Mouse_Up ipc; | ||
696 | |||
697 | ipc.b = ev->button; | ||
698 | ipc.flags = ev->flags; | ||
699 | ipc.timestamp = ev->timestamp; | ||
700 | ipc.mask = _ecore_evas_modifiers_locks_mask_get(ee->evas); | ||
701 | ipc.event_flags = ev->event_flags; | ||
702 | ecore_ipc_server_send(extn->ipc.server, MAJOR, OP_EV_MOUSE_UP, 0, 0, 0, &ipc, sizeof(ipc)); | ||
703 | } | ||
704 | } | ||
705 | |||
706 | static void | ||
707 | _ecore_evas_extn_cb_mouse_move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) | ||
708 | { | ||
709 | Ecore_Evas *ee = data; | ||
710 | Evas_Event_Mouse_Move *ev = event_info; | ||
711 | Extn *extn; | ||
712 | |||
713 | extn = ee->engine.buffer.data; | ||
714 | if (!extn) return; | ||
715 | if (extn->ipc.server) | ||
716 | { | ||
717 | Ipc_Data_Ev_Mouse_Move ipc; | ||
718 | Evas_Coord x, y; | ||
719 | |||
720 | x = ev->cur.canvas.x; | ||
721 | y = ev->cur.canvas.y; | ||
722 | _ecore_evas_extn_coord_translate(ee, &x, &y); | ||
723 | ipc.x = x; | ||
724 | ipc.y = y; | ||
725 | ipc.timestamp = ev->timestamp; | ||
726 | ipc.mask = _ecore_evas_modifiers_locks_mask_get(ee->evas); | ||
727 | ipc.event_flags = ev->event_flags; | ||
728 | ecore_ipc_server_send(extn->ipc.server, MAJOR, OP_EV_MOUSE_MOVE, 0, 0, 0, &ipc, sizeof(ipc)); | ||
729 | } | ||
730 | } | ||
731 | |||
732 | static void | ||
733 | _ecore_evas_extn_cb_mouse_wheel(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) | ||
734 | { | ||
735 | Ecore_Evas *ee = data; | ||
736 | Evas_Event_Mouse_Wheel *ev = event_info; | ||
737 | Extn *extn; | ||
738 | |||
739 | extn = ee->engine.buffer.data; | ||
740 | if (!extn) return; | ||
741 | if (extn->ipc.server) | ||
742 | { | ||
743 | Ipc_Data_Ev_Mouse_Wheel ipc; | ||
744 | |||
745 | ipc.direction = ev->direction; | ||
746 | ipc.z = ev->z; | ||
747 | ipc.timestamp = ev->timestamp; | ||
748 | ipc.mask = _ecore_evas_modifiers_locks_mask_get(ee->evas); | ||
749 | ipc.event_flags = ev->event_flags; | ||
750 | ecore_ipc_server_send(extn->ipc.server, MAJOR, OP_EV_MOUSE_WHEEL, 0, 0, 0, &ipc, sizeof(ipc)); | ||
751 | } | ||
752 | } | ||
753 | |||
754 | static void | ||
755 | _ecore_evas_extn_cb_multi_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) | ||
756 | { | ||
757 | Ecore_Evas *ee = data; | ||
758 | Evas_Event_Multi_Down *ev = event_info; | ||
759 | Extn *extn; | ||
760 | |||
761 | extn = ee->engine.buffer.data; | ||
762 | if (!extn) return; | ||
763 | if (extn->ipc.server) | ||
764 | { | ||
765 | Ipc_Data_Ev_Multi_Down ipc; | ||
766 | Evas_Coord x, y; | ||
767 | |||
768 | ipc.d = ev->device; | ||
769 | x = ev->canvas.x; | ||
770 | y = ev->canvas.y; | ||
771 | _ecore_evas_extn_coord_translate(ee, &x, &y); | ||
772 | ipc.x = x; | ||
773 | ipc.y = y; | ||
774 | ipc.rad = ev->radius; | ||
775 | ipc.radx = ev->radius_x; | ||
776 | ipc.rady = ev->radius_y; | ||
777 | ipc.pres = ev->pressure; | ||
778 | ipc.ang = ev->angle; | ||
779 | ipc.fx = ev->canvas.xsub; | ||
780 | ipc.fy = ev->canvas.ysub; | ||
781 | ipc.flags = ev->flags; | ||
782 | ipc.timestamp = ev->timestamp; | ||
783 | ipc.mask = _ecore_evas_modifiers_locks_mask_get(ee->evas); | ||
784 | ipc.event_flags = ev->event_flags; | ||
785 | ecore_ipc_server_send(extn->ipc.server, MAJOR, OP_EV_MULTI_DOWN, 0, 0, 0, &ipc, sizeof(ipc)); | ||
786 | } | ||
787 | } | ||
788 | |||
789 | |||
790 | static void | ||
791 | _ecore_evas_extn_cb_multi_up(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) | ||
792 | { | ||
793 | Ecore_Evas *ee = data; | ||
794 | Evas_Event_Multi_Up *ev = event_info; | ||
795 | Extn *extn; | ||
796 | |||
797 | extn = ee->engine.buffer.data; | ||
798 | if (!extn) return; | ||
799 | if (extn->ipc.server) | ||
800 | { | ||
801 | Ipc_Data_Ev_Multi_Up ipc; | ||
802 | Evas_Coord x, y; | ||
803 | |||
804 | ipc.d = ev->device; | ||
805 | x = ev->canvas.x; | ||
806 | y = ev->canvas.y; | ||
807 | _ecore_evas_extn_coord_translate(ee, &x, &y); | ||
808 | ipc.x = x; | ||
809 | ipc.y = y; | ||
810 | ipc.rad = ev->radius; | ||
811 | ipc.radx = ev->radius_x; | ||
812 | ipc.rady = ev->radius_y; | ||
813 | ipc.pres = ev->pressure; | ||
814 | ipc.ang = ev->angle; | ||
815 | ipc.fx = ev->canvas.xsub; | ||
816 | ipc.fy = ev->canvas.ysub; | ||
817 | ipc.flags = ev->flags; | ||
818 | ipc.timestamp = ev->timestamp; | ||
819 | ipc.mask = _ecore_evas_modifiers_locks_mask_get(ee->evas); | ||
820 | ipc.event_flags = ev->event_flags; | ||
821 | ecore_ipc_server_send(extn->ipc.server, MAJOR, OP_EV_MULTI_UP, 0, 0, 0, &ipc, sizeof(ipc)); | ||
822 | } | ||
823 | } | ||
824 | |||
825 | static void | ||
826 | _ecore_evas_extn_cb_multi_move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) | ||
827 | { | ||
828 | Ecore_Evas *ee = data; | ||
829 | Evas_Event_Multi_Move *ev = event_info; | ||
830 | Extn *extn; | ||
831 | |||
832 | extn = ee->engine.buffer.data; | ||
833 | if (!extn) return; | ||
834 | if (extn->ipc.server) | ||
835 | { | ||
836 | Ipc_Data_Ev_Multi_Move ipc; | ||
837 | Evas_Coord x, y; | ||
838 | |||
839 | ipc.d = ev->device; | ||
840 | x = ev->cur.canvas.x; | ||
841 | y = ev->cur.canvas.y; | ||
842 | _ecore_evas_extn_coord_translate(ee, &x, &y); | ||
843 | ipc.x = x; | ||
844 | ipc.y = y; | ||
845 | ipc.rad = ev->radius; | ||
846 | ipc.radx = ev->radius_x; | ||
847 | ipc.rady = ev->radius_y; | ||
848 | ipc.pres = ev->pressure; | ||
849 | ipc.ang = ev->angle; | ||
850 | ipc.fx = ev->cur.canvas.xsub; | ||
851 | ipc.fy = ev->cur.canvas.ysub; | ||
852 | ipc.timestamp = ev->timestamp; | ||
853 | ipc.mask = _ecore_evas_modifiers_locks_mask_get(ee->evas); | ||
854 | ipc.event_flags = ev->event_flags; | ||
855 | ecore_ipc_server_send(extn->ipc.server, MAJOR, OP_EV_MULTI_MOVE, 0, 0, 0, &ipc, sizeof(ipc)); | ||
856 | } | ||
857 | } | ||
858 | |||
859 | static void | ||
860 | _ecore_evas_extn_cb_free(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) | ||
861 | { | ||
862 | Ecore_Evas *ee; | ||
863 | |||
864 | ee = data; | ||
865 | if (ee->driver) _ecore_evas_free(ee); | ||
866 | } | ||
867 | |||
868 | static void | ||
869 | _ecore_evas_extn_cb_key_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) | ||
870 | { | ||
871 | Ecore_Evas *ee = data; | ||
872 | Evas_Event_Key_Down *ev = event_info; | ||
873 | Extn *extn; | ||
874 | |||
875 | extn = ee->engine.buffer.data; | ||
876 | if (!extn) return; | ||
877 | if (extn->ipc.server) | ||
878 | { | ||
879 | Ipc_Data_Ev_Key_Down *ipc; | ||
880 | char *st, *p; | ||
881 | int len = 0; | ||
882 | |||
883 | len = sizeof(Ipc_Data_Ev_Key_Down); | ||
884 | if (ev->key) len += strlen(ev->key) + 1; | ||
885 | if (ev->keyname) len += strlen(ev->keyname) + 1; | ||
886 | if (ev->string) len += strlen(ev->string) + 1; | ||
887 | if (ev->compose) len += strlen(ev->compose) + 1; | ||
888 | len += 1; | ||
889 | st = alloca(len); | ||
890 | ipc = (Ipc_Data_Ev_Key_Down *)st; | ||
891 | memset(st, 0, len); | ||
892 | p = st + sizeof(Ipc_Data_Ev_Key_Down); | ||
893 | if (ev->key) | ||
894 | { | ||
895 | strcpy(p, ev->key); | ||
896 | ipc->key = p - (long)st; | ||
897 | p += strlen(p) + 1; | ||
898 | } | ||
899 | if (ev->keyname) | ||
900 | { | ||
901 | strcpy(p, ev->keyname); | ||
902 | ipc->keyname = p - (long)st; | ||
903 | p += strlen(p) + 1; | ||
904 | } | ||
905 | if (ev->string) | ||
906 | { | ||
907 | strcpy(p, ev->string); | ||
908 | ipc->string = p - (long)st; | ||
909 | p += strlen(p) + 1; | ||
910 | } | ||
911 | if (ev->compose) | ||
912 | { | ||
913 | strcpy(p, ev->compose); | ||
914 | ipc->compose = p - (long)st; | ||
915 | p += strlen(p) + 1; | ||
916 | } | ||
917 | ipc->timestamp = ev->timestamp; | ||
918 | ipc->mask = _ecore_evas_modifiers_locks_mask_get(ee->evas); | ||
919 | ipc->event_flags = ev->event_flags; | ||
920 | ecore_ipc_server_send(extn->ipc.server, MAJOR, OP_EV_KEY_DOWN, 0, 0, 0, ipc, len); | ||
921 | } | ||
922 | } | ||
923 | |||
924 | static void | ||
925 | _ecore_evas_extn_cb_key_up(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) | ||
926 | { | ||
927 | Ecore_Evas *ee = data; | ||
928 | Evas_Event_Key_Up *ev = event_info; | ||
929 | Extn *extn; | ||
930 | |||
931 | extn = ee->engine.buffer.data; | ||
932 | if (!extn) return; | ||
933 | if (extn->ipc.server) | ||
934 | { | ||
935 | Ipc_Data_Ev_Key_Up *ipc; | ||
936 | char *st, *p; | ||
937 | int len = 0; | ||
938 | |||
939 | len = sizeof(Ipc_Data_Ev_Key_Up); | ||
940 | if (ev->key) len += strlen(ev->key) + 1; | ||
941 | if (ev->keyname) len += strlen(ev->keyname) + 1; | ||
942 | if (ev->string) len += strlen(ev->string) + 1; | ||
943 | if (ev->compose) len += strlen(ev->compose) + 1; | ||
944 | len += 1; | ||
945 | st = alloca(len); | ||
946 | ipc = (Ipc_Data_Ev_Key_Up *)st; | ||
947 | memset(st, 0, len); | ||
948 | p = st + sizeof(Ipc_Data_Ev_Key_Down); | ||
949 | if (ev->key) | ||
950 | { | ||
951 | strcpy(p, ev->key); | ||
952 | ipc->key = p - (long)st; | ||
953 | p += strlen(p) + 1; | ||
954 | } | ||
955 | if (ev->keyname) | ||
956 | { | ||
957 | strcpy(p, ev->keyname); | ||
958 | ipc->keyname = p - (long)st; | ||
959 | p += strlen(p) + 1; | ||
960 | } | ||
961 | if (ev->string) | ||
962 | { | ||
963 | strcpy(p, ev->string); | ||
964 | ipc->string = p - (long)st; | ||
965 | p += strlen(p) + 1; | ||
966 | } | ||
967 | if (ev->compose) | ||
968 | { | ||
969 | strcpy(p, ev->compose); | ||
970 | ipc->compose = p - (long)st; | ||
971 | p += strlen(p) + 1; | ||
972 | } | ||
973 | ipc->timestamp = ev->timestamp; | ||
974 | ipc->mask = _ecore_evas_modifiers_locks_mask_get(ee->evas); | ||
975 | ipc->event_flags = ev->event_flags; | ||
976 | ecore_ipc_server_send(extn->ipc.server, MAJOR, OP_EV_KEY_UP, 0, 0, 0, ipc, len); | ||
977 | } | ||
978 | } | ||
979 | |||
980 | static void | ||
981 | _ecore_evas_extn_cb_hold(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) | ||
982 | { | ||
983 | Ecore_Evas *ee = data; | ||
984 | Evas_Event_Hold *ev = event_info; | ||
985 | Extn *extn; | ||
986 | |||
987 | extn = ee->engine.buffer.data; | ||
988 | if (!extn) return; | ||
989 | if (extn->ipc.server) | ||
990 | { | ||
991 | Ipc_Data_Ev_Hold ipc; | ||
992 | |||
993 | ipc.hold = ev->hold; | ||
994 | ipc.timestamp = ev->timestamp; | ||
995 | ipc.event_flags = ev->event_flags; | ||
996 | ecore_ipc_server_send(extn->ipc.server, MAJOR, OP_EV_HOLD, 0, 0, 0, &ipc, sizeof(ipc)); | ||
997 | } | ||
998 | } | ||
999 | |||
1000 | static void | ||
1001 | _ecore_evas_extn_cb_focus_in(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) | ||
1002 | { | ||
1003 | Ecore_Evas *ee; | ||
1004 | Extn *extn; | ||
1005 | |||
1006 | ee = data; | ||
1007 | ee->prop.focused = 1; | ||
1008 | extn = ee->engine.buffer.data; | ||
1009 | if (!extn) return; | ||
1010 | if (!extn->ipc.server) return; | ||
1011 | ecore_ipc_server_send(extn->ipc.server, MAJOR, OP_FOCUS, 0, 0, 0, NULL, 0); | ||
1012 | } | ||
1013 | |||
1014 | static void | ||
1015 | _ecore_evas_extn_cb_focus_out(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) | ||
1016 | { | ||
1017 | Ecore_Evas *ee; | ||
1018 | Extn *extn; | ||
1019 | |||
1020 | ee = data; | ||
1021 | ee->prop.focused = 0; | ||
1022 | extn = ee->engine.buffer.data; | ||
1023 | if (!extn) return; | ||
1024 | if (!extn->ipc.server) return; | ||
1025 | ecore_ipc_server_send(extn->ipc.server, MAJOR, OP_UNFOCUS, 0, 0, 0, NULL, 0); | ||
1026 | } | ||
1027 | |||
1028 | static void | ||
1029 | _ecore_evas_extn_cb_show(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) | ||
1030 | { | ||
1031 | Ecore_Evas *ee; | ||
1032 | Extn *extn; | ||
1033 | |||
1034 | ee = data; | ||
1035 | ee->visible = 1; | ||
1036 | extn = ee->engine.buffer.data; | ||
1037 | if (!extn) return; | ||
1038 | if (!extn->ipc.server) return; | ||
1039 | ecore_ipc_server_send(extn->ipc.server, MAJOR, OP_SHOW, 0, 0, 0, NULL, 0); | ||
1040 | } | ||
1041 | |||
1042 | static void | ||
1043 | _ecore_evas_extn_cb_hide(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) | ||
1044 | { | ||
1045 | Ecore_Evas *ee; | ||
1046 | Extn *extn; | ||
1047 | |||
1048 | ee = data; | ||
1049 | ee->visible = 0; | ||
1050 | extn = ee->engine.buffer.data; | ||
1051 | if (!extn) return; | ||
1052 | if (!extn->ipc.server) return; | ||
1053 | ecore_ipc_server_send(extn->ipc.server, MAJOR, OP_HIDE, 0, 0, 0, NULL, 0); | ||
1054 | } | ||
1055 | |||
1056 | static const Ecore_Evas_Engine_Func _ecore_extn_plug_engine_func = | ||
1057 | { | ||
1058 | _ecore_evas_extn_free, | ||
1059 | NULL, | ||
1060 | NULL, | ||
1061 | NULL, | ||
1062 | NULL, | ||
1063 | NULL, | ||
1064 | NULL, | ||
1065 | NULL, | ||
1066 | NULL, | ||
1067 | NULL, | ||
1068 | NULL, | ||
1069 | NULL, | ||
1070 | NULL, | ||
1071 | NULL, | ||
1072 | NULL, | ||
1073 | NULL, | ||
1074 | NULL, | ||
1075 | _ecore_evas_resize, | ||
1076 | _ecore_evas_move_resize, | ||
1077 | NULL, | ||
1078 | NULL, | ||
1079 | NULL, | ||
1080 | NULL, | ||
1081 | NULL, | ||
1082 | NULL, | ||
1083 | NULL, | ||
1084 | NULL, | ||
1085 | NULL, | ||
1086 | NULL, | ||
1087 | NULL, | ||
1088 | NULL, | ||
1089 | NULL, | ||
1090 | NULL, | ||
1091 | NULL, | ||
1092 | NULL, | ||
1093 | NULL, | ||
1094 | NULL, | ||
1095 | NULL, | ||
1096 | NULL, | ||
1097 | NULL, | ||
1098 | NULL, | ||
1099 | NULL, | ||
1100 | NULL, | ||
1101 | NULL, | ||
1102 | NULL, | ||
1103 | NULL, //transparent | ||
1104 | |||
1105 | NULL, // render | ||
1106 | NULL // screen_geometry_get | ||
1107 | }; | ||
1108 | |||
1109 | static Eina_Bool | ||
1110 | _ipc_server_add(void *data, int type __UNUSED__, void *event) | ||
1111 | { | ||
1112 | Ecore_Ipc_Event_Server_Add *e = event; | ||
1113 | Ecore_Evas *ee = data; | ||
1114 | Extn *extn; | ||
1115 | |||
1116 | if (ee != ecore_ipc_server_data_get(e->server)) | ||
1117 | return ECORE_CALLBACK_PASS_ON; | ||
1118 | if (!eina_list_data_find(extn_ee_list, ee)) | ||
1119 | return ECORE_CALLBACK_PASS_ON; | ||
1120 | extn = ee->engine.buffer.data; | ||
1121 | if (!extn) return ECORE_CALLBACK_PASS_ON; | ||
1122 | //FIXME: find a way to let app know server there | ||
1123 | return ECORE_CALLBACK_PASS_ON; | ||
1124 | } | ||
1125 | |||
1126 | static Eina_Bool | ||
1127 | _ipc_server_del(void *data, int type __UNUSED__, void *event) | ||
1128 | { | ||
1129 | Ecore_Ipc_Event_Server_Del *e = event; | ||
1130 | Ecore_Evas *ee = data; | ||
1131 | Extn *extn; | ||
1132 | |||
1133 | extn = ee->engine.buffer.data; | ||
1134 | if (!extn) return ECORE_CALLBACK_PASS_ON; | ||
1135 | if (extn->ipc.server != e->server) return ECORE_CALLBACK_PASS_ON; | ||
1136 | evas_object_image_data_set(ee->engine.buffer.image, NULL); | ||
1137 | ee->engine.buffer.pixels = NULL; | ||
1138 | if (extn->file.shmfile) | ||
1139 | { | ||
1140 | shmfile_close(extn->file.shmfile); | ||
1141 | extn->file.shmfile = NULL; | ||
1142 | } | ||
1143 | if (extn->file.shm) | ||
1144 | { | ||
1145 | eina_stringshare_del(extn->file.shm); | ||
1146 | extn->file.shm = NULL; | ||
1147 | } | ||
1148 | extn->ipc.server = NULL; | ||
1149 | if (ee->func.fn_delete_request) ee->func.fn_delete_request(ee); | ||
1150 | return ECORE_CALLBACK_PASS_ON; | ||
1151 | } | ||
1152 | |||
1153 | static Eina_Bool | ||
1154 | _ipc_server_data(void *data, int type __UNUSED__, void *event) | ||
1155 | { | ||
1156 | Ecore_Ipc_Event_Server_Data *e = event; | ||
1157 | Ecore_Evas *ee = data; | ||
1158 | Extn *extn; | ||
1159 | |||
1160 | if (ee != ecore_ipc_server_data_get(e->server)) | ||
1161 | return ECORE_CALLBACK_PASS_ON; | ||
1162 | if (!eina_list_data_find(extn_ee_list, ee)) | ||
1163 | return ECORE_CALLBACK_PASS_ON; | ||
1164 | extn = ee->engine.buffer.data; | ||
1165 | if (!extn) return ECORE_CALLBACK_PASS_ON; | ||
1166 | if (e->major != MAJOR) | ||
1167 | return ECORE_CALLBACK_PASS_ON; | ||
1168 | switch (e->minor) | ||
1169 | { | ||
1170 | case OP_UPDATE: | ||
1171 | // add rect to update list | ||
1172 | if (e->size >= (int)sizeof(Ipc_Data_Update)) | ||
1173 | { | ||
1174 | Ipc_Data_Update *ipc = malloc(sizeof(Ipc_Data_Update)); | ||
1175 | if (ipc) | ||
1176 | { | ||
1177 | memcpy(ipc, e->data, sizeof(Ipc_Data_Update)); | ||
1178 | extn->file.updates = eina_list_append(extn->file.updates, ipc); | ||
1179 | } | ||
1180 | } | ||
1181 | break; | ||
1182 | case OP_UPDATE_DONE: | ||
1183 | // updates finished being sent - done now. frame ready | ||
1184 | { | ||
1185 | Ipc_Data_Update *ipc; | ||
1186 | |||
1187 | EINA_LIST_FREE(extn->file.updates, ipc) | ||
1188 | { | ||
1189 | if (ee->engine.buffer.image) | ||
1190 | evas_object_image_data_update_add(ee->engine.buffer.image, | ||
1191 | ipc->x, ipc->y, | ||
1192 | ipc->w, ipc->h); | ||
1193 | } | ||
1194 | } | ||
1195 | break; | ||
1196 | case OP_LOCK_FILE: | ||
1197 | if ((e->data) && (e->size > 0) && | ||
1198 | (((unsigned char *)e->data)[e->size - 1] == 0)) | ||
1199 | { | ||
1200 | if (extn->file.lockfd) close(extn->file.lockfd); | ||
1201 | if (extn->file.lock) eina_stringshare_del(extn->file.lock); | ||
1202 | extn->file.lock = eina_stringshare_add(e->data); | ||
1203 | extn->file.lockfd = open(extn->file.lock, O_RDONLY); | ||
1204 | } | ||
1205 | break; | ||
1206 | case OP_SHM_REF: | ||
1207 | // e->ref == w | ||
1208 | // e->ref_to == h | ||
1209 | // e->response == alpha | ||
1210 | // e->data = shm ref string + nul byte | ||
1211 | if ((e->data) && ((unsigned char *)e->data)[e->size - 1] == 0) | ||
1212 | { | ||
1213 | ee->engine.buffer.pixels = NULL; | ||
1214 | if (extn->file.shmfile) | ||
1215 | { | ||
1216 | shmfile_close(extn->file.shmfile); | ||
1217 | extn->file.shmfile = NULL; | ||
1218 | } | ||
1219 | if (extn->file.shm) | ||
1220 | { | ||
1221 | eina_stringshare_del(extn->file.shm); | ||
1222 | extn->file.shm = NULL; | ||
1223 | } | ||
1224 | if ((e->ref > 0) && (e->ref_to > 0)) | ||
1225 | { | ||
1226 | extn->file.w = e->ref; | ||
1227 | extn->file.h = e->ref_to; | ||
1228 | extn->file.shm = eina_stringshare_add(e->data); | ||
1229 | extn->file.shmfile = shmfile_open(extn->file.shm, | ||
1230 | extn->file.w * | ||
1231 | extn->file.h * 4, | ||
1232 | EINA_TRUE); | ||
1233 | if (extn->file.shmfile) | ||
1234 | { | ||
1235 | ee->engine.buffer.pixels = extn->file.shmfile->addr; | ||
1236 | if (ee->engine.buffer.image) | ||
1237 | { | ||
1238 | if (e->response) | ||
1239 | evas_object_image_alpha_set(ee->engine.buffer.image, | ||
1240 | EINA_TRUE); | ||
1241 | else | ||
1242 | evas_object_image_alpha_set(ee->engine.buffer.image, | ||
1243 | EINA_FALSE); | ||
1244 | evas_object_image_size_set(ee->engine.buffer.image, | ||
1245 | extn->file.w, | ||
1246 | extn->file.h); | ||
1247 | evas_object_image_data_set(ee->engine.buffer.image, | ||
1248 | ee->engine.buffer.pixels); | ||
1249 | evas_object_image_data_update_add(ee->engine.buffer.image, | ||
1250 | 0, 0, | ||
1251 | extn->file.w, | ||
1252 | extn->file.h); | ||
1253 | _ecore_evas_resize(ee, | ||
1254 | extn->file.w, | ||
1255 | extn->file.h); | ||
1256 | } | ||
1257 | else | ||
1258 | evas_object_image_data_set(ee->engine.buffer.image, NULL); | ||
1259 | } | ||
1260 | else | ||
1261 | evas_object_image_data_set(ee->engine.buffer.image, NULL); | ||
1262 | } | ||
1263 | else | ||
1264 | evas_object_image_data_set(ee->engine.buffer.image, NULL); | ||
1265 | } | ||
1266 | break; | ||
1267 | case OP_RESIZE: | ||
1268 | if ((e->data) && (e->size >= (int)sizeof(Ipc_Data_Resize))) | ||
1269 | { | ||
1270 | Ipc_Data_Resize *ipc = e->data; | ||
1271 | _ecore_evas_resize(ee, ipc->w, ipc->h); | ||
1272 | } | ||
1273 | break; | ||
1274 | default: | ||
1275 | break; | ||
1276 | } | ||
1277 | return ECORE_CALLBACK_PASS_ON; | ||
1278 | } | ||
1279 | #else | ||
1280 | void | ||
1281 | _ecore_evas_extn_init(void) | ||
1282 | { | ||
1283 | } | ||
1284 | |||
1285 | void | ||
1286 | _ecore_evas_extn_shutdown(void) | ||
1287 | { | ||
1288 | } | ||
1289 | #endif | ||
1290 | |||
1291 | EAPI Evas_Object * | ||
1292 | ecore_evas_extn_plug_new(Ecore_Evas *ee_target) | ||
1293 | { | ||
1294 | #ifdef EXTN_ENABLED | ||
1295 | Evas_Object *o; | ||
1296 | Ecore_Evas *ee; | ||
1297 | int w = 1, h = 1; | ||
1298 | |||
1299 | if (!ee_target) return NULL; | ||
1300 | |||
1301 | ee = calloc(1, sizeof(Ecore_Evas)); | ||
1302 | if (!ee) return NULL; | ||
1303 | |||
1304 | o = evas_object_image_filled_add(ee_target->evas); | ||
1305 | evas_object_image_content_hint_set(o, EVAS_IMAGE_CONTENT_HINT_DYNAMIC); | ||
1306 | evas_object_image_colorspace_set(o, EVAS_COLORSPACE_ARGB8888); | ||
1307 | evas_object_image_alpha_set(o, 1); | ||
1308 | evas_object_image_size_set(o, 1, 1); | ||
1309 | evas_object_image_data_set(o, &blank); | ||
1310 | |||
1311 | ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS); | ||
1312 | |||
1313 | ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_extn_plug_engine_func; | ||
1314 | |||
1315 | ee->driver = "extn_plug"; | ||
1316 | |||
1317 | ee->rotation = 0; | ||
1318 | ee->visible = 0; | ||
1319 | ee->w = w; | ||
1320 | ee->h = h; | ||
1321 | ee->req.w = ee->w; | ||
1322 | ee->req.h = ee->h; | ||
1323 | |||
1324 | ee->prop.max.w = 0; | ||
1325 | ee->prop.max.h = 0; | ||
1326 | ee->prop.layer = 0; | ||
1327 | ee->prop.focused = 0; | ||
1328 | ee->prop.borderless = 1; | ||
1329 | ee->prop.override = 1; | ||
1330 | ee->prop.maximized = 0; | ||
1331 | ee->prop.fullscreen = 0; | ||
1332 | ee->prop.withdrawn = 0; | ||
1333 | ee->prop.sticky = 0; | ||
1334 | |||
1335 | ee->engine.buffer.image = o; | ||
1336 | evas_object_data_set(ee->engine.buffer.image, "Ecore_Evas", ee); | ||
1337 | evas_object_data_set(ee->engine.buffer.image, "Ecore_Evas_Parent", ee_target); | ||
1338 | evas_object_event_callback_add(ee->engine.buffer.image, | ||
1339 | EVAS_CALLBACK_MOUSE_IN, | ||
1340 | _ecore_evas_extn_cb_mouse_in, ee); | ||
1341 | evas_object_event_callback_add(ee->engine.buffer.image, | ||
1342 | EVAS_CALLBACK_MOUSE_OUT, | ||
1343 | _ecore_evas_extn_cb_mouse_out, ee); | ||
1344 | evas_object_event_callback_add(ee->engine.buffer.image, | ||
1345 | EVAS_CALLBACK_MOUSE_DOWN, | ||
1346 | _ecore_evas_extn_cb_mouse_down, ee); | ||
1347 | evas_object_event_callback_add(ee->engine.buffer.image, | ||
1348 | EVAS_CALLBACK_MOUSE_UP, | ||
1349 | _ecore_evas_extn_cb_mouse_up, ee); | ||
1350 | evas_object_event_callback_add(ee->engine.buffer.image, | ||
1351 | EVAS_CALLBACK_MOUSE_MOVE, | ||
1352 | _ecore_evas_extn_cb_mouse_move, ee); | ||
1353 | evas_object_event_callback_add(ee->engine.buffer.image, | ||
1354 | EVAS_CALLBACK_MOUSE_WHEEL, | ||
1355 | _ecore_evas_extn_cb_mouse_wheel, ee); | ||
1356 | evas_object_event_callback_add(ee->engine.buffer.image, | ||
1357 | EVAS_CALLBACK_MULTI_DOWN, | ||
1358 | _ecore_evas_extn_cb_multi_down, ee); | ||
1359 | evas_object_event_callback_add(ee->engine.buffer.image, | ||
1360 | EVAS_CALLBACK_MULTI_UP, | ||
1361 | _ecore_evas_extn_cb_multi_up, ee); | ||
1362 | evas_object_event_callback_add(ee->engine.buffer.image, | ||
1363 | EVAS_CALLBACK_MULTI_MOVE, | ||
1364 | _ecore_evas_extn_cb_multi_move, ee); | ||
1365 | evas_object_event_callback_add(ee->engine.buffer.image, | ||
1366 | EVAS_CALLBACK_FREE, | ||
1367 | _ecore_evas_extn_cb_free, ee); | ||
1368 | evas_object_event_callback_add(ee->engine.buffer.image, | ||
1369 | EVAS_CALLBACK_KEY_DOWN, | ||
1370 | _ecore_evas_extn_cb_key_down, ee); | ||
1371 | evas_object_event_callback_add(ee->engine.buffer.image, | ||
1372 | EVAS_CALLBACK_KEY_UP, | ||
1373 | _ecore_evas_extn_cb_key_up, ee); | ||
1374 | evas_object_event_callback_add(ee->engine.buffer.image, | ||
1375 | EVAS_CALLBACK_HOLD, | ||
1376 | _ecore_evas_extn_cb_hold, ee); | ||
1377 | evas_object_event_callback_add(ee->engine.buffer.image, | ||
1378 | EVAS_CALLBACK_FOCUS_IN, | ||
1379 | _ecore_evas_extn_cb_focus_in, ee); | ||
1380 | evas_object_event_callback_add(ee->engine.buffer.image, | ||
1381 | EVAS_CALLBACK_FOCUS_OUT, | ||
1382 | _ecore_evas_extn_cb_focus_out, ee); | ||
1383 | evas_object_event_callback_add(ee->engine.buffer.image, | ||
1384 | EVAS_CALLBACK_SHOW, | ||
1385 | _ecore_evas_extn_cb_show, ee); | ||
1386 | evas_object_event_callback_add(ee->engine.buffer.image, | ||
1387 | EVAS_CALLBACK_HIDE, | ||
1388 | _ecore_evas_extn_cb_hide, ee); | ||
1389 | |||
1390 | evas_object_event_callback_add(ee->engine.buffer.image, | ||
1391 | EVAS_CALLBACK_DEL, | ||
1392 | _ecore_evas_extn_plug_image_obj_del, ee); | ||
1393 | |||
1394 | |||
1395 | extn_ee_list = eina_list_append(extn_ee_list, ee); | ||
1396 | ee_target->sub_ecore_evas = eina_list_append(ee_target->sub_ecore_evas, ee); | ||
1397 | |||
1398 | evas_event_callback_add(ee_target->evas, EVAS_CALLBACK_RENDER_PRE, | ||
1399 | _ecore_evas_extn_plug_targer_render_pre, ee); | ||
1400 | evas_event_callback_add(ee_target->evas, EVAS_CALLBACK_RENDER_POST, | ||
1401 | _ecore_evas_extn_plug_targer_render_post, ee); | ||
1402 | return o; | ||
1403 | #else | ||
1404 | return NULL; | ||
1405 | #endif | ||
1406 | } | ||
1407 | |||
1408 | EAPI Eina_Bool | ||
1409 | ecore_evas_extn_plug_connect(Evas_Object *obj, const char *svcname, int svcnum, Eina_Bool svcsys) | ||
1410 | { | ||
1411 | #ifdef EXTN_ENABLED | ||
1412 | Extn *extn; | ||
1413 | Ecore_Evas *ee = NULL; | ||
1414 | |||
1415 | if (!obj) return EINA_FALSE; | ||
1416 | |||
1417 | ee = evas_object_data_get(obj, "Ecore_Evas"); | ||
1418 | if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) return EINA_FALSE; | ||
1419 | |||
1420 | extn = calloc(1, sizeof(Extn)); | ||
1421 | if (!extn) return EINA_FALSE; | ||
1422 | |||
1423 | Ecore_Ipc_Type ipctype = ECORE_IPC_LOCAL_USER; | ||
1424 | |||
1425 | ecore_ipc_init(); | ||
1426 | extn->svc.name = eina_stringshare_add(svcname); | ||
1427 | extn->svc.num = svcnum; | ||
1428 | extn->svc.sys = svcsys; | ||
1429 | |||
1430 | if (extn->svc.sys) ipctype = ECORE_IPC_LOCAL_SYSTEM; | ||
1431 | extn->ipc.server = ecore_ipc_server_connect(ipctype, (char *)extn->svc.name, | ||
1432 | extn->svc.num, ee); | ||
1433 | if (!extn->ipc.server) | ||
1434 | { | ||
1435 | eina_stringshare_del(extn->svc.name); | ||
1436 | free(extn); | ||
1437 | ecore_ipc_shutdown(); | ||
1438 | return EINA_FALSE; | ||
1439 | } | ||
1440 | ee->engine.buffer.data = extn; | ||
1441 | extn->ipc.handlers = eina_list_append | ||
1442 | (extn->ipc.handlers, | ||
1443 | ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_ADD, | ||
1444 | _ipc_server_add, ee)); | ||
1445 | extn->ipc.handlers = eina_list_append | ||
1446 | (extn->ipc.handlers, | ||
1447 | ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_DEL, | ||
1448 | _ipc_server_del, ee)); | ||
1449 | extn->ipc.handlers = eina_list_append | ||
1450 | (extn->ipc.handlers, | ||
1451 | ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_DATA, | ||
1452 | _ipc_server_data, ee)); | ||
1453 | return EINA_TRUE; | ||
1454 | #else | ||
1455 | return EINA_FALSE; | ||
1456 | #endif | ||
1457 | } | ||
1458 | |||
1459 | EAPI void | ||
1460 | ecore_evas_extn_plug_object_data_lock(Evas_Object *obj) | ||
1461 | { | ||
1462 | #ifdef EXTN_ENABLED | ||
1463 | Ecore_Evas *ee; | ||
1464 | |||
1465 | ee = ecore_evas_object_ecore_evas_get(obj); | ||
1466 | if (!ee) return; | ||
1467 | _ecore_evas_socket_lock(ee); | ||
1468 | #endif | ||
1469 | } | ||
1470 | |||
1471 | EAPI void | ||
1472 | ecore_evas_extn_plug_object_data_unlock(Evas_Object *obj) | ||
1473 | { | ||
1474 | #ifdef EXTN_ENABLED | ||
1475 | Ecore_Evas *ee; | ||
1476 | |||
1477 | ee = ecore_evas_object_ecore_evas_get(obj); | ||
1478 | if (!ee) return; | ||
1479 | _ecore_evas_socket_unlock(ee); | ||
1480 | #endif | ||
1481 | } | ||
1482 | |||
1483 | #ifdef EXTN_ENABLED | ||
1484 | static void | ||
1485 | _ecore_evas_socket_resize(Ecore_Evas *ee, int w, int h) | ||
1486 | { | ||
1487 | Extn *extn; | ||
1488 | Evas_Engine_Info_Buffer *einfo; | ||
1489 | int stride = 0; | ||
1490 | |||
1491 | if (w < 1) w = 1; | ||
1492 | if (h < 1) h = 1; | ||
1493 | ee->req.w = w; | ||
1494 | ee->req.h = h; | ||
1495 | if ((w == ee->w) && (h == ee->h)) return; | ||
1496 | ee->w = w; | ||
1497 | ee->h = h; | ||
1498 | evas_output_size_set(ee->evas, ee->w, ee->h); | ||
1499 | evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h); | ||
1500 | evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); | ||
1501 | extn = ee->engine.buffer.data; | ||
1502 | if (extn) | ||
1503 | { | ||
1504 | if (extn->file.shmfile) | ||
1505 | shmfile_free(extn->file.shmfile); | ||
1506 | ee->engine.buffer.pixels = NULL; | ||
1507 | extn->file.shmfile = shmfile_new(extn->svc.name, extn->svc.num, | ||
1508 | ee->w * ee->h * 4, extn->svc.sys); | ||
1509 | if (extn->file.shmfile) | ||
1510 | ee->engine.buffer.pixels = extn->file.shmfile->addr; | ||
1511 | |||
1512 | stride = ee->w * 4; | ||
1513 | einfo = (Evas_Engine_Info_Buffer *)evas_engine_info_get(ee->evas); | ||
1514 | if (einfo) | ||
1515 | { | ||
1516 | if (ee->alpha) | ||
1517 | einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_ARGB32; | ||
1518 | else | ||
1519 | einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_RGB32; | ||
1520 | einfo->info.dest_buffer = ee->engine.buffer.pixels; | ||
1521 | einfo->info.dest_buffer_row_bytes = stride; | ||
1522 | einfo->info.use_color_key = 0; | ||
1523 | einfo->info.alpha_threshold = 0; | ||
1524 | einfo->info.func.new_update_region = NULL; | ||
1525 | einfo->info.func.free_update_region = NULL; | ||
1526 | if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) | ||
1527 | { | ||
1528 | ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); | ||
1529 | } | ||
1530 | } | ||
1531 | |||
1532 | if (extn->ipc.clients && extn->file.shmfile) | ||
1533 | { | ||
1534 | Ipc_Data_Resize ipc; | ||
1535 | Eina_List *l; | ||
1536 | Ecore_Ipc_Client *client; | ||
1537 | |||
1538 | EINA_LIST_FOREACH(extn->ipc.clients, l, client) | ||
1539 | ecore_ipc_client_send(client, MAJOR, OP_SHM_REF, | ||
1540 | ee->w, ee->h, ee->alpha, | ||
1541 | extn->file.shmfile->file, | ||
1542 | strlen(extn->file.shmfile->file) + 1); | ||
1543 | ipc.w = ee->w; | ||
1544 | ipc.h = ee->h; | ||
1545 | EINA_LIST_FOREACH(extn->ipc.clients, l, client) | ||
1546 | ecore_ipc_client_send(client, MAJOR, OP_RESIZE, | ||
1547 | 0, 0, 0, &ipc, sizeof(ipc)); | ||
1548 | } | ||
1549 | } | ||
1550 | if (ee->func.fn_resize) ee->func.fn_resize(ee); | ||
1551 | } | ||
1552 | |||
1553 | static void | ||
1554 | _ecore_evas_socket_move_resize(Ecore_Evas *ee, int x __UNUSED__, int y __UNUSED__, int w, int h) | ||
1555 | { | ||
1556 | _ecore_evas_socket_resize(ee, w, h); | ||
1557 | } | ||
1558 | |||
1559 | int | ||
1560 | _ecore_evas_extn_socket_render(Ecore_Evas *ee) | ||
1561 | { | ||
1562 | Eina_List *updates = NULL, *l, *ll; | ||
1563 | Ecore_Evas *ee2; | ||
1564 | int rend = 0; | ||
1565 | Eina_Rectangle *r; | ||
1566 | Extn *extn; | ||
1567 | Ecore_Ipc_Client *client; | ||
1568 | |||
1569 | extn = ee->engine.buffer.data; | ||
1570 | EINA_LIST_FOREACH(ee->sub_ecore_evas, ll, ee2) | ||
1571 | { | ||
1572 | if (ee2->func.fn_pre_render) ee2->func.fn_pre_render(ee2); | ||
1573 | if (ee2->engine.func->fn_render) | ||
1574 | rend |= ee2->engine.func->fn_render(ee2); | ||
1575 | if (ee2->func.fn_post_render) ee2->func.fn_post_render(ee2); | ||
1576 | } | ||
1577 | if (ee->engine.buffer.pixels) | ||
1578 | { | ||
1579 | _ecore_evas_socket_lock(ee); | ||
1580 | updates = evas_render_updates(ee->evas); | ||
1581 | _ecore_evas_socket_unlock(ee); | ||
1582 | } | ||
1583 | EINA_LIST_FOREACH(updates, l, r) | ||
1584 | { | ||
1585 | Ipc_Data_Update ipc; | ||
1586 | |||
1587 | |||
1588 | ipc.x = r->x; | ||
1589 | ipc.y = r->y; | ||
1590 | ipc.w = r->w; | ||
1591 | ipc.h = r->h; | ||
1592 | EINA_LIST_FOREACH(extn->ipc.clients, ll, client) | ||
1593 | ecore_ipc_client_send(client, MAJOR, OP_UPDATE, 0, 0, 0, &ipc, sizeof(ipc)); | ||
1594 | } | ||
1595 | if (updates) | ||
1596 | { | ||
1597 | evas_render_updates_free(updates); | ||
1598 | _ecore_evas_idle_timeout_update(ee); | ||
1599 | EINA_LIST_FOREACH(extn->ipc.clients, ll, client) | ||
1600 | ecore_ipc_client_send(client, MAJOR, OP_UPDATE_DONE, 0, 0, 0, NULL, 0); | ||
1601 | } | ||
1602 | |||
1603 | return updates ? 1 : rend; | ||
1604 | } | ||
1605 | |||
1606 | static Eina_Bool | ||
1607 | _ipc_client_add(void *data, int type __UNUSED__, void *event) | ||
1608 | { | ||
1609 | Ecore_Ipc_Event_Client_Add *e = event; | ||
1610 | Ecore_Evas *ee = data; | ||
1611 | Extn *extn; | ||
1612 | |||
1613 | if (ee != ecore_ipc_server_data_get(ecore_ipc_client_server_get(e->client))) | ||
1614 | return ECORE_CALLBACK_PASS_ON; | ||
1615 | if (!eina_list_data_find(extn_ee_list, ee)) | ||
1616 | return ECORE_CALLBACK_PASS_ON; | ||
1617 | extn = ee->engine.buffer.data; | ||
1618 | if (!extn) return ECORE_CALLBACK_PASS_ON; | ||
1619 | |||
1620 | extn->ipc.clients = eina_list_append(extn->ipc.clients, e->client); | ||
1621 | ecore_ipc_client_send(e->client, MAJOR, OP_LOCK_FILE, 0, 0, 0, extn->file.lock, strlen(extn->file.lock) + 1); | ||
1622 | |||
1623 | if (extn->file.shmfile) | ||
1624 | { | ||
1625 | Ipc_Data_Resize ipc; | ||
1626 | |||
1627 | ecore_ipc_client_send(e->client, MAJOR, OP_SHM_REF, | ||
1628 | ee->w, ee->h, ee->alpha, | ||
1629 | extn->file.shmfile->file, | ||
1630 | strlen(extn->file.shmfile->file) + 1); | ||
1631 | ipc.w = ee->w; | ||
1632 | ipc.h = ee->h; | ||
1633 | |||
1634 | ecore_ipc_client_send(e->client, MAJOR, OP_RESIZE, | ||
1635 | 0, 0, 0, &ipc, sizeof(ipc)); | ||
1636 | } | ||
1637 | _ecore_evas_extn_event(ee, ECORE_EVAS_EXTN_CLIENT_ADD); | ||
1638 | return ECORE_CALLBACK_PASS_ON; | ||
1639 | } | ||
1640 | |||
1641 | static Eina_Bool | ||
1642 | _ipc_client_del(void *data, int type __UNUSED__, void *event) | ||
1643 | { | ||
1644 | Ecore_Ipc_Event_Client_Del *e = event; | ||
1645 | Ecore_Evas *ee = data; | ||
1646 | Extn *extn; | ||
1647 | extn = ee->engine.buffer.data; | ||
1648 | if (!extn) return ECORE_CALLBACK_PASS_ON; | ||
1649 | if (!eina_list_data_find(extn->ipc.clients, e->client)) return ECORE_CALLBACK_PASS_ON; | ||
1650 | |||
1651 | extn->ipc.clients = eina_list_remove(extn->ipc.clients, e->client); | ||
1652 | |||
1653 | _ecore_evas_extn_event(ee, ECORE_EVAS_EXTN_CLIENT_DEL); | ||
1654 | return ECORE_CALLBACK_PASS_ON; | ||
1655 | } | ||
1656 | |||
1657 | static Eina_Bool | ||
1658 | _ipc_client_data(void *data, int type __UNUSED__, void *event) | ||
1659 | { | ||
1660 | Ecore_Ipc_Event_Client_Data *e = event; | ||
1661 | Ecore_Evas *ee = data; | ||
1662 | Extn *extn; | ||
1663 | |||
1664 | if (ee != ecore_ipc_server_data_get(ecore_ipc_client_server_get(e->client))) | ||
1665 | return ECORE_CALLBACK_PASS_ON; | ||
1666 | if (!eina_list_data_find(extn_ee_list, ee)) | ||
1667 | return ECORE_CALLBACK_PASS_ON; | ||
1668 | extn = ee->engine.buffer.data; | ||
1669 | if (!extn) return ECORE_CALLBACK_PASS_ON; | ||
1670 | if (e->major != MAJOR) | ||
1671 | return ECORE_CALLBACK_PASS_ON; | ||
1672 | switch (e->minor) | ||
1673 | { | ||
1674 | case OP_RESIZE: | ||
1675 | if ((e->data) && (e->size >= (int)sizeof(Ipc_Data_Resize))) | ||
1676 | { | ||
1677 | |||
1678 | Ipc_Data_Resize *ipc = e->data; | ||
1679 | /* create callbacke data size changed */ | ||
1680 | _ecore_evas_socket_resize(ee, ipc->w, ipc->h); | ||
1681 | } | ||
1682 | break; | ||
1683 | case OP_SHOW: | ||
1684 | if (!ee->visible) | ||
1685 | { | ||
1686 | ee->visible = 1; | ||
1687 | if (ee->func.fn_show) ee->func.fn_show(ee); | ||
1688 | } | ||
1689 | break; | ||
1690 | case OP_HIDE: | ||
1691 | if (ee->visible) | ||
1692 | { | ||
1693 | ee->visible = 0; | ||
1694 | if (ee->func.fn_hide) ee->func.fn_hide(ee); | ||
1695 | } | ||
1696 | break; | ||
1697 | case OP_FOCUS: | ||
1698 | if (!ee->prop.focused) | ||
1699 | { | ||
1700 | ee->prop.focused = 1; | ||
1701 | evas_focus_in(ee->evas); | ||
1702 | if (ee->func.fn_focus_in) ee->func.fn_focus_in(ee); | ||
1703 | } | ||
1704 | break; | ||
1705 | case OP_UNFOCUS: | ||
1706 | if (ee->prop.focused) | ||
1707 | { | ||
1708 | ee->prop.focused = 0; | ||
1709 | evas_focus_out(ee->evas); | ||
1710 | if (ee->func.fn_focus_out) ee->func.fn_focus_out(ee); | ||
1711 | } | ||
1712 | break; | ||
1713 | case OP_EV_MOUSE_IN: | ||
1714 | if (e->size >= (int)sizeof(Ipc_Data_Ev_Mouse_In)) | ||
1715 | { | ||
1716 | Ipc_Data_Ev_Mouse_In *ipc = e->data; | ||
1717 | Evas_Event_Flags flags; | ||
1718 | |||
1719 | flags = evas_event_default_flags_get(ee->evas); | ||
1720 | evas_event_default_flags_set(ee->evas, ipc->event_flags); | ||
1721 | _ecore_evas_modifiers_locks_mask_set(ee->evas, ipc->mask); | ||
1722 | evas_event_feed_mouse_in(ee->evas, ipc->timestamp, NULL); | ||
1723 | evas_event_default_flags_set(ee->evas, flags); | ||
1724 | } | ||
1725 | break; | ||
1726 | case OP_EV_MOUSE_OUT: | ||
1727 | if (e->size >= (int)sizeof(Ipc_Data_Ev_Mouse_Out)) | ||
1728 | { | ||
1729 | Ipc_Data_Ev_Mouse_Out *ipc = e->data; | ||
1730 | Evas_Event_Flags flags; | ||
1731 | |||
1732 | flags = evas_event_default_flags_get(ee->evas); | ||
1733 | evas_event_default_flags_set(ee->evas, ipc->event_flags); | ||
1734 | _ecore_evas_modifiers_locks_mask_set(ee->evas, ipc->mask); | ||
1735 | evas_event_feed_mouse_out(ee->evas, ipc->timestamp, NULL); | ||
1736 | evas_event_default_flags_set(ee->evas, flags); | ||
1737 | } | ||
1738 | break; | ||
1739 | case OP_EV_MOUSE_UP: | ||
1740 | if (e->size >= (int)sizeof(Ipc_Data_Ev_Mouse_Up)) | ||
1741 | { | ||
1742 | Ipc_Data_Ev_Mouse_Up *ipc = e->data; | ||
1743 | Evas_Event_Flags flags; | ||
1744 | |||
1745 | flags = evas_event_default_flags_get(ee->evas); | ||
1746 | evas_event_default_flags_set(ee->evas, ipc->event_flags); | ||
1747 | _ecore_evas_modifiers_locks_mask_set(ee->evas, ipc->mask); | ||
1748 | evas_event_feed_mouse_up(ee->evas, ipc->b, ipc->flags, ipc->timestamp, NULL); | ||
1749 | evas_event_default_flags_set(ee->evas, flags); | ||
1750 | } | ||
1751 | break; | ||
1752 | case OP_EV_MOUSE_DOWN: | ||
1753 | if (e->size >= (int)sizeof(Ipc_Data_Ev_Mouse_Down)) | ||
1754 | { | ||
1755 | Ipc_Data_Ev_Mouse_Up *ipc = e->data; | ||
1756 | Evas_Event_Flags flags; | ||
1757 | |||
1758 | flags = evas_event_default_flags_get(ee->evas); | ||
1759 | evas_event_default_flags_set(ee->evas, ipc->event_flags); | ||
1760 | _ecore_evas_modifiers_locks_mask_set(ee->evas, ipc->mask); | ||
1761 | evas_event_feed_mouse_down(ee->evas, ipc->b, ipc->flags, ipc->timestamp, NULL); | ||
1762 | evas_event_default_flags_set(ee->evas, flags); | ||
1763 | } | ||
1764 | break; | ||
1765 | case OP_EV_MOUSE_MOVE: | ||
1766 | if (e->size >= (int)sizeof(Ipc_Data_Ev_Mouse_Move)) | ||
1767 | { | ||
1768 | Ipc_Data_Ev_Mouse_Move *ipc = e->data; | ||
1769 | Evas_Event_Flags flags; | ||
1770 | |||
1771 | flags = evas_event_default_flags_get(ee->evas); | ||
1772 | evas_event_default_flags_set(ee->evas, ipc->event_flags); | ||
1773 | _ecore_evas_modifiers_locks_mask_set(ee->evas, ipc->mask); | ||
1774 | evas_event_feed_mouse_move(ee->evas, ipc->x, ipc->y, ipc->timestamp, NULL); | ||
1775 | evas_event_default_flags_set(ee->evas, flags); | ||
1776 | } | ||
1777 | break; | ||
1778 | case OP_EV_MOUSE_WHEEL: | ||
1779 | if (e->size >= (int)sizeof(Ipc_Data_Ev_Mouse_Wheel)) | ||
1780 | { | ||
1781 | Ipc_Data_Ev_Mouse_Wheel *ipc = e->data; | ||
1782 | Evas_Event_Flags flags; | ||
1783 | |||
1784 | flags = evas_event_default_flags_get(ee->evas); | ||
1785 | evas_event_default_flags_set(ee->evas, ipc->event_flags); | ||
1786 | _ecore_evas_modifiers_locks_mask_set(ee->evas, ipc->mask); | ||
1787 | evas_event_feed_mouse_wheel(ee->evas, ipc->direction, ipc->z, ipc->timestamp, NULL); | ||
1788 | evas_event_default_flags_set(ee->evas, flags); | ||
1789 | } | ||
1790 | break; | ||
1791 | case OP_EV_MULTI_UP: | ||
1792 | if (e->size >= (int)sizeof(Ipc_Data_Ev_Multi_Up)) | ||
1793 | { | ||
1794 | Ipc_Data_Ev_Multi_Up *ipc = e->data; | ||
1795 | Evas_Event_Flags flags; | ||
1796 | |||
1797 | flags = evas_event_default_flags_get(ee->evas); | ||
1798 | evas_event_default_flags_set(ee->evas, ipc->event_flags); | ||
1799 | _ecore_evas_modifiers_locks_mask_set(ee->evas, ipc->mask); | ||
1800 | evas_event_feed_multi_up(ee->evas, ipc->d, ipc->x, ipc->y, ipc->rad, ipc->radx, ipc->rady, ipc->pres, ipc->ang, ipc->fx, ipc->fy, ipc->flags, ipc->timestamp, NULL); | ||
1801 | evas_event_default_flags_set(ee->evas, flags); | ||
1802 | } | ||
1803 | break; | ||
1804 | case OP_EV_MULTI_DOWN: | ||
1805 | if (e->size >= (int)sizeof(Ipc_Data_Ev_Multi_Down)) | ||
1806 | { | ||
1807 | Ipc_Data_Ev_Multi_Down *ipc = e->data; | ||
1808 | Evas_Event_Flags flags; | ||
1809 | |||
1810 | flags = evas_event_default_flags_get(ee->evas); | ||
1811 | evas_event_default_flags_set(ee->evas, ipc->event_flags); | ||
1812 | _ecore_evas_modifiers_locks_mask_set(ee->evas, ipc->mask); | ||
1813 | evas_event_feed_multi_down(ee->evas, ipc->d, ipc->x, ipc->y, ipc->rad, ipc->radx, ipc->rady, ipc->pres, ipc->ang, ipc->fx, ipc->fy, ipc->flags, ipc->timestamp, NULL); | ||
1814 | evas_event_default_flags_set(ee->evas, flags); | ||
1815 | } | ||
1816 | break; | ||
1817 | case OP_EV_MULTI_MOVE: | ||
1818 | if (e->size >= (int)sizeof(Ipc_Data_Ev_Multi_Move)) | ||
1819 | { | ||
1820 | Ipc_Data_Ev_Multi_Move *ipc = e->data; | ||
1821 | Evas_Event_Flags flags; | ||
1822 | |||
1823 | flags = evas_event_default_flags_get(ee->evas); | ||
1824 | evas_event_default_flags_set(ee->evas, ipc->event_flags); | ||
1825 | _ecore_evas_modifiers_locks_mask_set(ee->evas, ipc->mask); | ||
1826 | evas_event_feed_multi_move(ee->evas, ipc->d, ipc->x, ipc->y, ipc->rad, ipc->radx, ipc->rady, ipc->pres, ipc->ang, ipc->fx, ipc->fy, ipc->timestamp, NULL); | ||
1827 | evas_event_default_flags_set(ee->evas, flags); | ||
1828 | } | ||
1829 | break; | ||
1830 | |||
1831 | #define STRGET(val) \ | ||
1832 | do { \ | ||
1833 | if ((ipc->val) && (ipc->val < (char *)(e->size - 1))) \ | ||
1834 | ipc->val = ((char *)ipc) + (long)ipc->val; \ | ||
1835 | else \ | ||
1836 | ipc->val = NULL; \ | ||
1837 | } while (0) | ||
1838 | |||
1839 | case OP_EV_KEY_UP: | ||
1840 | if (e->size >= (int)sizeof(Ipc_Data_Ev_Key_Up)) | ||
1841 | { | ||
1842 | if ((e->data) && (e->size > 0) && | ||
1843 | (((unsigned char *)e->data)[e->size - 1] == 0)) | ||
1844 | { | ||
1845 | Ipc_Data_Ev_Key_Up *ipc = e->data; | ||
1846 | Evas_Event_Flags flags; | ||
1847 | |||
1848 | STRGET(keyname); | ||
1849 | STRGET(key); | ||
1850 | STRGET(string); | ||
1851 | STRGET(compose); | ||
1852 | flags = evas_event_default_flags_get(ee->evas); | ||
1853 | evas_event_default_flags_set(ee->evas, ipc->event_flags); | ||
1854 | _ecore_evas_modifiers_locks_mask_set(ee->evas, ipc->mask); | ||
1855 | evas_event_feed_key_up(ee->evas, ipc->keyname, ipc->key, ipc->string, ipc->compose, ipc->timestamp, NULL); | ||
1856 | evas_event_default_flags_set(ee->evas, flags); | ||
1857 | } | ||
1858 | } | ||
1859 | break; | ||
1860 | case OP_EV_KEY_DOWN: | ||
1861 | if (e->size >= (int)sizeof(Ipc_Data_Ev_Key_Down)) | ||
1862 | { | ||
1863 | if ((e->data) && (e->size > 0) && | ||
1864 | (((unsigned char *)e->data)[e->size - 1] == 0)) | ||
1865 | { | ||
1866 | Ipc_Data_Ev_Key_Down *ipc = e->data; | ||
1867 | Evas_Event_Flags flags; | ||
1868 | |||
1869 | STRGET(keyname); | ||
1870 | STRGET(key); | ||
1871 | STRGET(string); | ||
1872 | STRGET(compose); | ||
1873 | flags = evas_event_default_flags_get(ee->evas); | ||
1874 | evas_event_default_flags_set(ee->evas, ipc->event_flags); | ||
1875 | _ecore_evas_modifiers_locks_mask_set(ee->evas, ipc->mask); | ||
1876 | evas_event_feed_key_down(ee->evas, ipc->keyname, ipc->key, ipc->string, ipc->compose, ipc->timestamp, NULL); | ||
1877 | evas_event_default_flags_set(ee->evas, flags); | ||
1878 | } | ||
1879 | } | ||
1880 | break; | ||
1881 | case OP_EV_HOLD: | ||
1882 | if (e->size >= (int)sizeof(Ipc_Data_Ev_Hold)) | ||
1883 | { | ||
1884 | Ipc_Data_Ev_Hold *ipc = e->data; | ||
1885 | Evas_Event_Flags flags; | ||
1886 | |||
1887 | flags = evas_event_default_flags_get(ee->evas); | ||
1888 | evas_event_default_flags_set(ee->evas, ipc->event_flags); | ||
1889 | evas_event_feed_hold(ee->evas, ipc->hold, ipc->timestamp, NULL); | ||
1890 | evas_event_default_flags_set(ee->evas, flags); | ||
1891 | } | ||
1892 | break; | ||
1893 | default: | ||
1894 | break; | ||
1895 | } | ||
1896 | return ECORE_CALLBACK_PASS_ON; | ||
1897 | } | ||
1898 | |||
1899 | static void | ||
1900 | _ecore_evas_extn_socket_alpha_set(Ecore_Evas *ee, int alpha) | ||
1901 | { | ||
1902 | Extn *extn; | ||
1903 | Eina_List *l; | ||
1904 | Ecore_Ipc_Client *client; | ||
1905 | |||
1906 | if (((ee->alpha) && (alpha)) || ((!ee->alpha) && (!alpha))) return; | ||
1907 | ee->alpha = alpha; | ||
1908 | |||
1909 | extn = ee->engine.buffer.data; | ||
1910 | if (extn) | ||
1911 | { | ||
1912 | Evas_Engine_Info_Buffer *einfo; | ||
1913 | |||
1914 | einfo = (Evas_Engine_Info_Buffer *)evas_engine_info_get(ee->evas); | ||
1915 | if (einfo) | ||
1916 | { | ||
1917 | if (ee->alpha) | ||
1918 | einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_ARGB32; | ||
1919 | else | ||
1920 | einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_RGB32; | ||
1921 | evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo); | ||
1922 | evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); | ||
1923 | } | ||
1924 | EINA_LIST_FOREACH(extn->ipc.clients, l, client) | ||
1925 | ecore_ipc_client_send(client, MAJOR, OP_SHM_REF, | ||
1926 | ee->w, ee->h, ee->alpha, | ||
1927 | extn->file.shmfile->file, | ||
1928 | strlen(extn->file.shmfile->file) + 1); | ||
1929 | } | ||
1930 | } | ||
1931 | |||
1932 | static const Ecore_Evas_Engine_Func _ecore_extn_socket_engine_func = | ||
1933 | { | ||
1934 | _ecore_evas_extn_free, | ||
1935 | NULL, | ||
1936 | NULL, | ||
1937 | NULL, | ||
1938 | NULL, | ||
1939 | NULL, | ||
1940 | NULL, | ||
1941 | NULL, | ||
1942 | NULL, | ||
1943 | NULL, | ||
1944 | NULL, | ||
1945 | NULL, | ||
1946 | NULL, | ||
1947 | NULL, | ||
1948 | NULL, | ||
1949 | NULL, | ||
1950 | NULL, | ||
1951 | _ecore_evas_socket_resize, | ||
1952 | _ecore_evas_socket_move_resize, | ||
1953 | NULL, | ||
1954 | NULL, | ||
1955 | NULL, | ||
1956 | NULL, | ||
1957 | NULL, | ||
1958 | NULL, | ||
1959 | NULL, | ||
1960 | NULL, | ||
1961 | NULL, | ||
1962 | NULL, | ||
1963 | NULL, | ||
1964 | NULL, | ||
1965 | NULL, | ||
1966 | NULL, | ||
1967 | NULL, | ||
1968 | NULL, | ||
1969 | NULL, | ||
1970 | NULL, | ||
1971 | NULL, | ||
1972 | NULL, | ||
1973 | NULL, | ||
1974 | NULL, | ||
1975 | NULL, | ||
1976 | NULL, | ||
1977 | NULL, | ||
1978 | _ecore_evas_extn_socket_alpha_set, | ||
1979 | NULL, //transparent | ||
1980 | |||
1981 | _ecore_evas_extn_socket_render, // render | ||
1982 | NULL // screen_geometry_get | ||
1983 | }; | ||
1984 | |||
1985 | #endif | ||
1986 | |||
1987 | EAPI Ecore_Evas * | ||
1988 | ecore_evas_extn_socket_new(int w, int h) | ||
1989 | { | ||
1990 | #ifdef EXTN_ENABLED | ||
1991 | Evas_Engine_Info_Buffer *einfo; | ||
1992 | Ecore_Evas *ee; | ||
1993 | int rmethod; | ||
1994 | |||
1995 | rmethod = evas_render_method_lookup("buffer"); | ||
1996 | if (!rmethod) return NULL; | ||
1997 | ee = calloc(1, sizeof(Ecore_Evas)); | ||
1998 | if (!ee) return NULL; | ||
1999 | |||
2000 | ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS); | ||
2001 | |||
2002 | ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_extn_socket_engine_func; | ||
2003 | |||
2004 | ee->driver = "extn_socket"; | ||
2005 | |||
2006 | ee->rotation = 0; | ||
2007 | ee->visible = 0; | ||
2008 | ee->w = w; | ||
2009 | ee->h = h; | ||
2010 | ee->req.w = ee->w; | ||
2011 | ee->req.h = ee->h; | ||
2012 | |||
2013 | ee->prop.max.w = 0; | ||
2014 | ee->prop.max.h = 0; | ||
2015 | ee->prop.layer = 0; | ||
2016 | ee->prop.focused = 0; | ||
2017 | ee->prop.borderless = 1; | ||
2018 | ee->prop.override = 1; | ||
2019 | ee->prop.maximized = 0; | ||
2020 | ee->prop.fullscreen = 0; | ||
2021 | ee->prop.withdrawn = 0; | ||
2022 | ee->prop.sticky = 0; | ||
2023 | |||
2024 | /* init evas here */ | ||
2025 | ee->evas = evas_new(); | ||
2026 | evas_data_attach_set(ee->evas, ee); | ||
2027 | evas_output_method_set(ee->evas, rmethod); | ||
2028 | evas_output_size_set(ee->evas, w, h); | ||
2029 | evas_output_viewport_set(ee->evas, 0, 0, w, h); | ||
2030 | |||
2031 | einfo = (Evas_Engine_Info_Buffer *)evas_engine_info_get(ee->evas); | ||
2032 | if (einfo) | ||
2033 | { | ||
2034 | if (ee->alpha) | ||
2035 | einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_ARGB32; | ||
2036 | else | ||
2037 | einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_RGB32; | ||
2038 | einfo->info.dest_buffer = NULL; | ||
2039 | einfo->info.dest_buffer_row_bytes = 0; | ||
2040 | einfo->info.use_color_key = 0; | ||
2041 | einfo->info.alpha_threshold = 0; | ||
2042 | einfo->info.func.new_update_region = NULL; | ||
2043 | einfo->info.func.free_update_region = NULL; | ||
2044 | if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) | ||
2045 | { | ||
2046 | ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); | ||
2047 | ecore_evas_free(ee); | ||
2048 | return NULL; | ||
2049 | } | ||
2050 | } | ||
2051 | else | ||
2052 | { | ||
2053 | ERR("evas_engine_info_set() init engine '%s' failed.", ee->driver); | ||
2054 | ecore_evas_free(ee); | ||
2055 | return NULL; | ||
2056 | } | ||
2057 | evas_key_modifier_add(ee->evas, "Shift"); | ||
2058 | evas_key_modifier_add(ee->evas, "Control"); | ||
2059 | evas_key_modifier_add(ee->evas, "Alt"); | ||
2060 | evas_key_modifier_add(ee->evas, "Meta"); | ||
2061 | evas_key_modifier_add(ee->evas, "Hyper"); | ||
2062 | evas_key_modifier_add(ee->evas, "Super"); | ||
2063 | evas_key_lock_add(ee->evas, "Caps_Lock"); | ||
2064 | evas_key_lock_add(ee->evas, "Num_Lock"); | ||
2065 | evas_key_lock_add(ee->evas, "Scroll_Lock"); | ||
2066 | |||
2067 | extn_ee_list = eina_list_append(extn_ee_list, ee); | ||
2068 | |||
2069 | _ecore_evas_register(ee); | ||
2070 | |||
2071 | return ee; | ||
2072 | #else | ||
2073 | return NULL; | ||
2074 | #endif | ||
2075 | } | ||
2076 | |||
2077 | EAPI Eina_Bool | ||
2078 | ecore_evas_extn_socket_listen(Ecore_Evas *ee, const char *svcname, int svcnum, Eina_Bool svcsys) | ||
2079 | { | ||
2080 | #ifdef EXTN_ENABLED | ||
2081 | Extn *extn; | ||
2082 | |||
2083 | extn = calloc(1, sizeof(Extn)); | ||
2084 | if (!extn) | ||
2085 | { | ||
2086 | return EINA_FALSE; | ||
2087 | } | ||
2088 | else | ||
2089 | { | ||
2090 | Ecore_Ipc_Type ipctype = ECORE_IPC_LOCAL_USER; | ||
2091 | char buf[PATH_MAX]; | ||
2092 | |||
2093 | ecore_ipc_init(); | ||
2094 | extn->svc.name = eina_stringshare_add(svcname); | ||
2095 | extn->svc.num = svcnum; | ||
2096 | extn->svc.sys = svcsys; | ||
2097 | |||
2098 | snprintf(buf, sizeof(buf), "/tmp/ee-lock-XXXXXX"); | ||
2099 | extn->file.lockfd = mkstemp(buf); | ||
2100 | if (extn->file.lockfd >= 0) | ||
2101 | extn->file.lock = eina_stringshare_add(buf); | ||
2102 | if ((extn->file.lockfd < 0) || (!extn->file.lock)) | ||
2103 | { | ||
2104 | if (extn->file.lockfd) | ||
2105 | { | ||
2106 | close(extn->file.lockfd); | ||
2107 | unlink(buf); | ||
2108 | } | ||
2109 | eina_stringshare_del(extn->svc.name); | ||
2110 | if (extn->file.lock) eina_stringshare_del(extn->file.lock); | ||
2111 | free(extn); | ||
2112 | ecore_ipc_shutdown(); | ||
2113 | return EINA_FALSE; | ||
2114 | } | ||
2115 | |||
2116 | if (extn->svc.sys) ipctype = ECORE_IPC_LOCAL_SYSTEM; | ||
2117 | extn->ipc.am_server = EINA_TRUE; | ||
2118 | extn->ipc.server = ecore_ipc_server_add(ipctype, | ||
2119 | (char *)extn->svc.name, | ||
2120 | extn->svc.num, ee); | ||
2121 | if (!extn->ipc.server) | ||
2122 | { | ||
2123 | if (extn->file.lockfd) | ||
2124 | { | ||
2125 | close(extn->file.lockfd); | ||
2126 | if (extn->file.lock) unlink(extn->file.lock); | ||
2127 | } | ||
2128 | eina_stringshare_del(extn->svc.name); | ||
2129 | eina_stringshare_del(extn->file.lock); | ||
2130 | free(extn); | ||
2131 | ecore_ipc_shutdown(); | ||
2132 | return EINA_FALSE; | ||
2133 | } | ||
2134 | ee->engine.buffer.data = extn; | ||
2135 | extn->ipc.handlers = eina_list_append | ||
2136 | (extn->ipc.handlers, | ||
2137 | ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_ADD, | ||
2138 | _ipc_client_add, ee)); | ||
2139 | extn->ipc.handlers = eina_list_append | ||
2140 | (extn->ipc.handlers, | ||
2141 | ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_DEL, | ||
2142 | _ipc_client_del, ee)); | ||
2143 | extn->ipc.handlers = eina_list_append | ||
2144 | (extn->ipc.handlers, | ||
2145 | ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_DATA, | ||
2146 | _ipc_client_data, ee)); | ||
2147 | } | ||
2148 | return EINA_TRUE; | ||
2149 | #else | ||
2150 | return EINA_FALSE; | ||
2151 | #endif | ||
2152 | } | ||