mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-01-09 21:30:15 +01:00
eis: fix the object creation API again
It's now consistently parent_new_child(). Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
86bac02026
commit
5747cbf8b8
7 changed files with 47 additions and 47 deletions
|
|
@ -56,7 +56,7 @@ static
|
|||
OBJECT_IMPLEMENT_CREATE(eis_keymap);
|
||||
|
||||
_public_ struct eis_keymap *
|
||||
eis_keymap_new(struct eis_device *device,
|
||||
eis_device_new_keymap(struct eis_device *device,
|
||||
enum eis_keymap_type type, int fd, size_t size)
|
||||
{
|
||||
switch (type) {
|
||||
|
|
@ -173,7 +173,7 @@ eis_device_get_client(struct eis_device *device)
|
|||
}
|
||||
|
||||
_public_ struct eis_device *
|
||||
eis_device_new(struct eis_seat *seat)
|
||||
eis_seat_new_device(struct eis_seat *seat)
|
||||
{
|
||||
static uint32_t deviceid;
|
||||
struct eis_device *device = eis_device_create(&seat->object);
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ static
|
|||
OBJECT_IMPLEMENT_CREATE(eis_region);
|
||||
|
||||
_public_ struct eis_region *
|
||||
eis_region_new(struct eis_device *device)
|
||||
eis_device_new_region(struct eis_device *device)
|
||||
{
|
||||
struct eis_region *region = eis_region_create(NULL);
|
||||
|
||||
|
|
|
|||
10
src/libeis.h
10
src/libeis.h
|
|
@ -71,7 +71,7 @@ struct eis_keymap;
|
|||
* been defined but this may change in the future.
|
||||
*
|
||||
* Regions must be assigned when the device is created and are static for the
|
||||
* lifetime of the device. See eis_region_new() and eis_region_add().
|
||||
* lifetime of the device. See eis_device_new_region() and eis_region_add().
|
||||
*/
|
||||
struct eis_region;
|
||||
|
||||
|
|
@ -437,7 +437,7 @@ eis_device_has_capability(struct eis_device *device,
|
|||
* reference.
|
||||
*/
|
||||
struct eis_device *
|
||||
eis_device_new(struct eis_seat *seat);
|
||||
eis_seat_new_device(struct eis_seat *seat);
|
||||
|
||||
void
|
||||
eis_device_configure_name(struct eis_device *device, const char *name);
|
||||
|
|
@ -452,7 +452,7 @@ eis_device_configure_capability(struct eis_device *device, enum eis_device_capab
|
|||
* A region **must** have a size to be valid, see eis_region_set_size().
|
||||
*/
|
||||
struct eis_region *
|
||||
eis_region_new(struct eis_device *device);
|
||||
eis_device_new_region(struct eis_device *device);
|
||||
|
||||
void
|
||||
eis_region_set_size(struct eis_region *region, uint32_t w, uint32_t h);
|
||||
|
|
@ -553,8 +553,8 @@ eis_device_resume(struct eis_device *device);
|
|||
* @return A keymap object or `NULL` on failure.
|
||||
*/
|
||||
struct eis_keymap *
|
||||
eis_keymap_new(struct eis_device *device,
|
||||
enum eis_keymap_type type, int fd, size_t size);
|
||||
eis_device_new_keymap(struct eis_device *device,
|
||||
enum eis_keymap_type type, int fd, size_t size);
|
||||
|
||||
/**
|
||||
* Set the keymap on the device. Note that **not** calling this function when
|
||||
|
|
|
|||
|
|
@ -447,7 +447,7 @@ peck_handle_eis_connect(struct peck *peck, struct eis_event *e)
|
|||
static inline struct eis_device *
|
||||
peck_eis_create_pointer(struct peck *peck, struct eis_seat *seat, const char *name)
|
||||
{
|
||||
struct eis_device *device = eis_device_new(seat);
|
||||
struct eis_device *device = eis_seat_new_device(seat);
|
||||
|
||||
eis_device_configure_name(device, name);
|
||||
eis_device_configure_capability(device, EIS_DEVICE_CAP_POINTER);
|
||||
|
|
@ -462,8 +462,8 @@ peck_eis_create_pointer(struct peck *peck, struct eis_seat *seat, const char *na
|
|||
static inline struct eis_device *
|
||||
peck_eis_create_pointer_absolute(struct peck *peck, struct eis_seat *seat, const char *name)
|
||||
{
|
||||
struct eis_device *device = eis_device_new(seat);
|
||||
_unref_(eis_region) *region = eis_region_new(device);
|
||||
struct eis_device *device = eis_seat_new_device(seat);
|
||||
_unref_(eis_region) *region = eis_device_new_region(device);
|
||||
|
||||
eis_region_set_offset(region, 0, 0);
|
||||
eis_region_set_size(region, 1920, 1080);
|
||||
|
|
@ -482,7 +482,7 @@ peck_eis_create_pointer_absolute(struct peck *peck, struct eis_seat *seat, const
|
|||
static inline struct eis_device *
|
||||
peck_eis_create_keyboard(struct peck *peck, struct eis_seat *seat, const char *name)
|
||||
{
|
||||
struct eis_device *device = eis_device_new(seat);
|
||||
struct eis_device *device = eis_seat_new_device(seat);
|
||||
|
||||
eis_device_configure_name(device, name);
|
||||
eis_device_configure_capability(device, EIS_DEVICE_CAP_KEYBOARD);
|
||||
|
|
@ -497,8 +497,8 @@ peck_eis_create_keyboard(struct peck *peck, struct eis_seat *seat, const char *n
|
|||
static inline struct eis_device *
|
||||
peck_eis_create_touch(struct peck *peck, struct eis_seat *seat, const char *name)
|
||||
{
|
||||
struct eis_device *device = eis_device_new(seat);
|
||||
_unref_(eis_region) *region = eis_region_new(device);
|
||||
struct eis_device *device = eis_seat_new_device(seat);
|
||||
_unref_(eis_region) *region = eis_device_new_region(device);
|
||||
|
||||
eis_region_set_offset(region, 0, 0);
|
||||
eis_region_set_size(region, 1920, 1080);
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ MUNIT_TEST(test_ei_device_basics)
|
|||
|
||||
with_server(peck) {
|
||||
struct eis_seat *seat = peck_eis_get_default_seat(peck);
|
||||
_unref_(eis_device) *device = eis_device_new(seat);
|
||||
_unref_(eis_device) *device = eis_seat_new_device(seat);
|
||||
|
||||
eis_device_configure_name(device, "string is freed");
|
||||
munit_assert_string_equal(eis_device_get_name(device), "string is freed");
|
||||
|
|
@ -103,16 +103,16 @@ MUNIT_TEST(test_ei_device_set_name_multiple_devices)
|
|||
|
||||
with_server(peck) {
|
||||
struct eis_seat *seat = peck_eis_get_default_seat(peck);
|
||||
_unref_(eis_device) *d1 = eis_device_new(seat);
|
||||
_unref_(eis_device) *d1 = eis_seat_new_device(seat);
|
||||
eis_device_configure_name(d1, "first device");
|
||||
eis_device_configure_capability(d1, EIS_DEVICE_CAP_POINTER);
|
||||
eis_device_add(d1);
|
||||
|
||||
_unref_(eis_device) *d2 = eis_device_new(seat);
|
||||
_unref_(eis_device) *d2 = eis_seat_new_device(seat);
|
||||
/* Unnamed */
|
||||
eis_device_add(d2);
|
||||
|
||||
_unref_(eis_device) *d3 = eis_device_new(seat);
|
||||
_unref_(eis_device) *d3 = eis_seat_new_device(seat);
|
||||
eis_device_configure_name(d3, "third device");
|
||||
eis_device_configure_capability(d3, EIS_DEVICE_CAP_POINTER);
|
||||
eis_device_add(d3);
|
||||
|
|
@ -147,7 +147,7 @@ MUNIT_TEST(test_ei_device_never_added)
|
|||
/* Unref after remove */
|
||||
with_server(peck) {
|
||||
struct eis_seat *seat = peck_eis_get_default_seat(peck);
|
||||
struct eis_device *device = eis_device_new(seat);
|
||||
struct eis_device *device = eis_seat_new_device(seat);
|
||||
eis_device_remove(device);
|
||||
eis_device_unref(device);
|
||||
}
|
||||
|
|
@ -167,7 +167,7 @@ MUNIT_TEST(test_ei_device_never_added)
|
|||
*/
|
||||
with_server(peck) {
|
||||
struct eis_seat *seat = peck_eis_get_default_seat(peck);
|
||||
struct eis_device *device = eis_device_new(seat);
|
||||
struct eis_device *device = eis_seat_new_device(seat);
|
||||
eis_device_unref(device);
|
||||
eis_device_remove(device);
|
||||
}
|
||||
|
|
@ -194,7 +194,7 @@ MUNIT_TEST(test_ei_device_add_remove)
|
|||
|
||||
with_server(peck) {
|
||||
struct eis_seat *seat = peck_eis_get_default_seat(peck);
|
||||
eis_device = eis_device_new(seat);
|
||||
eis_device = eis_seat_new_device(seat);
|
||||
eis_device_configure_name(eis_device, __func__);
|
||||
eis_device_configure_capability(eis_device, EIS_DEVICE_CAP_POINTER);
|
||||
eis_device_add(eis_device);
|
||||
|
|
@ -273,25 +273,25 @@ MUNIT_TEST(test_ei_device_regions)
|
|||
|
||||
with_server(peck) {
|
||||
struct eis_seat *seat = peck_eis_get_default_seat(peck);
|
||||
_unref_(eis_device) *device = eis_device_new(seat);
|
||||
_unref_(eis_device) *device = eis_seat_new_device(seat);
|
||||
eis_device_configure_name(device, __func__);
|
||||
eis_device_configure_capability(device, EIS_DEVICE_CAP_POINTER_ABSOLUTE);
|
||||
|
||||
/* nothing cares about the actual values, so we're just
|
||||
* checking for correct passthrough here */
|
||||
_unref_(eis_region) *r1 = eis_region_new(device);
|
||||
_unref_(eis_region) *r1 = eis_device_new_region(device);
|
||||
eis_region_set_size(r1, 100, 200);
|
||||
eis_region_set_offset(r1, 300, 400);
|
||||
/* no scale, default to 1.0 */
|
||||
eis_region_add(r1);
|
||||
|
||||
_unref_(eis_region) *r2 = eis_region_new(device);
|
||||
_unref_(eis_region) *r2 = eis_device_new_region(device);
|
||||
eis_region_set_size(r2, 500, 600);
|
||||
eis_region_set_offset(r2, 700, 800);
|
||||
eis_region_set_physical_scale(r2, 3.9);
|
||||
eis_region_add(r2);
|
||||
|
||||
_unref_(eis_region) *r3 = eis_region_new(device);
|
||||
_unref_(eis_region) *r3 = eis_device_new_region(device);
|
||||
eis_region_set_size(r3, 900, 1000);
|
||||
eis_region_set_offset(r3, 1100, 1200);
|
||||
eis_region_set_physical_scale(r3, 0.3);
|
||||
|
|
@ -348,12 +348,12 @@ MUNIT_TEST(test_ei_device_regions_ref_unref)
|
|||
|
||||
with_server(peck) {
|
||||
struct eis_seat *seat = peck_eis_get_default_seat(peck);
|
||||
_unref_(eis_device) *device = eis_device_new(seat);
|
||||
_unref_(eis_device) *device = eis_seat_new_device(seat);
|
||||
eis_device_configure_name(device, __func__);
|
||||
eis_device_configure_capability(device, EIS_DEVICE_CAP_POINTER_ABSOLUTE);
|
||||
|
||||
/* region never added */
|
||||
struct eis_region *r1 = eis_region_new(device);
|
||||
struct eis_region *r1 = eis_device_new_region(device);
|
||||
eis_region_unref(r1);
|
||||
eis_device_add(device);
|
||||
}
|
||||
|
|
@ -378,14 +378,14 @@ MUNIT_TEST(test_ei_device_regions_late_add)
|
|||
|
||||
with_server(peck) {
|
||||
struct eis_seat *seat = peck_eis_get_default_seat(peck);
|
||||
_unref_(eis_device) *device = eis_device_new(seat);
|
||||
_unref_(eis_device) *device = eis_seat_new_device(seat);
|
||||
eis_device_configure_name(device, __func__);
|
||||
eis_device_configure_capability(device, EIS_DEVICE_CAP_POINTER_ABSOLUTE);
|
||||
|
||||
eis_device_add(device);
|
||||
|
||||
/* region added after device_add -> ignored */
|
||||
_unref_(eis_region) *r1 = eis_region_new(device);
|
||||
_unref_(eis_region) *r1 = eis_device_new_region(device);
|
||||
eis_region_set_size(r1, 100, 200);
|
||||
eis_region_add(r1);
|
||||
}
|
||||
|
|
@ -671,23 +671,23 @@ MUNIT_TEST(test_ei_keymap_invalid)
|
|||
|
||||
with_server(peck) {
|
||||
struct eis_seat *seat = peck_eis_get_default_seat(peck);
|
||||
_unref_(eis_device) *device = eis_device_new(seat);
|
||||
_unref_(eis_device) *device = eis_seat_new_device(seat);
|
||||
|
||||
const char data[5] = {1, 2, 3, 4, 5};
|
||||
_unref_(memfile) *fd = memfile_new(data, sizeof(data));
|
||||
|
||||
munit_assert_ptr_null(eis_keymap_new(device, EIS_KEYMAP_TYPE_XKB + 1,
|
||||
munit_assert_ptr_null(eis_device_new_keymap(device, EIS_KEYMAP_TYPE_XKB + 1,
|
||||
memfile_get_fd(fd), memfile_get_size(fd)));
|
||||
munit_assert_ptr_null(eis_keymap_new(device, EIS_KEYMAP_TYPE_XKB - 1,
|
||||
munit_assert_ptr_null(eis_device_new_keymap(device, EIS_KEYMAP_TYPE_XKB - 1,
|
||||
memfile_get_fd(fd), memfile_get_size(fd)));
|
||||
munit_assert_ptr_null(eis_keymap_new(device, EIS_KEYMAP_TYPE_XKB,
|
||||
munit_assert_ptr_null(eis_device_new_keymap(device, EIS_KEYMAP_TYPE_XKB,
|
||||
-1, memfile_get_size(fd)));
|
||||
munit_assert_ptr_null(eis_keymap_new(device, EIS_KEYMAP_TYPE_XKB,
|
||||
munit_assert_ptr_null(eis_device_new_keymap(device, EIS_KEYMAP_TYPE_XKB,
|
||||
memfile_get_fd(fd), 0));
|
||||
|
||||
/* Valid keymap, valgrind checks only */
|
||||
_unref_(eis_keymap) *unused =
|
||||
eis_keymap_new(device, EIS_KEYMAP_TYPE_XKB, memfile_get_fd(fd), memfile_get_size(fd));
|
||||
eis_device_new_keymap(device, EIS_KEYMAP_TYPE_XKB, memfile_get_fd(fd), memfile_get_size(fd));
|
||||
munit_assert_ptr_not_null(unused);
|
||||
}
|
||||
|
||||
|
|
@ -709,11 +709,11 @@ MUNIT_TEST(test_ei_keymap_set)
|
|||
|
||||
with_server(peck) {
|
||||
struct eis_seat *seat = peck_eis_get_default_seat(peck);
|
||||
_unref_(eis_device) *device = eis_device_new(seat);
|
||||
_unref_(eis_device) *device = eis_seat_new_device(seat);
|
||||
eis_device_configure_name(device, __func__);
|
||||
eis_device_configure_capability(device, EIS_DEVICE_CAP_KEYBOARD);
|
||||
|
||||
keymap = eis_keymap_new(device, EIS_KEYMAP_TYPE_XKB,
|
||||
keymap = eis_device_new_keymap(device, EIS_KEYMAP_TYPE_XKB,
|
||||
memfile_get_fd(fd1), memfile_get_size(fd1));
|
||||
eis_keymap_add(keymap);
|
||||
munit_assert_ptr_equal(eis_device_keyboard_get_keymap(device), keymap);
|
||||
|
|
@ -723,7 +723,7 @@ MUNIT_TEST(test_ei_keymap_set)
|
|||
/* Not possible to overwrite a keymap on a device once it's set */
|
||||
_unref_(memfile) *fd2 = memfile_new(data, sizeof(data));
|
||||
_unref_(eis_keymap) *overwrite =
|
||||
eis_keymap_new(device, EIS_KEYMAP_TYPE_XKB, memfile_get_fd(fd2), memfile_get_size(fd2));
|
||||
eis_device_new_keymap(device, EIS_KEYMAP_TYPE_XKB, memfile_get_fd(fd2), memfile_get_size(fd2));
|
||||
eis_keymap_add(overwrite);
|
||||
munit_assert_ptr_equal(eis_device_keyboard_get_keymap(device), keymap);
|
||||
|
||||
|
|
@ -731,7 +731,7 @@ MUNIT_TEST(test_ei_keymap_set)
|
|||
|
||||
/* Still impossible to overwrite after add */
|
||||
_unref_(eis_keymap) *ignored =
|
||||
eis_keymap_new(device, EIS_KEYMAP_TYPE_XKB,
|
||||
eis_device_new_keymap(device, EIS_KEYMAP_TYPE_XKB,
|
||||
memfile_get_fd(fd2), memfile_get_size(fd2));
|
||||
eis_keymap_add(ignored);
|
||||
munit_assert_ptr_equal(eis_device_keyboard_get_keymap(device), keymap);
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ create_mouse(struct eis_demo_server *server, struct eis_seat *seat,
|
|||
{
|
||||
struct eis_client *client = eis_seat_get_client(seat);
|
||||
_cleanup_free_ char *devicename = xaprintf("%s pointer", eis_client_get_name(client));
|
||||
_unref_(eis_device) *device = eis_device_new(seat);
|
||||
_unref_(eis_device) *device = eis_seat_new_device(seat);
|
||||
|
||||
eis_device_configure_name(device, devicename);
|
||||
eis_device_configure_capability(device, EIS_DEVICE_CAP_POINTER);
|
||||
|
|
@ -100,7 +100,7 @@ create_keyboard(struct eis_demo_server *server, struct eis_seat *seat,
|
|||
{
|
||||
struct eis_client *client = eis_seat_get_client(seat);
|
||||
_cleanup_free_ char *devicename = xaprintf("%s keyboard", eis_client_get_name(client));
|
||||
_unref_(eis_device) *device = eis_device_new(seat);
|
||||
_unref_(eis_device) *device = eis_seat_new_device(seat);
|
||||
|
||||
eis_device_configure_name(device, devicename);
|
||||
eis_device_configure_capability(device, EIS_DEVICE_CAP_KEYBOARD);
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ setup_keymap(struct eis_demo_server *server, struct eis_device *device)
|
|||
if (!f)
|
||||
return;
|
||||
|
||||
_unref_(eis_keymap) *k = eis_keymap_new(device,
|
||||
_unref_(eis_keymap) *k = eis_device_new_keymap(device,
|
||||
EIS_KEYMAP_TYPE_XKB, memfile_get_fd(f),
|
||||
memfile_get_size(f));
|
||||
eis_keymap_add(k);
|
||||
|
|
@ -181,10 +181,10 @@ eis_demo_server_printf_handle_event(struct eis_demo_server *server,
|
|||
struct eis_client *client = eis_event_get_client(e);
|
||||
struct eis_seat *seat = eis_event_get_seat(e);
|
||||
|
||||
struct eis_device *ptr = eis_device_new(seat);
|
||||
struct eis_device *ptr = eis_seat_new_device(seat);
|
||||
eis_device_configure_name(ptr, "test pointer");
|
||||
eis_device_configure_capability(ptr, EIS_DEVICE_CAP_POINTER);
|
||||
_unref_(eis_region) *rel_region = eis_region_new(ptr);
|
||||
_unref_(eis_region) *rel_region = eis_device_new_region(ptr);
|
||||
eis_region_set_size(rel_region, 1920, 1080);
|
||||
eis_region_set_offset(rel_region, 0, 0);
|
||||
eis_region_add(rel_region);
|
||||
|
|
@ -195,7 +195,7 @@ eis_demo_server_printf_handle_event(struct eis_demo_server *server,
|
|||
/* ptr ref is dangling */
|
||||
|
||||
|
||||
struct eis_device *kbd = eis_device_new(seat);
|
||||
struct eis_device *kbd = eis_seat_new_device(seat);
|
||||
eis_device_configure_name(kbd, "test keyboard");
|
||||
eis_device_configure_capability(kbd, EIS_DEVICE_CAP_KEYBOARD);
|
||||
if (server->layout)
|
||||
|
|
@ -207,10 +207,10 @@ eis_demo_server_printf_handle_event(struct eis_demo_server *server,
|
|||
/* kbd ref is dangling */
|
||||
|
||||
|
||||
struct eis_device *abs = eis_device_new(seat);
|
||||
struct eis_device *abs = eis_seat_new_device(seat);
|
||||
eis_device_configure_name(abs, "test abs pointer");
|
||||
eis_device_configure_capability(abs, EIS_DEVICE_CAP_POINTER_ABSOLUTE);
|
||||
_unref_(eis_region) *region = eis_region_new(abs);
|
||||
_unref_(eis_region) *region = eis_device_new_region(abs);
|
||||
eis_region_set_size(region, 1920, 1080);
|
||||
eis_region_set_offset(region, 0, 0);
|
||||
eis_region_add(region);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue