Trying to understand how to display a surface

João Jerónimo joao.jeronimo.89 at gmail.com
Thu Apr 18 17:43:52 PDT 2013


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?

Sorry for my poor English (assuming that you think it's poor)....
João Jerónimo



More information about the wayland-devel mailing list