On Fri, 30 Sep 2016 23:25:30 +0200
Armin Krezović <krezovic.ar...@gmail.com> wrote:

> This patch adds horizontal output layout configuration using
> the previously added code.
> 
> When an output is added, it looks for outputs that it should
> be placed next to, if they are specified. If such output is
> found, output layout is updated if needed (outputs on a given
> position are moved right if they collide with the new output)
> and the output is positioned next to the specified output,
> either on its left or its right.
> 
> If a certain position wasn't specified for the current output,
> the compositor looks for any existing outputs that have
> current output specified on that position, and updates the
> positions accordingly, if corresponding output is found.
> 
> Output positions can only be set once, where config file
> specified option is always set, even if such output will
> never be present. If a certain position wasn't set, the
> compositor may update the position if it finds another
> output that wants to be placed next to the output that's
> being configured. In such case, first existing output that
> matches the position is picked up, rest is ignored.
> 
> Default behaviour is still to place outputs that have
> no matching configuration top right.
> 
> Signed-off-by: Armin Krezović <krezovic.ar...@gmail.com>
> ---
>  compositor/main.c | 159 
> +++++++++++++++++++++++++++++++++++++++++++++++++++---
>  1 file changed, 153 insertions(+), 6 deletions(-)
> 
> diff --git a/compositor/main.c b/compositor/main.c
> index e379d8d..c039ae6 100644
> --- a/compositor/main.c
> +++ b/compositor/main.c
> @@ -480,20 +480,167 @@ wet_init_parsed_options(struct weston_compositor *ec)
>       return config;
>  }
>  
> +static struct wet_output *
> +wet_output_from_output(struct wet_compositor *compositor, struct 
> weston_output *output)
> +{
> +     struct wet_output *iterator, *next;
> +
> +     if (wl_list_empty(&compositor->output_layout_list))
> +             return NULL;
> +
> +     wl_list_for_each_safe(iterator, next, &compositor->output_layout_list, 
> link) {
> +             if (iterator->output == output)
> +                     return iterator;
> +     }

Hi,

wet_output uses a destroy listener on the output, so use that:

listener = wl_signal_get(&output->destroy_signal, handle_output_destroy);
wet_output = container_of(...);

> +
> +     return NULL;
> +}
> +
> +static struct wet_output *
> +wet_output_from_name(struct wet_compositor *compositor, const char *name)
> +{
> +     struct wet_output *iterator, *next;
> +
> +     if (wl_list_empty(&compositor->output_layout_list))
> +             return NULL;
> +
> +     wl_list_for_each_safe(iterator, next, &compositor->output_layout_list, 
> link) {
> +             if (!strcmp(iterator->output->name, name))
> +                     return iterator;
> +     }

No need to check for empty list, and no need to use _safe. Applies
probably to all loop below, too.

> +
> +     return NULL;
> +}
> +

I kind of wonder how much sense it makes to do first just 1-D layout
and then later expand to 2-D layout. I fear the code re-use might be
non-existant.

If you are struggling with 2-D layout, maybe X.org could provide some
example?

I do not have a suggestion for a good layout algorithm or even a method
of description. People have been configuring X.org for ages, so
something similar might be familiar.

Positioning by absolute coordinates I would like to leave out if
possible, or at least you would need to check that:
- all outputs create a single connected region (so pointers can travel
  everywhere)
- no outputs overlap (IIRC this is a limitation of Weston's damage
  tracking)


Thanks,
pq

Attachment: pgpipaRSR54of.pgp
Description: OpenPGP digital signature

_______________________________________________
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to