if (listener)
return pepper_container_of(listener, pepper_buffer_t, resource_destroy_listener);
- buffer = (pepper_buffer_t *)pepper_object_alloc(sizeof(pepper_buffer_t));
+ buffer = (pepper_buffer_t *)pepper_object_alloc(PEPPER_OBJECT_BUFFER, sizeof(pepper_buffer_t));
if (!buffer)
return NULL;
pepper_compositor_create(const char *socket_name)
{
pepper_compositor_t *compositor =
- (pepper_compositor_t *)pepper_object_alloc(sizeof(pepper_compositor_t));
+ (pepper_compositor_t *)pepper_object_alloc(PEPPER_OBJECT_COMPOSITOR,
+ sizeof(pepper_compositor_t));
if (!compositor)
return NULL;
{
pepper_pointer_t *pointer;
- pointer = (pepper_pointer_t *)pepper_object_alloc(sizeof(pepper_pointer_t));
+ pointer = (pepper_pointer_t *)pepper_object_alloc(PEPPER_OBJECT_POINTER,
+ sizeof(pepper_pointer_t));
if (!pointer)
{
PEPPER_ERROR("Failed to allocate memory in %s\n", __FUNCTION__);
{
pepper_keyboard_t *keyboard;
- keyboard = (pepper_keyboard_t *)pepper_object_alloc(sizeof(pepper_keyboard_t));
+ 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__);
{
pepper_touch_t *touch;
- touch = (pepper_touch_t *)pepper_object_alloc(sizeof(pepper_touch_t));
+ touch = (pepper_touch_t *)pepper_object_alloc(PEPPER_OBJECT_TOUCH, sizeof(pepper_touch_t));
if (!touch)
{
PEPPER_ERROR("Failed to allocate memory in %s\n", __FUNCTION__);
const pepper_seat_backend_t *backend,
void *data)
{
- pepper_seat_t *seat = (pepper_seat_t *)pepper_object_alloc(sizeof(pepper_seat_t));
+ pepper_seat_t *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__);
}
pepper_object_t *
-pepper_object_alloc(size_t size)
+pepper_object_alloc(pepper_object_type_t type, size_t size)
{
pepper_object_t *object = pepper_calloc(1, size);
if (!object)
return NULL;
+ object->type = type;
wl_signal_init(&object->destroy_signal);
object->user_data_map = pepper_map_create(5, user_data_hash, user_data_key_length,
user_data_key_compare);
pepper_map_destroy(object->user_data_map);
}
+PEPPER_API pepper_object_type_t
+pepper_object_get_type(pepper_object_t *object)
+{
+ return object->type;
+}
+
PEPPER_API void
pepper_object_set_user_data(pepper_object_t *object, const void *key, void *data,
pepper_free_func_t free_func)
id = id - 1;
- output = (pepper_output_t *)pepper_object_alloc(sizeof(pepper_output_t));
+ output = (pepper_output_t *)pepper_object_alloc(PEPPER_OBJECT_OUTPUT, sizeof(pepper_output_t));
if (!output)
return NULL;
struct pepper_object
{
- struct wl_signal destroy_signal;
- pepper_map_t *user_data_map;
+ pepper_object_type_t type;
+ struct wl_signal destroy_signal;
+ pepper_map_t *user_data_map;
};
pepper_object_t *
-pepper_object_alloc(size_t size);
+pepper_object_alloc(pepper_object_type_t type, size_t size);
void
pepper_object_fini(pepper_object_t *object);
int32_t refresh;
};
+typedef enum pepper_object_type
+{
+ PEPPER_OBJECT_COMPOSITOR,
+ PEPPER_OBJECT_OUTPUT,
+ PEPPER_OBJECT_SURFACE,
+ PEPPER_OBJECT_BUFFER,
+ PEPPER_OBJECT_VIEW,
+ PEPPER_OBJECT_SEAT,
+ PEPPER_OBJECT_POINTER,
+ PEPPER_OBJECT_KEYBOARD,
+ PEPPER_OBJECT_TOUCH,
+ PEPPER_OBJECT_PLANE,
+} pepper_object_type_t;
+
/* Generic object functions. */
+PEPPER_API pepper_object_type_t
+pepper_object_get_type(pepper_object_t *object);
+
PEPPER_API void
pepper_object_set_user_data(pepper_object_t *object, const void *key, void *data,
pepper_free_func_t free_func);
if (above && above->output != output)
return NULL;
- plane = (pepper_plane_t *)pepper_object_alloc(sizeof(pepper_plane_t));
+ plane = (pepper_plane_t *)pepper_object_alloc(PEPPER_OBJECT_PLANE, sizeof(pepper_plane_t));
if (!plane)
return NULL;
struct wl_resource *resource,
uint32_t id)
{
- pepper_surface_t *surface = (pepper_surface_t *)pepper_object_alloc(sizeof(pepper_surface_t));
+ pepper_surface_t *surface = (pepper_surface_t *)pepper_object_alloc(PEPPER_OBJECT_SURFACE,
+ sizeof(pepper_surface_t));
if (!surface)
{
PEPPER_ERROR("Surface memory allocation failed\n");
PEPPER_API pepper_view_t *
pepper_compositor_add_surface_view(pepper_compositor_t *compositor, pepper_surface_t *surface)
{
- pepper_view_t *view = (pepper_view_t *)pepper_object_alloc(sizeof(pepper_view_t));
+ pepper_view_t *view = (pepper_view_t *)pepper_object_alloc(PEPPER_OBJECT_VIEW,
+ sizeof(pepper_view_t));
if (!view)
{
PEPPER_ERROR("Failed to allocate a pepper object.\n");