[PATCH weston v5 11/36] libweston: add weston_head::connected

Derek Foreman derekf at osg.samsung.com
Fri Feb 2 19:52:37 UTC 2018


On 2017-12-14 05:40 AM, Pekka Paalanen wrote:
> From: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
> 
> Heads may be disconnected or connected and the compositor needs to be
> able to know the state to know which heads to take into use.
> 
> Currently a single head is automatically created with an output, and
> outputs are only ever created as connected and destroyed on
> disconnection, so it suffices to set connected to true. In the future,
> backends are expected to create heads for both connected and
> disconnected connectors, so that a connector can be forced on without it
> being actually connected.
> 
> Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
> ---
>   libweston/compositor.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++
>   libweston/compositor.h | 10 ++++++++
>   2 files changed, 74 insertions(+)
> 
> diff --git a/libweston/compositor.c b/libweston/compositor.c
> index b0d1629e..349803e8 100644
> --- a/libweston/compositor.c
> +++ b/libweston/compositor.c
> @@ -4597,6 +4597,69 @@ weston_head_set_internal(struct weston_head *head)
>   	head->connection_internal = true;
>   }
>   
> +/** Store connector status
> + *
> + * \param head The head to modify.
> + * \param connected Whether the head is connected.
> + *
> + * Connectors are created as disconnected. This function can be used to
> + * set the connector status.
> + *
> + * The status should be set to true when a physical connector is connected to
> + * a video sink device like a monitor and to false when the connector is
> + * disconnected. For nested backends, the connection status should reflect the
> + * connection to the parent display server.
> + *
> + * \memberof weston_head
> + * \internal
> + */
> +WL_EXPORT void
> +weston_head_set_connection_status(struct weston_head *head, bool connected)
> +{
> +	head->connected = connected;
> +}
> +
> +/** Is the head currently connected?
> + *
> + * \param head The head to query.
> + * \return Connection status.
> + *
> + * Returns true if the head is physically connected to a monitor, or in
> + * case of a nested backend returns true when there is a connection to the
> + * parent display server.
> + *
> + * This is independent from the head being enabled.
> + *
> + * \sa weston_head_is_enabled
> + * \memberof weston_head
> + */
> +WL_EXPORT bool
> +weston_head_is_connected(struct weston_head *head)
> +{
> +	return head->connected;
> +}
> +
> +/** Is the head currently enabled?
> + *
> + * \param head The head to query.
> + * \return Video status.
> + *
> + * Returns true if the head is currently transmitting a video stream.
> + *
> + * This is independent of the head being connected.
> + *
> + * \sa weston_head_is_connected
> + * \memberof weston_head
> + */
> +WL_EXPORT bool
> +weston_head_is_enabled(struct weston_head *head)
> +{
> +	if (!head->output)
> +		return false;
> +
> +	return head->output->enabled;
> +}

I suppose if I'm trying to be as pedantic possible, I wasn't expecting 
to see this function added from the content of the commit log.

Reviewed-by: Derek Foreman <derekf at osg.samsung.com>

And if you decide to split weston_head_is_enabled() into its own patch, 
that's RB me too.  As is the previous "add name to weston_head" patch.

Thanks,
Derek

> +
>   /* Move other outputs when one is resized so the space remains contiguous. */
>   static void
>   weston_compositor_reflow_outputs(struct weston_compositor *compositor,
> @@ -4968,6 +5031,7 @@ weston_output_init(struct weston_output *output,
>   	wl_list_init(&output->head_list);
>   
>   	weston_head_init(&output->head, name);
> +	weston_head_set_connection_status(&output->head, true);
>   
>   	/* Add some (in)sane defaults which can be used
>   	 * for checking if an output was properly configured
> diff --git a/libweston/compositor.h b/libweston/compositor.h
> index 02b5fa32..d14dd6dc 100644
> --- a/libweston/compositor.h
> +++ b/libweston/compositor.h
> @@ -168,6 +168,7 @@ struct weston_head {
>   	bool connection_internal;	/**< embedded monitor (e.g. laptop) */
>   
>   	char *name;			/**< head name, e.g. connector name */
> +	bool connected;			/**< is physically connected */
>   };
>   
>   struct weston_output {
> @@ -1966,8 +1967,17 @@ weston_head_set_subpixel(struct weston_head *head,
>   			 enum wl_output_subpixel sp);
>   
>   void
> +weston_head_set_connection_status(struct weston_head *head, bool connected);
> +
> +void
>   weston_head_set_internal(struct weston_head *head);
>   
> +bool
> +weston_head_is_connected(struct weston_head *head);
> +
> +bool
> +weston_head_is_enabled(struct weston_head *head);
> +
>   void
>   weston_output_set_scale(struct weston_output *output,
>   			int32_t scale);
> 



More information about the wayland-devel mailing list