libweston: introduce weston_output_from_resource()

This is a simple wrapper for casting the user data of a wl_resource into
a struct weston_output pointer. Using the wrapper clearly marks all the
places where a wl_output protocol object is used.

Replace ALL wl_output related calls to wl_resource_get_user_data() with
a call to weston_output_from_resource().

v2: add type assert in weston_output_from_resource().

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Armin Krezović <krezovic.armin@gmail.com>
This commit is contained in:
Pekka Paalanen
2017-03-27 15:14:32 +03:00
parent 0079a949e0
commit 9ffb25009c
11 changed files with 30 additions and 11 deletions
+16
View File
@@ -4323,6 +4323,22 @@ bind_output(struct wl_client *client,
wl_output_send_done(resource);
}
/** Get the backing object of wl_output
*
* \param resource A wl_output protocol object.
* \return The backing object (user data) of a wl_resource representing a
* wl_output protocol object.
*/
WL_EXPORT struct weston_output *
weston_output_from_resource(struct wl_resource *resource)
{
assert(wl_resource_instance_of(resource, &wl_output_interface,
&output_interface));
return wl_resource_get_user_data(resource);
}
/* Move other outputs when one is resized so the space remains contiguous. */
static void
weston_compositor_reflow_outputs(struct weston_compositor *compositor,
+3
View File
@@ -1941,6 +1941,9 @@ weston_output_disable(struct weston_output *output);
void
weston_pending_output_coldplug(struct weston_compositor *compositor);
struct weston_output *
weston_output_from_resource(struct wl_resource *resource);
#ifdef __cplusplus
}
#endif