libwayland surface coordinate question
Scott Anderson
scott.anderson at collabora.com
Fri Nov 22 01:52:45 UTC 2019
On 22/11/19 2:40 pm, Ken C wrote:
> I am just starting out with libweston and have a beginner question
> regarding surface/view coordinates. I am looking to implement
> something along the lines of issue #277 on gitlab[1], "New shell
> plugin for single-app usecases". I have swapped out
> weston-desktop-shell with a toy client just to get grounded, and am
> using the X11 and RDP backends for testing. I can see where the
> initial client position gets set up in
> weston_view_set_initial_position() in shell.c. However I am finding
> that even if weston_view_set_position() is called with {0,0}, the
> resulting window on output is offset by ~32ish pixels. I've also
> started from westiny[2], which is about as simple as it gets, but find
> the same mysterious (to me) offset. I can set the initial position to
> a negative x,y value in weston_view_set_initial_position(), forcing
> the window into the corner. Maximizing the toy client interestingly
> enough fills the screen (a single head).
>
> I've looked high and low for where that ~32 pixel offset comes from,
> but have not had luck. While I look some more maybe someone has a
> quick pointer. If I can set a breakpoint I'm sure it will become
> obvious.
>
> [1] https://gitlab.freedesktop.org/wayland/weston/issues/277
> [2] https://gitlab.freedesktop.org/daniels/westiny/blob/master/westiny.c
Hi,
It may be because of the client's "window geometry"[1]. There may be
some drop shadows or otherwise transparent border around the client's
contents, and the window geometry will tell you which part of the
surface you should consider to be the client's contents.
If you'll excuse the terrible ASCII drawing:
(0,0)
+---------------+ <--- Surface
| (32,32) |
| +---------+<------- Geometry
| | |# |
| | |# |
| | |# |
| +---------+# |
| ############ |
+---------------+
When a client is maximized or fullscreened, they're asked to not draw
these kinds of things, and should fill the entire surface with their
window's contents.
weston_desktop_surface_get_geometry is the function you call to get this
information.
Scott
[1]:
https://gitlab.freedesktop.org/wayland/wayland-protocols/blob/master/stable/xdg-shell/xdg-shell.xml#L445-476
More information about the wayland-devel
mailing list