On Tue, 4 Apr 2017 22:19:55 +0200 Armin Krezović <[email protected]> wrote:
> On 04.04.2017 12:58, Pekka Paalanen wrote: > > From: Pekka Paalanen <[email protected]> > > > > 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(). > > > > This patch does not add any type checks or asserts to ensure the user > > data actually is a weston_output. That is left for another patch, as > > well as introducing similar wrappers for other casts. > > > > Hi, > > Now, introducing and exporting this, without any safety checks is > just asking for trouble. If it wasn't exported, it would be > fine. But don't underestimate libweston user, people make mistakes. Hi, it is a good question though why I didn't add any asserts on this path. It might be because this will be replaced with a weston_head_from_resource() and maybe I had a plan for all similar cast-wrappers but I have long forgot. I'll add a simple assert there to check the wl_resource interface. Thanks, pq > > Signed-off-by: Pekka Paalanen <[email protected]> > > --- > > compositor/weston-screenshooter.c | 2 +- > > desktop-shell/input-panel.c | 2 +- > > desktop-shell/shell.c | 4 ++-- > > fullscreen-shell/fullscreen-shell.c | 4 ++-- > > ivi-shell/input-panel-ivi.c | 2 +- > > libweston-desktop/wl-shell.c | 2 +- > > libweston-desktop/xdg-shell-v5.c | 2 +- > > libweston-desktop/xdg-shell-v6.c | 2 +- > > libweston/compositor.c | 13 +++++++++++++ > > libweston/compositor.h | 3 +++ > > tests/weston-test.c | 2 +- > > 11 files changed, 27 insertions(+), 11 deletions(-) > > diff --git a/libweston/compositor.c b/libweston/compositor.c > > index cd5b6ec..8f53b65 100644 > > --- a/libweston/compositor.c > > +++ b/libweston/compositor.c > > @@ -4318,6 +4318,19 @@ 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) > > +{ > > + 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, > > diff --git a/libweston/compositor.h b/libweston/compositor.h > > index c375f48..e5f111c 100644 > > --- a/libweston/compositor.h > > +++ b/libweston/compositor.h > > @@ -1937,6 +1937,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
pgpgY1DfvgxKv.pgp
Description: OpenPGP digital signature
_______________________________________________ wayland-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/wayland-devel
