The part of code that maintains the position of each surface

Pekka Paalanen ppaalanen at gmail.com
Sat Sep 20 01:45:59 PDT 2014


On Fri, 19 Sep 2014 14:24:50 -0400
Hongze Zhao <zhaohongze at gmail.com> wrote:

> Hi All,
> 
> I am using weston-1.5.X and I am curious about the which part of code that
> maintains the position of each surface.
> 
> When multiple clients connects to the weston server and initializes its
> surface, the surfaces are not showed in the exactly same position
> initially, which means someone is maintaining the position of the
> each surfaces to avoid the newly created surfaces from being showed in the
> same position. I am wondering if anyone could give me some hint where I can
> look for the code doing this job.

It is not maintained in any single place.

- A wl_surface is usually bigger than appears on screen, because
  windows may have shadows that add transparent margins. xdg-shell
  defined "window geometry" which defines the extents of "the
  window".

- weston_surface does not define a position at all, weston_view
  does, and there can be several views for a surface. That means a
  window may have multiple positions. It is up to the shell to
  decide which one is "the" position.

- weston_view::geometry.x,y is the basic translation part, but the
  matrices added to the transformation_list may also modify the
  position.

- if weston_view::geometry.parent is set, the surface is positioned
  relative to the parent, not in absolute coordinates. I forget if
  the parent matrix is in the transformation_list.

If you want to find the position in absolute coordinates given a
weston_view, use weston_view_to_global_{float,fixed}() function on
all the corners of the window. It is not enough to inspect only the
top-left corner, as the window may be rotated. It is also usually
not useful to inspect the surface point (0,0) because of the
possible shadow margins - you should use the window geometry
instead.

You might inspect weston_view::transform.boundingbox, that will not
take the window geometry into account.

But like Jonas said, the desktop shell does not inspect any of
this. It just randomizes the initial positions.


Thanks,
pq


More information about the wayland-devel mailing list