commit c3dba11

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