Split seats into having a physical and a logical name
authorPeter Hutterer <peter.hutterer@who-t.net>
Wed, 15 Jan 2014 07:04:00 +0000 (17:04 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Fri, 17 Jan 2014 08:17:45 +0000 (18:17 +1000)
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
src/libinput-private.h
src/libinput.c
src/libinput.h
src/path.c
src/udev-seat.c
test/path.c
test/udev.c

index b08c03516801dcaa52fc5c031d6f4110945f910e..a95967fdbe93639ee6f9f6c96c4e048be0e3a92f 100644 (file)
@@ -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
index 61e71026bce03c5726c52df95c249ec2d5e4d572..fd1261dc54a15645e832fe961c475de4dbd8dc4c 100644 (file)
@@ -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
index 52c7c1a45e1a07104b448b8e612bcb36a00395f8..1fce32b74a4abdc6fb82f55ceb08dd48ee1126c7 100644 (file)
@@ -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 physical name of this seat
+ */
+const char *
+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 name of this seat
+ * @return the logical name of this seat
  */
 const char *
-libinput_seat_get_name(struct libinput_seat *seat);
+libinput_seat_get_logical_name(struct libinput_seat *seat);
 
 /**
  * @defgroup device Initialization and manipulation of input devices
index 10f6b1e0b12f71d4005bcc325356bb90a6e8b67d..f2962bfae73d9026802e36b93b7fa37a5dcb3890 100644 (file)
@@ -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;
index 1522c30faa379bc7c6a6d19a865ecd86609c7f51..2a7c9a2e067d9d6fa92a234ec5577fe3a6db4417 100644 (file)
@@ -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;
        }
 
index 6a9da7543dc47caf715d39573d9120ab5ad16db3..87775a7b0a815305bb2699d325fc1f976ee12aa5 100644 (file)
@@ -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);
index 50f05211f93725437d79b049648dda04add48a59..37658f18ac6227b317c556ec992e97f9209729d2 100644 (file)
@@ -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);
        }