[PATCH weston] Convert resources to use wl_resource_init
Jason Ekstrand
jason at jlekstrand.net
Wed Feb 27 19:31:31 PST 2013
This patch goes along with the 4 wayland patches and updates weston to build
against them. The main question I have here is what we should do with the
shell surface and the input panel surface. For some reason, the creation of
these two objects is split into two pieces. The wl_resource_init function
really needs to be called in the first one so it can set up the destroy signal,
however the second one is where the interface and implementaiton are assigned.
In any case, this patch should work and allow weston to build.
Signed-off-by: Jason Ekstrand <jason at jlekstrand.net>
---
src/compositor.c | 18 ++++++------------
src/shell.c | 14 +++++++-------
src/tablet-shell.c | 16 ++++++----------
src/text-backend.c | 15 +++++----------
4 files changed, 24 insertions(+), 39 deletions(-)
diff --git a/src/compositor.c b/src/compositor.c
index 5ff68d7..ca92e1f 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -1488,13 +1488,10 @@ compositor_create_surface(struct wl_client *client,
return;
}
- surface->surface.resource.destroy = destroy_surface;
+ wl_resource_init(&surface->surface.resource, &wl_surface_interface,
+ &surface_interface, id, surface);
- surface->surface.resource.object.id = id;
- surface->surface.resource.object.interface = &wl_surface_interface;
- surface->surface.resource.object.implementation =
- (void (**)(void)) &surface_interface;
- surface->surface.resource.data = surface;
+ surface->surface.resource.destroy = destroy_surface;
wl_client_add_resource(client, &surface->surface.resource);
}
@@ -1555,13 +1552,10 @@ compositor_create_region(struct wl_client *client,
return;
}
- region->resource.destroy = destroy_region;
+ wl_resource_init(®ion->resource, &wl_region_interface,
+ ®ion_interface, id, region);
- region->resource.object.id = id;
- region->resource.object.interface = &wl_region_interface;
- region->resource.object.implementation =
- (void (**)(void)) ®ion_interface;
- region->resource.data = region;
+ region->resource.destroy = destroy_region;
pixman_region32_init(®ion->region);
diff --git a/src/shell.c b/src/shell.c
index 6573038..9467483 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -2060,6 +2060,8 @@ create_shell_surface(void *shell, struct weston_surface *surface,
return NULL;
}
+ wl_resource_init(&shsurf->resource, NULL, NULL, 0, shsurf);
+
surface->configure = shell_surface_configure;
surface->private = shsurf;
@@ -2074,7 +2076,6 @@ create_shell_surface(void *shell, struct weston_surface *surface,
shsurf->ping_timer = NULL;
wl_list_init(&shsurf->fullscreen.transform.link);
- wl_signal_init(&shsurf->resource.destroy_signal);
shsurf->surface_destroy_listener.notify = shell_handle_surface_destroy;
wl_signal_add(&surface->surface.resource.destroy_signal,
&shsurf->surface_destroy_listener);
@@ -2125,9 +2126,7 @@ shell_get_shell_surface(struct wl_client *client,
shsurf->resource.destroy = shell_destroy_shell_surface;
shsurf->resource.object.id = id;
shsurf->resource.object.interface = &wl_shell_surface_interface;
- shsurf->resource.object.implementation =
- (void (**)(void)) &shell_surface_implementation;
- shsurf->resource.data = shsurf;
+ shsurf->resource.object.implementation = &shell_surface_implementation;
wl_client_add_resource(client, &shsurf->resource);
}
@@ -3438,6 +3437,9 @@ create_input_panel_surface(struct desktop_shell *shell,
if (!input_panel_surface)
return NULL;
+ wl_resource_init(&input_panel_surface->resource, NULL, NULL, 0,
+ input_panel_surface);
+
surface->configure = input_panel_configure;
surface->private = input_panel_surface;
@@ -3445,7 +3447,6 @@ create_input_panel_surface(struct desktop_shell *shell,
input_panel_surface->surface = surface;
- wl_signal_init(&input_panel_surface->resource.destroy_signal);
input_panel_surface->surface_destroy_listener.notify = input_panel_handle_surface_destroy;
wl_signal_add(&surface->surface.resource.destroy_signal,
&input_panel_surface->surface_destroy_listener);
@@ -3508,8 +3509,7 @@ input_panel_get_input_panel_surface(struct wl_client *client,
ipsurf->resource.object.id = id;
ipsurf->resource.object.interface = &input_panel_surface_interface;
ipsurf->resource.object.implementation =
- (void (**)(void)) &input_panel_surface_implementation;
- ipsurf->resource.data = ipsurf;
+ &input_panel_surface_implementation;
wl_client_add_resource(client, &ipsurf->resource);
}
diff --git a/src/tablet-shell.c b/src/tablet-shell.c
index 9006b19..afeff6b 100644
--- a/src/tablet-shell.c
+++ b/src/tablet-shell.c
@@ -350,16 +350,14 @@ tablet_shell_create_client(struct wl_client *client,
return;
}
+ wl_resource_init(&tablet_client->resource, &tablet_client_interface,
+ &tablet_client_implementation, id, NULL);
+
tablet_client->client = wl_client_create(compositor->wl_display, fd);
tablet_client->shell = shell;
tablet_client->name = strdup(name);
tablet_client->resource.destroy = destroy_tablet_client;
- tablet_client->resource.object.id = id;
- tablet_client->resource.object.interface =
- &tablet_client_interface;
- tablet_client->resource.object.implementation =
- (void (**)(void)) &tablet_client_implementation;
wl_client_add_resource(client, &tablet_client->resource);
tablet_client->surface = NULL;
@@ -502,13 +500,11 @@ bind_tablet_shell(struct wl_client *client, void *data, uint32_t version,
/* Throw an error or just let the client fail when it
* tries to access the object?. */
return;
+
+ wl_resource_init(&shell->resource, &tablet_shell_interface,
+ &tablet_shell_implementation, id, shell);
- shell->resource.object.id = id;
- shell->resource.object.interface = &tablet_shell_interface;
- shell->resource.object.implementation =
- (void (**)(void)) &tablet_shell_implementation;
shell->resource.client = client;
- shell->resource.data = shell;
shell->resource.destroy = destroy_tablet_shell;
wl_client_add_resource(client, &shell->resource);
diff --git a/src/text-backend.c b/src/text-backend.c
index a92aebe..e219121 100644
--- a/src/text-backend.c
+++ b/src/text-backend.c
@@ -322,12 +322,9 @@ static void text_model_factory_create_text_model(struct wl_client *client,
text_model = calloc(1, sizeof *text_model);
- text_model->resource.object.id = id;
- text_model->resource.object.interface = &text_model_interface;
- text_model->resource.object.implementation =
- (void (**)(void)) &text_model_implementation;
+ wl_resource_init(&text_model->resource, &text_model_interface,
+ &text_model_implementation, id, text_model);
- text_model->resource.data = text_model;
text_model->resource.destroy = destroy_text_model;
text_model->ec = text_model_factory->ec;
@@ -642,13 +639,11 @@ input_method_context_create(struct text_model *model,
if (context == NULL)
return;
+ wl_resource_init(&context->resource, &input_method_context_interface,
+ &input_method_context_implementation, 0, context);
+
context->resource.destroy = destroy_input_method_context;
- context->resource.object.id = 0;
- context->resource.object.interface = &input_method_context_interface;
- context->resource.object.implementation =
- (void (**)(void)) &input_method_context_implementation;
context->resource.data = context;
- wl_signal_init(&context->resource.destroy_signal);
context->model = model;
context->input_method = input_method;
--
1.8.1.2
More information about the wayland-devel
mailing list