[PATCH weston 4/4] compositor: Implement horizontal output layout configuration

Armin Krezović krezovic.armin at gmail.com
Sun Oct 9 17:30:11 UTC 2016


On 07.10.2016 12:19, Pekka Paalanen wrote:
> On Fri, 30 Sep 2016 23:25:30 +0200
> Armin Krezović <krezovic.armin at 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.armin at 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(...);
> 

Thanks for the hint.

>> +
>> +	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.
> 

I have been burned when using non-safe version in the past (getting
random segfaults with non-safe version and not with safe version),
so I keep on using it. I'll see if it's still needed.

>> +
>> +	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
> 

I have thought about 2D layout, but I have ran in a problem that I can't
solve.

I'll try to illustrate.


|--------||-------------|
|        ||             |
|________||             |
          |_____________|
|--------------|
|              |
|              |
|______________|

Lets say I have an 800x600 output top left, and 1024x768 next to it.
I want to place an 1280x1024 output below 800x600 one. I'd get something
like this, or the output below would overlap with the one on top right.

Now, one of the solutions is to align both of the outputs on the bottom
border, so I get something like this:

           |-------------|
|---------||             |
|         ||             |
|_________||_____________|
|--------------|
|              |
|              |
|______________|

Suggestions welcome.

(Sorry for my bad illustrations).

Thanks, Armin.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 837 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20161009/24cba8d4/attachment.sig>


More information about the wayland-devel mailing list