Trying to understand how to display a surface
Pekka Paalanen
ppaalanen at gmail.com
Fri Apr 19 00:10:35 PDT 2013
On Fri, 19 Apr 2013 01:43:52 +0100
João Jerónimo <joao.jeronimo.89 at gmail.com> wrote:
> Hello.
>
> I was trying to understand what is the minimal code needed to get a
> square painter on the screen. However, although I can make the client
> talk to the Weston compositor, enumerate the global objects, etc, I
> can't still see my surface drawn in the compositor scene.
>
> The steps that my program makes so far are as follows:
> - call wl_display_connect(NULL)
> - call wl_display_get_registry(display)
> - Install listeners for the registry that wl_registry_bind() many
> of the advertised objects. However, I'm not listening to the events
> of the objects advertised by the registry. Is it needed?
> - call wl_display_dispatch() and wl_display_roundtrip()
> - call wl_compositor_create_surface()
> - mkostemp() a file and ftruncate() it to some 10MB or so
> - mmap() the entire file created
> - call wl_shm_create_pool()
> - call wl_shm_pool_create_buffer()
> - call wl_display_dispatch()
> - Fill the buffer with some content. I filled it entirely with
> pattern 0x40404040.
> - call wl_surface_attach(surface, buffer, 0, 0)
> - Then the program just sits in an infinite loop...
>
> Am I missing anything?
After wl_surface.attach and damage, you must also send
wl_surface.commit to actually apply your changes.
Before that, you also need to give the surface a role, otherwise the
surface will not be visible. Create a wl_shell_surface for your
wl_surface, and send wl_shell_surface.set_toplevel.
simple-shm.c is a standalone example in the weston repository for all
this, plus proper animation and wl_buffer handling.
Thanks,
pq
More information about the wayland-devel
mailing list