How do I set the x,y coordinates of a window in Wa

2019-04-06 23:26发布

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.

标签: wayland
1条回答
倾城 Initia
2楼-- · 2019-04-06 23:56

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.

查看更多
登录 后发表回答