mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-20 15:00:05 +01:00
Split seats into having a physical and a logical name
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
5b5b6bca06
commit
c29a8e8093
7 changed files with 80 additions and 18 deletions
|
|
@ -57,7 +57,8 @@ struct libinput_seat {
|
|||
struct list devices_list;
|
||||
void *user_data;
|
||||
int refcount;
|
||||
char *name;
|
||||
char *physical_name;
|
||||
char *logical_name;
|
||||
libinput_seat_destroy_func destroy;
|
||||
};
|
||||
|
||||
|
|
@ -99,7 +100,8 @@ close_restricted(struct libinput *libinput, int fd);
|
|||
void
|
||||
libinput_seat_init(struct libinput_seat *seat,
|
||||
struct libinput *libinput,
|
||||
const char *name,
|
||||
const char *physical_name,
|
||||
const char *logical_name,
|
||||
libinput_seat_destroy_func destroy);
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -463,12 +463,14 @@ close_restricted(struct libinput *libinput, int fd)
|
|||
void
|
||||
libinput_seat_init(struct libinput_seat *seat,
|
||||
struct libinput *libinput,
|
||||
const char *name,
|
||||
const char *physical_name,
|
||||
const char *logical_name,
|
||||
libinput_seat_destroy_func destroy)
|
||||
{
|
||||
seat->refcount = 1;
|
||||
seat->libinput = libinput;
|
||||
seat->name = strdup(name);
|
||||
seat->physical_name = strdup(physical_name);
|
||||
seat->logical_name = strdup(logical_name);
|
||||
seat->destroy = destroy;
|
||||
list_init(&seat->devices_list);
|
||||
}
|
||||
|
|
@ -483,7 +485,8 @@ static void
|
|||
libinput_seat_destroy(struct libinput_seat *seat)
|
||||
{
|
||||
list_remove(&seat->link);
|
||||
free(seat->name);
|
||||
free(seat->logical_name);
|
||||
free(seat->physical_name);
|
||||
seat->destroy(seat);
|
||||
}
|
||||
|
||||
|
|
@ -509,9 +512,15 @@ libinput_seat_get_user_data(struct libinput_seat *seat)
|
|||
}
|
||||
|
||||
LIBINPUT_EXPORT const char *
|
||||
libinput_seat_get_name(struct libinput_seat *seat)
|
||||
libinput_seat_get_physical_name(struct libinput_seat *seat)
|
||||
{
|
||||
return seat->name;
|
||||
return seat->physical_name;
|
||||
}
|
||||
|
||||
LIBINPUT_EXPORT const char *
|
||||
libinput_seat_get_logical_name(struct libinput_seat *seat)
|
||||
{
|
||||
return seat->logical_name;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -544,6 +544,28 @@ libinput_destroy(struct libinput *libinput);
|
|||
|
||||
/**
|
||||
* @defgroup seat Initialization and manipulation of seats
|
||||
*
|
||||
* A seat has two identifiers, the physical name and the logical name. The
|
||||
* physical name is summarized as the list of devices a process on the same
|
||||
* physical seat has access to.
|
||||
*
|
||||
* The logical seat name is the seat name for a logical group of devices. A
|
||||
* compositor may use that to create additonal seats as independent device
|
||||
* sets. Alternatively, a compositor may limit itself to a single logical
|
||||
* seat, leaving a second compositor to manage devices on the other logical
|
||||
* seats.
|
||||
*
|
||||
* @code
|
||||
* +---+--------+------------+------------------------+------------+
|
||||
* | | event0 | | | log seat A |
|
||||
* | K +--------+ | +------------+
|
||||
* | e | event1 | phys seat0 | libinput context 1 | |
|
||||
* | r +--------+ | | log seat B |
|
||||
* | n | event2 | | | |
|
||||
* | e +--------+------------+------------------------+------------+
|
||||
* | l | event3 | phys seat1 | libinput context 2 | log seat C |
|
||||
* +---+--------+------------+------------------------+------------+
|
||||
* @endcode
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
@ -601,11 +623,33 @@ libinput_seat_get_user_data(struct libinput_seat *seat);
|
|||
/**
|
||||
* @ingroup seat
|
||||
*
|
||||
* Return the physical name of the seat. For libinput contexts created from
|
||||
* udev, this is always the same value as passed into
|
||||
* libinput_create_from_udev() and all seats from that context will have the
|
||||
* same physical name.
|
||||
*
|
||||
* The physical name of the seat is one that is usually set by the system or
|
||||
* lower levels of the stack. In most cases, this is the base filter for
|
||||
* devices - devices assigned to seats outside the current seat will not
|
||||
* be available to the caller.
|
||||
*
|
||||
* @param seat A previously obtained seat
|
||||
* @return the name of this seat
|
||||
* @return the physical name of this seat
|
||||
*/
|
||||
const char *
|
||||
libinput_seat_get_name(struct libinput_seat *seat);
|
||||
libinput_seat_get_physical_name(struct libinput_seat *seat);
|
||||
|
||||
/**
|
||||
* @ingroup seat
|
||||
*
|
||||
* Return the logical name of the seat. This is an identifier to group sets
|
||||
* of devices within the compositor.
|
||||
*
|
||||
* @param seat A previously obtained seat
|
||||
* @return the logical name of this seat
|
||||
*/
|
||||
const char *
|
||||
libinput_seat_get_logical_name(struct libinput_seat *seat);
|
||||
|
||||
/**
|
||||
* @defgroup device Initialization and manipulation of input devices
|
||||
|
|
|
|||
|
|
@ -71,7 +71,8 @@ path_seat_create(struct path_input *input)
|
|||
|
||||
seat->name = "default";
|
||||
|
||||
libinput_seat_init(&seat->base, &input->base, seat->name, path_seat_destroy);
|
||||
/* FIXME: get physical seat from udev */
|
||||
libinput_seat_init(&seat->base, &input->base, seat->name, seat->name, path_seat_destroy);
|
||||
list_insert(&input->base.seat_list, &seat->base.link);
|
||||
|
||||
return seat;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,9 @@ static const char default_seat[] = "seat0";
|
|||
static const char default_seat_name[] = "default";
|
||||
|
||||
static struct udev_seat *
|
||||
udev_seat_create(struct udev_input *input, const char *seat_name);
|
||||
udev_seat_create(struct udev_input *input,
|
||||
const char *device_seat,
|
||||
const char *seat_name);
|
||||
static struct udev_seat *
|
||||
udev_seat_get_named(struct udev_input *input, const char *seat_name);
|
||||
|
||||
|
|
@ -71,7 +73,7 @@ device_added(struct udev_device *udev_device, struct udev_input *input)
|
|||
if (seat)
|
||||
libinput_seat_ref(&seat->base);
|
||||
else {
|
||||
seat = udev_seat_create(input, seat_name);
|
||||
seat = udev_seat_create(input, device_seat, seat_name);
|
||||
if (!seat)
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -224,7 +226,7 @@ udev_input_remove_devices(struct udev_input *input)
|
|||
/* if the seat may be referenced by the
|
||||
client, so make sure it's dropped from
|
||||
the seat list now, to be freed whenever
|
||||
the device is removed */
|
||||
* the device is removed */
|
||||
list_remove(&seat->base.link);
|
||||
list_init(&seat->base.link);
|
||||
}
|
||||
|
|
@ -316,7 +318,9 @@ udev_seat_destroy(struct libinput_seat *seat)
|
|||
}
|
||||
|
||||
static struct udev_seat *
|
||||
udev_seat_create(struct udev_input *input, const char *seat_name)
|
||||
udev_seat_create(struct udev_input *input,
|
||||
const char *device_seat,
|
||||
const char *seat_name)
|
||||
{
|
||||
struct udev_seat *seat;
|
||||
|
||||
|
|
@ -324,7 +328,9 @@ udev_seat_create(struct udev_input *input, const char *seat_name)
|
|||
if (!seat)
|
||||
return NULL;
|
||||
|
||||
libinput_seat_init(&seat->base, &input->base, seat_name, udev_seat_destroy);
|
||||
libinput_seat_init(&seat->base, &input->base,
|
||||
device_seat, seat_name,
|
||||
udev_seat_destroy);
|
||||
list_insert(&input->base.seat_list, &seat->base.link);
|
||||
|
||||
return seat;
|
||||
|
|
@ -336,7 +342,7 @@ udev_seat_get_named(struct udev_input *input, const char *seat_name)
|
|||
struct udev_seat *seat;
|
||||
|
||||
list_for_each(seat, &input->base.seat_list, base.link) {
|
||||
if (strcmp(seat->base.name, seat_name) == 0)
|
||||
if (strcmp(seat->base.logical_name, seat_name) == 0)
|
||||
return seat;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ START_TEST(path_added_seat)
|
|||
seat = libinput_device_get_seat(device);
|
||||
ck_assert(seat != NULL);
|
||||
|
||||
seat_name = libinput_seat_get_name(seat);
|
||||
seat_name = libinput_seat_get_logical_name(seat);
|
||||
ck_assert_int_eq(strcmp(seat_name, "default"), 0);
|
||||
|
||||
libinput_event_destroy(event);
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ START_TEST(udev_added_seat_default)
|
|||
seat = libinput_device_get_seat(device);
|
||||
ck_assert(seat != NULL);
|
||||
|
||||
seat_name = libinput_seat_get_name(seat);
|
||||
seat_name = libinput_seat_get_logical_name(seat);
|
||||
default_seat_found = !strcmp(seat_name, "default");
|
||||
libinput_event_destroy(event);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue