summaryrefslogtreecommitdiff
path: root/src
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
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')
-rw-r--r--src/bin/edje/edje_cc_handlers.c40
-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
5 files changed, 125 insertions, 2 deletions
diff --git a/src/bin/edje/edje_cc_handlers.c b/src/bin/edje/edje_cc_handlers.c
index 9428e45746..3861cd9aec 100644
--- a/src/bin/edje/edje_cc_handlers.c
+++ b/src/bin/edje/edje_cc_handlers.c
@@ -262,6 +262,7 @@ static void st_collections_group_broadcast_signal(void);
262static void st_collections_group_data_item(void); 262static void st_collections_group_data_item(void);
263static void st_collections_group_orientation(void); 263static void st_collections_group_orientation(void);
264static void st_collections_group_mouse_events(void); 264static void st_collections_group_mouse_events(void);
265static void st_collections_group_use_custom_seat_names(void);
265 266
266static void st_collections_group_limits_vertical(void); 267static void st_collections_group_limits_vertical(void);
267static void st_collections_group_limits_horizontal(void); 268static void st_collections_group_limits_horizontal(void);
@@ -716,6 +717,7 @@ New_Statement_Handler statement_handlers[] =
716 {"collections.group.program_source", st_collections_group_program_source}, 717 {"collections.group.program_source", st_collections_group_program_source},
717 {"collections.group.inherit", st_collections_group_inherit}, 718 {"collections.group.inherit", st_collections_group_inherit},
718 {"collections.group.inherit_only", st_collections_group_inherit_only}, 719 {"collections.group.inherit_only", st_collections_group_inherit_only},
720 {"collections.group.use_custom_seat_names", st_collections_group_use_custom_seat_names},
719 {"collections.group.target_group", st_collections_group_target_group}, /* dup */ 721 {"collections.group.target_group", st_collections_group_target_group}, /* dup */
720 {"collections.group.part_remove", st_collections_group_part_remove}, 722 {"collections.group.part_remove", st_collections_group_part_remove},
721 {"collections.group.program_remove", st_collections_group_program_remove}, 723 {"collections.group.program_remove", st_collections_group_program_remove},
@@ -4517,6 +4519,43 @@ st_collections_group_inherit_only(void)
4517/** 4519/**
4518 @page edcref 4520 @page edcref
4519 @property 4521 @property
4522 use_custom_seat_names
4523 @parameters
4524 [1 or 0]
4525 @effect
4526 This flags a group as designed to listen for multiseat signals
4527 following a custom naming instead of default Edje naming.
4528 Seats are named on Edje as "seat1", "seat2", etc, in an incremental
4529 way and never are changed.
4530
4531 But on Evas, names may be set on different places
4532 (Evas, Ecore Evas backends, the application itself)
4533 and name changes are allowed.
4534 So custom names come from system at first, but can be overriden with
4535 evas_device_name_set().
4536 Also Evas seat names don't need to follow any pattern.
4537
4538 It's useful for cases where there is control of the
4539 system, as seat names, or when the application
4540 sets the devices names to guarantee they'll match
4541 seat names on EDC.
4542 @since 1.19
4543 @endproperty
4544*/
4545static void
4546st_collections_group_use_custom_seat_names(void)
4547{
4548 Edje_Part_Collection *pc;
4549
4550 check_arg_count(1);
4551
4552 pc = eina_list_data_get(eina_list_last(edje_collections));
4553 pc->use_custom_seat_names = parse_bool(0);
4554}
4555
4556/**
4557 @page edcref
4558 @property
4520 target_group 4559 target_group
4521 @parameters 4560 @parameters
4522 [name] [part or program] (part or program) (part or program) ... 4561 [name] [part or program] (part or program) (part or program) ...
@@ -4692,6 +4731,7 @@ st_collections_group_inherit(void)
4692 pc->prop.orientation = pc2->prop.orientation; 4731 pc->prop.orientation = pc2->prop.orientation;
4693 4732
4694 pc->lua_script_only = pc2->lua_script_only; 4733 pc->lua_script_only = pc2->lua_script_only;
4734 pc->use_custom_seat_names = pc2->use_custom_seat_names;
4695 4735
4696 pcp = (Edje_Part_Collection_Parser *)pc; 4736 pcp = (Edje_Part_Collection_Parser *)pc;
4697 pcp2 = (Edje_Part_Collection_Parser *)pc2; 4737 pcp2 = (Edje_Part_Collection_Parser *)pc2;
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