commit c3dba11b2e624ed062c30263a3eead6a97c954dd
parent 29e72e650963cf46ca55e802bbad43bdd50a7c53
Author: Michael Forney <mforney@mforney.org>
Date: Sat, 10 Aug 2013 14:02:09 -0700
Use new api for adding resources/globals
Diffstat:
10 files changed, 57 insertions(+), 42 deletions(-)
diff --git a/compositor.c b/compositor.c
@@ -318,9 +318,15 @@ static void bind_compositor(struct wl_client * client, void * data,
uint32_t version, uint32_t id)
{
struct swc_compositor * compositor = data;
+ struct wl_resource * resource;
- wl_client_add_object(client, &wl_compositor_interface,
- &compositor_implementation, id, compositor);
+ if (version >= 3)
+ version = 3;
+
+ resource = wl_resource_create(client, &wl_compositor_interface,
+ version, id);
+ wl_resource_set_implementation(resource, &compositor_implementation,
+ compositor, NULL);
}
bool swc_compositor_initialize(struct swc_compositor * compositor,
@@ -482,8 +488,8 @@ void swc_compositor_add_globals(struct swc_compositor * compositor,
{
struct swc_output * output;
- wl_display_add_global(display, &wl_compositor_interface, compositor,
- &bind_compositor);
+ wl_global_create(display, &wl_compositor_interface, 3, compositor,
+ &bind_compositor);
swc_data_device_manager_add_globals(display);
swc_seat_add_globals(&compositor->seat, display);
diff --git a/data.c b/data.c
@@ -143,11 +143,11 @@ struct wl_resource * swc_data_source_new(struct wl_client * client, uint32_t id)
return NULL;
/* Add the data source to the client. */
- data->source = wl_client_add_object(client, &wl_data_source_interface,
- &data_source_implementation, id, data);
+ data->source = wl_resource_create(client, &wl_data_source_interface, 1, id);
/* Destroy the data object when the source disappears. */
- wl_resource_set_destructor(data->source, &data_destroy);
+ wl_resource_set_implementation(data->source, &data_source_implementation,
+ data, &data_destroy);
return data->source;
}
@@ -158,10 +158,10 @@ struct wl_resource * swc_data_offer_new(struct wl_client * client,
struct data * data = wl_resource_get_user_data(source);
struct wl_resource * offer;
- offer = wl_client_new_object(client, &wl_data_offer_interface,
- &data_offer_implementation, data);
+ offer = wl_resource_create(client, &wl_data_offer_interface, 1, 0);
+ wl_resource_set_implementation(offer, &data_offer_implementation,
+ data, &swc_remove_resource);
wl_list_insert(&data->offers, wl_resource_get_link(offer));
- wl_resource_set_destructor(offer, &swc_remove_resource);
return offer;
}
diff --git a/data_device.c b/data_device.c
@@ -98,11 +98,10 @@ void swc_data_device_bind(struct swc_data_device * data_device,
{
struct wl_resource * resource;
- resource = wl_client_add_object(client, &wl_data_device_interface,
- &data_device_implementation, id,
- data_device);
+ resource = wl_resource_create(client, &wl_data_device_interface, 1, id);
+ wl_resource_set_implementation(resource, &data_device_implementation,
+ data_device, &swc_remove_resource);
wl_list_insert(&data_device->resources, &resource->link);
- wl_resource_set_destructor(resource, &swc_remove_resource);
}
static struct wl_resource * new_offer(struct wl_resource * resource,
diff --git a/data_device_manager.c b/data_device_manager.c
@@ -57,13 +57,17 @@ static struct wl_data_device_manager_interface
static void bind_data_device_manager(struct wl_client * client, void * data,
uint32_t version, uint32_t id)
{
- wl_client_add_object(client, &wl_data_device_manager_interface,
- &data_device_manager_implementation, id, NULL);
+ struct wl_resource * resource;
+
+ resource = wl_resource_create(client, &wl_data_device_manager_interface,
+ 1, id);
+ wl_resource_set_implementation
+ (resource, &data_device_manager_implementation, NULL, NULL);
}
void swc_data_device_manager_add_globals(struct wl_display * display)
{
- wl_display_add_global(display, &wl_data_device_manager_interface, NULL,
- &bind_data_device_manager);
+ wl_global_create(display, &wl_data_device_manager_interface, 1, NULL,
+ &bind_data_device_manager);
}
diff --git a/keyboard.c b/keyboard.c
@@ -73,9 +73,8 @@ struct wl_resource * swc_keyboard_bind(struct swc_keyboard * keyboard,
{
struct wl_resource * client_resource;
- client_resource = wl_client_add_object(client, &wl_keyboard_interface,
- NULL, id, keyboard);
- wl_resource_set_destructor(client_resource, &unbind);
+ client_resource = wl_resource_create(client, &wl_keyboard_interface, 1, id);
+ wl_resource_set_implementation(client_resource, NULL, keyboard, &unbind);
swc_input_focus_add_resource(&keyboard->focus, client_resource);
return client_resource;
diff --git a/output.c b/output.c
@@ -18,10 +18,13 @@ static void bind_output(struct wl_client * client, void * data,
struct wl_resource * resource;
uint32_t flags;
- resource = wl_client_add_object(client, &wl_output_interface, NULL, id,
- output);
+ if (version >= 1)
+ version = 1;
+
+ resource = wl_resource_create(client, &wl_output_interface, version, id);
+ wl_resource_set_implementation(resource, NULL, output,
+ &swc_remove_resource);
wl_list_insert(&output->resource_list, wl_resource_get_link(resource));
- wl_resource_set_destructor(resource, &swc_remove_resource);
wl_output_send_geometry(resource, output->x, output->y,
output->physical_width, output->physical_height, 0, "unknown",
@@ -144,7 +147,7 @@ void swc_output_finish(struct swc_output * output)
void swc_output_add_globals(struct swc_output * output,
struct wl_display * display)
{
- wl_display_add_global(display, &wl_output_interface, output, &bind_output);
+ wl_global_create(display, &wl_output_interface, 1, output, &bind_output);
}
void swc_output_switch_buffer(struct swc_output * output)
diff --git a/pointer.c b/pointer.c
@@ -114,9 +114,9 @@ struct wl_resource * swc_pointer_bind(struct swc_pointer * pointer,
printf("pointer: adding client %p\n", client);
- client_resource = wl_client_add_object(client, &wl_pointer_interface,
- &pointer_implementation, id, pointer);
- wl_resource_set_destructor(client_resource, &unbind);
+ client_resource = wl_resource_create(client, &wl_pointer_interface, 1, id);
+ wl_resource_set_implementation(client_resource, &pointer_implementation,
+ pointer, &unbind);
swc_input_focus_add_resource(&pointer->focus, client_resource);
return client_resource;
diff --git a/region.c b/region.c
@@ -55,9 +55,9 @@ struct swc_region * swc_region_new(struct wl_client * client, uint32_t id)
pixman_region32_init(®ion->region);
/* Add the region to the client. */
- region->resource = wl_client_add_object(client, &wl_region_interface,
- ®ion_implementation, id, region);
- wl_resource_set_destructor(region->resource, ®ion_destroy);
+ region->resource = wl_resource_create(client, &wl_region_interface, 1, id);
+ wl_resource_set_implementation(region->resource, ®ion_implementation,
+ region, ®ion_destroy);
return region;
}
diff --git a/seat.c b/seat.c
@@ -238,10 +238,13 @@ static void bind_seat(struct wl_client * client, void * data, uint32_t version,
struct swc_seat * seat = data;
struct wl_resource * resource;
- resource = wl_client_add_object(client, &wl_seat_interface,
- &seat_implementation, id, seat);
+ if (version >= 1)
+ version = 1;
+
+ resource = wl_resource_create(client, &wl_seat_interface, version, id);
+ wl_resource_set_implementation(resource, &seat_implementation, seat,
+ &swc_remove_resource);
wl_list_insert(&seat->resources, wl_resource_get_link(resource));
- wl_resource_set_destructor(resource, &swc_remove_resource);
wl_seat_send_capabilities(resource, seat->capabilities);
}
@@ -374,7 +377,7 @@ void swc_seat_finish(struct swc_seat * seat)
void swc_seat_add_globals(struct swc_seat * seat, struct wl_display * display)
{
- wl_display_add_global(display, &wl_seat_interface, seat, &bind_seat);
+ wl_global_create(display, &wl_seat_interface, 1, seat, &bind_seat);
}
void swc_seat_add_event_sources(struct swc_seat * seat,
diff --git a/surface.c b/surface.c
@@ -122,9 +122,10 @@ static void frame(struct wl_client * client, struct wl_resource * resource,
struct swc_surface * surface = wl_resource_get_user_data(resource);
struct wl_resource * callback_resource;
- callback_resource = wl_client_add_object(client, &wl_callback_interface,
- NULL, id, NULL);
- wl_resource_set_destructor(callback_resource, &swc_remove_resource);
+ callback_resource = wl_resource_create(client, &wl_callback_interface,
+ 1, id);
+ wl_resource_set_implementation(callback_resource, NULL, NULL,
+ &swc_remove_resource);
wl_list_insert(surface->pending.state.frame_callbacks.prev,
wl_resource_get_link(callback_resource));
}
@@ -300,10 +301,10 @@ struct swc_surface * swc_surface_new(struct wl_client * client, uint32_t id)
wl_signal_init(&surface->event_signal);
/* Add the surface to the client. */
- surface->resource
- = wl_client_add_object(client, &wl_surface_interface,
- &surface_implementation, id, surface);
- wl_resource_set_destructor(surface->resource, &surface_destroy);
+ surface->resource = wl_resource_create(client, &wl_surface_interface,
+ 1, id);
+ wl_resource_set_implementation(surface->resource, &surface_implementation,
+ surface, &surface_destroy);
return surface;
}