Convert to wl_global_create/destroy()

dev
Kristian Høgsberg 12 years ago
parent ac3a8b83fd
commit 919cddb0ab
  1. 36
      clients/nested.c
  2. 10
      src/compositor.c
  3. 4
      src/data-device.c
  4. 7
      src/input.c
  5. 6
      src/screenshooter.c
  6. 12
      src/shell.c
  7. 2
      src/tablet-shell.c
  8. 13
      src/text-backend.c
  9. 2
      src/xwayland/launcher.c
  10. 13
      src/zoom.c
  11. 2
      tests/weston-test.c

@ -44,6 +44,8 @@
#include "window.h" #include "window.h"
#define MIN(x,y) (((x) < (y)) ? (x) : (y))
struct nested { struct nested {
struct display *display; struct display *display;
struct window *window; struct window *window;
@ -347,10 +349,10 @@ surface_frame(struct wl_client *client,
return; return;
} }
callback->resource = callback->resource = wl_resource_create(client,
wl_client_add_object(client, &wl_callback_interface, &wl_callback_interface, 1, id);
NULL, id, callback); wl_resource_set_implementation(callback->resource, NULL, callback,
wl_resource_set_destructor(callback->resource, destroy_frame_callback); destroy_frame_callback);
wl_list_insert(nested->frame_callback_list.prev, &callback->link); wl_list_insert(nested->frame_callback_list.prev, &callback->link);
} }
@ -423,9 +425,11 @@ compositor_create_surface(struct wl_client *client,
display_release_window_surface(nested->display, nested->window); display_release_window_surface(nested->display, nested->window);
surface->resource = surface->resource =
wl_client_add_object(client, &wl_surface_interface, wl_resource_create(client, &wl_surface_interface, 1, id);
&surface_interface, id, surface);
wl_resource_set_destructor(surface->resource, destroy_surface); wl_resource_set_implementation(surface->resource,
&surface_interface, surface,
destroy_surface);
wl_list_insert(nested->surface_list.prev, &surface->link); wl_list_insert(nested->surface_list.prev, &surface->link);
} }
@ -488,23 +492,27 @@ compositor_create_region(struct wl_client *client,
pixman_region32_init(&region->region); pixman_region32_init(&region->region);
region->resource = region->resource =
wl_client_add_object(client, &wl_region_interface, wl_resource_create(client, &wl_region_interface, 1, id);
&region_interface, id, region); wl_resource_set_implementation(region->resource, &region_interface,
wl_resource_set_destructor(region->resource, destroy_region); region, destroy_region);
} }
static const struct wl_compositor_interface compositor_interface = { static const struct wl_compositor_interface compositor_interface = {
compositor_create_surface, compositor_create_surface,
compositor_create_region compositor_create_region
}; };
static void static void
compositor_bind(struct wl_client *client, compositor_bind(struct wl_client *client,
void *data, uint32_t version, uint32_t id) void *data, uint32_t version, uint32_t id)
{ {
struct nested *nested = data; struct nested *nested = data;
struct wl_resource *resource;
wl_client_add_object(client, &wl_compositor_interface, resource = wl_resource_create(client, &wl_compositor_interface,
&compositor_interface, id, nested); MIN(version, 3), id);
wl_resource_set_implementation(resource, &compositor_interface,
nested, NULL);
} }
static int static int
@ -523,8 +531,8 @@ nested_init_compositor(struct nested *nested)
display_watch_fd(nested->display, fd, display_watch_fd(nested->display, fd,
EPOLLIN, &nested->child_task); EPOLLIN, &nested->child_task);
if (!wl_display_add_global(nested->child_display, if (!wl_global_create(nested->child_display,
&wl_compositor_interface, &wl_compositor_interface, 1,
nested, compositor_bind)) nested, compositor_bind))
return -1; return -1;

@ -2571,8 +2571,6 @@ bind_output(struct wl_client *client,
WL_EXPORT void WL_EXPORT void
weston_output_destroy(struct weston_output *output) weston_output_destroy(struct weston_output *output)
{ {
struct weston_compositor *c = output->compositor;
wl_signal_emit(&output->destroy_signal, output); wl_signal_emit(&output->destroy_signal, output);
free(output->name); free(output->name);
@ -2580,7 +2578,7 @@ weston_output_destroy(struct weston_output *output)
pixman_region32_fini(&output->previous_damage); pixman_region32_fini(&output->previous_damage);
output->compositor->output_id_pool &= ~(1 << output->id); output->compositor->output_id_pool &= ~(1 << output->id);
wl_display_remove_global(c->wl_display, output->global); wl_global_destroy(output->global);
} }
static void static void
@ -2748,7 +2746,7 @@ weston_output_init(struct weston_output *output, struct weston_compositor *c,
output->compositor->output_id_pool |= 1 << output->id; output->compositor->output_id_pool |= 1 << output->id;
output->global = output->global =
wl_display_add_global(c->wl_display, &wl_output_interface, wl_global_create(c->wl_display, &wl_output_interface, 2,
output, bind_output); output, bind_output);
wl_signal_emit(&c->output_created_signal, output); wl_signal_emit(&c->output_created_signal, output);
} }
@ -2828,11 +2826,11 @@ weston_compositor_init(struct weston_compositor *ec,
ec->output_id_pool = 0; ec->output_id_pool = 0;
if (!wl_display_add_global(display, &wl_compositor_interface, if (!wl_global_create(display, &wl_compositor_interface, 3,
ec, compositor_bind)) ec, compositor_bind))
return -1; return -1;
if (!wl_display_add_global(display, &wl_subcompositor_interface, if (!wl_global_create(display, &wl_subcompositor_interface, 1,
ec, bind_subcompositor)) ec, bind_subcompositor))
return -1; return -1;

@ -620,8 +620,8 @@ wl_data_device_set_keyboard_focus(struct weston_seat *seat)
WL_EXPORT int WL_EXPORT int
wl_data_device_manager_init(struct wl_display *display) wl_data_device_manager_init(struct wl_display *display)
{ {
if (wl_display_add_global(display, if (wl_global_create(display,
&wl_data_device_manager_interface, &wl_data_device_manager_interface, 1,
NULL, bind_manager) == NULL) NULL, bind_manager) == NULL)
return -1; return -1;

@ -1531,9 +1531,8 @@ weston_seat_init(struct weston_seat *seat, struct weston_compositor *ec,
wl_list_init(&seat->drag_resource_list); wl_list_init(&seat->drag_resource_list);
wl_signal_init(&seat->destroy_signal); wl_signal_init(&seat->destroy_signal);
seat->global = seat->global = wl_global_create(ec->wl_display, &wl_seat_interface, 2,
wl_display_add_global(ec->wl_display, seat, bind_seat);
&wl_seat_interface, seat, bind_seat);
seat->compositor = ec; seat->compositor = ec;
seat->modifier_state = 0; seat->modifier_state = 0;
@ -1569,7 +1568,7 @@ weston_seat_release(struct weston_seat *seat)
free (seat->seat_name); free (seat->seat_name);
wl_display_remove_global(seat->compositor->wl_display, seat->global); wl_global_destroy(seat->global);
wl_signal_emit(&seat->destroy_signal, seat); wl_signal_emit(&seat->destroy_signal, seat);
} }

@ -559,7 +559,7 @@ screenshooter_destroy(struct wl_listener *listener, void *data)
struct screenshooter *shooter = struct screenshooter *shooter =
container_of(listener, struct screenshooter, destroy_listener); container_of(listener, struct screenshooter, destroy_listener);
wl_display_remove_global(shooter->ec->wl_display, shooter->global); wl_global_destroy(shooter->global);
free(shooter); free(shooter);
} }
@ -575,8 +575,8 @@ screenshooter_create(struct weston_compositor *ec)
shooter->ec = ec; shooter->ec = ec;
shooter->client = NULL; shooter->client = NULL;
shooter->global = wl_display_add_global(ec->wl_display, shooter->global = wl_global_create(ec->wl_display,
&screenshooter_interface, &screenshooter_interface, 1,
shooter, bind_shooter); shooter, bind_shooter);
weston_compositor_add_key_binding(ec, KEY_S, MODIFIER_SUPER, weston_compositor_add_key_binding(ec, KEY_S, MODIFIER_SUPER,
screenshooter_binding, shooter); screenshooter_binding, shooter);

@ -4507,24 +4507,24 @@ module_init(struct weston_compositor *ec,
wl_list_init(&shell->workspaces.animation.link); wl_list_init(&shell->workspaces.animation.link);
shell->workspaces.animation.frame = animate_workspace_change_frame; shell->workspaces.animation.frame = animate_workspace_change_frame;
if (wl_display_add_global(ec->wl_display, &wl_shell_interface, if (wl_global_create(ec->wl_display, &wl_shell_interface, 1,
shell, bind_shell) == NULL) shell, bind_shell) == NULL)
return -1; return -1;
if (wl_display_add_global(ec->wl_display, if (wl_global_create(ec->wl_display,
&desktop_shell_interface, &desktop_shell_interface, 2,
shell, bind_desktop_shell) == NULL) shell, bind_desktop_shell) == NULL)
return -1; return -1;
if (wl_display_add_global(ec->wl_display, &screensaver_interface, if (wl_global_create(ec->wl_display, &screensaver_interface, 1,
shell, bind_screensaver) == NULL) shell, bind_screensaver) == NULL)
return -1; return -1;
if (wl_display_add_global(ec->wl_display, &wl_input_panel_interface, if (wl_global_create(ec->wl_display, &wl_input_panel_interface, 1,
shell, bind_input_panel) == NULL) shell, bind_input_panel) == NULL)
return -1; return -1;
if (wl_display_add_global(ec->wl_display, &workspace_manager_interface, if (wl_global_create(ec->wl_display, &workspace_manager_interface, 1,
shell, bind_workspace_manager) == NULL) shell, bind_workspace_manager) == NULL)
return -1; return -1;

@ -542,7 +542,7 @@ module_init(struct weston_compositor *compositor,
wl_signal_add(&compositor->wake_signal, &shell->unlock_listener); wl_signal_add(&compositor->wake_signal, &shell->unlock_listener);
/* FIXME: This will make the object available to all clients. */ /* FIXME: This will make the object available to all clients. */
wl_display_add_global(compositor->wl_display, &tablet_shell_interface, wl_global_create(compositor->wl_display, &tablet_shell_interface, 1,
shell, bind_tablet_shell); shell, bind_tablet_shell);
loop = wl_display_get_event_loop(compositor->wl_display); loop = wl_display_get_event_loop(compositor->wl_display);

@ -398,8 +398,7 @@ text_input_manager_notifier_destroy(struct wl_listener *listener, void *data)
struct text_input_manager *text_input_manager = struct text_input_manager *text_input_manager =
container_of(listener, struct text_input_manager, destroy_listener); container_of(listener, struct text_input_manager, destroy_listener);
wl_display_remove_global(text_input_manager->ec->wl_display, wl_global_destroy(text_input_manager->text_input_manager_global);
text_input_manager->text_input_manager_global);
free(text_input_manager); free(text_input_manager);
} }
@ -414,8 +413,8 @@ text_input_manager_create(struct weston_compositor *ec)
text_input_manager->ec = ec; text_input_manager->ec = ec;
text_input_manager->text_input_manager_global = text_input_manager->text_input_manager_global =
wl_display_add_global(ec->wl_display, wl_global_create(ec->wl_display,
&wl_text_input_manager_interface, &wl_text_input_manager_interface, 1,
text_input_manager, bind_text_input_manager); text_input_manager, bind_text_input_manager);
text_input_manager->destroy_listener.notify = text_input_manager_notifier_destroy; text_input_manager->destroy_listener.notify = text_input_manager_notifier_destroy;
@ -792,8 +791,7 @@ input_method_notifier_destroy(struct wl_listener *listener, void *data)
if (input_method->model) if (input_method->model)
deactivate_text_input(input_method->model, input_method); deactivate_text_input(input_method->model, input_method);
wl_display_remove_global(input_method->seat->compositor->wl_display, wl_global_destroy(input_method->input_method_global);
input_method->input_method_global);
free(input_method); free(input_method);
} }
@ -899,8 +897,7 @@ handle_seat_created(struct wl_listener *listener,
input_method->text_backend = text_backend; input_method->text_backend = text_backend;
input_method->input_method_global = input_method->input_method_global =
wl_display_add_global(ec->wl_display, wl_global_create(ec->wl_display, &wl_input_method_interface, 1,
&wl_input_method_interface,
input_method, bind_input_method); input_method, bind_input_method);
input_method->destroy_listener.notify = input_method_notifier_destroy; input_method->destroy_listener.notify = input_method_notifier_destroy;

@ -376,7 +376,7 @@ module_init(struct weston_compositor *compositor,
WL_EVENT_READABLE, WL_EVENT_READABLE,
weston_xserver_handle_event, wxs); weston_xserver_handle_event, wxs);
wl_display_add_global(display, &xserver_interface, wxs, bind_xserver); wl_global_create(display, &xserver_interface, 1, wxs, bind_xserver);
wxs->destroy_listener.notify = weston_xserver_destroy; wxs->destroy_listener.notify = weston_xserver_destroy;
wl_signal_add(&compositor->destroy_signal, &wxs->destroy_listener); wl_signal_add(&compositor->destroy_signal, &wxs->destroy_listener);

@ -69,7 +69,7 @@ text_cursor_position_notifier_destroy(struct wl_listener *listener, void *data)
struct text_cursor_position *text_cursor_position = struct text_cursor_position *text_cursor_position =
container_of(listener, struct text_cursor_position, destroy_listener); container_of(listener, struct text_cursor_position, destroy_listener);
wl_display_remove_global(text_cursor_position->ec->wl_display, text_cursor_position->global); wl_global_destroy(text_cursor_position->global);
free(text_cursor_position); free(text_cursor_position);
} }
@ -84,11 +84,14 @@ text_cursor_position_notifier_create(struct weston_compositor *ec)
text_cursor_position->ec = ec; text_cursor_position->ec = ec;
text_cursor_position->global = wl_display_add_global(ec->wl_display, text_cursor_position->global =
&text_cursor_position_interface, wl_global_create(ec->wl_display,
text_cursor_position, bind_text_cursor_position); &text_cursor_position_interface, 1,
text_cursor_position,
bind_text_cursor_position);
text_cursor_position->destroy_listener.notify = text_cursor_position_notifier_destroy; text_cursor_position->destroy_listener.notify =
text_cursor_position_notifier_destroy;
wl_signal_add(&ec->destroy_signal, &text_cursor_position->destroy_listener); wl_signal_add(&ec->destroy_signal, &text_cursor_position->destroy_listener);
} }

@ -240,7 +240,7 @@ module_init(struct weston_compositor *ec,
test->compositor = ec; test->compositor = ec;
weston_layer_init(&test->layer, &ec->cursor_layer.link); weston_layer_init(&test->layer, &ec->cursor_layer.link);
if (wl_display_add_global(ec->wl_display, &wl_test_interface, if (wl_global_create(ec->wl_display, &wl_test_interface, 1,
test, bind_test) == NULL) test, bind_test) == NULL)
return -1; return -1;

Loading…
Cancel
Save