11

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.

mpr
  • 3,250
  • 26
  • 44
  • Did you find any answer ? I'm also looking to set a default position for my windows under weston – Erwan Douaille Mar 01 '16 at 11:31
  • 1
    With some help from the Wayland/Weston forums I made a workaround, which was to set my windows to fullscreen output dimensions with a transparent background, then offset my content within the full screen. The Wayland APIs just aren't meant for this kind of application level control as of now. – mpr Mar 07 '16 at 14:00
  • @mpr can you plz share your code or any link to forums discussions for this workaround, i'm kinda stuck and need to apply same hack – Khode_Erfan Jun 27 '21 at 00:23
  • 1
    Sorry Khode_Erfan, it's long gone. It's kinda sad to see this question still open though! I never fully understood what problems Wayland was meant to tackle, and in fact ended up going back to X-related solutions. – mpr Jun 28 '21 at 05:42

1 Answers1

1

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.

Erwan Douaille
  • 553
  • 1
  • 10
  • 31
  • How did you get the `weston_view` and `desktop_shell` objects from your client program? – mpr Mar 01 '16 at 14:43
  • It's accessible in weston sources. I don't know if it's accessible from client program side. This modification will be applied for every windows. – Erwan Douaille Mar 01 '16 at 15:14
  • I looked into extending Weston but it was a bit too much for me to bite off at the moment. I'm gonna leave the question open for now, with the idea that maybe the Wayland APIs will provide more application level control in the future. – mpr Mar 07 '16 at 14:06