summaryrefslogtreecommitdiff
path: root/src/lib/edje
diff options
context:
space:
mode:
authorBruno Dilly <bdilly@profusion.mobi>2016-12-06 15:06:38 -0200
committerBruno Dilly <bdilly@profusion.mobi>2016-12-19 14:58:35 -0200
commit287486e9208687ba57529adc4bd3b33c99bfbdbb (patch)
tree4df39880d44cae523e4b672be35cd7f0ec70cea9 /src/lib/edje
parentf34220f0890f5107a330addfc06bbe02c313602a (diff)
edje: add flag to choose between evas or edje seat naming
collections.group.use_custom_seat_names should be set to '1' to use seat names on signals as provided by Evas. By default just follow Edje naming approach ("seat1", "seat2", ...)
Diffstat (limited to 'src/lib/edje')
-rw-r--r--src/lib/edje/edje_data.c1
-rw-r--r--src/lib/edje/edje_edit.c3
-rw-r--r--src/lib/edje/edje_load.c82
-rw-r--r--src/lib/edje/edje_private.h1
4 files changed, 85 insertions, 2 deletions
diff --git a/src/lib/edje/edje_data.c b/src/lib/edje/edje_data.c
index 9141ae139b..6c4ef6aec1 100644
--- a/src/lib/edje/edje_data.c
+++ b/src/lib/edje/edje_data.c
@@ -1814,6 +1814,7 @@ _edje_edd_init(void)
1814#endif 1814#endif
1815 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "physics_enabled", physics_enabled, EET_T_UCHAR); 1815 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "physics_enabled", physics_enabled, EET_T_UCHAR);
1816 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "script_recursion", script_recursion, EET_T_UCHAR); 1816 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "script_recursion", script_recursion, EET_T_UCHAR);
1817 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "use_custom_seat_names", use_custom_seat_names, EET_T_UCHAR);
1817} 1818}
1818 1819
1819EAPI void 1820EAPI void
diff --git a/src/lib/edje/edje_edit.c b/src/lib/edje/edje_edit.c
index 317892016e..6c57a7569b 100644
--- a/src/lib/edje/edje_edit.c
+++ b/src/lib/edje/edje_edit.c
@@ -15616,6 +15616,9 @@ _edje_generate_source_of_group(Edje *ed, Edje_Part_Collection_Directory_Entry *p
15616 /* Limits */ 15616 /* Limits */
15617 _edje_limits_source_generate(ed, buf, &ret); 15617 _edje_limits_source_generate(ed, buf, &ret);
15618 15618
15619 if (pc->use_custom_seat_names)
15620 BUF_APPENDF(I2 "use_custom_seat_names: 1;\n");
15621
15619 /* Data */ 15622 /* Data */
15620 if (pc->data) 15623 if (pc->data)
15621 { 15624 {
diff --git a/src/lib/edje/edje_load.c b/src/lib/edje/edje_load.c
index d3b9f20db3..91695b2aa1 100644
--- a/src/lib/edje/edje_load.c
+++ b/src/lib/edje/edje_load.c
@@ -515,8 +515,13 @@ _edje_device_add(Edje *ed, Efl_Input_Device *dev)
515 char sig[256]; 515 char sig[256];
516 Eina_List *l; 516 Eina_List *l;
517 517
518 ed->seats_count++; 518 if (ed->collection && ed->collection->use_custom_seat_names)
519 name = eina_stringshare_printf("seat%i", ed->seats_count); 519 name = eina_stringshare_add(efl_input_device_name_get(dev));
520 else
521 {
522 ed->seats_count++;
523 name = eina_stringshare_printf("seat%i", ed->seats_count);
524 }
520 EINA_SAFETY_ON_NULL_RETURN(name); 525 EINA_SAFETY_ON_NULL_RETURN(name);
521 526
522 EINA_LIST_FOREACH(ed->seats, l, s) 527 EINA_LIST_FOREACH(ed->seats, l, s)
@@ -585,6 +590,71 @@ _edje_device_removed_cb(void *data, const Efl_Event *event)
585} 590}
586 591
587static void 592static void
593_edje_device_changed_cb(void *data, const Efl_Event *event)
594{
595 Efl_Input_Device *dev = event->info;
596 Edje_Seat *s, *seat = NULL;
597 Eina_Stringshare *name;
598 Edje *ed = data;
599 char sig[256];
600 Eina_List *l;
601
602 if (efl_input_device_type_get(dev) != EFL_INPUT_DEVICE_CLASS_SEAT)
603 return;
604
605 EINA_LIST_FOREACH(ed->seats, l, s)
606 {
607 if (s->device != dev)
608 continue;
609 seat = s;
610 break;
611 }
612
613 /* not registered seat */
614 if (!seat)
615 return;
616
617 name = efl_input_device_name_get(dev);
618 if (!name)
619 return;
620
621 /* no name changes */
622 if (eina_streq(seat->name, name))
623 return;
624
625 /* check if device name was changed to match name used on EDC */
626 EINA_LIST_FOREACH(ed->seats, l, s)
627 {
628 if (eina_streq(s->name, name))
629 {
630 if (s->device == dev)
631 continue;
632 if (s->device)
633 {
634 WRN("Two seats were detected with the same name: %s.\n"
635 "Fix it or focus will misbehave", name);
636 break;
637 }
638
639 /* merge seats */
640 s->device = dev;
641 if (seat->focused_part)
642 s->focused_part = seat->focused_part;
643
644 ed->seats = eina_list_remove(ed->seats, seat);
645 eina_stringshare_del(seat->name);
646 free(seat);
647
648 return;
649 }
650 }
651
652 snprintf(sig, sizeof(sig), "seat,renamed,%s,%s", seat->name, name);
653 eina_stringshare_replace(&seat->name, name);
654 _edje_emit(ed, sig, "");
655}
656
657static void
588_edje_devices_add(Edje *ed, Evas *tev) 658_edje_devices_add(Edje *ed, Evas *tev)
589{ 659{
590 const Eina_List *devices, *l; 660 const Eina_List *devices, *l;
@@ -601,6 +671,10 @@ _edje_devices_add(Edje *ed, Evas *tev)
601 _edje_device_added_cb, ed); 671 _edje_device_added_cb, ed);
602 efl_event_callback_add(tev, EFL_CANVAS_EVENT_DEVICE_REMOVED, 672 efl_event_callback_add(tev, EFL_CANVAS_EVENT_DEVICE_REMOVED,
603 _edje_device_removed_cb, ed); 673 _edje_device_removed_cb, ed);
674
675 if (ed->collection && ed->collection->use_custom_seat_names)
676 efl_event_callback_add(tev, EFL_CANVAS_EVENT_DEVICE_CHANGED,
677 _edje_device_changed_cb, ed);
604} 678}
605 679
606int 680int
@@ -1704,6 +1778,10 @@ _edje_file_del(Edje *ed)
1704 _edje_device_added_cb, ed); 1778 _edje_device_added_cb, ed);
1705 efl_event_callback_del(tev, EFL_CANVAS_EVENT_DEVICE_REMOVED, 1779 efl_event_callback_del(tev, EFL_CANVAS_EVENT_DEVICE_REMOVED,
1706 _edje_device_removed_cb, ed); 1780 _edje_device_removed_cb, ed);
1781 if (ed->collection && ed->collection->use_custom_seat_names)
1782 efl_event_callback_del(tev, EFL_CANVAS_EVENT_DEVICE_CHANGED,
1783 _edje_device_changed_cb, ed);
1784
1707 evas_event_freeze(tev); 1785 evas_event_freeze(tev);
1708 } 1786 }
1709 1787
diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h
index d98f324f23..93b131cd09 100644
--- a/src/lib/edje/edje_private.h
+++ b/src/lib/edje/edje_private.h
@@ -1137,6 +1137,7 @@ struct _Edje_Part_Collection
1137 unsigned char broadcast_signal; 1137 unsigned char broadcast_signal;
1138 unsigned char physics_enabled; /* will be 1 if a body is declared */ 1138 unsigned char physics_enabled; /* will be 1 if a body is declared */
1139 unsigned char script_recursion; /* permits unsafe Embryo->EDC->Embryo scripting */ 1139 unsigned char script_recursion; /* permits unsafe Embryo->EDC->Embryo scripting */
1140 unsigned char use_custom_seat_names;
1140 unsigned char checked : 1; 1141 unsigned char checked : 1;
1141}; 1142};
1142 1143