static void st_collections_group_data_item(void);
static void st_collections_group_orientation(void);
static void st_collections_group_mouse_events(void);
+static void st_collections_group_use_custom_seat_names(void);
static void st_collections_group_limits_vertical(void);
static void st_collections_group_limits_horizontal(void);
{"collections.group.program_source", st_collections_group_program_source},
{"collections.group.inherit", st_collections_group_inherit},
{"collections.group.inherit_only", st_collections_group_inherit_only},
+ {"collections.group.use_custom_seat_names", st_collections_group_use_custom_seat_names},
{"collections.group.target_group", st_collections_group_target_group}, /* dup */
{"collections.group.part_remove", st_collections_group_part_remove},
{"collections.group.program_remove", st_collections_group_program_remove},
/**
@page edcref
@property
+ use_custom_seat_names
+ @parameters
+ [1 or 0]
+ @effect
+ This flags a group as designed to listen for multiseat signals
+ following a custom naming instead of default Edje naming.
+ Seats are named on Edje as "seat1", "seat2", etc, in an incremental
+ way and never are changed.
+
+ But on Evas, names may be set on different places
+ (Evas, Ecore Evas backends, the application itself)
+ and name changes are allowed.
+ So custom names come from system at first, but can be overriden with
+ evas_device_name_set().
+ Also Evas seat names don't need to follow any pattern.
+
+ It's useful for cases where there is control of the
+ system, as seat names, or when the application
+ sets the devices names to guarantee they'll match
+ seat names on EDC.
+ @since 1.19
+ @endproperty
+*/
+static void
+st_collections_group_use_custom_seat_names(void)
+{
+ Edje_Part_Collection *pc;
+
+ check_arg_count(1);
+
+ pc = eina_list_data_get(eina_list_last(edje_collections));
+ pc->use_custom_seat_names = parse_bool(0);
+}
+
+/**
+ @page edcref
+ @property
target_group
@parameters
[name] [part or program] (part or program) (part or program) ...
pc->prop.orientation = pc2->prop.orientation;
pc->lua_script_only = pc2->lua_script_only;
+ pc->use_custom_seat_names = pc2->use_custom_seat_names;
pcp = (Edje_Part_Collection_Parser *)pc;
pcp2 = (Edje_Part_Collection_Parser *)pc2;
#endif
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "physics_enabled", physics_enabled, EET_T_UCHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "script_recursion", script_recursion, EET_T_UCHAR);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "use_custom_seat_names", use_custom_seat_names, EET_T_UCHAR);
}
EAPI void
/* Limits */
_edje_limits_source_generate(ed, buf, &ret);
+ if (pc->use_custom_seat_names)
+ BUF_APPENDF(I2 "use_custom_seat_names: 1;\n");
+
/* Data */
if (pc->data)
{
char sig[256];
Eina_List *l;
- ed->seats_count++;
- name = eina_stringshare_printf("seat%i", ed->seats_count);
+ if (ed->collection && ed->collection->use_custom_seat_names)
+ name = eina_stringshare_add(efl_input_device_name_get(dev));
+ else
+ {
+ ed->seats_count++;
+ name = eina_stringshare_printf("seat%i", ed->seats_count);
+ }
EINA_SAFETY_ON_NULL_RETURN(name);
EINA_LIST_FOREACH(ed->seats, l, s)
}
static void
+_edje_device_changed_cb(void *data, const Efl_Event *event)
+{
+ Efl_Input_Device *dev = event->info;
+ Edje_Seat *s, *seat = NULL;
+ Eina_Stringshare *name;
+ Edje *ed = data;
+ char sig[256];
+ Eina_List *l;
+
+ if (efl_input_device_type_get(dev) != EFL_INPUT_DEVICE_CLASS_SEAT)
+ return;
+
+ EINA_LIST_FOREACH(ed->seats, l, s)
+ {
+ if (s->device != dev)
+ continue;
+ seat = s;
+ break;
+ }
+
+ /* not registered seat */
+ if (!seat)
+ return;
+
+ name = efl_input_device_name_get(dev);
+ if (!name)
+ return;
+
+ /* no name changes */
+ if (eina_streq(seat->name, name))
+ return;
+
+ /* check if device name was changed to match name used on EDC */
+ EINA_LIST_FOREACH(ed->seats, l, s)
+ {
+ if (eina_streq(s->name, name))
+ {
+ if (s->device == dev)
+ continue;
+ if (s->device)
+ {
+ WRN("Two seats were detected with the same name: %s.\n"
+ "Fix it or focus will misbehave", name);
+ break;
+ }
+
+ /* merge seats */
+ s->device = dev;
+ if (seat->focused_part)
+ s->focused_part = seat->focused_part;
+
+ ed->seats = eina_list_remove(ed->seats, seat);
+ eina_stringshare_del(seat->name);
+ free(seat);
+
+ return;
+ }
+ }
+
+ snprintf(sig, sizeof(sig), "seat,renamed,%s,%s", seat->name, name);
+ eina_stringshare_replace(&seat->name, name);
+ _edje_emit(ed, sig, "");
+}
+
+static void
_edje_devices_add(Edje *ed, Evas *tev)
{
const Eina_List *devices, *l;
_edje_device_added_cb, ed);
efl_event_callback_add(tev, EFL_CANVAS_EVENT_DEVICE_REMOVED,
_edje_device_removed_cb, ed);
+
+ if (ed->collection && ed->collection->use_custom_seat_names)
+ efl_event_callback_add(tev, EFL_CANVAS_EVENT_DEVICE_CHANGED,
+ _edje_device_changed_cb, ed);
}
int
_edje_device_added_cb, ed);
efl_event_callback_del(tev, EFL_CANVAS_EVENT_DEVICE_REMOVED,
_edje_device_removed_cb, ed);
+ if (ed->collection && ed->collection->use_custom_seat_names)
+ efl_event_callback_del(tev, EFL_CANVAS_EVENT_DEVICE_CHANGED,
+ _edje_device_changed_cb, ed);
+
evas_event_freeze(tev);
}
unsigned char broadcast_signal;
unsigned char physics_enabled; /* will be 1 if a body is declared */
unsigned char script_recursion; /* permits unsafe Embryo->EDC->Embryo scripting */
+ unsigned char use_custom_seat_names;
unsigned char checked : 1;
};