11 #ifdef HAVE_SYS_MMAN_H
12 # include <sys/mman.h>
21 #include "ecore_private.h"
22 #include <Ecore_Input.h>
24 #ifdef BUILD_ECORE_EVAS_EXTN
26 #include <Ecore_Ipc.h>
30 #include "ecore_evas_private.h"
31 #include "Ecore_Evas.h"
34 #ifdef BUILD_ECORE_EVAS_EXTN
37 typedef struct _Shmfile Shmfile;
47 static int blank = 0x00000000;
50 shmfile_new(const char *base, int id, int size, Eina_Bool sys)
55 sf = calloc(1, sizeof(Shmfile));
60 snprintf(file, sizeof(file), "/%s-%i-%i.%i.%i",
61 base, id, (int)time(NULL), (int)getpid(), (int)rand());
62 mode = S_IRUSR | S_IWUSR;
63 if (sys) mode |= S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
64 sf->fd = shm_open(file, O_RDWR | O_CREAT | O_EXCL, mode);
68 sf->file = eina_stringshare_add(file);
73 eina_stringshare_del(sf->file);
78 if (ftruncate(sf->fd, size) < 0)
82 eina_stringshare_del(sf->file);
86 sf->addr = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, sf->fd, 0);
87 if (sf->addr == MAP_FAILED)
91 eina_stringshare_del(sf->file);
99 shmfile_free(Shmfile *sf)
101 munmap(sf->addr, sf->size);
103 shm_unlink(sf->file);
104 eina_stringshare_del(sf->file);
109 shmfile_open(const char *ref, int size, Eina_Bool sys)
114 sf = calloc(1, sizeof(Shmfile));
115 mode = S_IRUSR | S_IWUSR;
116 if (sys) mode |= S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
117 sf->fd = shm_open(ref, O_RDWR, mode);
123 sf->file = eina_stringshare_add(ref);
127 eina_stringshare_del(sf->file);
132 sf->addr = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, sf->fd, 0);
133 if (sf->addr == MAP_FAILED)
136 eina_stringshare_del(sf->file);
144 shmfile_close(Shmfile *sf)
146 munmap(sf->addr, sf->size);
148 eina_stringshare_del(sf->file);
152 // procotol version - change this as needed
182 MOD_SHIFT = (1 << 0),
186 MOD_HYPER = (1 << 4),
187 MOD_SUPER = (1 << 5),
190 MOD_SCROLL = (1 << 8),
193 typedef struct _Ipc_Data_Resize Ipc_Data_Resize;
194 typedef struct _Ipc_Data_Update Ipc_Data_Update;
195 typedef struct _Ipc_Data_Ev_Mouse_In Ipc_Data_Ev_Mouse_In;
196 typedef struct _Ipc_Data_Ev_Mouse_Out Ipc_Data_Ev_Mouse_Out;
197 typedef struct _Ipc_Data_Ev_Mouse_Up Ipc_Data_Ev_Mouse_Up;
198 typedef struct _Ipc_Data_Ev_Mouse_Down Ipc_Data_Ev_Mouse_Down;
199 typedef struct _Ipc_Data_Ev_Mouse_Move Ipc_Data_Ev_Mouse_Move;
200 typedef struct _Ipc_Data_Ev_Mouse_Wheel Ipc_Data_Ev_Mouse_Wheel;
201 typedef struct _Ipc_Data_Ev_Hold Ipc_Data_Ev_Hold;
202 typedef struct _Ipc_Data_Ev_Multi_Up Ipc_Data_Ev_Multi_Up;
203 typedef struct _Ipc_Data_Ev_Multi_Down Ipc_Data_Ev_Multi_Down;
204 typedef struct _Ipc_Data_Ev_Multi_Move Ipc_Data_Ev_Multi_Move;
205 typedef struct _Ipc_Data_Ev_Key_Up Ipc_Data_Ev_Key_Up;
206 typedef struct _Ipc_Data_Ev_Key_Down Ipc_Data_Ev_Key_Down;
208 struct _Ipc_Data_Resize
213 struct _Ipc_Data_Update
218 struct _Ipc_Data_Ev_Mouse_In
220 unsigned int timestamp;
222 Evas_Event_Flags event_flags;
225 struct _Ipc_Data_Ev_Mouse_Out
227 unsigned int timestamp;
229 Evas_Event_Flags event_flags;
232 struct _Ipc_Data_Ev_Mouse_Up
235 Evas_Button_Flags flags;
237 unsigned int timestamp;
238 Evas_Event_Flags event_flags;
241 struct _Ipc_Data_Ev_Mouse_Down
244 Evas_Button_Flags flags;
246 unsigned int timestamp;
247 Evas_Event_Flags event_flags;
250 struct _Ipc_Data_Ev_Mouse_Move
253 Evas_Button_Flags flags;
255 unsigned int timestamp;
256 Evas_Event_Flags event_flags;
259 struct _Ipc_Data_Ev_Mouse_Wheel
262 Evas_Button_Flags flags;
264 unsigned int timestamp;
265 Evas_Event_Flags event_flags;
268 struct _Ipc_Data_Ev_Hold
271 unsigned int timestamp;
272 Evas_Event_Flags event_flags;
275 struct _Ipc_Data_Ev_Multi_Up
277 Evas_Button_Flags flags;
279 double rad, radx, rady, pres, ang, fx, fy;
281 unsigned int timestamp;
282 Evas_Event_Flags event_flags;
285 struct _Ipc_Data_Ev_Multi_Down
287 Evas_Button_Flags flags;
289 double rad, radx, rady, pres, ang, fx, fy;
291 unsigned int timestamp;
292 Evas_Event_Flags event_flags;
295 struct _Ipc_Data_Ev_Multi_Move
298 double rad, radx, rady, pres, ang, fx, fy;
300 unsigned int timestamp;
301 Evas_Event_Flags event_flags;
304 struct _Ipc_Data_Ev_Key_Up
306 const char *keyname, *key, *string, *compose;
308 unsigned int timestamp;
309 Evas_Event_Flags event_flags;
312 struct _Ipc_Data_Ev_Key_Down
314 const char *keyname, *key, *string, *compose;
316 unsigned int timestamp;
317 Evas_Event_Flags event_flags;
320 typedef struct _Extn Extn;
325 Ecore_Ipc_Server *server;
328 Eina_Bool am_server : 1;
342 Eina_Bool have_lock : 1;
346 static Eina_List *extn_ee_list = NULL;
348 EAPI int ECORE_EVAS_EXTN_CLIENT_ADD = 0;
349 EAPI int ECORE_EVAS_EXTN_CLIENT_DEL = 0;
352 _ecore_evas_extn_init(void)
354 if (ECORE_EVAS_EXTN_CLIENT_ADD) return;
355 ECORE_EVAS_EXTN_CLIENT_ADD = ecore_event_type_new();
356 ECORE_EVAS_EXTN_CLIENT_DEL = ecore_event_type_new();
360 _ecore_evas_extn_shutdown(void)
365 _ecore_evas_extn_event_free(void *data, void *ev __UNUSED__)
367 Ecore_Evas *ee = data;
368 if (ee->engine.buffer.image)
369 evas_object_unref(ee->engine.buffer.image);
370 _ecore_evas_unref(ee);
374 _ecore_evas_extn_event(Ecore_Evas *ee, int event)
377 if (ee->engine.buffer.image)
378 evas_object_ref(ee->engine.buffer.image);
379 ecore_event_add(event, ee->engine.buffer.image,
380 _ecore_evas_extn_event_free, ee);
384 _ecore_evas_socket_lock(Ecore_Evas *ee)
388 extn = ee->engine.buffer.data;
390 if (extn->file.lockfd < 0) return;
391 if (extn->file.have_lock) return;
392 flock(extn->file.lockfd, LOCK_EX);
393 extn->file.have_lock = EINA_TRUE;
397 _ecore_evas_socket_unlock(Ecore_Evas *ee)
401 extn = ee->engine.buffer.data;
403 if (extn->file.lockfd < 0) return;
404 if (!extn->file.have_lock) return;
405 flock(extn->file.lockfd, LOCK_UN);
406 extn->file.have_lock = EINA_FALSE;
410 _ecore_evas_extn_plug_targer_render_pre(void *data, Evas *e __UNUSED__, void *event_info __UNUSED__)
412 Ecore_Evas *ee = data;
413 if (ee) _ecore_evas_socket_lock(ee);
417 _ecore_evas_extn_plug_targer_render_post(void *data, Evas *e __UNUSED__, void *event_info __UNUSED__)
419 Ecore_Evas *ee = data;
420 if (ee) _ecore_evas_socket_unlock(ee);
424 _ecore_evas_extn_plug_image_obj_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
426 Ecore_Evas *ee = data;
427 if (ee) ecore_evas_free(ee);
431 _ecore_evas_extn_coord_translate(Ecore_Evas *ee, Evas_Coord *x, Evas_Coord *y)
433 Evas_Coord xx, yy, ww, hh, fx, fy, fw, fh;
435 evas_object_geometry_get(ee->engine.buffer.image, &xx, &yy, &ww, &hh);
436 evas_object_image_fill_get(ee->engine.buffer.image, &fx, &fy, &fw, &fh);
441 if (evas_object_map_get(ee->engine.buffer.image) &&
442 evas_object_map_enable_get(ee->engine.buffer.image))
445 fw = ee->w; fh = ee->h;
446 ww = ee->w; hh = ee->h;
449 if ((fx == 0) && (fy == 0) && (fw == ww) && (fh == hh))
451 *x = (ee->w * (*x - xx)) / fw;
452 *y = (ee->h * (*y - yy)) / fh;
457 while (xx < 0) xx += fw;
458 while (xx > fw) xx -= fw;
459 *x = (ee->w * xx) / fw;
462 while (yy < 0) yy += fh;
463 while (yy > fh) yy -= fh;
464 *y = (ee->h * yy) / fh;
469 _ecore_evas_extn_free(Ecore_Evas *ee)
472 Ecore_Ipc_Client *client;
474 extn = ee->engine.buffer.data;
477 Ecore_Event_Handler *hdl;
479 if (extn->file.have_lock)
480 _ecore_evas_socket_unlock(ee);
481 if (extn->file.lockfd)
483 close(extn->file.lockfd);
484 if (extn->ipc.am_server)
486 if (extn->file.lock) unlink(extn->file.lock);
489 if (extn->svc.name) eina_stringshare_del(extn->svc.name);
490 if (extn->ipc.clients)
492 EINA_LIST_FREE(extn->ipc.clients, client)
493 ecore_ipc_client_del(client);
495 if (extn->ipc.server) ecore_ipc_server_del(extn->ipc.server);
496 if (extn->file.lock) eina_stringshare_del(extn->file.lock);
497 if (extn->file.shm) eina_stringshare_del(extn->file.shm);
498 if (extn->file.shmfile)
500 if (extn->ipc.am_server)
501 shmfile_free(extn->file.shmfile);
503 shmfile_close(extn->file.shmfile);
506 EINA_LIST_FREE(extn->ipc.handlers, hdl)
507 ecore_event_handler_del(hdl);
509 ecore_ipc_shutdown();
510 ee->engine.buffer.data = NULL;
512 if (ee->engine.buffer.image)
516 evas_object_event_callback_del_full(ee->engine.buffer.image,
518 _ecore_evas_extn_plug_image_obj_del,
520 evas_event_callback_del_full(evas_object_evas_get(ee->engine.buffer.image),
521 EVAS_CALLBACK_RENDER_PRE,
522 _ecore_evas_extn_plug_targer_render_pre,
524 evas_event_callback_del_full(evas_object_evas_get(ee->engine.buffer.image),
525 EVAS_CALLBACK_RENDER_POST,
526 _ecore_evas_extn_plug_targer_render_post,
528 evas_object_del(ee->engine.buffer.image);
529 ee2 = evas_object_data_get(ee->engine.buffer.image, "Ecore_Evas_Parent");
532 ee2->sub_ecore_evas = eina_list_remove(ee2->sub_ecore_evas, ee);
535 extn_ee_list = eina_list_remove(extn_ee_list, ee);
539 _ecore_evas_resize(Ecore_Evas *ee, int w, int h)
545 if ((w == ee->w) && (h == ee->h)) return;
550 * No need for it if not used later.
553 extn = ee->engine.buffer.data;
555 if (ee->engine.buffer.image)
556 evas_object_image_size_set(ee->engine.buffer.image, ee->w, ee->h);
557 /* Server can have many plugs, so I block resize comand from client to server *
558 if ((extn) && (extn->ipc.server))
564 ecore_ipc_server_send(extn->ipc.server, MAJOR, OP_RESIZE, 0, 0, 0, &ipc, sizeof(ipc));
566 if (ee->func.fn_resize) ee->func.fn_resize(ee);
570 _ecore_evas_move_resize(Ecore_Evas *ee, int x __UNUSED__, int y __UNUSED__, int w, int h)
572 _ecore_evas_resize(ee, w, h);
576 _ecore_evas_modifiers_locks_mask_get(Evas *e)
580 if (evas_key_modifier_is_set(evas_key_modifier_get(e), "Shift"))
582 if (evas_key_modifier_is_set(evas_key_modifier_get(e), "Control"))
584 if (evas_key_modifier_is_set(evas_key_modifier_get(e), "Alt"))
586 if (evas_key_modifier_is_set(evas_key_modifier_get(e), "Meta"))
588 if (evas_key_modifier_is_set(evas_key_modifier_get(e), "Hyper"))
590 if (evas_key_modifier_is_set(evas_key_modifier_get(e), "Super"))
592 if (evas_key_lock_is_set(evas_key_lock_get(e), "Scroll_Lock"))
594 if (evas_key_lock_is_set(evas_key_lock_get(e), "Num_Lock"))
596 if (evas_key_lock_is_set(evas_key_lock_get(e), "Caps_Lock"))
602 _ecore_evas_modifiers_locks_mask_set(Evas *e, int mask)
604 if (mask & MOD_SHIFT) evas_key_modifier_on (e, "Shift");
605 else evas_key_modifier_off(e, "Shift");
606 if (mask & MOD_CTRL) evas_key_modifier_on (e, "Control");
607 else evas_key_modifier_off(e, "Control");
608 if (mask & MOD_ALT) evas_key_modifier_on (e, "Alt");
609 else evas_key_modifier_off(e, "Alt");
610 if (mask & MOD_META) evas_key_modifier_on (e, "Meta");
611 else evas_key_modifier_off(e, "Meta");
612 if (mask & MOD_HYPER) evas_key_modifier_on (e, "Hyper");
613 else evas_key_modifier_off(e, "Hyper");
614 if (mask & MOD_SUPER) evas_key_modifier_on (e, "Super");
615 else evas_key_modifier_off(e, "Super");
616 if (mask & MOD_SCROLL) evas_key_lock_on (e, "Scroll_Lock");
617 else evas_key_lock_off(e, "Scroll_Lock");
618 if (mask & MOD_NUM) evas_key_lock_on (e, "Num_Lock");
619 else evas_key_lock_off(e, "Num_Lock");
620 if (mask & MOD_CAPS) evas_key_lock_on (e, "Caps_Lock");
621 else evas_key_lock_off(e, "Caps_Lock");
625 _ecore_evas_extn_cb_mouse_in(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
627 Ecore_Evas *ee = data;
628 Evas_Event_Mouse_In *ev = event_info;
631 extn = ee->engine.buffer.data;
633 if (extn->ipc.server)
635 Ipc_Data_Ev_Mouse_In ipc;
637 ipc.timestamp = ev->timestamp;
638 ipc.mask = _ecore_evas_modifiers_locks_mask_get(ee->evas);
639 ipc.event_flags = ev->event_flags;
640 ecore_ipc_server_send(extn->ipc.server, MAJOR, OP_EV_MOUSE_IN, 0, 0, 0, &ipc, sizeof(ipc));
645 _ecore_evas_extn_cb_mouse_out(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
647 Ecore_Evas *ee = data;
648 Evas_Event_Mouse_Out *ev = event_info;
651 extn = ee->engine.buffer.data;
653 if (extn->ipc.server)
655 Ipc_Data_Ev_Mouse_Out ipc;
657 ipc.timestamp = ev->timestamp;
658 ipc.mask = _ecore_evas_modifiers_locks_mask_get(ee->evas);
659 ipc.event_flags = ev->event_flags;
660 ecore_ipc_server_send(extn->ipc.server, MAJOR, OP_EV_MOUSE_OUT, 0, 0, 0, &ipc, sizeof(ipc));
665 _ecore_evas_extn_cb_mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
667 Ecore_Evas *ee = data;
668 Evas_Event_Mouse_Down *ev = event_info;
671 extn = ee->engine.buffer.data;
673 if (extn->ipc.server)
675 /* We have send mouse move event before mouse down event */
677 Ipc_Data_Ev_Mouse_Move ipc_move;
682 _ecore_evas_extn_coord_translate(ee, &x, &y);
685 ipc_move.timestamp = ev->timestamp;
686 ipc_move.mask = _ecore_evas_modifiers_locks_mask_get(ee->evas);
687 ipc_move.event_flags = ev->event_flags;
688 ecore_ipc_server_send(extn->ipc.server, MAJOR, OP_EV_MOUSE_MOVE, 0, 0, 0, &ipc_move, sizeof(ipc_move));
691 Ipc_Data_Ev_Mouse_Down ipc;
693 ipc.flags = ev->flags;
694 ipc.timestamp = ev->timestamp;
695 ipc.mask = _ecore_evas_modifiers_locks_mask_get(ee->evas);
696 ipc.event_flags = ev->event_flags;
697 ecore_ipc_server_send(extn->ipc.server, MAJOR, OP_EV_MOUSE_DOWN, 0, 0, 0, &ipc, sizeof(ipc));
703 _ecore_evas_extn_cb_mouse_up(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
705 Ecore_Evas *ee = data;
706 Evas_Event_Mouse_Up *ev = event_info;
709 extn = ee->engine.buffer.data;
711 if (extn->ipc.server)
713 Ipc_Data_Ev_Mouse_Up ipc;
716 ipc.flags = ev->flags;
717 ipc.timestamp = ev->timestamp;
718 ipc.mask = _ecore_evas_modifiers_locks_mask_get(ee->evas);
719 ipc.event_flags = ev->event_flags;
720 ecore_ipc_server_send(extn->ipc.server, MAJOR, OP_EV_MOUSE_UP, 0, 0, 0, &ipc, sizeof(ipc));
725 _ecore_evas_extn_cb_mouse_move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
727 Ecore_Evas *ee = data;
728 Evas_Event_Mouse_Move *ev = event_info;
731 extn = ee->engine.buffer.data;
733 if (extn->ipc.server)
735 Ipc_Data_Ev_Mouse_Move ipc;
738 x = ev->cur.canvas.x;
739 y = ev->cur.canvas.y;
740 _ecore_evas_extn_coord_translate(ee, &x, &y);
743 ipc.timestamp = ev->timestamp;
744 ipc.mask = _ecore_evas_modifiers_locks_mask_get(ee->evas);
745 ipc.event_flags = ev->event_flags;
746 ecore_ipc_server_send(extn->ipc.server, MAJOR, OP_EV_MOUSE_MOVE, 0, 0, 0, &ipc, sizeof(ipc));
751 _ecore_evas_extn_cb_mouse_wheel(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
753 Ecore_Evas *ee = data;
754 Evas_Event_Mouse_Wheel *ev = event_info;
757 extn = ee->engine.buffer.data;
759 if (extn->ipc.server)
761 Ipc_Data_Ev_Mouse_Wheel ipc;
763 ipc.direction = ev->direction;
765 ipc.timestamp = ev->timestamp;
766 ipc.mask = _ecore_evas_modifiers_locks_mask_get(ee->evas);
767 ipc.event_flags = ev->event_flags;
768 ecore_ipc_server_send(extn->ipc.server, MAJOR, OP_EV_MOUSE_WHEEL, 0, 0, 0, &ipc, sizeof(ipc));
773 _ecore_evas_extn_cb_multi_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
775 Ecore_Evas *ee = data;
776 Evas_Event_Multi_Down *ev = event_info;
779 extn = ee->engine.buffer.data;
781 if (extn->ipc.server)
783 Ipc_Data_Ev_Multi_Down ipc;
789 _ecore_evas_extn_coord_translate(ee, &x, &y);
792 ipc.rad = ev->radius;
793 ipc.radx = ev->radius_x;
794 ipc.rady = ev->radius_y;
795 ipc.pres = ev->pressure;
797 ipc.fx = ev->canvas.xsub;
798 ipc.fy = ev->canvas.ysub;
799 ipc.flags = ev->flags;
800 ipc.timestamp = ev->timestamp;
801 ipc.mask = _ecore_evas_modifiers_locks_mask_get(ee->evas);
802 ipc.event_flags = ev->event_flags;
803 ecore_ipc_server_send(extn->ipc.server, MAJOR, OP_EV_MULTI_DOWN, 0, 0, 0, &ipc, sizeof(ipc));
809 _ecore_evas_extn_cb_multi_up(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
811 Ecore_Evas *ee = data;
812 Evas_Event_Multi_Up *ev = event_info;
815 extn = ee->engine.buffer.data;
817 if (extn->ipc.server)
819 Ipc_Data_Ev_Multi_Up ipc;
825 _ecore_evas_extn_coord_translate(ee, &x, &y);
828 ipc.rad = ev->radius;
829 ipc.radx = ev->radius_x;
830 ipc.rady = ev->radius_y;
831 ipc.pres = ev->pressure;
833 ipc.fx = ev->canvas.xsub;
834 ipc.fy = ev->canvas.ysub;
835 ipc.flags = ev->flags;
836 ipc.timestamp = ev->timestamp;
837 ipc.mask = _ecore_evas_modifiers_locks_mask_get(ee->evas);
838 ipc.event_flags = ev->event_flags;
839 ecore_ipc_server_send(extn->ipc.server, MAJOR, OP_EV_MULTI_UP, 0, 0, 0, &ipc, sizeof(ipc));
844 _ecore_evas_extn_cb_multi_move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
846 Ecore_Evas *ee = data;
847 Evas_Event_Multi_Move *ev = event_info;
850 extn = ee->engine.buffer.data;
852 if (extn->ipc.server)
854 Ipc_Data_Ev_Multi_Move ipc;
858 x = ev->cur.canvas.x;
859 y = ev->cur.canvas.y;
860 _ecore_evas_extn_coord_translate(ee, &x, &y);
863 ipc.rad = ev->radius;
864 ipc.radx = ev->radius_x;
865 ipc.rady = ev->radius_y;
866 ipc.pres = ev->pressure;
868 ipc.fx = ev->cur.canvas.xsub;
869 ipc.fy = ev->cur.canvas.ysub;
870 ipc.timestamp = ev->timestamp;
871 ipc.mask = _ecore_evas_modifiers_locks_mask_get(ee->evas);
872 ipc.event_flags = ev->event_flags;
873 ecore_ipc_server_send(extn->ipc.server, MAJOR, OP_EV_MULTI_MOVE, 0, 0, 0, &ipc, sizeof(ipc));
878 _ecore_evas_extn_cb_free(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
883 if (ee->driver) _ecore_evas_free(ee);
887 _ecore_evas_extn_cb_key_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
889 Ecore_Evas *ee = data;
890 Evas_Event_Key_Down *ev = event_info;
893 extn = ee->engine.buffer.data;
895 if (extn->ipc.server)
897 Ipc_Data_Ev_Key_Down *ipc;
901 len = sizeof(Ipc_Data_Ev_Key_Down);
902 if (ev->key) len += strlen(ev->key) + 1;
903 if (ev->keyname) len += strlen(ev->keyname) + 1;
904 if (ev->string) len += strlen(ev->string) + 1;
905 if (ev->compose) len += strlen(ev->compose) + 1;
908 ipc = (Ipc_Data_Ev_Key_Down *)st;
910 p = st + sizeof(Ipc_Data_Ev_Key_Down);
914 ipc->key = p - (long)st;
919 strcpy(p, ev->keyname);
920 ipc->keyname = p - (long)st;
925 strcpy(p, ev->string);
926 ipc->string = p - (long)st;
931 strcpy(p, ev->compose);
932 ipc->compose = p - (long)st;
935 ipc->timestamp = ev->timestamp;
936 ipc->mask = _ecore_evas_modifiers_locks_mask_get(ee->evas);
937 ipc->event_flags = ev->event_flags;
938 ecore_ipc_server_send(extn->ipc.server, MAJOR, OP_EV_KEY_DOWN, 0, 0, 0, ipc, len);
943 _ecore_evas_extn_cb_key_up(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
945 Ecore_Evas *ee = data;
946 Evas_Event_Key_Up *ev = event_info;
949 extn = ee->engine.buffer.data;
951 if (extn->ipc.server)
953 Ipc_Data_Ev_Key_Up *ipc;
957 len = sizeof(Ipc_Data_Ev_Key_Up);
958 if (ev->key) len += strlen(ev->key) + 1;
959 if (ev->keyname) len += strlen(ev->keyname) + 1;
960 if (ev->string) len += strlen(ev->string) + 1;
961 if (ev->compose) len += strlen(ev->compose) + 1;
964 ipc = (Ipc_Data_Ev_Key_Up *)st;
966 p = st + sizeof(Ipc_Data_Ev_Key_Down);
970 ipc->key = p - (long)st;
975 strcpy(p, ev->keyname);
976 ipc->keyname = p - (long)st;
981 strcpy(p, ev->string);
982 ipc->string = p - (long)st;
987 strcpy(p, ev->compose);
988 ipc->compose = p - (long)st;
991 ipc->timestamp = ev->timestamp;
992 ipc->mask = _ecore_evas_modifiers_locks_mask_get(ee->evas);
993 ipc->event_flags = ev->event_flags;
994 ecore_ipc_server_send(extn->ipc.server, MAJOR, OP_EV_KEY_UP, 0, 0, 0, ipc, len);
999 _ecore_evas_extn_cb_hold(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1001 Ecore_Evas *ee = data;
1002 Evas_Event_Hold *ev = event_info;
1005 extn = ee->engine.buffer.data;
1007 if (extn->ipc.server)
1009 Ipc_Data_Ev_Hold ipc;
1011 ipc.hold = ev->hold;
1012 ipc.timestamp = ev->timestamp;
1013 ipc.event_flags = ev->event_flags;
1014 ecore_ipc_server_send(extn->ipc.server, MAJOR, OP_EV_HOLD, 0, 0, 0, &ipc, sizeof(ipc));
1019 _ecore_evas_extn_cb_focus_in(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1025 ee->prop.focused = 1;
1026 extn = ee->engine.buffer.data;
1028 if (!extn->ipc.server) return;
1029 ecore_ipc_server_send(extn->ipc.server, MAJOR, OP_FOCUS, 0, 0, 0, NULL, 0);
1033 _ecore_evas_extn_cb_focus_out(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1039 ee->prop.focused = 0;
1040 extn = ee->engine.buffer.data;
1042 if (!extn->ipc.server) return;
1043 ecore_ipc_server_send(extn->ipc.server, MAJOR, OP_UNFOCUS, 0, 0, 0, NULL, 0);
1047 _ecore_evas_extn_cb_show(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1054 extn = ee->engine.buffer.data;
1056 if (!extn->ipc.server) return;
1057 ecore_ipc_server_send(extn->ipc.server, MAJOR, OP_SHOW, 0, 0, 0, NULL, 0);
1061 _ecore_evas_extn_cb_hide(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1068 extn = ee->engine.buffer.data;
1070 if (!extn->ipc.server) return;
1071 ecore_ipc_server_send(extn->ipc.server, MAJOR, OP_HIDE, 0, 0, 0, NULL, 0);
1074 static const Ecore_Evas_Engine_Func _ecore_extn_plug_engine_func =
1076 _ecore_evas_extn_free,
1094 _ecore_evas_move_resize,
1131 NULL // screen_geometry_get
1135 _ipc_server_add(void *data, int type __UNUSED__, void *event)
1137 Ecore_Ipc_Event_Server_Add *e = event;
1138 Ecore_Evas *ee = data;
1141 if (ee != ecore_ipc_server_data_get(e->server))
1142 return ECORE_CALLBACK_PASS_ON;
1143 if (!eina_list_data_find(extn_ee_list, ee))
1144 return ECORE_CALLBACK_PASS_ON;
1145 extn = ee->engine.buffer.data;
1146 if (!extn) return ECORE_CALLBACK_PASS_ON;
1147 //FIXME: find a way to let app know server there
1148 return ECORE_CALLBACK_PASS_ON;
1152 _ipc_server_del(void *data, int type __UNUSED__, void *event)
1154 Ecore_Ipc_Event_Server_Del *e = event;
1155 Ecore_Evas *ee = data;
1158 extn = ee->engine.buffer.data;
1159 if (!extn) return ECORE_CALLBACK_PASS_ON;
1160 if (extn->ipc.server != e->server) return ECORE_CALLBACK_PASS_ON;
1161 evas_object_image_data_set(ee->engine.buffer.image, NULL);
1162 ee->engine.buffer.pixels = NULL;
1163 if (extn->file.shmfile)
1165 shmfile_close(extn->file.shmfile);
1166 extn->file.shmfile = NULL;
1170 eina_stringshare_del(extn->file.shm);
1171 extn->file.shm = NULL;
1173 extn->ipc.server = NULL;
1174 if (ee->func.fn_delete_request) ee->func.fn_delete_request(ee);
1175 return ECORE_CALLBACK_PASS_ON;
1179 _ipc_server_data(void *data, int type __UNUSED__, void *event)
1181 Ecore_Ipc_Event_Server_Data *e = event;
1182 Ecore_Evas *ee = data;
1185 if (ee != ecore_ipc_server_data_get(e->server))
1186 return ECORE_CALLBACK_PASS_ON;
1187 if (!eina_list_data_find(extn_ee_list, ee))
1188 return ECORE_CALLBACK_PASS_ON;
1189 extn = ee->engine.buffer.data;
1190 if (!extn) return ECORE_CALLBACK_PASS_ON;
1191 if (e->major != MAJOR)
1192 return ECORE_CALLBACK_PASS_ON;
1196 // add rect to update list
1197 if (e->size >= (int)sizeof(Ipc_Data_Update))
1199 Ipc_Data_Update *ipc = malloc(sizeof(Ipc_Data_Update));
1202 memcpy(ipc, e->data, sizeof(Ipc_Data_Update));
1203 extn->file.updates = eina_list_append(extn->file.updates, ipc);
1207 case OP_UPDATE_DONE:
1208 // updates finished being sent - done now. frame ready
1210 Ipc_Data_Update *ipc;
1212 EINA_LIST_FREE(extn->file.updates, ipc)
1214 if (ee->engine.buffer.image)
1215 evas_object_image_data_update_add(ee->engine.buffer.image,
1222 if ((e->data) && (e->size > 0) &&
1223 (((unsigned char *)e->data)[e->size - 1] == 0))
1225 if (extn->file.lockfd) close(extn->file.lockfd);
1226 if (extn->file.lock) eina_stringshare_del(extn->file.lock);
1227 extn->file.lock = eina_stringshare_add(e->data);
1228 extn->file.lockfd = open(extn->file.lock, O_RDONLY);
1234 // e->response == alpha
1235 // e->data = shm ref string + nul byte
1236 if ((e->data) && ((unsigned char *)e->data)[e->size - 1] == 0)
1238 ee->engine.buffer.pixels = NULL;
1239 if (extn->file.shmfile)
1241 shmfile_close(extn->file.shmfile);
1242 extn->file.shmfile = NULL;
1246 eina_stringshare_del(extn->file.shm);
1247 extn->file.shm = NULL;
1249 if ((e->ref > 0) && (e->ref_to > 0))
1251 extn->file.w = e->ref;
1252 extn->file.h = e->ref_to;
1253 extn->file.shm = eina_stringshare_add(e->data);
1254 extn->file.shmfile = shmfile_open(extn->file.shm,
1258 if (extn->file.shmfile)
1260 ee->engine.buffer.pixels = extn->file.shmfile->addr;
1261 if (ee->engine.buffer.image)
1264 evas_object_image_alpha_set(ee->engine.buffer.image,
1267 evas_object_image_alpha_set(ee->engine.buffer.image,
1269 evas_object_image_size_set(ee->engine.buffer.image,
1272 evas_object_image_data_set(ee->engine.buffer.image,
1273 ee->engine.buffer.pixels);
1274 evas_object_image_data_update_add(ee->engine.buffer.image,
1278 _ecore_evas_resize(ee,
1283 evas_object_image_data_set(ee->engine.buffer.image, NULL);
1286 evas_object_image_data_set(ee->engine.buffer.image, NULL);
1289 evas_object_image_data_set(ee->engine.buffer.image, NULL);
1293 if ((e->data) && (e->size >= (int)sizeof(Ipc_Data_Resize)))
1295 Ipc_Data_Resize *ipc = e->data;
1296 _ecore_evas_resize(ee, ipc->w, ipc->h);
1302 return ECORE_CALLBACK_PASS_ON;
1306 _ecore_evas_extn_init(void)
1311 _ecore_evas_extn_shutdown(void)
1315 #endif /* BUILD_ECORE_EVAS_EXTN */
1318 ecore_evas_extn_plug_new(Ecore_Evas *ee_target)
1320 #ifdef BUILD_ECORE_EVAS_EXTN
1325 if (!ee_target) return NULL;
1327 ee = calloc(1, sizeof(Ecore_Evas));
1328 if (!ee) return NULL;
1330 o = evas_object_image_filled_add(ee_target->evas);
1331 evas_object_image_content_hint_set(o, EVAS_IMAGE_CONTENT_HINT_DYNAMIC);
1332 evas_object_image_colorspace_set(o, EVAS_COLORSPACE_ARGB8888);
1333 evas_object_image_alpha_set(o, 1);
1334 evas_object_image_size_set(o, 1, 1);
1335 evas_object_image_data_set(o, &blank);
1337 ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS);
1339 ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_extn_plug_engine_func;
1341 ee->driver = "extn_plug";
1353 ee->prop.focused = 0;
1354 ee->prop.borderless = 1;
1355 ee->prop.override = 1;
1356 ee->prop.maximized = 0;
1357 ee->prop.fullscreen = 0;
1358 ee->prop.withdrawn = 0;
1359 ee->prop.sticky = 0;
1361 ee->engine.buffer.image = o;
1362 evas_object_data_set(ee->engine.buffer.image, "Ecore_Evas", ee);
1363 evas_object_data_set(ee->engine.buffer.image, "Ecore_Evas_Parent", ee_target);
1364 evas_object_event_callback_add(ee->engine.buffer.image,
1365 EVAS_CALLBACK_MOUSE_IN,
1366 _ecore_evas_extn_cb_mouse_in, ee);
1367 evas_object_event_callback_add(ee->engine.buffer.image,
1368 EVAS_CALLBACK_MOUSE_OUT,
1369 _ecore_evas_extn_cb_mouse_out, ee);
1370 evas_object_event_callback_add(ee->engine.buffer.image,
1371 EVAS_CALLBACK_MOUSE_DOWN,
1372 _ecore_evas_extn_cb_mouse_down, ee);
1373 evas_object_event_callback_add(ee->engine.buffer.image,
1374 EVAS_CALLBACK_MOUSE_UP,
1375 _ecore_evas_extn_cb_mouse_up, ee);
1376 evas_object_event_callback_add(ee->engine.buffer.image,
1377 EVAS_CALLBACK_MOUSE_MOVE,
1378 _ecore_evas_extn_cb_mouse_move, ee);
1379 evas_object_event_callback_add(ee->engine.buffer.image,
1380 EVAS_CALLBACK_MOUSE_WHEEL,
1381 _ecore_evas_extn_cb_mouse_wheel, ee);
1382 evas_object_event_callback_add(ee->engine.buffer.image,
1383 EVAS_CALLBACK_MULTI_DOWN,
1384 _ecore_evas_extn_cb_multi_down, ee);
1385 evas_object_event_callback_add(ee->engine.buffer.image,
1386 EVAS_CALLBACK_MULTI_UP,
1387 _ecore_evas_extn_cb_multi_up, ee);
1388 evas_object_event_callback_add(ee->engine.buffer.image,
1389 EVAS_CALLBACK_MULTI_MOVE,
1390 _ecore_evas_extn_cb_multi_move, ee);
1391 evas_object_event_callback_add(ee->engine.buffer.image,
1393 _ecore_evas_extn_cb_free, ee);
1394 evas_object_event_callback_add(ee->engine.buffer.image,
1395 EVAS_CALLBACK_KEY_DOWN,
1396 _ecore_evas_extn_cb_key_down, ee);
1397 evas_object_event_callback_add(ee->engine.buffer.image,
1398 EVAS_CALLBACK_KEY_UP,
1399 _ecore_evas_extn_cb_key_up, ee);
1400 evas_object_event_callback_add(ee->engine.buffer.image,
1402 _ecore_evas_extn_cb_hold, ee);
1403 evas_object_event_callback_add(ee->engine.buffer.image,
1404 EVAS_CALLBACK_FOCUS_IN,
1405 _ecore_evas_extn_cb_focus_in, ee);
1406 evas_object_event_callback_add(ee->engine.buffer.image,
1407 EVAS_CALLBACK_FOCUS_OUT,
1408 _ecore_evas_extn_cb_focus_out, ee);
1409 evas_object_event_callback_add(ee->engine.buffer.image,
1411 _ecore_evas_extn_cb_show, ee);
1412 evas_object_event_callback_add(ee->engine.buffer.image,
1414 _ecore_evas_extn_cb_hide, ee);
1416 evas_object_event_callback_add(ee->engine.buffer.image,
1418 _ecore_evas_extn_plug_image_obj_del, ee);
1421 extn_ee_list = eina_list_append(extn_ee_list, ee);
1422 ee_target->sub_ecore_evas = eina_list_append(ee_target->sub_ecore_evas, ee);
1424 evas_event_callback_add(ee_target->evas, EVAS_CALLBACK_RENDER_PRE,
1425 _ecore_evas_extn_plug_targer_render_pre, ee);
1426 evas_event_callback_add(ee_target->evas, EVAS_CALLBACK_RENDER_POST,
1427 _ecore_evas_extn_plug_targer_render_post, ee);
1435 ecore_evas_extn_plug_connect(Evas_Object *obj, const char *svcname, int svcnum, Eina_Bool svcsys)
1437 #ifdef BUILD_ECORE_EVAS_EXTN
1439 Ecore_Evas *ee = NULL;
1441 if (!obj) return EINA_FALSE;
1443 ee = evas_object_data_get(obj, "Ecore_Evas");
1444 if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) return EINA_FALSE;
1446 extn = calloc(1, sizeof(Extn));
1447 if (!extn) return EINA_FALSE;
1449 Ecore_Ipc_Type ipctype = ECORE_IPC_LOCAL_USER;
1452 extn->svc.name = eina_stringshare_add(svcname);
1453 extn->svc.num = svcnum;
1454 extn->svc.sys = svcsys;
1456 if (extn->svc.sys) ipctype = ECORE_IPC_LOCAL_SYSTEM;
1457 extn->ipc.server = ecore_ipc_server_connect(ipctype, (char *)extn->svc.name,
1459 if (!extn->ipc.server)
1461 eina_stringshare_del(extn->svc.name);
1463 ecore_ipc_shutdown();
1466 ee->engine.buffer.data = extn;
1467 extn->ipc.handlers = eina_list_append
1468 (extn->ipc.handlers,
1469 ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_ADD,
1470 _ipc_server_add, ee));
1471 extn->ipc.handlers = eina_list_append
1472 (extn->ipc.handlers,
1473 ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_DEL,
1474 _ipc_server_del, ee));
1475 extn->ipc.handlers = eina_list_append
1476 (extn->ipc.handlers,
1477 ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_DATA,
1478 _ipc_server_data, ee));
1486 ecore_evas_extn_plug_object_data_lock(Evas_Object *obj)
1488 #ifdef BUILD_ECORE_EVAS_EXTN
1491 ee = ecore_evas_object_ecore_evas_get(obj);
1493 _ecore_evas_socket_lock(ee);
1498 ecore_evas_extn_plug_object_data_unlock(Evas_Object *obj)
1500 #ifdef BUILD_ECORE_EVAS_EXTN
1503 ee = ecore_evas_object_ecore_evas_get(obj);
1505 _ecore_evas_socket_unlock(ee);
1509 #ifdef BUILD_ECORE_EVAS_EXTN
1511 _ecore_evas_socket_resize(Ecore_Evas *ee, int w, int h)
1514 Evas_Engine_Info_Buffer *einfo;
1521 if ((w == ee->w) && (h == ee->h)) return;
1524 evas_output_size_set(ee->evas, ee->w, ee->h);
1525 evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h);
1526 evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
1527 extn = ee->engine.buffer.data;
1530 if (extn->file.shmfile)
1531 shmfile_free(extn->file.shmfile);
1532 ee->engine.buffer.pixels = NULL;
1533 extn->file.shmfile = shmfile_new(extn->svc.name, extn->svc.num,
1534 ee->w * ee->h * 4, extn->svc.sys);
1535 if (extn->file.shmfile)
1536 ee->engine.buffer.pixels = extn->file.shmfile->addr;
1539 einfo = (Evas_Engine_Info_Buffer *)evas_engine_info_get(ee->evas);
1543 einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_ARGB32;
1545 einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_RGB32;
1546 einfo->info.dest_buffer = ee->engine.buffer.pixels;
1547 einfo->info.dest_buffer_row_bytes = stride;
1548 einfo->info.use_color_key = 0;
1549 einfo->info.alpha_threshold = 0;
1550 einfo->info.func.new_update_region = NULL;
1551 einfo->info.func.free_update_region = NULL;
1552 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
1554 ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
1558 if (extn->ipc.clients && extn->file.shmfile)
1560 Ipc_Data_Resize ipc;
1562 Ecore_Ipc_Client *client;
1564 EINA_LIST_FOREACH(extn->ipc.clients, l, client)
1565 ecore_ipc_client_send(client, MAJOR, OP_SHM_REF,
1566 ee->w, ee->h, ee->alpha,
1567 extn->file.shmfile->file,
1568 strlen(extn->file.shmfile->file) + 1);
1571 EINA_LIST_FOREACH(extn->ipc.clients, l, client)
1572 ecore_ipc_client_send(client, MAJOR, OP_RESIZE,
1573 0, 0, 0, &ipc, sizeof(ipc));
1576 if (ee->func.fn_resize) ee->func.fn_resize(ee);
1580 _ecore_evas_socket_move_resize(Ecore_Evas *ee, int x __UNUSED__, int y __UNUSED__, int w, int h)
1582 _ecore_evas_socket_resize(ee, w, h);
1586 _ecore_evas_extn_socket_render(Ecore_Evas *ee)
1588 Eina_List *updates = NULL, *l, *ll;
1593 Ecore_Ipc_Client *client;
1595 extn = ee->engine.buffer.data;
1596 EINA_LIST_FOREACH(ee->sub_ecore_evas, ll, ee2)
1598 if (ee2->func.fn_pre_render) ee2->func.fn_pre_render(ee2);
1599 if (ee2->engine.func->fn_render)
1600 rend |= ee2->engine.func->fn_render(ee2);
1601 if (ee2->func.fn_post_render) ee2->func.fn_post_render(ee2);
1603 if (ee->engine.buffer.pixels)
1605 _ecore_evas_socket_lock(ee);
1606 updates = evas_render_updates(ee->evas);
1607 _ecore_evas_socket_unlock(ee);
1609 EINA_LIST_FOREACH(updates, l, r)
1611 Ipc_Data_Update ipc;
1618 EINA_LIST_FOREACH(extn->ipc.clients, ll, client)
1619 ecore_ipc_client_send(client, MAJOR, OP_UPDATE, 0, 0, 0, &ipc, sizeof(ipc));
1623 evas_render_updates_free(updates);
1624 _ecore_evas_idle_timeout_update(ee);
1625 EINA_LIST_FOREACH(extn->ipc.clients, ll, client)
1626 ecore_ipc_client_send(client, MAJOR, OP_UPDATE_DONE, 0, 0, 0, NULL, 0);
1629 return updates ? 1 : rend;
1633 _ipc_client_add(void *data, int type __UNUSED__, void *event)
1635 Ecore_Ipc_Event_Client_Add *e = event;
1636 Ecore_Evas *ee = data;
1639 if (ee != ecore_ipc_server_data_get(ecore_ipc_client_server_get(e->client)))
1640 return ECORE_CALLBACK_PASS_ON;
1641 if (!eina_list_data_find(extn_ee_list, ee))
1642 return ECORE_CALLBACK_PASS_ON;
1643 extn = ee->engine.buffer.data;
1644 if (!extn) return ECORE_CALLBACK_PASS_ON;
1646 extn->ipc.clients = eina_list_append(extn->ipc.clients, e->client);
1647 ecore_ipc_client_send(e->client, MAJOR, OP_LOCK_FILE, 0, 0, 0, extn->file.lock, strlen(extn->file.lock) + 1);
1649 if (extn->file.shmfile)
1651 Ipc_Data_Resize ipc;
1653 ecore_ipc_client_send(e->client, MAJOR, OP_SHM_REF,
1654 ee->w, ee->h, ee->alpha,
1655 extn->file.shmfile->file,
1656 strlen(extn->file.shmfile->file) + 1);
1660 ecore_ipc_client_send(e->client, MAJOR, OP_RESIZE,
1661 0, 0, 0, &ipc, sizeof(ipc));
1663 _ecore_evas_extn_event(ee, ECORE_EVAS_EXTN_CLIENT_ADD);
1664 return ECORE_CALLBACK_PASS_ON;
1668 _ipc_client_del(void *data, int type __UNUSED__, void *event)
1670 Ecore_Ipc_Event_Client_Del *e = event;
1671 Ecore_Evas *ee = data;
1673 extn = ee->engine.buffer.data;
1674 if (!extn) return ECORE_CALLBACK_PASS_ON;
1675 if (!eina_list_data_find(extn->ipc.clients, e->client)) return ECORE_CALLBACK_PASS_ON;
1677 extn->ipc.clients = eina_list_remove(extn->ipc.clients, e->client);
1679 _ecore_evas_extn_event(ee, ECORE_EVAS_EXTN_CLIENT_DEL);
1680 return ECORE_CALLBACK_PASS_ON;
1684 _ipc_client_data(void *data, int type __UNUSED__, void *event)
1686 Ecore_Ipc_Event_Client_Data *e = event;
1687 Ecore_Evas *ee = data;
1690 if (ee != ecore_ipc_server_data_get(ecore_ipc_client_server_get(e->client)))
1691 return ECORE_CALLBACK_PASS_ON;
1692 if (!eina_list_data_find(extn_ee_list, ee))
1693 return ECORE_CALLBACK_PASS_ON;
1694 extn = ee->engine.buffer.data;
1695 if (!extn) return ECORE_CALLBACK_PASS_ON;
1696 if (e->major != MAJOR)
1697 return ECORE_CALLBACK_PASS_ON;
1701 if ((e->data) && (e->size >= (int)sizeof(Ipc_Data_Resize)))
1704 Ipc_Data_Resize *ipc = e->data;
1705 /* create callbacke data size changed */
1706 _ecore_evas_socket_resize(ee, ipc->w, ipc->h);
1713 if (ee->func.fn_show) ee->func.fn_show(ee);
1720 if (ee->func.fn_hide) ee->func.fn_hide(ee);
1724 if (!ee->prop.focused)
1726 ee->prop.focused = 1;
1727 evas_focus_in(ee->evas);
1728 if (ee->func.fn_focus_in) ee->func.fn_focus_in(ee);
1732 if (ee->prop.focused)
1734 ee->prop.focused = 0;
1735 evas_focus_out(ee->evas);
1736 if (ee->func.fn_focus_out) ee->func.fn_focus_out(ee);
1739 case OP_EV_MOUSE_IN:
1740 if (e->size >= (int)sizeof(Ipc_Data_Ev_Mouse_In))
1742 Ipc_Data_Ev_Mouse_In *ipc = e->data;
1743 Evas_Event_Flags flags;
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_in(ee->evas, ipc->timestamp, NULL);
1749 evas_event_default_flags_set(ee->evas, flags);
1752 case OP_EV_MOUSE_OUT:
1753 if (e->size >= (int)sizeof(Ipc_Data_Ev_Mouse_Out))
1755 Ipc_Data_Ev_Mouse_Out *ipc = e->data;
1756 Evas_Event_Flags flags;
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_out(ee->evas, ipc->timestamp, NULL);
1762 evas_event_default_flags_set(ee->evas, flags);
1765 case OP_EV_MOUSE_UP:
1766 if (e->size >= (int)sizeof(Ipc_Data_Ev_Mouse_Up))
1768 Ipc_Data_Ev_Mouse_Up *ipc = e->data;
1769 Evas_Event_Flags flags;
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_up(ee->evas, ipc->b, ipc->flags, ipc->timestamp, NULL);
1775 evas_event_default_flags_set(ee->evas, flags);
1778 case OP_EV_MOUSE_DOWN:
1779 if (e->size >= (int)sizeof(Ipc_Data_Ev_Mouse_Down))
1781 Ipc_Data_Ev_Mouse_Up *ipc = e->data;
1782 Evas_Event_Flags flags;
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_down(ee->evas, ipc->b, ipc->flags, ipc->timestamp, NULL);
1788 evas_event_default_flags_set(ee->evas, flags);
1791 case OP_EV_MOUSE_MOVE:
1792 if (e->size >= (int)sizeof(Ipc_Data_Ev_Mouse_Move))
1794 Ipc_Data_Ev_Mouse_Move *ipc = e->data;
1795 Evas_Event_Flags flags;
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_mouse_move(ee->evas, ipc->x, ipc->y, ipc->timestamp, NULL);
1801 evas_event_default_flags_set(ee->evas, flags);
1804 case OP_EV_MOUSE_WHEEL:
1805 if (e->size >= (int)sizeof(Ipc_Data_Ev_Mouse_Wheel))
1807 Ipc_Data_Ev_Mouse_Wheel *ipc = e->data;
1808 Evas_Event_Flags flags;
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_mouse_wheel(ee->evas, ipc->direction, ipc->z, ipc->timestamp, NULL);
1814 evas_event_default_flags_set(ee->evas, flags);
1817 case OP_EV_MULTI_UP:
1818 if (e->size >= (int)sizeof(Ipc_Data_Ev_Multi_Up))
1820 Ipc_Data_Ev_Multi_Up *ipc = e->data;
1821 Evas_Event_Flags flags;
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_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);
1827 evas_event_default_flags_set(ee->evas, flags);
1830 case OP_EV_MULTI_DOWN:
1831 if (e->size >= (int)sizeof(Ipc_Data_Ev_Multi_Down))
1833 Ipc_Data_Ev_Multi_Down *ipc = e->data;
1834 Evas_Event_Flags flags;
1836 flags = evas_event_default_flags_get(ee->evas);
1837 evas_event_default_flags_set(ee->evas, ipc->event_flags);
1838 _ecore_evas_modifiers_locks_mask_set(ee->evas, ipc->mask);
1839 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);
1840 evas_event_default_flags_set(ee->evas, flags);
1843 case OP_EV_MULTI_MOVE:
1844 if (e->size >= (int)sizeof(Ipc_Data_Ev_Multi_Move))
1846 Ipc_Data_Ev_Multi_Move *ipc = e->data;
1847 Evas_Event_Flags flags;
1849 flags = evas_event_default_flags_get(ee->evas);
1850 evas_event_default_flags_set(ee->evas, ipc->event_flags);
1851 _ecore_evas_modifiers_locks_mask_set(ee->evas, ipc->mask);
1852 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);
1853 evas_event_default_flags_set(ee->evas, flags);
1857 #define STRGET(val) \
1859 if ((ipc->val) && (ipc->val < (char *)(long)(e->size - 1))) \
1860 ipc->val = ((char *)ipc) + (long)ipc->val; \
1866 if (e->size >= (int)sizeof(Ipc_Data_Ev_Key_Up))
1868 if ((e->data) && (e->size > 0) &&
1869 (((unsigned char *)e->data)[e->size - 1] == 0))
1871 Ipc_Data_Ev_Key_Up *ipc = e->data;
1872 Evas_Event_Flags flags;
1878 flags = evas_event_default_flags_get(ee->evas);
1879 evas_event_default_flags_set(ee->evas, ipc->event_flags);
1880 _ecore_evas_modifiers_locks_mask_set(ee->evas, ipc->mask);
1881 evas_event_feed_key_up(ee->evas, ipc->keyname, ipc->key, ipc->string, ipc->compose, ipc->timestamp, NULL);
1882 evas_event_default_flags_set(ee->evas, flags);
1886 case OP_EV_KEY_DOWN:
1887 if (e->size >= (int)sizeof(Ipc_Data_Ev_Key_Down))
1889 if ((e->data) && (e->size > 0) &&
1890 (((unsigned char *)e->data)[e->size - 1] == 0))
1892 Ipc_Data_Ev_Key_Down *ipc = e->data;
1893 Evas_Event_Flags flags;
1899 flags = evas_event_default_flags_get(ee->evas);
1900 evas_event_default_flags_set(ee->evas, ipc->event_flags);
1901 _ecore_evas_modifiers_locks_mask_set(ee->evas, ipc->mask);
1902 evas_event_feed_key_down(ee->evas, ipc->keyname, ipc->key, ipc->string, ipc->compose, ipc->timestamp, NULL);
1903 evas_event_default_flags_set(ee->evas, flags);
1908 if (e->size >= (int)sizeof(Ipc_Data_Ev_Hold))
1910 Ipc_Data_Ev_Hold *ipc = e->data;
1911 Evas_Event_Flags flags;
1913 flags = evas_event_default_flags_get(ee->evas);
1914 evas_event_default_flags_set(ee->evas, ipc->event_flags);
1915 evas_event_feed_hold(ee->evas, ipc->hold, ipc->timestamp, NULL);
1916 evas_event_default_flags_set(ee->evas, flags);
1922 return ECORE_CALLBACK_PASS_ON;
1926 _ecore_evas_extn_socket_alpha_set(Ecore_Evas *ee, int alpha)
1930 Ecore_Ipc_Client *client;
1932 if (((ee->alpha) && (alpha)) || ((!ee->alpha) && (!alpha))) return;
1935 extn = ee->engine.buffer.data;
1938 Evas_Engine_Info_Buffer *einfo;
1940 einfo = (Evas_Engine_Info_Buffer *)evas_engine_info_get(ee->evas);
1944 einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_ARGB32;
1946 einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_RGB32;
1947 evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
1948 evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
1950 EINA_LIST_FOREACH(extn->ipc.clients, l, client)
1951 ecore_ipc_client_send(client, MAJOR, OP_SHM_REF,
1952 ee->w, ee->h, ee->alpha,
1953 extn->file.shmfile->file,
1954 strlen(extn->file.shmfile->file) + 1);
1958 static const Ecore_Evas_Engine_Func _ecore_extn_socket_engine_func =
1960 _ecore_evas_extn_free,
1977 _ecore_evas_socket_resize,
1978 _ecore_evas_socket_move_resize,
2004 _ecore_evas_extn_socket_alpha_set,
2014 _ecore_evas_extn_socket_render, // render
2015 NULL // screen_geometry_get
2021 ecore_evas_extn_socket_new(int w, int h)
2023 #ifdef BUILD_ECORE_EVAS_EXTN
2024 Evas_Engine_Info_Buffer *einfo;
2028 rmethod = evas_render_method_lookup("buffer");
2029 if (!rmethod) return NULL;
2030 ee = calloc(1, sizeof(Ecore_Evas));
2031 if (!ee) return NULL;
2033 ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS);
2035 ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_extn_socket_engine_func;
2037 ee->driver = "extn_socket";
2049 ee->prop.focused = 0;
2050 ee->prop.borderless = 1;
2051 ee->prop.override = 1;
2052 ee->prop.maximized = 0;
2053 ee->prop.fullscreen = 0;
2054 ee->prop.withdrawn = 0;
2055 ee->prop.sticky = 0;
2057 /* init evas here */
2058 ee->evas = evas_new();
2059 evas_data_attach_set(ee->evas, ee);
2060 evas_output_method_set(ee->evas, rmethod);
2061 evas_output_size_set(ee->evas, w, h);
2062 evas_output_viewport_set(ee->evas, 0, 0, w, h);
2064 einfo = (Evas_Engine_Info_Buffer *)evas_engine_info_get(ee->evas);
2068 einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_ARGB32;
2070 einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_RGB32;
2071 einfo->info.dest_buffer = NULL;
2072 einfo->info.dest_buffer_row_bytes = 0;
2073 einfo->info.use_color_key = 0;
2074 einfo->info.alpha_threshold = 0;
2075 einfo->info.func.new_update_region = NULL;
2076 einfo->info.func.free_update_region = NULL;
2077 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
2079 ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
2080 ecore_evas_free(ee);
2086 ERR("evas_engine_info_set() init engine '%s' failed.", ee->driver);
2087 ecore_evas_free(ee);
2090 evas_key_modifier_add(ee->evas, "Shift");
2091 evas_key_modifier_add(ee->evas, "Control");
2092 evas_key_modifier_add(ee->evas, "Alt");
2093 evas_key_modifier_add(ee->evas, "Meta");
2094 evas_key_modifier_add(ee->evas, "Hyper");
2095 evas_key_modifier_add(ee->evas, "Super");
2096 evas_key_lock_add(ee->evas, "Caps_Lock");
2097 evas_key_lock_add(ee->evas, "Num_Lock");
2098 evas_key_lock_add(ee->evas, "Scroll_Lock");
2100 extn_ee_list = eina_list_append(extn_ee_list, ee);
2102 _ecore_evas_register(ee);
2111 ecore_evas_extn_socket_listen(Ecore_Evas *ee, const char *svcname, int svcnum, Eina_Bool svcsys)
2113 #ifdef BUILD_ECORE_EVAS_EXTN
2116 extn = calloc(1, sizeof(Extn));
2123 Ecore_Ipc_Type ipctype = ECORE_IPC_LOCAL_USER;
2127 extn->svc.name = eina_stringshare_add(svcname);
2128 extn->svc.num = svcnum;
2129 extn->svc.sys = svcsys;
2131 snprintf(buf, sizeof(buf), "/tmp/ee-lock-XXXXXX");
2132 extn->file.lockfd = mkstemp(buf);
2133 if (extn->file.lockfd >= 0)
2134 extn->file.lock = eina_stringshare_add(buf);
2135 if ((extn->file.lockfd < 0) || (!extn->file.lock))
2137 if (extn->file.lockfd)
2139 close(extn->file.lockfd);
2142 eina_stringshare_del(extn->svc.name);
2143 if (extn->file.lock) eina_stringshare_del(extn->file.lock);
2145 ecore_ipc_shutdown();
2149 if (extn->svc.sys) ipctype = ECORE_IPC_LOCAL_SYSTEM;
2150 extn->ipc.am_server = EINA_TRUE;
2151 extn->ipc.server = ecore_ipc_server_add(ipctype,
2152 (char *)extn->svc.name,
2154 if (!extn->ipc.server)
2156 if (extn->file.lockfd)
2158 close(extn->file.lockfd);
2159 if (extn->file.lock) unlink(extn->file.lock);
2161 eina_stringshare_del(extn->svc.name);
2162 eina_stringshare_del(extn->file.lock);
2164 ecore_ipc_shutdown();
2167 ee->engine.buffer.data = extn;
2168 extn->ipc.handlers = eina_list_append
2169 (extn->ipc.handlers,
2170 ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_ADD,
2171 _ipc_client_add, ee));
2172 extn->ipc.handlers = eina_list_append
2173 (extn->ipc.handlers,
2174 ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_DEL,
2175 _ipc_client_del, ee));
2176 extn->ipc.handlers = eina_list_append
2177 (extn->ipc.handlers,
2178 ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_DATA,
2179 _ipc_client_data, ee));