summaryrefslogtreecommitdiff
path: root/src/lib/edje
diff options
context:
space:
mode:
authorBruno Dilly <bdilly@profusion.mobi>2016-12-07 21:10:34 -0200
committerBruno Dilly <bdilly@profusion.mobi>2016-12-21 23:03:33 -0200
commit9308410479b398169ec81daa6b77ef522a0f84ee (patch)
tree76c253d3fca42d58de5d2f1ebf8fff5d76473587 /src/lib/edje
parent65723a190ae34157b6e0335fc86ea70370d17b18 (diff)
edje: support filtering allowed seats per part
collections.group.parts.part.allowed_seats keeps a list of seat names to be used for events filter. So when evas devices of seat type are added, filters may be applied for each part. If no seat is listed, every seat may interact with such part.
Diffstat (limited to 'src/lib/edje')
-rw-r--r--src/lib/edje/edje_data.c13
-rw-r--r--src/lib/edje/edje_edit.c13
-rw-r--r--src/lib/edje/edje_load.c69
-rw-r--r--src/lib/edje/edje_private.h10
-rw-r--r--src/lib/edje/edje_program.c5
5 files changed, 110 insertions, 0 deletions
diff --git a/src/lib/edje/edje_data.c b/src/lib/edje/edje_data.c
index 6c4ef6aec1..0af3b130fb 100644
--- a/src/lib/edje/edje_data.c
+++ b/src/lib/edje/edje_data.c
@@ -37,6 +37,8 @@ Eet_Data_Descriptor *_edje_edd_edje_pack_element = NULL;
37Eet_Data_Descriptor *_edje_edd_edje_pack_element_pointer = NULL; 37Eet_Data_Descriptor *_edje_edd_edje_pack_element_pointer = NULL;
38Eet_Data_Descriptor *_edje_edd_edje_part = NULL; 38Eet_Data_Descriptor *_edje_edd_edje_part = NULL;
39Eet_Data_Descriptor *_edje_edd_edje_part_pointer = NULL; 39Eet_Data_Descriptor *_edje_edd_edje_part_pointer = NULL;
40Eet_Data_Descriptor *_edje_edd_edje_part_allowed_seat = NULL;
41Eet_Data_Descriptor *_edje_edd_edje_part_allowed_seat_pointer = NULL;
40Eet_Data_Descriptor *_edje_edd_edje_part_description_variant = NULL; 42Eet_Data_Descriptor *_edje_edd_edje_part_description_variant = NULL;
41Eet_Data_Descriptor *_edje_edd_edje_part_description_rectangle = NULL; 43Eet_Data_Descriptor *_edje_edd_edje_part_description_rectangle = NULL;
42Eet_Data_Descriptor *_edje_edd_edje_part_description_snapshot = NULL; 44Eet_Data_Descriptor *_edje_edd_edje_part_description_snapshot = NULL;
@@ -690,6 +692,8 @@ _edje_edd_shutdown(void)
690 FREED(_edje_edd_edje_pack_element_pointer); 692 FREED(_edje_edd_edje_pack_element_pointer);
691 FREED(_edje_edd_edje_part); 693 FREED(_edje_edd_edje_part);
692 FREED(_edje_edd_edje_part_pointer); 694 FREED(_edje_edd_edje_part_pointer);
695 FREED(_edje_edd_edje_part_allowed_seat);
696 FREED(_edje_edd_edje_part_allowed_seat_pointer);
693 FREED(_edje_edd_edje_part_description_variant); 697 FREED(_edje_edd_edje_part_description_variant);
694 FREED(_edje_edd_edje_part_description_rectangle); 698 FREED(_edje_edd_edje_part_description_rectangle);
695 FREED(_edje_edd_edje_part_description_snapshot); 699 FREED(_edje_edd_edje_part_description_snapshot);
@@ -946,6 +950,11 @@ _edje_edd_init(void)
946 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_style_tag, Edje_Style_Tag, "key", key, EET_T_STRING); 950 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_style_tag, Edje_Style_Tag, "key", key, EET_T_STRING);
947 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_style_tag, Edje_Style_Tag, "value", value, EET_T_STRING); 951 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_style_tag, Edje_Style_Tag, "value", value, EET_T_STRING);
948 952
953 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Allowed_Seat);
954 _edje_edd_edje_part_allowed_seat =
955 eet_data_descriptor_file_new(&eddc);
956 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_allowed_seat, Edje_Part_Allowed_Seat, "name", name, EET_T_STRING);
957
949 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Style); 958 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Style);
950 _edje_edd_edje_style = 959 _edje_edd_edje_style =
951 eet_data_descriptor_file_new(&eddc); 960 eet_data_descriptor_file_new(&eddc);
@@ -1766,6 +1775,10 @@ _edje_edd_init(void)
1766 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "nested_children_count", nested_children_count, EET_T_UCHAR); 1775 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "nested_children_count", nested_children_count, EET_T_UCHAR);
1767 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "required", required, EET_T_UCHAR); 1776 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "required", required, EET_T_UCHAR);
1768 1777
1778 EDJE_DEFINE_POINTER_TYPE(Part_Allowed_Seat, part_allowed_seat);
1779 EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_edje_edd_edje_part, Edje_Part, "allowed_seats", allowed_seats, _edje_edd_edje_part_allowed_seat_pointer);
1780
1781
1769 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Limit); 1782 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Limit);
1770 _edje_edd_edje_part_limit = eet_data_descriptor_file_new(&eddc); 1783 _edje_edd_edje_part_limit = eet_data_descriptor_file_new(&eddc);
1771 1784
diff --git a/src/lib/edje/edje_edit.c b/src/lib/edje/edje_edit.c
index de88db33e4..291b5afaf0 100644
--- a/src/lib/edje/edje_edit.c
+++ b/src/lib/edje/edje_edit.c
@@ -15248,6 +15248,19 @@ _edje_generate_source_of_part(Evas_Object *obj, Edje_Part *ep, Eina_Strbuf *buf)
15248 BUF_APPEND(I4 "precise_is_inside: 1;\n"); 15248 BUF_APPEND(I4 "precise_is_inside: 1;\n");
15249 if (rp->part->access) 15249 if (rp->part->access)
15250 BUF_APPEND(I4 "access: 1;\n"); 15250 BUF_APPEND(I4 "access: 1;\n");
15251 if (rp->part->allowed_seats)
15252 {
15253 Edje_Part_Allowed_Seat *seat;
15254 unsigned int i;
15255
15256 BUF_APPEND(I4 "allowed_seats:");
15257 for (i = 0; i < rp->part->allowed_seats_count; i++)
15258 {
15259 seat = rp->part->allowed_seats[i];
15260 BUF_APPENDF(" %s", seat->name);
15261 }
15262 BUF_APPEND(";\n");
15263 }
15251 15264
15252 if ((str = _edje_part_clip_to_get(ed, rp))) 15265 if ((str = _edje_part_clip_to_get(ed, rp)))
15253 { 15266 {
diff --git a/src/lib/edje/edje_load.c b/src/lib/edje/edje_load.c
index e530926c33..bdbf698ca7 100644
--- a/src/lib/edje/edje_load.c
+++ b/src/lib/edje/edje_load.c
@@ -507,6 +507,60 @@ _edje_physics_world_update_cb(void *data, EPhysics_World *world EINA_UNUSED, voi
507} 507}
508#endif 508#endif
509 509
510Eina_Bool
511_edje_part_allowed_seat_find(Edje_Real_Part *rp, const char *seat_name)
512{
513 const char *name;
514 unsigned int i;
515
516 for (i = 0; i < rp->part->allowed_seats_count; i++)
517 {
518 name = rp->part->allowed_seats[i]->name;
519 if (!strcmp(seat_name, name))
520 return EINA_TRUE;
521 }
522
523 return EINA_FALSE;
524}
525
526/* It goes throught the list of registered seats and
527 * set event filters for each of these seats. */
528static void
529_edje_part_seat_filter_apply(Edje *ed, Edje_Real_Part *rp)
530{
531 Edje_Seat *seat;
532 Eina_List *l;
533 Eina_Bool found;
534
535 EINA_LIST_FOREACH(ed->seats, l, seat)
536 {
537 found = _edje_part_allowed_seat_find(rp, seat->name);
538 efl_input_seat_event_filter_set(rp->object, seat->device, found);
539 }
540}
541
542/* It goes throught the list of all edje parts and
543 * set event filters for each of these parts. Should be called when
544 * a new seat is added.
545 */
546static void
547_edje_seat_event_filter_apply(Edje *ed, Edje_Seat *seat)
548{
549 Edje_Real_Part *rp;
550 unsigned short i;
551 Eina_Bool found;
552
553 for (i = 0; i < ed->table_parts_size; i++)
554 {
555 rp = ed->table_parts[i];
556 if (!rp->part->allowed_seats)
557 continue;
558
559 found = _edje_part_allowed_seat_find(rp, seat->name);
560 efl_input_seat_event_filter_set(rp->object, seat->device, found);
561 }
562}
563
510static void 564static void
511_edje_device_add(Edje *ed, Efl_Input_Device *dev) 565_edje_device_add(Edje *ed, Efl_Input_Device *dev)
512{ 566{
@@ -544,6 +598,7 @@ _edje_device_add(Edje *ed, Efl_Input_Device *dev)
544 snprintf(sig, sizeof(sig), "seat,added,%s,%s", seat->name, 598 snprintf(sig, sizeof(sig), "seat,added,%s,%s", seat->name,
545 efl_input_device_name_get(dev)); 599 efl_input_device_name_get(dev));
546 _edje_emit(ed, sig, ""); 600 _edje_emit(ed, sig, "");
601 _edje_seat_event_filter_apply(ed, seat);
547 602
548seat_err: 603seat_err:
549 eina_stringshare_del(name); 604 eina_stringshare_del(name);
@@ -645,6 +700,8 @@ _edje_device_changed_cb(void *data, const Efl_Event *event)
645 eina_stringshare_del(seat->name); 700 eina_stringshare_del(seat->name);
646 free(seat); 701 free(seat);
647 702
703 _edje_seat_event_filter_apply(ed, s);
704
648 return; 705 return;
649 } 706 }
650 } 707 }
@@ -652,6 +709,7 @@ _edje_device_changed_cb(void *data, const Efl_Event *event)
652 snprintf(sig, sizeof(sig), "seat,renamed,%s,%s", seat->name, name); 709 snprintf(sig, sizeof(sig), "seat,renamed,%s,%s", seat->name, name);
653 eina_stringshare_replace(&seat->name, name); 710 eina_stringshare_replace(&seat->name, name);
654 _edje_emit(ed, sig, ""); 711 _edje_emit(ed, sig, "");
712 _edje_seat_event_filter_apply(ed, seat);
655} 713}
656 714
657static void 715static void
@@ -1093,6 +1151,9 @@ _edje_object_file_set_internal(Evas_Object *obj, const Eina_File *file, const ch
1093 nested_smart = NULL; 1151 nested_smart = NULL;
1094 } 1152 }
1095 1153
1154 if (ep->allowed_seats)
1155 _edje_part_seat_filter_apply(ed, rp);
1156
1096 if (ep->no_render) 1157 if (ep->no_render)
1097 efl_canvas_object_no_render_set(rp->object, 1); 1158 efl_canvas_object_no_render_set(rp->object, 1);
1098 1159
@@ -2228,6 +2289,14 @@ _edje_collection_free(Edje_File *edf, Edje_Part_Collection *ec, Edje_Part_Collec
2228 for (j = 0; j < ep->items_count; ++j) 2289 for (j = 0; j < ep->items_count; ++j)
2229 free(ep->items[j]); 2290 free(ep->items[j]);
2230 free(ep->items); 2291 free(ep->items);
2292
2293 for (j = 0; j < ep->allowed_seats_count; ++j)
2294 {
2295 if (edf->free_strings)
2296 eina_stringshare_del(ep->allowed_seats[j]->name);
2297 free(ep->allowed_seats[j]);
2298 }
2299 free(ep->allowed_seats);
2231 // technically need this - but we ASSUME we use "one_big" so everything gets 2300 // technically need this - but we ASSUME we use "one_big" so everything gets
2232 // freed in one go lower down when we del the mempool... but what if pool goes 2301 // freed in one go lower down when we del the mempool... but what if pool goes
2233 // "over"? 2302 // "over"?
diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h
index 1a2d7dbdea..13dc7961dd 100644
--- a/src/lib/edje/edje_private.h
+++ b/src/lib/edje/edje_private.h
@@ -377,6 +377,7 @@ typedef struct _Edje_Part_Box_Animation Edje_Part_Box_Animation;
377typedef struct _Edje_Part_Limit Edje_Part_Limit; 377typedef struct _Edje_Part_Limit Edje_Part_Limit;
378typedef struct _Edje_Part_Description_Vector Edje_Part_Description_Vector; 378typedef struct _Edje_Part_Description_Vector Edje_Part_Description_Vector;
379typedef struct _Edje_Part_Description_Spec_Svg Edje_Part_Description_Spec_Svg; 379typedef struct _Edje_Part_Description_Spec_Svg Edje_Part_Description_Spec_Svg;
380typedef struct _Edje_Part_Allowed_Seat Edje_Part_Allowed_Seat;
380typedef struct _Edje_Real_Part_Vector Edje_Real_Part_Vector; 381typedef struct _Edje_Real_Part_Vector Edje_Real_Part_Vector;
381typedef struct _Edje_Vector_Data Edje_Vector_Data; 382typedef struct _Edje_Vector_Data Edje_Vector_Data;
382 383
@@ -1195,6 +1196,8 @@ struct _Edje_Part
1195 unsigned int items_count; 1196 unsigned int items_count;
1196 Edje_3D_Vec scale_3d; 1197 Edje_3D_Vec scale_3d;
1197 Edje_Part_Api api; 1198 Edje_Part_Api api;
1199 Edje_Part_Allowed_Seat **allowed_seats;
1200 unsigned int allowed_seats_count;
1198 unsigned char type; /* what type (image, rect, text) */ 1201 unsigned char type; /* what type (image, rect, text) */
1199#ifdef HAVE_EPHYSICS 1202#ifdef HAVE_EPHYSICS
1200 unsigned char physics_body; /* body (none, rigid box, soft circle, ...) */ 1203 unsigned char physics_body; /* body (none, rigid box, soft circle, ...) */
@@ -1628,6 +1631,12 @@ struct _Edje_Part_Description_Vector
1628 Edje_Part_Description_Spec_Svg vg; 1631 Edje_Part_Description_Spec_Svg vg;
1629}; 1632};
1630 1633
1634struct _Edje_Part_Allowed_Seat
1635{
1636 const char *name;
1637};
1638
1639
1631/*----------*/ 1640/*----------*/
1632 1641
1633struct _Edje_Signal_Source_Char 1642struct _Edje_Signal_Source_Char
@@ -2495,6 +2504,7 @@ void _edje_part_focus_set(Edje *ed, const char *seat_name, Edje_Real_Part *rp);
2495 2504
2496Eina_Stringshare *_edje_seat_name_get(Edje *ed, Efl_Input_Device *device); 2505Eina_Stringshare *_edje_seat_name_get(Edje *ed, Efl_Input_Device *device);
2497Efl_Input_Device *_edje_seat_get(Edje *ed, Eina_Stringshare *name); 2506Efl_Input_Device *_edje_seat_get(Edje *ed, Eina_Stringshare *name);
2507Eina_Bool _edje_part_allowed_seat_find(Edje_Real_Part *rp, const char *seat_name);
2498 2508
2499const Edje_Signals_Sources_Patterns *_edje_signal_callback_patterns_ref(const Edje_Signal_Callback_Group *gp); 2509const Edje_Signals_Sources_Patterns *_edje_signal_callback_patterns_ref(const Edje_Signal_Callback_Group *gp);
2500void _edje_signal_callback_patterns_unref(const Edje_Signals_Sources_Patterns *essp); 2510void _edje_signal_callback_patterns_unref(const Edje_Signals_Sources_Patterns *essp);
diff --git a/src/lib/edje/edje_program.c b/src/lib/edje/edje_program.c
index ef4cf40d05..7ab1498814 100644
--- a/src/lib/edje/edje_program.c
+++ b/src/lib/edje/edje_program.c
@@ -662,6 +662,10 @@ _edje_part_focus_set(Edje *ed, const char *seat_name, Edje_Real_Part *rp)
662 662
663 if (focused_part != rp) 663 if (focused_part != rp)
664 { 664 {
665 if ((rp->part->allowed_seats) &&
666 (!_edje_part_allowed_seat_find(rp, sname)))
667 goto not_allowed;
668
665 if (focused_part) 669 if (focused_part)
666 _edje_seat_name_emit(ed, sname, "focus,part,out", 670 _edje_seat_name_emit(ed, sname, "focus,part,out",
667 focused_part->part->name); 671 focused_part->part->name);
@@ -670,6 +674,7 @@ _edje_part_focus_set(Edje *ed, const char *seat_name, Edje_Real_Part *rp)
670 _edje_seat_name_emit(ed, sname, "focus,part,in", rp->part->name); 674 _edje_seat_name_emit(ed, sname, "focus,part,in", rp->part->name);
671 } 675 }
672 676
677not_allowed:
673 eina_stringshare_del(sname); 678 eina_stringshare_del(sname);
674} 679}
675 680