[Weston] More discussion about weston output relative motion algorithm

Wang, Quanxian quanxian.wang at intel.com
Wed May 7 01:49:47 PDT 2014



> -----Original Message-----
> From: Pekka Paalanen [mailto:ppaalanen at gmail.com]
> Sent: Wednesday, May 7, 2014 3:41 PM
> To: Wang, Quanxian
> Cc: Hardening (rdp.effort at gmail.com); Bryce W. Harrington
> (b.harrington at samsung.com); wayland-devel at lists.freedesktop.org; Jason
> Ekstrand (jason at jlekstrand.net); Kang, Jeong Seok; Fu, Michael
> Subject: Re: [Weston] More discussion about weston output relative motion
> algorithm
> 
> On Wed, 7 May 2014 07:03:32 +0000
> "Wang, Quanxian" <quanxian.wang at intel.com> wrote:
> 
> >
> >
> > > -----Original Message-----
> > > From: Pekka Paalanen [mailto:ppaalanen at gmail.com]
> > > Sent: Wednesday, May 7, 2014 2:17 PM
> > > To: Wang, Quanxian
> > > Cc: Hardening (rdp.effort at gmail.com); Bryce W. Harrington
> > > (b.harrington at samsung.com); wayland-devel at lists.freedesktop.org;
> > > Jason Ekstrand (jason at jlekstrand.net); Kang, Jeong Seok; Fu, Michael
> > > Subject: Re: [Weston] More discussion about weston output relative
> > > motion algorithm
> > >
> > > On Wed, 7 May 2014 03:26:56 +0000
> > > "Wang, Quanxian" <quanxian.wang at intel.com> wrote:
> > >
> > > > Thanks Pq's comment. Before you continue my comment, I mentioned
> > > > one
> > > point.
> > > > This is output movement algorithm and it is completely different
> > > > with pre-
> > > configuration of output in weston.ini.
> > > > For output, no alive, no movement.
> > > > If you want to keep pre-configuration in weston.ini when output
> > > > change,
> > > just keep it in some place and follow it when pre-defined output is
> > > plugged or unplugged. But anyway, it is a static configuration.  It
> > > is conflict with dynamic output movement.
> > > >
> > >
> > > Of course it is, but users expect both to work at the same time, not
> > > have an option to choose between dynamic and static configuration.
> > > They want to configure what the dynamic code will do on hotplug,
> > > hence these two cases are inseparable.
> > >
> > > The weston-randr protocol could be seen as a way to modify the
> > > static configuration in-memory and then trigger a re-layout.
> > >
> > > Btw. there is no reason to avoid negative global coordinates. If you
> > > have output A at 0,0 and add output B to the left of it, it is
> > > perfectly valid to put B at -widthB,0. You *can* add to the left or
> > > above without moving all the existing outputs. Also nothing says
> > > that you have to have an output with origin at 0,0. (There may be
> > > bugs, but that is all.)
> > [Wang, Quanxian] no negative coordinate happens. Top left most is the
> > (0,0), it is the primary output.
> 
> You misunderstood. I mean that sometimes it is *good* to use negative
> coordinates, exactly to avoid moving the world, and that is *perfectly ok*.
> 
> Moving the world (all existing outputs) is usually not what a user might
> expect when adding a new output.
> 
> The top-left most output does not need to be at 0,0.
> 
> > When you move output left of or
> > above primary output(0,0), other outputs will be moved consistently
> > based on the change. Once you primary output is changed, for example
> > in this case, primary output will be changed to another output.  All
> > others outputs' coordinate will be calculated again. But the relative
> > position between outputs will not be changed. Top left most output is
> > the root of tree. All other outputs must be descendants of
> > it.(including clone link, hlink, vlink).  Output movement algorithm
> > have implemented that. Negative coordinate is invalid.
> 
> I'm not talking about your specific algorithm anymore. I am talking in general.
> 
> Existing outputs are usually expected to stay put, when adding outputs to
> the extremes. Literally that means that the position of the existing outputs
> must not change, but only the position of the new output is computed
> appropriately, even if it results in negative coordinates.
> 
> If I have one output active, and I add another output to the left of it, I
> certainly do not expect all windows to jump from the existing output to the
> new output. IOW, the position of the existing output must not change, and
> the new output will get a negative position.
> 
> This is about the absolute global coordinates, not the relative positioning
> between outputs.
[Wang, Quanxian] Hi, Pq
After getting your opinion, I called back my initial thought for this algorithm.  I ever thought it like you, but after draw them one by one, I found I was wrong.
The following information will tell you how to get the principle of algorithm.

How to get that principle?
Take a very simple example, it is a horizontal link.
Current output layout:
A->B->C->D
Next action:  Move new E output into left of C
A->B->E->C->D

Question: Can you keep un-changed on all output's coordinate? 
Absolutely not. C and D will be changed(right extension) or A and B are changed (left extension). Take common case to allow right extension.
E will take place of C, C and D's coordinate will be changed at the same time. It is the minor change.
The same thing for moving E leftof A. They are the same principle. Therefore in this case no negative happens. We implicitly support right extension.

Now you get the principle from simple link. And then vlink is the same thing. And then combine vlink and hlink together. 
At last I got this algorithm. I know principle will exist in both complex and simple layout. The algorithm can be summarized from them.
Therefore my first step is to study simple case and find what the rule is. And then turn to complex and enhance the algorithm. Make the algorithm to be complete.

Here I list several questions for you.
1) Why use tree to link all outputs together?
If just use coordinate to calculated the x, y, you will be lost. Because when you moving output, you can't avoid affecting the position of other outputs. You have to review all coordinates of outputs and make decision who is left, right, above, below. It will be much more complex. But if you use tree to link all, everything is very clear. Who is left, right, above, below. It is very clear. Coordinate and relative motion could be easily figured out.

It will be very easy to control the position and movement of outputs.

2) Why one root
One root will tell you, this is the top left most. No other outputs will be left or above it. From this, you can calculate and review all outputs. No one is lost.

3) Why only one parent?
If two parents, you will find more links will cross each other. It is absolutely a disaster. (This could cause conflict of coordinates, from this path, it will A, for that path, it will B. A and B is not same.)

I am not sure if you understand my idea. Sorry for my poor language.

Anyway, you can have a try to draw output layout on your paper and calculated their coordinate. I believe you can get more thought about that.
I give you a hint. 4 outputs will generate 14x24=336  types of layout. 14 stand for formation. 24 means every formation will generate 24 different layouts. You can list them and define their relation of them as you want.

> 
> > > Btw. I don't understand the comment "no alive, no movement".
> > [Wang, Quanxian] if output is not active, no movement should happens
> > on this output. Any movement on such kind of output will be invalid.
> > The inactive status include two status. a)unplugged-hardware disable
> > b) plugged but disabled - software disable
> 
> What does "movement happening on an output" mean? What could be
> moving on that inactive output? Are you perhaps instead trying to say, that
> using an inactive output as the reference point for placing another output is
> not allowed?
[Wang, Quanxian]right. No movement is allowed on inactive output.
> 
> 
> Thanks,
> pq


More information about the wayland-devel mailing list