[RFC weston 10/12] output: Use wl_resource_get accessors for weston_output resources

Jason Ekstrand jason at jlekstrand.net
Fri Jun 14 08:08:01 PDT 2013


Signed-off-by: Jason Ekstrand <jason at jlekstrand.net>
---
 src/compositor.c    | 21 ++++-----------------
 src/data-device.c   |  6 +++---
 src/screenshooter.c |  3 ++-
 src/shell.c         | 12 ++++++------
 4 files changed, 15 insertions(+), 27 deletions(-)

diff --git a/src/compositor.c b/src/compositor.c
index f1ff516..28be309 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -502,19 +502,6 @@ weston_surface_damage_below(struct weston_surface *surface)
 	pixman_region32_fini(&damage);
 }
 
-static struct wl_resource *
-find_resource_for_client(struct wl_list *list, struct wl_client *client)
-{
-        struct wl_resource *r;
-
-        wl_list_for_each(r, list, link) {
-                if (r->client == client)
-                        return r;
-        }
-
-        return NULL;
-}
-
 static void
 weston_surface_update_output_mask(struct weston_surface *es, uint32_t mask)
 {
@@ -536,7 +523,7 @@ weston_surface_update_output_mask(struct weston_surface *es, uint32_t mask)
 	wl_list_for_each(output, &es->compositor->output_list, link) {
 		if (1 << output->id & different)
 			resource =
-				find_resource_for_client(&output->resource_list,
+				wl_resource_find_for_client(&output->resource_list,
 							 client);
 		if (resource == NULL)
 			continue;
@@ -2487,7 +2474,7 @@ weston_compositor_stack_plane(struct weston_compositor *ec,
 
 static void unbind_resource(struct wl_resource *resource)
 {
-	wl_list_remove(&resource->link);
+	wl_list_remove(wl_resource_get_link(resource));
 	free(resource);
 }
 
@@ -2502,8 +2489,8 @@ bind_output(struct wl_client *client,
 	resource = wl_client_add_object(client,
 					&wl_output_interface, NULL, id, data);
 
-	wl_list_insert(&output->resource_list, &resource->link);
-	resource->destroy = unbind_resource;
+	wl_list_insert(&output->resource_list, wl_resource_get_link(resource));
+	wl_resource_set_destructor(resource, unbind_resource);
 
 	wl_output_send_geometry(resource,
 				output->x,
diff --git a/src/data-device.c b/src/data-device.c
index 91c18df..5bf14cd 100644
--- a/src/data-device.c
+++ b/src/data-device.c
@@ -352,8 +352,8 @@ data_device_start_drag(struct wl_client *client, struct wl_resource *resource,
 		       struct wl_resource *origin_resource,
 		       struct wl_resource *icon_resource, uint32_t serial)
 {
-	struct weston_seat *seat = resource->data;
-	struct weston_drag *drag = resource->data;
+	struct weston_seat *seat = wl_resource_get_user_data(resource);
+	struct weston_drag *drag = wl_resource_get_user_data(resource);
 	struct weston_surface *icon = NULL;
 
 	if (seat->pointer->button_count == 0 ||
@@ -563,7 +563,7 @@ get_data_device(struct wl_client *client,
 		struct wl_resource *manager_resource,
 		uint32_t id, struct wl_resource *seat_resource)
 {
-	struct weston_seat *seat = seat_resource->data;
+	struct weston_seat *seat = wl_resource_get_user_data(seat_resource);
 	struct wl_resource *resource;
 
 	resource = wl_client_add_object(client, &wl_data_device_interface,
diff --git a/src/screenshooter.c b/src/screenshooter.c
index 3a4f6c2..1fdfc9a 100644
--- a/src/screenshooter.c
+++ b/src/screenshooter.c
@@ -175,7 +175,8 @@ screenshooter_shoot(struct wl_client *client,
 		    struct wl_resource *output_resource,
 		    struct wl_resource *buffer_resource)
 {
-	struct weston_output *output = output_resource->data;
+	struct weston_output *output =
+		wl_resource_get_user_data(output_resource);
 	struct screenshooter_frame_listener *l;
 	struct wl_buffer *buffer = buffer_resource->data;
 
diff --git a/src/shell.c b/src/shell.c
index a3ec07c..0cee501 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -1710,7 +1710,7 @@ shell_surface_set_maximized(struct wl_client *client,
 	/* get the default output, if the client set it as NULL
 	   check whether the ouput is available */
 	if (output_resource)
-		shsurf->output = output_resource->data;
+		shsurf->output = wl_resource_get_user_data(output_resource);
 	else if (es->output)
 		shsurf->output = es->output;
 	else
@@ -1923,7 +1923,7 @@ shell_surface_set_fullscreen(struct wl_client *client,
 	struct weston_output *output;
 
 	if (output_resource)
-		output = output_resource->data;
+		output = wl_resource_get_user_data(output_resource);
 	else
 		output = NULL;
 
@@ -2432,7 +2432,7 @@ desktop_shell_set_background(struct wl_client *client,
 
 	surface->configure = background_configure;
 	surface->configure_private = shell;
-	surface->output = output_resource->data;
+	surface->output = wl_resource_get_user_data(output_resource);
 	desktop_shell_send_configure(resource, 0,
 				     surface_resource,
 				     surface->output->width,
@@ -2466,7 +2466,7 @@ desktop_shell_set_panel(struct wl_client *client,
 
 	surface->configure = panel_configure;
 	surface->configure_private = shell;
-	surface->output = output_resource->data;
+	surface->output = wl_resource_get_user_data(output_resource);
 	desktop_shell_send_configure(resource, 0,
 				     surface_resource,
 				     surface->output->width,
@@ -3654,7 +3654,7 @@ screensaver_set_surface(struct wl_client *client,
 	struct desktop_shell *shell = wl_resource_get_user_data(resource);
 	struct weston_surface *surface =
 		wl_resource_get_user_data(surface_resource);
-	struct weston_output *output = output_resource->data;
+	struct weston_output *output = wl_resource_get_user_data(output_resource);
 
 	surface->configure = screensaver_configure;
 	surface->configure_private = shell;
@@ -3817,7 +3817,7 @@ input_panel_surface_set_toplevel(struct wl_client *client,
 	wl_list_insert(&shell->input_panel.surfaces,
 		       &input_panel_surface->link);
 
-	input_panel_surface->output = output_resource->data;
+	input_panel_surface->output = wl_resource_get_user_data(output_resource);
 	input_panel_surface->panel = 0;
 }
 
-- 
1.8.1.4



More information about the wayland-devel mailing list