pepper: Common behavior of pointer/keyboard/touch into a single object
authorTaekyun Kim <tkq.kim@samsung.com>
Wed, 16 Sep 2015 04:07:01 +0000 (13:07 +0900)
committerTaekyun Kim <tkq.kim@samsung.com>
Wed, 16 Sep 2015 04:11:17 +0000 (13:11 +0900)
1. wl_resource management
2. focus management

Change-Id: I44e7af40baf8ea490a3493acb757a1f8e9c4c4b9

src/lib/pepper/Makefile.am
src/lib/pepper/input.c
src/lib/pepper/keyboard.c [new file with mode: 0644]
src/lib/pepper/pepper-internal.h
src/lib/pepper/pepper.h
src/lib/pepper/pointer.c [new file with mode: 0644]
src/lib/pepper/touch.c [new file with mode: 0644]

index a61ae92..fd27025 100644 (file)
@@ -14,6 +14,9 @@ libpepper_la_SOURCES = pepper.h                 \
                        compositor.c             \
                        output.c                 \
                        input.c                  \
+                       pointer.c                \
+                       keyboard.c               \
+                       touch.c                  \
                        surface.c                \
                        region.c                 \
                        buffer.c                 \
index eb661ba..cd201da 100644 (file)
@@ -16,120 +16,78 @@ unbind_resource(struct wl_resource *resource)
     wl_list_remove(wl_resource_get_link(resource));
 }
 
-static void
-pointer_set_cursor(struct wl_client *client, struct wl_resource *resource, uint32_t serial,
-                   struct wl_resource *surface_resource, int32_t x, int32_t y)
+void
+pepper_input_init(pepper_input_t *input, pepper_seat_t *seat)
 {
-    /* TODO */
-}
+    input->seat = seat;
+    input->focus = NULL;
 
-static void
-pointer_release(struct wl_client *client, struct wl_resource *resource)
-{
-    wl_resource_destroy(resource);
+    wl_list_init(&input->resource_list);
+    wl_list_init(&input->focus_resource_list);
 }
 
-static const struct wl_pointer_interface pointer_interface =
+void
+pepper_input_fini(pepper_input_t *input)
 {
-    pointer_set_cursor,
-    pointer_release,
-};
+    wl_list_remove(&input->focus_destroy_listener.link);
+}
 
-static void
-seat_get_pointer(struct wl_client *client, struct wl_resource *resource, uint32_t id)
+void
+pepper_input_bind_resource(pepper_input_t *input,
+                           struct wl_client *client, int version, uint32_t id,
+                           const struct wl_interface *interface, const void *impl, void *data)
 {
-    pepper_seat_t      *seat = (pepper_seat_t *)wl_resource_get_user_data(resource);
-    struct wl_resource *r;
+    struct wl_resource *resource = wl_resource_create(client, interface, version, id);
 
-    if (!seat->pointer.active)
-        return;
-
-    r = wl_resource_create(client, &wl_pointer_interface, wl_resource_get_version(resource), id);
-    if (!r)
+    if (!resource)
     {
         wl_client_post_no_memory(client);
         return;
     }
 
-    wl_list_insert(&seat->pointer.resource_list, wl_resource_get_link(r));
-    wl_resource_set_implementation(r, &pointer_interface, &seat->pointer, unbind_resource);
-
-    /* TODO */
-
-}
-
-static void
-keyboard_release(struct wl_client *client, struct wl_resource *resource)
-{
-    wl_resource_destroy(resource);
+    wl_list_insert(&input->resource_list, wl_resource_get_link(resource));
+    wl_resource_set_implementation(resource, impl, data, unbind_resource);
 }
 
-static const struct wl_keyboard_interface keyboard_interface =
+void
+pepper_input_set_focus(pepper_input_t *input, pepper_view_t *focus)
 {
-    keyboard_release,
-};
-
-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;
-
-    if (!seat->keyboard.active)
+    if (input->focus == focus)
         return;
 
-    r = wl_resource_create(client, &wl_keyboard_interface, wl_resource_get_version(resource), id);
-    if (!r)
+    PEPPER_ASSERT(!focus || focus->surface != NULL);
+
+    if (input->focus)
     {
-        wl_client_post_no_memory(client);
-        return;
+        wl_list_insert_list(&input->resource_list, &input->focus_resource_list);
+        wl_list_init(&input->focus_resource_list);
+        wl_list_remove(&input->focus_destroy_listener.link);
     }
 
-    wl_list_insert(&seat->keyboard.resource_list, wl_resource_get_link(r));
-    wl_resource_set_implementation(r, &keyboard_interface, &seat->keyboard, unbind_resource);
-
-    /* TODO */
+    input->focus = focus;
 
-}
-
-static void
-touch_release(struct wl_client *client, struct wl_resource *resource)
-{
-    wl_resource_destroy(resource);
-}
-
-static const struct wl_touch_interface touch_interface =
-{
-    touch_release,
-};
-
-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;
-
-    if (!seat->touch.active)
-        return;
-
-    r = wl_resource_create(client, &wl_touch_interface, wl_resource_get_version(resource), id);
-    if (!r)
+    if (focus)
     {
-        wl_client_post_no_memory(client);
-        return;
-    }
+        struct wl_resource *resource, *tmp;
+        struct wl_client   *client = wl_resource_get_client(focus->surface->resource);
 
-    wl_list_insert(&seat->touch.resource_list, wl_resource_get_link(r));
-    wl_resource_set_implementation(r, &touch_interface, &seat->touch, unbind_resource);
-
-    /* TODO */
+        wl_resource_for_each_safe(resource, tmp, &input->resource_list)
+        {
+            if (wl_resource_get_client(resource) == client)
+            {
+                wl_list_remove(wl_resource_get_link(resource));
+                wl_list_insert(&input->focus_resource_list, wl_resource_get_link(resource));
+            }
+        }
 
+        wl_resource_add_destroy_listener(focus->surface->resource, &input->focus_destroy_listener);
+    }
 }
 
 static const struct wl_seat_interface seat_interface = {
-    seat_get_pointer,
-    seat_get_keyboard,
-    seat_get_touch,
+    pepper_pointer_bind_resource,
+    pepper_keyboard_bind_resource,
+    pepper_touch_bind_resource,
 };
 
 static void
@@ -197,26 +155,14 @@ pepper_seat_destroy(pepper_seat_t *seat)
     if (seat->name)
         free(seat->name);
 
-    if (seat->pointer.active)
-    {
-        wl_resource_for_each_safe(resource, tmp, &seat->pointer.resource_list)
-            wl_resource_destroy(resource);
-        pepper_object_fini(&seat->pointer.base);
-    }
+    if (seat->pointer)
+        pepper_pointer_destroy(seat->pointer);
 
-    if (seat->keyboard.active)
-    {
-        wl_resource_for_each_safe(resource, tmp, &seat->keyboard.resource_list)
-            wl_resource_destroy(resource);
-        pepper_object_fini(&seat->keyboard.base);
-    }
+    if (seat->keyboard)
+        pepper_keyboard_destroy(seat->keyboard);
 
-    if (seat->touch.active)
-    {
-        wl_resource_for_each_safe(resource, tmp, &seat->touch.resource_list)
-            wl_resource_destroy(resource);
-        pepper_object_fini(&seat->touch.base);
-    }
+    if (seat->touch)
+        pepper_touch_destroy(seat->touch);
 
     if (seat->global)
         wl_global_destroy(seat->global);
@@ -228,28 +174,19 @@ pepper_seat_destroy(pepper_seat_t *seat)
 PEPPER_API pepper_pointer_t *
 pepper_seat_get_pointer(pepper_seat_t *seat)
 {
-    if (seat->pointer.active)
-        return &seat->pointer;
-
-    return NULL;
+    return seat->pointer;
 }
 
 PEPPER_API pepper_keyboard_t *
 pepper_seat_get_keyboard(pepper_seat_t *seat)
 {
-    if (seat->keyboard.active)
-        return &seat->keyboard;
-
-    return NULL;
+    return seat->keyboard;
 }
 
 PEPPER_API pepper_touch_t *
 pepper_seat_get_touch(pepper_seat_t *seat)
 {
-    if (seat->touch.active)
-        return &seat->touch;
-
-    return NULL;
+    return seat->touch;
 }
 
 PEPPER_API const char *
@@ -258,149 +195,48 @@ pepper_seat_get_name(pepper_seat_t *seat)
     return seat->name;
 }
 
-PEPPER_API void
-pepper_pointer_set_position(pepper_pointer_t *pointer, int32_t x, int32_t y)
-{
-    /* TODO */
-}
-
-PEPPER_API void
-pepper_pointer_get_position(pepper_pointer_t *pointer, int32_t *x, int32_t *y)
-{
-    /* TODO */
-}
-
-PEPPER_API pepper_view_t *
-pepper_pointer_get_focus_view(pepper_pointer_t *pointer)
-{
-    /* TODO */
-    return NULL;
-}
-
-PEPPER_API void
-pepper_pointer_set_focus_view(pepper_pointer_t *pointer, pepper_view_t *view)
-{
-    /* TODO */
-}
-
-PEPPER_API void
-pepper_pointer_send_leave(pepper_pointer_t *pointer, pepper_view_t *target_view)
-{
-    /* TODO */
-}
-
-PEPPER_API void
-pepper_pointer_send_enter(pepper_pointer_t *pointer, pepper_view_t *target_view)
-{
-    /* TODO */
-}
-
-PEPPER_API void
-pepper_pointer_send_motion(pepper_pointer_t     *pointer,
-                           pepper_view_t        *target_view,
-                           uint32_t              time,
-                           int32_t               x,
-                           int32_t               y)
-{
-    /* TODO */
-}
-
-PEPPER_API void
-pepper_pointer_send_button(pepper_pointer_t     *pointer,
-                           pepper_view_t        *target_view,
-                           uint32_t              time,
-                           uint32_t              button,
-                           uint32_t              state)
-{
-    /* TODO */
-}
-
-PEPPER_API void
-pepper_pointer_send_axis(pepper_pointer_t   *pointer,
-                         pepper_view_t      *target_view,
-                         uint32_t            time,
-                         uint32_t            axis,
-                         uint32_t            amount)
-{
-    /* TODO */
-}
-
-PEPPER_API pepper_view_t *
-pepper_keyboard_get_focus_view(pepper_keyboard_t *keyboard)
-{
-    /* TODO */
-    return NULL;
-}
-
-PEPPER_API void
-pepper_keyboard_set_focus_view(pepper_keyboard_t *keyboard, pepper_view_t *view)
-{
-    /* TODO */
-}
-
-PEPPER_API void
-pepper_keyboard_send_leave(pepper_keyboard_t *keyboard, pepper_view_t *target_view)
-{
-    /* TODO */
-}
-
-PEPPER_API void
-pepper_keyboard_send_enter(pepper_keyboard_t *keyboard, pepper_view_t *target_view)
-{
-    /* TODO */
-}
-
 static void
 seat_update_pointer_cap(pepper_seat_t *seat)
 {
-    if ((seat->caps & WL_SEAT_CAPABILITY_POINTER) && !seat->pointer.active)
+    if ((seat->caps & WL_SEAT_CAPABILITY_POINTER) && seat->pointer)
     {
-        seat->pointer.active = PEPPER_TRUE;
-        pepper_object_init(&seat->pointer.base, PEPPER_OBJECT_POINTER);
-        wl_list_init(&seat->pointer.resource_list);
+        seat->pointer = pepper_pointer_create(seat);
         pepper_object_emit_event(&seat->base, PEPPER_EVENT_SEAT_POINTER_ADD, &seat->pointer);
     }
-    else if (!(seat->caps & WL_SEAT_CAPABILITY_POINTER) && seat->pointer.active)
+    else if (!(seat->caps & WL_SEAT_CAPABILITY_POINTER) && seat->pointer)
     {
-        seat->pointer.active = PEPPER_FALSE;
         pepper_object_emit_event(&seat->base, PEPPER_EVENT_SEAT_POINTER_REMOVE, &seat->pointer);
-        pepper_object_fini(&seat->pointer.base);
+        pepper_pointer_destroy(seat->pointer);
     }
 }
 
 static void
 seat_update_keyboard_cap(pepper_seat_t *seat)
 {
-    if ((seat->caps & WL_SEAT_CAPABILITY_KEYBOARD) && !seat->keyboard.active)
+    if ((seat->caps & WL_SEAT_CAPABILITY_KEYBOARD) && !seat->keyboard)
     {
-        seat->keyboard.active = PEPPER_TRUE;
-        pepper_object_init(&seat->keyboard.base, PEPPER_OBJECT_KEYBOARD);
-        wl_list_init(&seat->keyboard.resource_list);
+        seat->keyboard = pepper_keyboard_create(seat);
         pepper_object_emit_event(&seat->base, PEPPER_EVENT_SEAT_KEYBOARD_ADD, &seat->keyboard);
     }
-    else if (!(seat->caps & WL_SEAT_CAPABILITY_KEYBOARD) && seat->keyboard.active)
+    else if (!(seat->caps & WL_SEAT_CAPABILITY_KEYBOARD) && seat->keyboard)
     {
-        seat->keyboard.active = PEPPER_FALSE;
         pepper_object_emit_event(&seat->base, PEPPER_EVENT_SEAT_KEYBOARD_REMOVE, &seat->keyboard);
-        pepper_object_fini(&seat->keyboard.base);
+        pepper_keyboard_destroy(seat->keyboard);
     }
 }
 
 static void
 seat_update_touch_cap(pepper_seat_t *seat)
 {
-    if ((seat->caps & WL_SEAT_CAPABILITY_TOUCH) && !seat->touch.active)
+    if ((seat->caps & WL_SEAT_CAPABILITY_TOUCH) && !seat->touch)
     {
-        seat->touch.active = PEPPER_TRUE;
-        pepper_object_init(&seat->touch.base, PEPPER_OBJECT_TOUCH);
-        wl_list_init(&seat->touch.resource_list);
+        seat->touch = pepper_touch_create(seat);
         pepper_object_emit_event(&seat->base, PEPPER_EVENT_SEAT_TOUCH_ADD, &seat->touch);
     }
-    else if (!(seat->caps & WL_SEAT_CAPABILITY_TOUCH) && seat->touch.active)
+    else if (!(seat->caps & WL_SEAT_CAPABILITY_TOUCH) && seat->touch)
     {
-        seat->touch.active = PEPPER_FALSE;
         pepper_object_emit_event(&seat->base, PEPPER_EVENT_SEAT_TOUCH_REMOVE, &seat->touch);
-        pepper_object_fini(&seat->touch.base);
+        pepper_touch_destroy(seat->touch);
     }
 }
 
diff --git a/src/lib/pepper/keyboard.c b/src/lib/pepper/keyboard.c
new file mode 100644 (file)
index 0000000..5c22946
--- /dev/null
@@ -0,0 +1,68 @@
+#include "pepper-internal.h"
+
+static void
+keyboard_release(struct wl_client *client, struct wl_resource *resource)
+{
+    wl_resource_destroy(resource);
+}
+
+static const struct wl_keyboard_interface keyboard_impl =
+{
+    keyboard_release,
+};
+
+pepper_keyboard_t *
+pepper_keyboard_create(pepper_seat_t *seat)
+{
+    pepper_keyboard_t *keyboard =
+        (pepper_keyboard_t *)pepper_object_alloc(PEPPER_OBJECT_TOUCH, sizeof(pepper_keyboard_t));
+
+    PEPPER_CHECK(keyboard, return NULL, "pepper_object_alloc() failed.\n");
+
+    pepper_input_init(&keyboard->input, seat);
+    return keyboard;
+}
+
+void
+pepper_keyboard_destroy(pepper_keyboard_t *keyboard)
+{
+    pepper_input_fini(&keyboard->input);
+    free(keyboard);
+}
+
+void
+pepper_keyboard_bind_resource(struct wl_client *client, struct wl_resource *resource, uint32_t id)
+{
+    pepper_seat_t *seat = (pepper_seat_t *)wl_resource_get_user_data(resource);
+
+    if (seat->keyboard)
+        return;
+
+    pepper_input_bind_resource(&seat->keyboard->input, client, wl_resource_get_version(resource),
+                               id, &wl_keyboard_interface, &keyboard_impl, seat->keyboard);
+}
+
+PEPPER_API void
+pepper_keyboard_set_focus(pepper_keyboard_t *keyboard, pepper_view_t *view)
+{
+    /* TODO: */
+}
+
+PEPPER_API pepper_view_t *
+pepper_keyboard_get_focus(pepper_keyboard_t *keyboard)
+{
+    /* TODO: */
+    return NULL;
+}
+
+PEPPER_API void
+pepper_keyboard_send_leave(pepper_keyboard_t *keyboard, pepper_view_t *target_view)
+{
+    /* TODO: */
+}
+
+PEPPER_API void
+pepper_keyboard_send_enter(pepper_keyboard_t *keyboard, pepper_view_t *target_view)
+{
+    /* TODO: */
+}
index f34ad97..48b72c3 100644 (file)
@@ -16,6 +16,7 @@ typedef struct pepper_plane_entry   pepper_plane_entry_t;
 typedef struct pepper_data_source   pepper_data_source_t;
 typedef struct pepper_data_device   pepper_data_device_t;
 typedef struct pepper_data_offer    pepper_data_offer_t;
+typedef struct pepper_input         pepper_input_t;
 
 struct pepper_object
 {
@@ -207,30 +208,74 @@ void
 pepper_transform_pixman_region(pixman_region32_t *region, const pepper_mat4_t *matrix);
 
 /* Input */
+struct pepper_input
+{
+    pepper_seat_t      *seat;
+    struct wl_list      resource_list;
+    pepper_view_t      *focus;
+    struct wl_listener  focus_destroy_listener;
+    struct wl_list      focus_resource_list;
+};
+
+void
+pepper_input_init(pepper_input_t *input, pepper_seat_t *seat);
+
+void
+pepper_input_fini(pepper_input_t *input);
+
+void
+pepper_input_bind_resource(pepper_input_t *input,
+                           struct wl_client *client, int version, uint32_t id,
+                           const struct wl_interface *interface, const void *impl, void *data);
+
+void
+pepper_input_set_focus(pepper_input_t *input, pepper_view_t *view);
+
 struct pepper_pointer
 {
     pepper_object_t             base;
-    pepper_seat_t              *seat;
-    pepper_bool_t               active;
-    struct wl_list              resource_list;
+    pepper_input_t              input;
 };
 
+pepper_pointer_t *
+pepper_pointer_create(pepper_seat_t *seat);
+
+void
+pepper_pointer_destroy(pepper_pointer_t *pointer);
+
+void
+pepper_pointer_bind_resource(struct wl_client *client, struct wl_resource *resource, uint32_t id);
+
 struct pepper_keyboard
 {
     pepper_object_t             base;
-    pepper_seat_t              *seat;
-    pepper_bool_t               active;
-    struct wl_list              resource_list;
+    pepper_input_t              input;
 };
 
+pepper_keyboard_t *
+pepper_keyboard_create(pepper_seat_t *seat);
+
+void
+pepper_keyboard_destroy(pepper_keyboard_t *keyboard);
+
+void
+pepper_keyboard_bind_resource(struct wl_client *client, struct wl_resource *resource, uint32_t id);
+
 struct pepper_touch
 {
     pepper_object_t             base;
-    pepper_seat_t              *seat;
-    pepper_bool_t               active;
-    struct wl_list              resource_list;
+    pepper_input_t              input;
 };
 
+pepper_touch_t *
+pepper_touch_create(pepper_seat_t *seat);
+
+void
+pepper_touch_destroy(pepper_touch_t *touch);
+
+void
+pepper_touch_bind_resource(struct wl_client *client, struct wl_resource *resource, uint32_t id);
+
 struct pepper_seat
 {
     pepper_object_t             base;
@@ -243,9 +288,9 @@ struct pepper_seat
     enum wl_seat_capability     caps;
     uint32_t                    modifier;
 
-    pepper_pointer_t            pointer;
-    pepper_keyboard_t           keyboard;
-    pepper_touch_t              touch;
+    pepper_pointer_t           *pointer;
+    pepper_keyboard_t          *keyboard;
+    pepper_touch_t             *touch;
 
     pepper_list_t               input_device_list;
 };
index 8a662d2..61c72b7 100644 (file)
@@ -254,7 +254,7 @@ pepper_output_get_name(pepper_output_t *output);
 PEPPER_API pepper_output_t *
 pepper_compositor_find_output(pepper_compositor_t *compositor, const char *name);
 
-/* Input. */
+/* Seat & Input Device. */
 PEPPER_API pepper_seat_t *
 pepper_compositor_add_seat(pepper_compositor_t *compositor, const char *seat_name);
 
@@ -279,17 +279,21 @@ pepper_seat_add_input_device(pepper_seat_t *seat, pepper_input_device_t *device)
 PEPPER_API void
 pepper_seat_remove_input_device(pepper_seat_t *seat, pepper_input_device_t *device);
 
+PEPPER_API const char *
+pepper_input_device_get_property(pepper_input_device_t *device, const char *key);
+
+/* Pointer. */
 PEPPER_API void
 pepper_pointer_set_position(pepper_pointer_t *pointer, int32_t x, int32_t y);
 
 PEPPER_API void
 pepper_pointer_get_position(pepper_pointer_t *pointer, int32_t *x, int32_t *y);
 
-PEPPER_API pepper_view_t *
-pepper_pointer_get_focus_view(pepper_pointer_t *pointer);
-
 PEPPER_API void
-pepper_pointer_set_focus_view(pepper_pointer_t *pointer, pepper_view_t *view);
+pepper_pointer_set_focus(pepper_pointer_t *pointer, pepper_view_t *focus);
+
+PEPPER_API pepper_view_t *
+pepper_pointer_get_focus(pepper_pointer_t *pointer);
 
 PEPPER_API void
 pepper_pointer_send_leave(pepper_pointer_t *pointer, pepper_view_t *target_view);
@@ -308,11 +312,12 @@ PEPPER_API void
 pepper_pointer_send_axis(pepper_pointer_t *pointer, pepper_view_t *target_view,
                          uint32_t time, uint32_t axis, uint32_t amount);
 
-PEPPER_API pepper_view_t *
-pepper_keyboard_get_focus_view(pepper_keyboard_t *keyboard);
-
+/* Keyboard. */
 PEPPER_API void
-pepper_keyboard_set_focus_view(pepper_keyboard_t *keyboard, pepper_view_t *view);
+pepper_keyboard_set_focus(pepper_keyboard_t *keyboard, pepper_view_t *focus);
+
+PEPPER_API pepper_view_t *
+pepper_keyboard_get_focus(pepper_keyboard_t *keyboard);
 
 PEPPER_API void
 pepper_keyboard_send_leave(pepper_keyboard_t *keyboard, pepper_view_t *target_view);
@@ -320,8 +325,12 @@ pepper_keyboard_send_leave(pepper_keyboard_t *keyboard, pepper_view_t *target_vi
 PEPPER_API void
 pepper_keyboard_send_enter(pepper_keyboard_t *keyboard, pepper_view_t *target_view);
 
-PEPPER_API const char *
-pepper_input_device_get_property(pepper_input_device_t *device, const char *key);
+/* Touch. */
+PEPPER_API void
+pepper_touch_set_focus(pepper_touch_t *touch, pepper_view_t *focus);
+
+PEPPER_API pepper_view_t *
+pepper_touch_get_focus(pepper_touch_t *touch);
 
 /* Surface. */
 PEPPER_API const char *
diff --git a/src/lib/pepper/pointer.c b/src/lib/pepper/pointer.c
new file mode 100644 (file)
index 0000000..2bd767d
--- /dev/null
@@ -0,0 +1,109 @@
+#include "pepper-internal.h"
+
+static void
+pointer_set_cursor(struct wl_client *client, struct wl_resource *resource, uint32_t serial,
+                   struct wl_resource *surface_resource, int32_t x, int32_t y)
+{
+    /* TODO: */
+}
+
+static void
+pointer_release(struct wl_client *client, struct wl_resource *resource)
+{
+    wl_resource_destroy(resource);
+}
+
+static const struct wl_pointer_interface pointer_impl =
+{
+    pointer_set_cursor,
+    pointer_release,
+};
+
+pepper_pointer_t *
+pepper_pointer_create(pepper_seat_t *seat)
+{
+    pepper_pointer_t *pointer =
+        (pepper_pointer_t *)pepper_object_alloc(PEPPER_OBJECT_TOUCH, sizeof(pepper_pointer_t));
+
+    PEPPER_CHECK(pointer, return NULL, "pepper_object_alloc() failed.\n");
+
+    pepper_input_init(&pointer->input, seat);
+    return pointer;
+}
+
+void
+pepper_pointer_destroy(pepper_pointer_t *pointer)
+{
+    pepper_input_fini(&pointer->input);
+    free(pointer);
+}
+
+void
+pepper_pointer_bind_resource(struct wl_client *client, struct wl_resource *resource, uint32_t id)
+{
+    pepper_seat_t *seat = (pepper_seat_t *)wl_resource_get_user_data(resource);
+
+    if (!seat->pointer)
+        return;
+
+    pepper_input_bind_resource(&seat->pointer->input, client, wl_resource_get_version(resource),
+                               id, &wl_pointer_interface, &pointer_impl, seat->pointer);
+}
+
+PEPPER_API void
+pepper_pointer_set_position(pepper_pointer_t *pointer, int32_t x, int32_t y)
+{
+    /* TODO: */
+}
+
+PEPPER_API void
+pepper_pointer_get_position(pepper_pointer_t *pointer, int32_t *x, int32_t *y)
+{
+    /* TODO: */
+}
+
+PEPPER_API void
+pepper_pointer_set_focus(pepper_pointer_t *pointer, pepper_view_t *focus)
+{
+    /* TODO: */
+}
+
+PEPPER_API pepper_view_t *
+pepper_pointer_get_focus(pepper_pointer_t *pointer)
+{
+    /* TODO: */
+    return NULL;
+}
+
+PEPPER_API void
+pepper_pointer_send_leave(pepper_pointer_t *pointer, pepper_view_t *target_view)
+{
+    /* TODO: */
+}
+
+PEPPER_API void
+pepper_pointer_send_enter(pepper_pointer_t *pointer, pepper_view_t *target_view)
+{
+    /* TODO: */
+}
+
+PEPPER_API void
+pepper_pointer_send_motion(pepper_pointer_t *pointer, pepper_view_t *target_view,
+                           uint32_t time, int32_t x, int32_t y)
+{
+    /* TODO: */
+}
+
+PEPPER_API void
+pepper_pointer_send_button(pepper_pointer_t *pointer, pepper_view_t *target_view,
+                           uint32_t time, uint32_t button, uint32_t state)
+{
+    /* TODO: */
+}
+
+PEPPER_API void
+pepper_pointer_send_axis(pepper_pointer_t *pointer, pepper_view_t *target_view,
+                         uint32_t time, uint32_t axis, uint32_t amount)
+{
+    /* TODO: */
+}
diff --git a/src/lib/pepper/touch.c b/src/lib/pepper/touch.c
new file mode 100644 (file)
index 0000000..958cf5b
--- /dev/null
@@ -0,0 +1,56 @@
+#include "pepper-internal.h"
+
+static void
+touch_release(struct wl_client *client, struct wl_resource *resource)
+{
+    wl_resource_destroy(resource);
+}
+
+static const struct wl_touch_interface touch_impl =
+{
+    touch_release,
+};
+
+pepper_touch_t *
+pepper_touch_create(pepper_seat_t *seat)
+{
+    pepper_touch_t *touch =
+        (pepper_touch_t *)pepper_object_alloc(PEPPER_OBJECT_TOUCH, sizeof(pepper_touch_t));
+
+    PEPPER_CHECK(touch, return NULL, "pepper_object_alloc() failed.\n");
+
+    pepper_input_init(&touch->input, seat);
+    return touch;
+}
+
+void
+pepper_touch_destroy(pepper_touch_t *touch)
+{
+    pepper_input_fini(&touch->input);
+    free(touch);
+}
+
+void
+pepper_touch_bind_resource(struct wl_client *client, struct wl_resource *resource, uint32_t id)
+{
+    pepper_seat_t *seat = (pepper_seat_t *)wl_resource_get_user_data(resource);
+
+    if (seat->touch)
+        return;
+
+    pepper_input_bind_resource(&seat->touch->input, client, wl_resource_get_version(resource),
+                               id, &wl_touch_interface, &touch_impl, seat->touch);
+}
+
+PEPPER_API void
+pepper_touch_set_focus(pepper_touch_t *touch, pepper_view_t *view)
+{
+    /* TODO: */
+}
+
+PEPPER_API pepper_view_t *
+pepper_touch_get_focus(pepper_touch_t *touch)
+{
+    /* TODO: */
+    return NULL;
+}