Signed-off-by: Jason Ekstrand <ja...@jlekstrand.net> --- src/compositor.c | 56 +++++++++++++++++++++++++------------------ src/data-device.c | 32 ++++++++++++++----------- src/input.c | 20 ++++++++-------- src/screenshooter.c | 8 ++++--- src/shell.c | 64 ++++++++++++++++++++++++++----------------------- src/tablet-shell.c | 21 ++++++++-------- src/text-backend.c | 45 ++++++++++++++++++---------------- src/xwayland/launcher.c | 6 +++-- src/zoom.c | 11 ++++++--- tests/weston-test.c | 6 +++-- 10 files changed, 150 insertions(+), 119 deletions(-)
diff --git a/src/compositor.c b/src/compositor.c index 55831f6..3194e84 100644 --- a/src/compositor.c +++ b/src/compositor.c @@ -1486,9 +1486,10 @@ surface_frame(struct wl_client *client, } cb->resource = wl_client_add_versioned_object(client, - &wl_callback_interface, 1, - NULL, callback, cb); - wl_resource_set_destructor(cb->resource, destroy_frame_callback); + &wl_callback_interface, + 1, callback); + wl_resource_set_implementation(cb->resource, NULL, cb, + destroy_frame_callback); wl_list_insert(surface->pending.frame_callback_list.prev, &cb->link); } @@ -1688,9 +1689,9 @@ compositor_create_surface(struct wl_client *client, surface->resource = wl_client_add_versioned_object(client, &wl_surface_interface, wl_resource_get_version(resource), - &surface_interface, - id, surface); - wl_resource_set_destructor(surface->resource, destroy_surface); + id); + wl_resource_set_implementation(surface->resource, &surface_interface, + surface, destroy_surface); } static void @@ -1751,9 +1752,10 @@ compositor_create_region(struct wl_client *client, pixman_region32_init(®ion->region); region->resource = - wl_client_add_versioned_object(client, &wl_region_interface, 1, - ®ion_interface, id, region); - wl_resource_set_destructor(region->resource, destroy_region); + wl_client_add_versioned_object(client, &wl_region_interface, + 1, id); + wl_resource_set_implementation(region->resource, ®ion_interface, + region, destroy_region); } static const struct wl_compositor_interface compositor_interface = { @@ -2292,16 +2294,16 @@ weston_subsurface_create(uint32_t id, struct weston_surface *surface, return NULL; sub->resource = - wl_client_add_versioned_object(client, - &wl_subsurface_interface, 1, - &subsurface_implementation, - id, sub); + wl_client_add_versioned_object(client, &wl_subsurface_interface, + 1, id); if (!sub->resource) { free(sub); return NULL; } - wl_resource_set_destructor(sub->resource, subsurface_resource_destroy); + wl_resource_set_implementation(sub->resource, + &subsurface_implementation, + sub, subsurface_resource_destroy); weston_subsurface_link_surface(sub, surface); weston_subsurface_link_parent(sub, parent); weston_subsurface_cache_init(sub); @@ -2412,9 +2414,14 @@ bind_subcompositor(struct wl_client *client, void *data, uint32_t version, uint32_t id) { struct weston_compositor *compositor = data; - - wl_client_add_versioned_object(client, &wl_subcompositor_interface, 1, - &subcompositor_interface, id, compositor); + struct wl_resource *resource = + wl_client_add_versioned_object(client, + &wl_subcompositor_interface, + 1, id); + if (resource) + wl_resource_set_implementation(resource, + &subcompositor_interface, + compositor, NULL); } static void @@ -2527,11 +2534,10 @@ bind_output(struct wl_client *client, struct wl_resource *resource; resource = wl_client_add_versioned_object(client, &wl_output_interface, - MIN(version, 2), - NULL, id, data); + MIN(version, 2), id); wl_list_insert(&output->resource_list, wl_resource_get_link(resource)); - wl_resource_set_destructor(resource, unbind_resource); + wl_resource_set_implementation(resource, NULL, data, unbind_resource); wl_output_send_geometry(resource, output->x, @@ -2748,10 +2754,14 @@ compositor_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id) { struct weston_compositor *compositor = data; + struct wl_resource *resource; - wl_client_add_versioned_object(client, &wl_compositor_interface, - MIN(version, 3), &compositor_interface, - id, compositor); + resource = + wl_client_add_versioned_object(client, &wl_compositor_interface, + MIN(version, 3), id); + if (resource) + wl_resource_set_implementation(resource, &compositor_interface, + compositor, NULL); } static void diff --git a/src/data-device.c b/src/data-device.c index eee1d3a..88a2744 100644 --- a/src/data-device.c +++ b/src/data-device.c @@ -119,9 +119,9 @@ wl_data_source_send_offer(struct wl_data_source *source, offer->resource = wl_client_new_versioned_object(wl_resource_get_client(target), - &wl_data_offer_interface, 1, - &data_offer_interface, offer); - wl_resource_set_destructor(offer->resource, destroy_data_offer); + &wl_data_offer_interface, 1); + wl_resource_set_implementation(offer->resource, &data_offer_interface, + offer, destroy_data_offer); offer->source = source; offer->source_destroy_listener.notify = destroy_offer_data_source; @@ -548,10 +548,10 @@ create_data_source(struct wl_client *client, source->resource = wl_client_add_versioned_object(client, - &wl_data_source_interface, 1, - &data_source_interface, - id, source); - wl_resource_set_destructor(source->resource, destroy_data_source); + &wl_data_source_interface, + 1, id); + wl_resource_set_implementation(source->resource, &data_source_interface, + source, destroy_data_source); } static void unbind_data_device(struct wl_resource *resource) @@ -568,12 +568,12 @@ get_data_device(struct wl_client *client, struct wl_resource *resource; resource = wl_client_add_versioned_object(client, - &wl_data_device_interface, 1, - &data_device_interface, id, - seat); + &wl_data_device_interface, + 1, id); wl_list_insert(&seat->drag_resource_list, wl_resource_get_link(resource)); - wl_resource_set_destructor(resource, unbind_data_device); + wl_resource_set_implementation(resource, &data_device_interface, + seat, unbind_data_device); } static const struct wl_data_device_manager_interface manager_interface = { @@ -585,9 +585,13 @@ static void bind_manager(struct wl_client *client, void *data, uint32_t version, uint32_t id) { - wl_client_add_versioned_object(client, - &wl_data_device_manager_interface, 1, - &manager_interface, id, NULL); + struct wl_resource *resource = + wl_client_add_versioned_object(client, + &wl_data_device_manager_interface, + 1, id); + if (resource) + wl_resource_set_implementation(resource, &manager_interface, + NULL, NULL); } WL_EXPORT void diff --git a/src/input.c b/src/input.c index 8a61e5b..77ec303 100644 --- a/src/input.c +++ b/src/input.c @@ -1165,10 +1165,10 @@ seat_get_pointer(struct wl_client *client, struct wl_resource *resource, cr = wl_client_add_versioned_object(client, &wl_pointer_interface, wl_resource_get_version(resource), - &pointer_interface, id, - seat->pointer); + id); wl_list_insert(&seat->pointer->resource_list, wl_resource_get_link(cr)); - wl_resource_set_destructor(cr, unbind_resource); + wl_resource_set_implementation(cr, &pointer_interface, seat->pointer, + unbind_resource); if (seat->pointer->focus && wl_resource_get_client(seat->pointer->focus->resource) == client) { @@ -1200,9 +1200,9 @@ seat_get_keyboard(struct wl_client *client, struct wl_resource *resource, cr = wl_client_add_versioned_object(client, &wl_keyboard_interface, wl_resource_get_version(resource), - NULL, id, seat); + id); wl_list_insert(&seat->keyboard->resource_list, wl_resource_get_link(cr)); - wl_resource_set_destructor(cr, unbind_resource); + wl_resource_set_implementation(cr, NULL, seat, unbind_resource); wl_keyboard_send_keymap(cr, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1, seat->xkb_info.keymap_fd, @@ -1228,9 +1228,9 @@ seat_get_touch(struct wl_client *client, struct wl_resource *resource, cr = wl_client_add_versioned_object(client, &wl_touch_interface, wl_resource_get_version(resource), - NULL, id, seat); + id); wl_list_insert(&seat->touch->resource_list, wl_resource_get_link(cr)); - wl_resource_set_destructor(cr, unbind_resource); + wl_resource_set_implementation(cr, NULL, seat, unbind_resource); } static const struct wl_seat_interface seat_interface = { @@ -1247,10 +1247,10 @@ bind_seat(struct wl_client *client, void *data, uint32_t version, uint32_t id) enum wl_seat_capability caps = 0; resource = wl_client_add_versioned_object(client, &wl_seat_interface, - MIN(version, 2), - &seat_interface, id, data); + MIN(version, 2), id); wl_list_insert(&seat->base_resource_list, wl_resource_get_link(resource)); - wl_resource_set_destructor(resource, unbind_resource); + wl_resource_set_implementation(resource, &seat_interface, data, + unbind_resource); if (seat->pointer) caps |= WL_SEAT_CAPABILITY_POINTER; diff --git a/src/screenshooter.c b/src/screenshooter.c index 4edfe9a..6334ddc 100644 --- a/src/screenshooter.c +++ b/src/screenshooter.c @@ -218,15 +218,17 @@ bind_shooter(struct wl_client *client, struct wl_resource *resource; resource = wl_client_add_versioned_object(client, - &screenshooter_interface, 1, - &screenshooter_implementation, - id, data); + &screenshooter_interface, + 1, id); if (client != shooter->client) { wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, "screenshooter failed: permission denied"); wl_resource_destroy(resource); } + + wl_resource_set_implementation(resource, &screenshooter_implementation, + data, NULL); } static void diff --git a/src/shell.c b/src/shell.c index d2d7baa..4e06ad4 100644 --- a/src/shell.c +++ b/src/shell.c @@ -1016,16 +1016,17 @@ bind_workspace_manager(struct wl_client *client, struct wl_resource *resource; resource = wl_client_add_versioned_object(client, - &workspace_manager_interface, 1, - &workspace_manager_implementation, - id, shell); + &workspace_manager_interface, + 1, id); if (resource == NULL) { weston_log("couldn't add workspace manager object"); return; } - wl_resource_set_destructor(resource, unbind_resource); + wl_resource_set_implementation(resource, + &workspace_manager_implementation, + shell, unbind_resource); wl_list_insert(&shell->workspaces.client_list, wl_resource_get_link(resource)); @@ -2335,11 +2336,11 @@ shell_get_shell_surface(struct wl_client *client, shsurf->resource = wl_client_add_versioned_object(client, - &wl_shell_surface_interface, 1, - &shell_surface_implementation, - id, shsurf); - wl_resource_set_destructor(shsurf->resource, - shell_destroy_shell_surface); + &wl_shell_surface_interface, + 1, id); + wl_resource_set_implementation(shsurf->resource, + &shell_surface_implementation, + shsurf, shell_destroy_shell_surface); } static const struct wl_shell_interface shell_implementation = { @@ -3600,9 +3601,12 @@ static void bind_shell(struct wl_client *client, void *data, uint32_t version, uint32_t id) { struct desktop_shell *shell = data; - - wl_client_add_versioned_object(client, &wl_shell_interface, 1, - &shell_implementation, id, shell); + struct wl_resource *resource = + wl_client_add_versioned_object(client, &wl_shell_interface, + 1, id); + if (resource) + wl_resource_set_implementation(resource, &shell_implementation, + shell, NULL); } static void @@ -3626,12 +3630,12 @@ bind_desktop_shell(struct wl_client *client, resource = wl_client_add_versioned_object(client, &desktop_shell_interface, - MIN(version, 2), - &desktop_shell_implementation, - id, shell); + MIN(version, 2), id); if (client == shell->child.client) { - wl_resource_set_destructor(resource, unbind_desktop_shell); + wl_resource_set_implementation(resource, + &desktop_shell_implementation, + shell, unbind_desktop_shell); shell->child.desktop_shell = resource; if (version < 2) @@ -3705,12 +3709,12 @@ bind_screensaver(struct wl_client *client, struct wl_resource *resource; resource = wl_client_add_versioned_object(client, - &screensaver_interface, 1, - &screensaver_implementation, - id, shell); + &screensaver_interface, 1, id); if (shell->screensaver.binding == NULL) { - wl_resource_set_destructor(resource, unbind_screensaver); + wl_resource_set_implementation(resource, + &screensaver_implementation, + shell, unbind_screensaver); shell->screensaver.binding = resource; return; } @@ -3902,12 +3906,11 @@ input_panel_get_input_panel_surface(struct wl_client *client, ipsurf->resource = wl_client_add_versioned_object(client, &wl_input_panel_surface_interface, - 1, - &input_panel_surface_implementation, - id, ipsurf); - - wl_resource_set_destructor(ipsurf->resource, - destroy_input_panel_surface_resource); + 1, id); + wl_resource_set_implementation(ipsurf->resource, + &input_panel_surface_implementation, + ipsurf, + destroy_input_panel_surface_resource); } static const struct wl_input_panel_interface input_panel_implementation = { @@ -3930,12 +3933,13 @@ bind_input_panel(struct wl_client *client, struct wl_resource *resource; resource = wl_client_add_versioned_object(client, - &wl_input_panel_interface, 1, - &input_panel_implementation, - id, shell); + &wl_input_panel_interface, + 1, id); if (shell->input_panel.binding == NULL) { - wl_resource_set_destructor(resource, unbind_input_panel); + wl_resource_set_implementation(resource, + &input_panel_implementation, + shell, unbind_input_panel); shell->input_panel.binding = resource; return; } diff --git a/src/tablet-shell.c b/src/tablet-shell.c index 6be5bb8..ff8954f 100644 --- a/src/tablet-shell.c +++ b/src/tablet-shell.c @@ -351,12 +351,11 @@ tablet_shell_create_client(struct wl_client *client, tablet_client->name = strdup(name); tablet_client->resource = - wl_client_add_versioned_object(client, - &tablet_client_interface, 1, - &tablet_client_implementation, - id, tablet_client); - wl_resource_set_destructor(tablet_client->resource, - destroy_tablet_client); + wl_client_add_versioned_object(client, &tablet_client_interface, + 1, id); + wl_resource_set_implementation(tablet_client->resource, + &tablet_client_implementation, + tablet_client, destroy_tablet_client); tablet_client->surface = NULL; shell->current_client = tablet_client; @@ -500,11 +499,11 @@ bind_tablet_shell(struct wl_client *client, void *data, uint32_t version, return; shell->resource = - wl_client_add_versioned_object(client, - &tablet_shell_interface, 1, - &tablet_shell_implementation, - id, shell); - wl_resource_set_destructor(shell->resource, destroy_tablet_shell); + wl_client_add_versioned_object(client, &tablet_shell_interface, + 1, id); + wl_resource_set_implementation(shell->resource, + &tablet_shell_implementation, + shell, destroy_tablet_shell); } static void diff --git a/src/text-backend.c b/src/text-backend.c index 69034c9..7e48276 100644 --- a/src/text-backend.c +++ b/src/text-backend.c @@ -360,10 +360,10 @@ static void text_input_manager_create_text_input(struct wl_client *client, text_input->resource = wl_client_add_versioned_object(client, - &wl_text_input_interface, 1, - &text_input_implementation, - id, text_input); - wl_resource_set_destructor(text_input->resource, destroy_text_input); + &wl_text_input_interface, 1, id); + wl_resource_set_implementation(text_input->resource, + &text_input_implementation, + text_input, destroy_text_input); text_input->ec = text_input_manager->ec; @@ -382,12 +382,15 @@ bind_text_input_manager(struct wl_client *client, { struct text_input_manager *text_input_manager = data; - /* No checking for duplicate binding necessary. - * No events have to be sent, so we don't need the return value. */ - wl_client_add_versioned_object(client, - &wl_text_input_manager_interface, 1, - &text_input_manager_implementation, - id, text_input_manager); + /* No checking for duplicate binding necessary. */ + struct wl_resource *resource = + wl_client_add_versioned_object(client, + &wl_text_input_manager_interface, + 1, id); + if (resource) + wl_resource_set_implementation(resource, + &text_input_manager_implementation, + text_input_manager, NULL); } static void @@ -585,9 +588,9 @@ input_method_context_grab_keyboard(struct wl_client *client, struct weston_seat *seat = context->input_method->seat; struct weston_keyboard *keyboard = seat->keyboard; - cr = wl_client_add_versioned_object(client, &wl_keyboard_interface, 1, - NULL, id, context); - wl_resource_set_destructor(cr, unbind_keyboard); + cr = wl_client_add_versioned_object(client, &wl_keyboard_interface, + 1, id); + wl_resource_set_implementation(cr, NULL, context, unbind_keyboard); context->keyboard = cr; @@ -709,11 +712,10 @@ input_method_context_create(struct text_input *model, context->resource = wl_client_new_versioned_object(wl_resource_get_client(binding), &wl_input_method_context_interface, - 1, - &input_method_context_implementation, - context); - wl_resource_set_destructor(context->resource, - destroy_input_method_context); + 1); + wl_resource_set_implementation(context->resource, + &input_method_context_implementation, + context, destroy_input_method_context); context->model = model; context->input_method = input_method; @@ -762,8 +764,8 @@ bind_input_method(struct wl_client *client, struct wl_resource *resource; resource = wl_client_add_versioned_object(client, - &wl_input_method_interface, 1, - NULL, id, input_method); + &wl_input_method_interface, + 1, id); if (input_method->input_method_binding != NULL) { wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, @@ -779,7 +781,8 @@ bind_input_method(struct wl_client *client, return; } - wl_resource_set_destructor(resource, unbind_input_method); + wl_resource_set_implementation(resource, NULL, input_method, + unbind_input_method); input_method->input_method_binding = resource; text_backend->input_method.binding = resource; diff --git a/src/xwayland/launcher.c b/src/xwayland/launcher.c index 2d9ccdf..23a9261 100644 --- a/src/xwayland/launcher.c +++ b/src/xwayland/launcher.c @@ -159,8 +159,10 @@ bind_xserver(struct wl_client *client, return; wxs->resource = - wl_client_add_versioned_object(client, &xserver_interface, 1, - &xserver_implementation, id, wxs); + wl_client_add_versioned_object(client, &xserver_interface, + 1, id); + wl_resource_set_implementation(wxs->resource, &xserver_implementation, + wxs, NULL); wxs->wm = weston_wm_create(wxs); if (wxs->wm == NULL) { diff --git a/src/zoom.c b/src/zoom.c index 29bfde9..57410a7 100644 --- a/src/zoom.c +++ b/src/zoom.c @@ -53,9 +53,14 @@ static void bind_text_cursor_position(struct wl_client *client, void *data, uint32_t version, uint32_t id) { - wl_client_add_versioned_object(client, &text_cursor_position_interface, - 1, &text_cursor_position_implementation, - id, data); + struct wl_resource *resource = + wl_client_add_versioned_object(client, + &text_cursor_position_interface, + 1, id); + if (resource) + wl_resource_set_implementation(resource, + &text_cursor_position_implementation, + data, NULL); } static void diff --git a/tests/weston-test.c b/tests/weston-test.c index fd61819..f296f05 100644 --- a/tests/weston-test.c +++ b/tests/weston-test.c @@ -191,8 +191,10 @@ bind_test(struct wl_client *client, void *data, uint32_t version, uint32_t id) struct weston_test *test = data; struct wl_resource *resource; - resource = wl_client_add_versioned_object(client, &wl_test_interface, 1, - &test_implementation, id, test); + resource = wl_client_add_versioned_object(client, &wl_test_interface, + 1, id); + wl_resource_set_implementation(resource, &test_implementation, + test, NULL); notify_pointer_position(test, resource); } -- 1.8.2.1 _______________________________________________ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel