/* TODO: Error logging. */
#define PEPPER_ERROR(...)
-typedef struct li_seat li_seat_t;
+typedef struct li_device li_device_t;
+typedef struct li_device_property li_device_property_t;
struct pepper_libinput
{
struct wl_event_source *libinput_event_source;
int libinput_fd;
- struct wl_list seat_list;
+ struct wl_list device_list;
};
-struct li_seat
+struct li_device
{
- pepper_seat_t *base;
pepper_libinput_t *input;
+ pepper_pointer_device_t *pointer;
+ pepper_keyboard_device_t *keyboard;
+ pepper_touch_device_t *touch;
- uint32_t id;
uint32_t caps;
- char *name;
- int pointer_x_last;
- int pointer_y_last;
- int touch_x_last; /* FIXME */
- int touch_y_last; /* FIXME */
+ struct wl_list property_list;
+ struct wl_list link;
+};
+struct li_device_property /* FIXME */
+{
+ char *key;
+ char *data;
struct wl_list link;
- struct wl_signal capabilities_signal;
- struct wl_signal name_signal;
};
#endif /* LIBINPUT_INTERNAL_H */
#include "libinput-internal.h"
-static void
-li_seat_destroy(void *data)
-{
- li_seat_t *seat = (li_seat_t *)data;
-
- wl_list_remove(&seat->link);
-
- if (seat->name)
- free(seat->name);
-
- free(seat);
-}
-
-static void
-li_seat_add_capabilities_listener(void *data, struct wl_listener *listener)
-{
- li_seat_t *seat = (li_seat_t *)data;
- wl_signal_add(&seat->capabilities_signal, listener);
-}
-
-static void
-li_seat_add_name_listener(void *data, struct wl_listener *listener)
-{
- li_seat_t *seat = (li_seat_t *)data;
- wl_signal_add(&seat->name_signal, listener);
-}
-
-static uint32_t
-li_seat_get_capabilities(void *data)
-{
- li_seat_t *seat = (li_seat_t *)data;
- return seat->caps;
-}
-
-static const char *
-li_seat_get_name(void *data)
-{
- li_seat_t *seat = (li_seat_t *)data;
- return seat->name;
-}
-
-static const pepper_seat_backend_t li_seat_backend =
-{
- li_seat_destroy,
- li_seat_add_capabilities_listener,
- li_seat_add_name_listener,
- li_seat_get_capabilities,
- li_seat_get_name,
-};
-
-static li_seat_t *
-li_seat_create(pepper_libinput_t *input)
-{
- li_seat_t *seat;
-
- seat = (li_seat_t *)calloc(1, sizeof(li_seat_t));
- if (!seat)
- {
- PEPPER_ERROR("Failed to allocate memory in %s\n", __FUNCTION__);
- return NULL;
- }
-
- wl_signal_init(&seat->capabilities_signal);
- wl_signal_init(&seat->name_signal);
-
- seat->input = input;
- seat->base = pepper_compositor_add_seat(input->compositor,
- &li_seat_backend, seat);
- if (!seat->base)
- {
- PEPPER_ERROR("Failed to create pepper_seat in %s\n", __FUNCTION__);
- goto error;
- }
-
- return seat;
-
-error:
- if (seat)
- free(seat);
-
- return NULL;
-}
-
static int
libinput_open_restricted(const char *path, int flags, void *user_data)
{
}
static void
+libinput_device_get_properties(struct libinput_device *libinput_device,
+ struct wl_list *property_list)
+{
+ /* get properties */
+ struct udev_device *udev_device = libinput_device_get_udev_device(libinput_device);
+ struct udev_list_entry *e;
+
+ e = udev_device_get_properties_list_entry(udev_device);
+ while (e)
+ {
+ li_device_property_t *property;
+ const char *name = udev_list_entry_get_name(e);
+ const char *value = udev_list_entry_get_value(e);
+
+ property = (li_device_property_t *)calloc(1, sizeof(li_device_property_t));
+ if (!property)
+ continue;
+
+ property->key = strdup(name);
+ property->data = strdup(value);
+
+ wl_list_insert(property_list, &property->link);
+
+ e = udev_list_entry_get_next(e);
+ }
+}
+
+static void
device_added(pepper_libinput_t *input, struct libinput_device *libinput_device)
{
- struct libinput_seat *libinput_seat;
- const char *seat_name;
- li_seat_t *tmp, *seat = NULL;
- uint32_t caps;
+ struct wl_list property_list;
+ uint32_t caps;
+ li_device_t *device;
- libinput_seat = libinput_device_get_seat(libinput_device);
- seat_name = libinput_seat_get_logical_name(libinput_seat);
+ caps = get_capabilities(libinput_device);
+ device = (li_device_t *)calloc(1, sizeof(li_device_t));
+ if (!device)
+ {
+ PEPPER_ERROR("Failed to allocate memory\n");
+ /* TODO: error handling */
+ return;
+ }
+
+ device->input = input;
+ device->caps = caps;
- wl_list_for_each(tmp, &input->seat_list, link)
+
+ if (caps & WL_SEAT_CAPABILITY_POINTER)
{
- if (strcmp(tmp->name, seat_name) == 0)
+ pepper_pointer_device_t *pointer_device;
+
+ pointer_device = pepper_pointer_device_create(input->compositor);
+ if (!pointer_device)
{
- seat = tmp;
- break;
+ PEPPER_ERROR("Failed to create pepper pointer device\n");
+ /* TODO: error handling */
+ return;
}
+ device->pointer = pointer_device;
}
-
- if (!seat)
+ else if (caps & WL_SEAT_CAPABILITY_KEYBOARD)
{
- seat = li_seat_create(input);
- if (!seat)
+ pepper_keyboard_device_t *keyboard_device;
+
+ keyboard_device = pepper_keyboard_device_create(input->compositor);
+ if (!keyboard_device)
{
- PEPPER_ERROR("Failed to create libinput_seat in %s\n", __FUNCTION__);
+ PEPPER_ERROR("Failed to create pepper keyboard device\n");
+ /* TODO: error handling */
return;
}
+ device->keyboard = keyboard_device;
+ }
+ else if (caps & WL_SEAT_CAPABILITY_TOUCH)
+ {
+ pepper_touch_device_t *touch_device;
- wl_list_insert(&input->seat_list, &seat->link);
+ touch_device = pepper_touch_device_create(input->compositor);
+ if (!touch_device)
+ {
+ PEPPER_ERROR("Failed to create pepper touch device\n");
+ /* TODO: error handling */
+ return;
+ }
+ device->touch = touch_device;
}
- libinput_device_set_user_data(libinput_device, seat);
+ wl_list_init(&property_list); /* FIXME */
+ libinput_device_get_properties(libinput_device, &property_list); /* FIXME */
+ wl_list_init(&device->property_list); /* FIXME */
+ wl_list_insert_list(&device->property_list, &property_list); /* FIXME */
- /* TODO
- * check tab count
- * check calibration
- */
+ wl_list_insert(&input->device_list, &device->link);
+ libinput_device_set_user_data(libinput_device, device);
+}
- caps = get_capabilities(libinput_device);
- if (seat->caps != caps)
- {
- seat->caps |= caps;
- wl_signal_emit(&seat->capabilities_signal, seat);
- }
+static void
+clear_property_list(struct wl_list *list)
+{
+ li_device_property_t *property, *tmp;
+
+ if (wl_list_empty(list))
+ return;
- if (!seat->name)
+ wl_list_for_each_safe(property, tmp, list, link)
{
- seat->name = strdup(seat_name);
- wl_signal_emit(&seat->name_signal, seat);
+ wl_list_remove(&property->link);
+
+ if (property->key)
+ free(property->key);
+ if (property->data)
+ free(property->data);
+
+ free(property);
}
}
static void
-device_removed(pepper_libinput_t *input, struct libinput_device *libinput_device)
+li_device_destroy(li_device_t *device)
{
- li_seat_t *seat;
- uint32_t caps;
+ wl_list_remove(&device->link);
+ clear_property_list(&device->property_list);
- seat = (li_seat_t *)libinput_device_get_user_data(libinput_device);
- caps = get_capabilities(libinput_device);
+ if (device->pointer)
+ pepper_pointer_device_destroy(device->pointer);
- if (seat->caps != caps)
- {
- seat->caps = caps;
- wl_signal_emit(&seat->capabilities_signal, seat);
- }
+ if (device->keyboard)
+ pepper_keyboard_device_destroy(device->keyboard);
+
+ if (device->touch)
+ pepper_touch_device_destroy(device->touch);
+
+ free(device);
+}
+
+static void
+device_removed(pepper_libinput_t *input, struct libinput_device *libinput_device)
+{
+ li_device_t *device;
+ device = (li_device_t *)libinput_device_get_user_data(libinput_device);
+ li_device_destroy(device);
}
static void
pointer_motion(struct libinput_device *libinput_device,
struct libinput_event_pointer *pointer_event)
{
- li_seat_t *seat;
- pepper_input_event_t event;
-
- seat = (li_seat_t *)libinput_device_get_user_data(libinput_device);
-
- event.type = PEPPER_INPUT_EVENT_POINTER_MOTION;
- event.time = libinput_event_pointer_get_time(pointer_event);
- event.serial = 0;
- event.index = 0;
- event.state = 0;
- event.value = 0;
- event.x = seat->pointer_x_last = wl_fixed_from_double(
- libinput_event_pointer_get_dx(pointer_event));
- event.y = seat->pointer_y_last = wl_fixed_from_double(
- libinput_event_pointer_get_dy(pointer_event));
-
- pepper_seat_handle_event(seat->base, &event);
+ li_device_t *device;
+ wl_fixed_t dx, dy;
+
+ device = (li_device_t *)libinput_device_get_user_data(libinput_device);
+
+ dx = wl_fixed_from_double(libinput_event_pointer_get_dx(pointer_event));
+ dy = wl_fixed_from_double(libinput_event_pointer_get_dy(pointer_event));
+
+ /* TODO */
}
static void
pointer_motion_absolute(struct libinput_device *libinput_device,
struct libinput_event_pointer *pointer_event)
{
- li_seat_t *seat;
- pepper_input_event_t event;
-
- seat = (li_seat_t *)libinput_device_get_user_data(libinput_device);
-
+ li_device_t *device;
+ device = (li_device_t *)libinput_device_get_user_data(libinput_device);
/* TODO */
-
- pepper_seat_handle_event(seat->base, &event);
}
static void
pointer_button(struct libinput_device *libinput_device,
struct libinput_event_pointer *pointer_event)
{
- li_seat_t *seat;
- pepper_input_event_t event;
-
- seat = (li_seat_t *)libinput_device_get_user_data(libinput_device);
-
- event.type = PEPPER_INPUT_EVENT_POINTER_BUTTON;
- event.time = libinput_event_pointer_get_time(pointer_event);
- event.serial = 0;
- event.index = libinput_event_pointer_get_button(pointer_event);
- event.state = libinput_event_pointer_get_button_state(pointer_event);
- event.value = 0;
- event.x = seat->pointer_x_last;
- event.y = seat->pointer_y_last;
-
- pepper_seat_handle_event(seat->base, &event);
+ li_device_t *device;
+ device = (li_device_t *)libinput_device_get_user_data(libinput_device);
+ /* TODO */
}
static void
pointer_axis(struct libinput_device *libinput_device,
struct libinput_event_pointer *pointer_event)
{
- li_seat_t *seat;
- pepper_input_event_t event;
-
- seat = (li_seat_t *)libinput_device_get_user_data(libinput_device);
-
- event.type = PEPPER_INPUT_EVENT_POINTER_AXIS;
- event.time = libinput_event_pointer_get_time(pointer_event);
- event.serial = 0;
+ int axis = -1;
+ wl_fixed_t value;
+ li_device_t *device;
+ device = (li_device_t *)libinput_device_get_user_data(libinput_device);
if (libinput_event_pointer_has_axis(pointer_event,
LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL) != 0)
- {
- event.index = LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL;
- }
+ axis = LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL; /* FIXME */
else if (libinput_event_pointer_has_axis(pointer_event,
LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL) != 0)
- {
- event.index = LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL;
- }
+ axis = LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL; /* FIXME */
- event.state = 0;
- event.value = wl_fixed_from_double(libinput_event_pointer_get_axis_value(pointer_event,
- event.index));
- event.x = seat->pointer_x_last;
- event.y = seat->pointer_y_last;
+ if (axis < 0)
+ return;
- /* TODO: check axis_source */
+ value = wl_fixed_from_double(libinput_event_pointer_get_axis_value(pointer_event, axis));
- pepper_seat_handle_event(seat->base, &event);
+ /* TODO */
}
static void
keyboard_key(struct libinput_device *libinput_device,
struct libinput_event_keyboard *keyboard_event)
{
- li_seat_t *seat;
- pepper_input_event_t event;
+ li_device_t *device;
+ device = (li_device_t *)libinput_device_get_user_data(libinput_device);
- seat = (li_seat_t *)libinput_device_get_user_data(libinput_device);
-
- event.type = PEPPER_INPUT_EVENT_KEYBOARD_KEY;
- event.time = libinput_event_keyboard_get_time(keyboard_event);
- event.serial = 0;
- event.index = libinput_event_keyboard_get_key(keyboard_event);
- event.state = libinput_event_keyboard_get_key_state(keyboard_event);
- event.value = 0;
- event.x = 0;
- event.y = 0;
-
- pepper_seat_handle_event(seat->base, &event);
+ /* TODO */
}
static void
touch_down(struct libinput_device *libinput_device,
struct libinput_event_touch *touch_event)
{
- li_seat_t *seat;
- pepper_input_event_t event;
- uint32_t width, height;
-
- seat = (li_seat_t *)libinput_device_get_user_data(libinput_device);
-
- event.type = PEPPER_INPUT_EVENT_TOUCH_DOWN;
- event.time = libinput_event_touch_get_time(touch_event);
- event.serial = 0;
- event.index = libinput_event_touch_get_seat_slot(touch_event); /* XXX */
- event.value = 0;
- event.state = 0;
-
- width = 1280; /* FIXME: get width from output */
- event.x = wl_fixed_from_double(
- libinput_event_touch_get_x_transformed(touch_event, width));
- seat->touch_x_last = event.x;
-
- height = 720; /* FIXME: get height from output */
- event.y = wl_fixed_from_double(
- libinput_event_touch_get_y_transformed(touch_event, height));
- seat->touch_y_last = event.y;
-
- pepper_seat_handle_event(seat->base, &event);
+ li_device_t *device;
+ device = (li_device_t *)libinput_device_get_user_data(libinput_device);
+ /* TODO */
}
static void
touch_up(struct libinput_device *libinput_device,
struct libinput_event_touch *touch_event)
{
- li_seat_t *seat;
- pepper_input_event_t event;
-
- seat = (li_seat_t *)libinput_device_get_user_data(libinput_device);
-
- event.type = PEPPER_INPUT_EVENT_TOUCH_UP;
- event.time = libinput_event_touch_get_time(touch_event);
- event.serial = 0;
- event.index = libinput_event_touch_get_seat_slot(touch_event); /* XXX */
- event.value = 0;
- event.state = 0;
- event.x = seat->touch_x_last;
- event.y = seat->touch_y_last;
-
- pepper_seat_handle_event(seat->base, &event);
+ li_device_t *device;
+ device = (li_device_t *)libinput_device_get_user_data(libinput_device);
+ /* TODO */
}
static void
touch_motion(struct libinput_device *libinput_device,
struct libinput_event_touch *touch_event)
{
- li_seat_t *seat;
- pepper_input_event_t event;
- uint32_t width, height;
-
- seat = (li_seat_t *)libinput_device_get_user_data(libinput_device);
-
-
- event.type = PEPPER_INPUT_EVENT_TOUCH_MOTION;
- event.time = libinput_event_touch_get_time(touch_event);
- event.serial = 0;
- event.index = libinput_event_touch_get_seat_slot(touch_event); /* XXX */
- event.value = 0;
- event.state = 0;
-
- width = 1280; /* FIXME: get width from output */
- event.x = wl_fixed_from_double(
- libinput_event_touch_get_x_transformed(touch_event, width));
- seat->touch_x_last = event.x;
-
- height = 720; /* FIXME: get height from output */
- event.y = wl_fixed_from_double(
- libinput_event_touch_get_y_transformed(touch_event, height));
- seat->touch_y_last = event.y;
-
- pepper_seat_handle_event(seat->base, &event);
+ li_device_t *device;
+ device = (li_device_t *)libinput_device_get_user_data(libinput_device);
+ /* TODO */
}
static void
touch_frame(struct libinput_device *libinput_device,
struct libinput_event_touch *touch_event)
{
- li_seat_t *seat;
- pepper_input_event_t event;
-
- seat = (li_seat_t *)libinput_device_get_user_data(libinput_device);
-
- event.type = PEPPER_INPUT_EVENT_TOUCH_FRAME;
- pepper_seat_handle_event(seat->base, &event);
+ li_device_t *device;
+ device = (li_device_t *)libinput_device_get_user_data(libinput_device);
+ /* TODO */
}
static void
input->compositor = compositor;
input->udev = udev;
-
- wl_list_init(&input->seat_list);
+ wl_list_init(&input->device_list);
input->libinput = libinput_udev_create_context(&libinput_interface, input, input->udev);
if (!input->libinput)
PEPPER_API void
pepper_libinput_destroy(pepper_libinput_t *input)
{
- li_seat_t *seat, *tmp;
+ li_device_t *device, *tmp;
- wl_list_for_each_safe(seat, tmp, &input->seat_list, link)
- li_seat_destroy(seat);
+ wl_list_for_each_safe(device, tmp, &input->device_list, link)
+ li_device_destroy(device);
if (input->libinput)
libinput_unref(input->libinput);
static void
seat_get_pointer(struct wl_client *client, struct wl_resource *resource, uint32_t id)
{
- pepper_seat_t *seat = (pepper_seat_t *)wl_resource_get_user_data(resource);
- struct wl_resource *r;
+ pepper_seat_t *seat = (pepper_seat_t *)wl_resource_get_user_data(resource);
+ struct wl_resource *r;
if (!seat->pointer)
return;
static void
seat_get_keyboard(struct wl_client *client, struct wl_resource *resource, uint32_t id)
{
- pepper_seat_t *seat = (pepper_seat_t *)wl_resource_get_user_data(resource);
- struct wl_resource *r;
+ pepper_seat_t *seat = (pepper_seat_t *)wl_resource_get_user_data(resource);
+ struct wl_resource *r;
if (!seat->keyboard)
return;
}
wl_list_insert(&seat->keyboard->resources, wl_resource_get_link(r));
- wl_resource_set_implementation(r, &keyboard_interface, seat, unbind_resource);
+ wl_resource_set_implementation(r, &keyboard_interface, seat->keyboard, unbind_resource);
/* TODO */
static void
seat_get_touch(struct wl_client *client, struct wl_resource *resource, uint32_t id)
{
- pepper_seat_t *seat = (pepper_seat_t *)wl_resource_get_user_data(resource);
- struct wl_resource *r;
+ pepper_seat_t *seat = (pepper_seat_t *)wl_resource_get_user_data(resource);
+ struct wl_resource *r;
if (!seat->touch)
return;
}
wl_list_insert(&seat->touch->resources, wl_resource_get_link(r));
- wl_resource_set_implementation(r, &touch_interface, seat, unbind_resource);
+ wl_resource_set_implementation(r, &touch_interface, seat->touch, unbind_resource);
/* TODO */
wl_resource_set_implementation(resource, &seat_interface, data, unbind_resource);
wl_seat_send_capabilities(resource, seat->caps);
+
+ if ((seat->name) && (version >= WL_SEAT_NAME_SINCE_VERSION))
+ wl_seat_send_name(resource, seat->name);
}
-static pepper_pointer_t *
-pointer_create(pepper_seat_t *seat)
+PEPPER_API pepper_seat_t *
+pepper_compositor_add_seat(pepper_compositor_t *compositor,
+ const char *seat_name,
+ void *data)
{
- pepper_pointer_t *pointer;
+ pepper_seat_t *seat;
- pointer = (pepper_pointer_t *)pepper_object_alloc(PEPPER_OBJECT_POINTER,
- sizeof(pepper_pointer_t));
- if (!pointer)
+ seat = (pepper_seat_t *)pepper_object_alloc(PEPPER_OBJECT_SEAT, sizeof(pepper_seat_t));
+ if (!seat)
{
PEPPER_ERROR("Failed to allocate memory in %s\n", __FUNCTION__);
return NULL;
}
- pointer->seat = seat;
- wl_list_init(&pointer->resources);
+ seat->compositor = compositor;
+ seat->data = data;
- return pointer;
-}
+ wl_list_init(&seat->resources);
+ wl_list_init(&seat->link);
+ wl_list_insert(&compositor->seat_list, &seat->link);
-static void
-pointer_destroy(pepper_seat_t *seat)
-{
- struct wl_resource *resource;
- struct wl_list *resource_list = &seat->pointer->resources;
+ if (seat_name)
+ seat->name = strdup(seat_name);
- wl_resource_for_each(resource, resource_list)
- wl_resource_destroy(resource);
- pepper_free(seat->pointer);
+ seat->global = wl_global_create(compositor->display, &wl_seat_interface, 4, seat,
+ bind_seat);
+ return seat;
}
-static pepper_keyboard_t *
-keyboard_create(pepper_seat_t *seat)
+PEPPER_API pepper_pointer_t *
+pepper_seat_get_pointer(pepper_seat_t *seat)
{
- pepper_keyboard_t *keyboard;
-
- keyboard = (pepper_keyboard_t *)pepper_object_alloc(PEPPER_OBJECT_KEYBOARD,
- sizeof(pepper_keyboard_t));
- if (!keyboard)
- {
- PEPPER_ERROR("Failed to allocate memory in %s\n", __FUNCTION__);
- return NULL;
- }
+ return seat->pointer;
+}
- keyboard->seat = seat;
- wl_list_init(&keyboard->resources);
+PEPPER_API pepper_keyboard_t *
+pepper_seat_get_keyboard(pepper_seat_t *seat)
+{
+ return seat->keyboard;
+}
- return keyboard;
+PEPPER_API pepper_touch_t *
+pepper_seat_get_touch(pepper_seat_t *seat)
+{
+ return seat->touch;
}
static void
-keyboard_destroy(pepper_seat_t *seat)
+send_capabilities(pepper_seat_t *seat)
{
- struct wl_resource *resource;
- struct wl_list *resource_list = &seat->keyboard->resources;
+ struct wl_resource *resource;
+ struct wl_list *resource_list = &seat->resources;
wl_resource_for_each(resource, resource_list)
- wl_resource_destroy(resource);
- pepper_free(seat->keyboard);
+ wl_seat_send_capabilities(resource, seat->caps);
}
-static pepper_touch_t *
-touch_create(pepper_seat_t *seat)
+PEPPER_API pepper_pointer_device_t *
+pepper_pointer_device_create(pepper_compositor_t *compositor)
{
- pepper_touch_t *touch;
+ pepper_pointer_device_t *device;
- touch = (pepper_touch_t *)pepper_object_alloc(PEPPER_OBJECT_TOUCH, sizeof(pepper_touch_t));
- if (!touch)
+ device = (pepper_pointer_device_t *)pepper_object_alloc(PEPPER_OBJECT_POINTER_DEVICE,
+ sizeof(pepper_pointer_device_t));
+ if (!device)
{
- PEPPER_ERROR("Failed to allocate memory in %s\n", __FUNCTION__);
+ PEPPER_ERROR("Failed to allocate memory\n");
return NULL;
}
- touch->seat = seat;
- wl_list_init(&touch->resources);
-
- return touch;
+ return device;
}
-static void
-touch_destroy(pepper_seat_t *seat)
+PEPPER_API void
+pepper_pointer_device_destroy(pepper_pointer_device_t *device)
{
- struct wl_resource *resource;
- struct wl_list *resource_list = &seat->touch->resources;
-
- wl_resource_for_each(resource, resource_list)
- wl_resource_destroy(resource);
- pepper_free(seat->touch);
+ pepper_object_fini((pepper_object_t *)device);
+ pepper_free(device);
}
-static void
-seat_set_capabilities(pepper_seat_t *seat, uint32_t caps)
+PEPPER_API pepper_keyboard_device_t *
+pepper_keyboard_device_create(pepper_compositor_t *compositor)
{
- struct wl_resource *resource;
-
- seat->caps = caps;
-
- if ((caps & WL_SEAT_CAPABILITY_POINTER) && (!seat->pointer))
- {
- seat->pointer = pointer_create(seat);
- if (!seat->pointer)
- {
- PEPPER_ERROR("Failed to allocate memory in %s\n", __FUNCTION__);
- return;
- }
- }
- else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && (seat->pointer))
- {
- pointer_destroy(seat);
- }
+ pepper_keyboard_device_t *device;
- if ((caps & WL_SEAT_CAPABILITY_KEYBOARD) && (!seat->keyboard))
- {
- seat->keyboard = keyboard_create(seat);
- if (!seat->keyboard)
- {
- PEPPER_ERROR("Failed to allocate memory in %s\n", __FUNCTION__);
- return;
- }
- }
- else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && (seat->keyboard))
- {
- keyboard_destroy(seat);
- }
-
- if ((caps & WL_SEAT_CAPABILITY_TOUCH) && (!seat->touch))
- {
- seat->touch = touch_create(seat);
- if (!seat->touch)
- {
- PEPPER_ERROR("Failed to allocate memory in %s\n", __FUNCTION__);
- return;
- }
- }
- else if (!(caps & WL_SEAT_CAPABILITY_TOUCH) && (seat->touch))
+ device = (pepper_keyboard_device_t *)pepper_object_alloc(PEPPER_OBJECT_KEYBOARD_DEVICE,
+ sizeof(pepper_keyboard_device_t));
+ if (!device)
{
- touch_destroy(seat);
+ PEPPER_ERROR("Failed to allocate memory\n");
+ return NULL;
}
- wl_resource_for_each(resource, &seat->resources)
- wl_seat_send_capabilities(resource, caps);
+ return device;
}
-static void
-handle_seat_set_capabilities(struct wl_listener *listener, void *data)
-{
- pepper_seat_t *seat = pepper_container_of(listener, pepper_seat_t, capabilities_listener);
- uint32_t caps;
-
- caps = seat->backend->get_capabilities(data);
- seat_set_capabilities(seat, caps);
-}
-
-static void
-seat_set_name(pepper_seat_t *seat, const char *name)
+PEPPER_API void
+pepper_keyboard_device_destroy(pepper_keyboard_device_t *device)
{
- struct wl_resource *resource;
-
- seat->name = name;
- wl_resource_for_each(resource, &seat->resources)
- wl_seat_send_name(resource, name);
+ pepper_object_fini((pepper_object_t *)device);
+ pepper_free(device);
}
-static void
-handle_seat_set_name(struct wl_listener *listener, void *data)
+PEPPER_API pepper_touch_device_t *
+pepper_touch_device_create(pepper_compositor_t *compositor)
{
- pepper_seat_t *seat = pepper_container_of(listener, pepper_seat_t, name_listener);
- const char *name;
-
- name = seat->backend->get_name(data);
- seat_set_name(seat, name);
-}
+ pepper_touch_device_t *device;
-PEPPER_API pepper_seat_t *
-pepper_compositor_add_seat(pepper_compositor_t *compositor,
- const pepper_seat_backend_t *backend,
- void *data)
-{
- pepper_seat_t *seat = (pepper_seat_t *)pepper_object_alloc(PEPPER_OBJECT_SEAT,
- sizeof(pepper_seat_t));
- if (!seat)
+ device = (pepper_touch_device_t *)pepper_object_alloc(PEPPER_OBJECT_TOUCH_DEVICE,
+ sizeof(pepper_touch_device_t));
+ if (!device)
{
- PEPPER_ERROR("Failed to allocate memory in %s\n", __FUNCTION__);
+ PEPPER_ERROR("Failed to allocate memory\n");
return NULL;
}
- seat->compositor = compositor;
- seat->backend = (pepper_seat_backend_t *)backend;
- seat->data = data;
-
- wl_list_init(&seat->resources);
- wl_list_init(&seat->link);
- wl_list_insert(&compositor->seat_list, &seat->link);
-
- seat->capabilities_listener.notify = handle_seat_set_capabilities;
- seat->backend->add_capabilities_listener(seat->data, &seat->capabilities_listener);
- seat->name_listener.notify = handle_seat_set_name;
- seat->backend->add_name_listener(seat->data, &seat->name_listener);
+ return device;
+}
- seat->global = wl_global_create(compositor->display, &wl_seat_interface, 4, seat,
- bind_seat);
- return seat;
+PEPPER_API void
+pepper_touch_device_destroy(pepper_touch_device_t *device)
+{
+ pepper_object_fini((pepper_object_t *)device);
+ pepper_free(device);
}
void
extern "C" {
#endif
-typedef struct pepper_seat_backend pepper_seat_backend_t;
-
-struct pepper_seat_backend
-{
- void (*destroy)(void *data);
- void (*add_capabilities_listener)(void *data, struct wl_listener *listener);
- void (*add_name_listener)(void *data, struct wl_listener *listener);
-
- uint32_t (*get_capabilities)(void *data);
- const char * (*get_name)(void *data);
-};
-
-PEPPER_API pepper_seat_t *
-pepper_compositor_add_seat(pepper_compositor_t *compositor,
- const pepper_seat_backend_t *backend,
- void *data);
+PEPPER_API pepper_pointer_device_t *
+pepper_pointer_device_create(pepper_compositor_t *compositor);
+
+PEPPER_API void
+pepper_pointer_device_destroy(pepper_pointer_device_t *device);
+
+PEPPER_API pepper_keyboard_device_t *
+pepper_keyboard_device_create(pepper_compositor_t *compositor);
+
+PEPPER_API void
+pepper_keyboard_device_destroy(pepper_keyboard_device_t *device);
+
+PEPPER_API pepper_touch_device_t *
+pepper_touch_device_create(pepper_compositor_t *compositor);
+
+PEPPER_API void
+pepper_touch_device_destroy(pepper_touch_device_t *device);
#ifdef __cplusplus
}
{
pepper_object_t base;
pepper_compositor_t *compositor;
+
pepper_pointer_t *pointer;
pepper_keyboard_t *keyboard;
pepper_touch_t *touch;
struct wl_list resources;
struct wl_list link;
- struct wl_listener capabilities_listener;
- struct wl_listener name_listener;
-
enum wl_seat_capability caps;
- const char *name;
+ char *name;
uint32_t modifier;
/* Backend-specific variables. */
- pepper_seat_backend_t *backend;
void *data;
};
{
pepper_object_t base;
pepper_seat_t *seat;
+
+ pepper_view_t *focus;
+ wl_fixed_t x;
+ wl_fixed_t y;
+
+ struct wl_list devices;
struct wl_list resources;
+ struct wl_list link;
};
struct pepper_keyboard
{
pepper_object_t base;
pepper_seat_t *seat;
+
+ pepper_view_t *focus;
+
+ struct wl_list devices;
struct wl_list resources;
+ struct wl_list link;
};
struct pepper_touch
{
pepper_object_t base;
pepper_seat_t *seat;
+
+ pepper_output_t *output;
+ pepper_view_t *focus;
+
+ struct wl_list devices;
struct wl_list resources;
+ struct wl_list link;
+};
+
+struct pepper_pointer_device
+{
+ pepper_object_t base;
+ pepper_pointer_t *pointer;
+ struct wl_list link;
+
+ /* Backend-specific variables. */
+ void *data;
+};
+
+struct pepper_keyboard_device
+{
+ pepper_object_t base;
+ pepper_keyboard_t *keyboard;
+ struct wl_list link;
+
+ /* Backend-specific variables. */
+ void *data;
+};
+
+struct pepper_touch_device
+{
+ pepper_object_t base;
+ pepper_touch_t *touch;
+ struct wl_list link;
+
+ /* Backend-specific variables. */
+ void *data;
};
void
typedef struct pepper_pointer pepper_pointer_t;
typedef struct pepper_keyboard pepper_keyboard_t;
typedef struct pepper_touch pepper_touch_t;
+typedef struct pepper_pointer_device pepper_pointer_device_t;
+typedef struct pepper_keyboard_device pepper_keyboard_device_t;
+typedef struct pepper_touch_device pepper_touch_device_t;
typedef struct pepper_output_geometry pepper_output_geometry_t;
typedef struct pepper_output_mode pepper_output_mode_t;
PEPPER_OBJECT_POINTER,
PEPPER_OBJECT_KEYBOARD,
PEPPER_OBJECT_TOUCH,
+ PEPPER_OBJECT_POINTER_DEVICE,
+ PEPPER_OBJECT_KEYBOARD_DEVICE,
+ PEPPER_OBJECT_TOUCH_DEVICE,
PEPPER_OBJECT_PLANE,
} pepper_object_type_t;
wl_fixed_t y;
};
+PEPPER_API pepper_seat_t *
+pepper_compositor_add_seat(pepper_compositor_t *compositor,
+ const char *seat_name,
+ void *data);
+
+PEPPER_API void
+pepper_seat_destroy(pepper_seat_t *seat);
+
+PEPPER_API pepper_pointer_t *
+pepper_seat_get_pointer(pepper_seat_t *seat);
+
+PEPPER_API pepper_keyboard_t *
+pepper_seat_get_keyboard(pepper_seat_t *seat);
+
+PEPPER_API pepper_touch_t *
+pepper_seat_get_touch(pepper_seat_t *seat);
+
PEPPER_API pepper_bool_t
pepper_seat_handle_event(pepper_seat_t *seat, pepper_input_event_t *event);
uint32_t serial, struct wl_surface *surface,
wl_fixed_t surface_x, wl_fixed_t surface_y)
{
- wayland_seat_t *seat = (wayland_seat_t *)data;
-
- seat->pointer_x_last = surface_x;
- seat->pointer_y_last = surface_y;
-
/* TODO */
}
pointer_handle_leave(void *data, struct wl_pointer *pointer,
uint32_t serial, struct wl_surface *surface)
{
- /* TODO: */
+ /* TODO */
}
static void
pointer_handle_motion(void *data, struct wl_pointer *pointer,
uint32_t time, wl_fixed_t surface_x, wl_fixed_t surface_y)
{
- wayland_seat_t *seat = (wayland_seat_t *)data;
- pepper_input_event_t event;
-
- event.type = PEPPER_INPUT_EVENT_POINTER_MOTION;
- event.time = time;
- event.serial = 0;
- event.index = 0;
- event.state = 0;
- event.value = 0;
- event.x = seat->pointer_x_last = surface_x;
- event.y = seat->pointer_y_last = surface_y;
-
- pepper_seat_handle_event(seat->base, &event);
+ /* TODO */
}
static void
pointer_handle_button(void *data, struct wl_pointer *pointer,
uint32_t serial, uint32_t time, uint32_t button, uint32_t state)
{
- wayland_seat_t *seat = (wayland_seat_t *)data;
- pepper_input_event_t event;
-
- event.type = PEPPER_INPUT_EVENT_POINTER_BUTTON;
- event.time = time;
- event.serial = serial; /* FIXME */
- event.index = button;
- event.state = state;
- event.value = 0;
- event.x = seat->pointer_x_last;
- event.y = seat->pointer_y_last;
-
- pepper_seat_handle_event(seat->base, &event);
+ /* TODO */
}
static void
pointer_handle_axis(void *data, struct wl_pointer *pointer,
uint32_t time, uint32_t axis, wl_fixed_t value)
{
- wayland_seat_t *seat = (wayland_seat_t *)data;
- pepper_input_event_t event;
-
- event.type = PEPPER_INPUT_EVENT_POINTER_AXIS;
- event.time = time;
- event.serial = 0;
- event.index = axis;
- event.value = value;
- event.state = 0;
- event.x = 0;
- event.y = 0;
-
- pepper_seat_handle_event(seat->base, &event);
+ /* TODO */
}
static const struct wl_pointer_listener pointer_listener =
};
static void
-keyboard_handle_key_map(void *data, struct wl_keyboard *keyboard,
+keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard,
uint32_t format, int32_t fd, uint32_t size)
{
- /* TODO: */
+ /* TODO */
}
static void
uint32_t serial, struct wl_surface *surface,
struct wl_array *keys)
{
- /* TODO: */
+ /* TODO */
}
static void
keyboard_handle_leave(void *data, struct wl_keyboard *keyboard,
uint32_t serial, struct wl_surface *surface)
{
- /* TODO: */
+ /* TODO */
}
static void
keyboard_handle_key(void *data, struct wl_keyboard *keyboard,
uint32_t serial, uint32_t time, uint32_t key, uint32_t state)
{
- wayland_seat_t *seat = (wayland_seat_t *)data;
- pepper_input_event_t event;
-
- event.type = PEPPER_INPUT_EVENT_KEYBOARD_KEY;
- event.time = time;
- event.serial = serial; /* FIXME */
- event.index = key;
- event.value = 0;
- event.state = state;
- event.x = 0;
- event.y = 0;
-
- pepper_seat_handle_event(seat->base, &event);
+ /* TODO */
}
static void
uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched,
uint32_t mods_locked, uint32_t group)
{
- /* TODO: */
+ /* TODO */
}
static void
keyboard_handle_repeat_info(void *data, struct wl_keyboard *keyboard,
int32_t rate, int32_t delay)
{
- /* TODO: */
+ /* TODO */
}
static const struct wl_keyboard_listener keyboard_listener =
{
- keyboard_handle_key_map,
+ keyboard_handle_keymap,
keyboard_handle_enter,
keyboard_handle_leave,
keyboard_handle_key,
uint32_t serial, uint32_t time, struct wl_surface *surface,
int32_t id, wl_fixed_t x, wl_fixed_t y)
{
- wayland_seat_t *seat = (wayland_seat_t *)data;
- pepper_input_event_t event;
-
- event.type = PEPPER_INPUT_EVENT_TOUCH_DOWN;
- event.time = time;
- event.serial = serial; /* FIXME */
- event.index = id;
- event.value = 0;
- event.state = 0;
- event.x = seat->touch_x_last = x;
- event.y = seat->touch_y_last = y;
-
- pepper_seat_handle_event(seat->base, &event);
+ /* TODO */
}
static void
touch_handle_up(void *data, struct wl_touch *touch,
uint32_t serial, uint32_t time, int32_t id)
{
- wayland_seat_t *seat = (wayland_seat_t *)data;
- pepper_input_event_t event;
-
- event.type = PEPPER_INPUT_EVENT_TOUCH_UP;
- event.time = time;
- event.serial = serial; /* FIXME */
- event.index = id;
- event.value = 0;
- event.state = 0;
- event.x = seat->touch_x_last;
- event.y = seat->touch_y_last;
-
- pepper_seat_handle_event(seat->base, &event);
+ /* TODO */
}
static void
touch_handle_motion(void *data, struct wl_touch *touch,
uint32_t time, int32_t id, wl_fixed_t x, wl_fixed_t y)
{
- wayland_seat_t *seat = (wayland_seat_t *)data;
- pepper_input_event_t event;
-
- event.type = PEPPER_INPUT_EVENT_TOUCH_MOTION;
- event.time = time;
- event.serial = 0;
- event.index = id;
- event.value = 0;
- event.state = 0;
- event.x = seat->touch_x_last = x;
- event.y = seat->touch_y_last = y;
-
- pepper_seat_handle_event(seat->base, &event);
+ /* TODO */
}
static void
touch_handle_frame(void *data, struct wl_touch *touch)
{
- wayland_seat_t *seat = (wayland_seat_t *)data;
- pepper_input_event_t event;
-
- event.type = PEPPER_INPUT_EVENT_TOUCH_FRAME;
- pepper_seat_handle_event(seat->base, &event);
+ /* TODO */
}
static void
touch_handle_cancel(void *data, struct wl_touch *touch)
{
- wayland_seat_t *seat = (wayland_seat_t *)data;
- pepper_input_event_t event;
-
- event.type = PEPPER_INPUT_EVENT_TOUCH_CANCEL;
- pepper_seat_handle_event(seat->base, &event);
+ /* TODO */
}
static const struct wl_touch_listener touch_listener =
if (seat->seat != s) /* FIXME */
return;
- if ((caps & WL_SEAT_CAPABILITY_POINTER) && (!seat->pointer))
+ if ((caps & WL_SEAT_CAPABILITY_POINTER) && (!seat->pointer.wl_pointer))
{
- seat->pointer = wl_seat_get_pointer(seat->seat);
- if (seat->pointer)
- wl_pointer_add_listener(seat->pointer, &pointer_listener, seat);
+ seat->pointer.wl_pointer = wl_seat_get_pointer(seat->seat);
+ if (seat->pointer.wl_pointer)
+ wl_pointer_add_listener(seat->pointer.wl_pointer, &pointer_listener, seat);
+
+ seat->pointer.base = pepper_pointer_device_create(seat->conn->pepper);
}
- else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && (seat->pointer))
+ else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && (seat->pointer.wl_pointer))
{
- wl_pointer_release(seat->pointer);
- seat->pointer = NULL;
+ pepper_pointer_device_destroy(seat->pointer.base);
+ wl_pointer_release(seat->pointer.wl_pointer);
+ seat->pointer.wl_pointer = NULL;
}
- if ((caps & WL_SEAT_CAPABILITY_KEYBOARD) && (!seat->keyboard))
+ if ((caps & WL_SEAT_CAPABILITY_KEYBOARD) && (!seat->keyboard.wl_keyboard))
{
- seat->keyboard = wl_seat_get_keyboard(seat->seat);
- if (seat->keyboard)
- wl_keyboard_add_listener(seat->keyboard, &keyboard_listener, seat);
+ seat->keyboard.wl_keyboard = wl_seat_get_keyboard(seat->seat);
+ if (seat->keyboard.wl_keyboard)
+ wl_keyboard_add_listener(seat->keyboard.wl_keyboard, &keyboard_listener, seat);
+
+ seat->keyboard.base = pepper_keyboard_device_create(seat->conn->pepper);
}
- else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && (seat->keyboard))
+ else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && (seat->keyboard.wl_keyboard))
{
- wl_keyboard_release(seat->keyboard);
- seat->keyboard = NULL;
+ pepper_keyboard_device_destroy(seat->keyboard.base);
+ wl_keyboard_release(seat->keyboard.wl_keyboard);
+ seat->keyboard.wl_keyboard = NULL;
}
- if ((caps & WL_SEAT_CAPABILITY_TOUCH) && (!seat->touch))
+ if ((caps & WL_SEAT_CAPABILITY_TOUCH) && (!seat->touch.wl_touch))
{
- seat->touch = wl_seat_get_touch(seat->seat);
- if (seat->touch)
- wl_touch_add_listener(seat->touch, &touch_listener, seat);
+ seat->touch.wl_touch = wl_seat_get_touch(seat->seat);
+ if (seat->touch.wl_touch)
+ wl_touch_add_listener(seat->touch.wl_touch, &touch_listener, seat);
+
+ seat->touch.base = pepper_touch_device_create(seat->conn->pepper);
}
- else if (!(caps & WL_SEAT_CAPABILITY_TOUCH) && (seat->touch))
+ else if (!(caps & WL_SEAT_CAPABILITY_TOUCH) && (seat->touch.wl_touch))
{
- wl_touch_release(seat->touch);
- seat->touch = NULL;
+ pepper_touch_device_destroy(seat->touch.base);
+ wl_touch_release(seat->touch.wl_touch);
+ seat->touch.wl_touch = NULL;
}
-
- seat->caps = caps;
- wl_signal_emit(&seat->capabilities_signal, seat);
}
static void
seat_handle_name(void *data, struct wl_seat *s, const char *name)
{
- wayland_seat_t *seat = (wayland_seat_t *)data;
-
- if (seat->seat != s) /* FIXME */
- return;
-
- seat->name = string_copy(name);
- wl_signal_emit(&seat->name_signal, seat);
+ /* TODO */
}
static const struct wl_seat_listener seat_listener =
seat_handle_name,
};
-static void
-wayland_seat_destroy(void *data)
-{
- /* TODO: */
-}
-
-static void
-wayland_seat_add_capability_listener(void *data, struct wl_listener *listener)
-{
- wayland_seat_t *seat = (wayland_seat_t *)data;
- wl_signal_add(&seat->capabilities_signal, listener);
-}
-
-static void
-wayland_seat_add_name_listener(void *data, struct wl_listener *listener)
-{
- wayland_seat_t *seat = (wayland_seat_t *)data;
- wl_signal_add(&seat->name_signal, listener);
-}
-
-static uint32_t
-wayland_seat_get_capabilities(void *data)
-{
- wayland_seat_t *seat = (wayland_seat_t *)data;
- return seat->caps;
-}
-
-static const char *
-wayland_seat_get_name(void *data)
-{
- wayland_seat_t *seat = (wayland_seat_t *)data;
- return seat->name;
-}
-
-static const pepper_seat_backend_t wayland_seat_backend =
-{
- wayland_seat_destroy,
- wayland_seat_add_capability_listener,
- wayland_seat_add_name_listener,
- wayland_seat_get_capabilities,
- wayland_seat_get_name,
-};
-
void
wayland_handle_global_seat(pepper_wayland_t *conn, struct wl_registry *registry,
uint32_t name, uint32_t version)
seat->seat = wl_registry_bind(registry, name, &wl_seat_interface, 1);
wl_seat_add_listener(seat->seat, &seat_listener, seat);
- wl_signal_init(&seat->capabilities_signal);
- wl_signal_init(&seat->name_signal);
-
- seat->base = pepper_compositor_add_seat(conn->pepper, &wayland_seat_backend, seat);
+ seat->conn = conn;
seat->id = name;
- wl_list_init(&seat->link);
wl_list_insert(&conn->seat_list, &seat->link);
}
struct wayland_seat
{
- pepper_seat_t *base;
-
+ pepper_wayland_t *conn;
+ struct wl_seat *seat;
uint32_t id;
- uint32_t caps;
- char *name;
- struct wl_seat *seat;
- struct wl_pointer *pointer;
- struct wl_keyboard *keyboard;
- struct wl_touch *touch;
+ struct
+ {
+ pepper_pointer_device_t *base;
+ struct wl_pointer *wl_pointer;
+ } pointer;
+
+ struct
+ {
+ pepper_keyboard_device_t *base;
+ struct wl_keyboard *wl_keyboard;
+ } keyboard;
- wl_fixed_t pointer_x_last;
- wl_fixed_t pointer_y_last;
- wl_fixed_t touch_x_last; /* FIXME */
- wl_fixed_t touch_y_last; /* FIXME */
+ struct
+ {
+ pepper_touch_device_t *base;
+ struct wl_touch *wl_touch;
+ } touch;
struct wl_list link;
- struct wl_signal capabilities_signal;
- struct wl_signal name_signal;
};
void
pepper_x11_output_create(pepper_x11_connection_t *connection, int32_t w, int32_t h,
const char *renderer);
-PEPPER_API void
-pepper_x11_seat_create(pepper_x11_connection_t* connection);
+PEPPER_API pepper_bool_t
+pepper_x11_input_init(pepper_x11_connection_t* connection);
#ifdef __cplusplus
}
PEPPER_ERROR("unknown input event, [0x%x]\n", type);
}
- pepper_seat_handle_event(seat->base, &event);
+ /* TODO: send input event */
}
void
}
static void
-x11_seat_add_capability_listener(void *data, struct wl_listener *listener)
-{
- x11_seat_t *seat = (x11_seat_t *)data;
- wl_signal_add(&seat->capabilities_signal, listener);
-}
-
-static void
-x11_seat_add_name_listener(void *data, struct wl_listener *listener)
-{
- x11_seat_t *seat = (x11_seat_t *)data;
- wl_signal_add(&seat->name_signal, listener);
-}
-
-static uint32_t
-x11_seat_get_capabilities(void *data)
-{
- x11_seat_t *seat = (x11_seat_t *)data;
- return seat->caps;
-}
-
-static const char *
-x11_seat_get_name(void *data)
-{
- x11_seat_t *seat = (x11_seat_t *)data;
- return seat->name;
-}
-
-static const pepper_seat_backend_t x11_seat_backend =
-{
- x11_seat_destroy,
- x11_seat_add_capability_listener,
- x11_seat_add_name_listener,
- x11_seat_get_capabilities,
- x11_seat_get_name,
-};
-
-static void
handle_connection_destroy(struct wl_listener *listener, void *data)
{
x11_seat_t *seat = wl_container_of(listener, seat, conn_destroy_listener);
/* XXX: if x-input-module used without x-output-module,
* need to create dummy window for input with output-size */
- wl_signal_init(&seat->capabilities_signal);
- wl_signal_init(&seat->name_signal);
-
seat->conn_destroy_listener.notify = handle_connection_destroy;
wl_signal_add(&conn->destroy_signal, &seat->conn_destroy_listener);
- seat->base = pepper_compositor_add_seat(conn->compositor, &x11_seat_backend, seat);
seat->id = X11_BACKEND_INPUT_ID;
/* Hard-coded: */
+ seat->pointer = pepper_pointer_device_create(conn->compositor);
+ if (!seat->pointer)
+ {
+ PEPPER_ERROR("failed to create pepper pointer device\n");
+ /* TODO: error handling */
+ }
seat->caps |= WL_SEAT_CAPABILITY_POINTER;
+ seat->keyboard = pepper_keyboard_device_create(conn->compositor);
+ if (!seat->keyboard)
+ {
+ PEPPER_ERROR("failed to create pepper keyboard device\n");
+ /* TODO: error handling */
+ }
seat->caps |= WL_SEAT_CAPABILITY_KEYBOARD;
- wl_signal_emit(&seat->capabilities_signal, seat);
/* x-connection has only 1 seat */
conn->seat = seat;
struct x11_seat
{
- pepper_seat_t *base;
+ pepper_pointer_device_t *pointer;
+ pepper_keyboard_device_t *keyboard;
+ pepper_touch_device_t *touch;
- uint32_t id;
- uint32_t caps;
- char *name;
+ uint32_t id;
+ uint32_t caps;
+ char *name;
- wl_fixed_t pointer_x_last;
- wl_fixed_t pointer_y_last;
- wl_fixed_t touch_x_last; /* FIXME */
- wl_fixed_t touch_y_last; /* FIXME */
+ struct wl_list link;
- struct wl_list link;
- struct wl_signal capabilities_signal;
- struct wl_signal name_signal;
-
- struct wl_listener conn_destroy_listener;
+ struct wl_listener conn_destroy_listener;
};
struct pepper_x11_connection
output->base = base;
output->primary_plane = pepper_output_add_plane(output->base, NULL);
- /* X11 input seat create */
- if (!connection->use_xinput)
- pepper_x11_seat_create(connection);
-
return base;
}