Apparently this is something that's not part of the core Wayland protocol, but I am using Weston and the xdg-shell extension appears to have the necessary method:
xdg_surface_set_window_geometry
So I ran wayland-scanner
to create xdg code and header files:
wayland-scanner code < ./weston-1.6.0/protocol/xdg-shell.xml > xdg_shell.c
wayland-scanner client-header < ./weston-1.6.0/protocol/xdg-shell.xml > xdg_shell.h
The code I'm using is roughly as follows:
surface = wl_compositor_create_surface(compositor);
if(surface == NULL) {
...
}
native_window = wl_egl_window_create(surface, some_width, some_height);
if(native_window == NULL) {
...
}
_xdg_surface = xdg_shell_get_xdg_surface(_xdg_shell, surface);
xdg_surface_set_window_geometry(_xdg_surface, 0, 0, some_width, some_height);
The code runs without error but does nothing. I'm running on Debian Jessie with the stock Wayland and Weston packages.
If there are approaches other than xdg_shell
that might work I'm all ears.
Not sure if it corresponds to your need, but in weston/desktop-shell/shell.c in weston_view_set_initial_position(...) there is a function used in it, named set_position.
I set default xy value and it works.
来源:https://stackoverflow.com/questions/35633817/how-do-i-set-the-x-y-coordinates-of-a-window-in-wayland