Trying to understand how to show a surface

Ander Conselvan de Oliveira conselvan2 at gmail.com
Thu Apr 18 23:04:10 PDT 2013


On 04/19/2013 04:57 AM, João Jerónimo wrote:
> Em 19-04-2013 01:52, darxus at chaosreigns.com escreveu:
>> Might be useful to post the code.
>
> Ok. I'll post it then.
> I'm linking only the wayland libraries. One also needs to use the
> -std=gnu++11 flag.

[...]

> int main()
> {
>      try {
>          printf("Hello world!!!!! Example Wayland client...\n");
>
>          // Connect

[...]

>          wl_display_dispatch(display);
>          wl_display_roundtrip(display);
>          cout << "End of globals..." << endl << endl;
>
>          // Create surface

[...]

>          for (int i=0; i<100*200; ++i) {
>              buffer[i] = 0x40404040;
>          }
>
>          wl_surface_attach(surface, buffer_wl, 0, 0);
>
>          wl_surface_damage(surface, 0, 0, 100, 200);
>          wl_surface_commit(surface);
>
>          for(;;);

When the program enters the infinite loop, the requests are still 
sitting in the connection buffer in the client side. Before blocking, 
clients should call wl_display_flush(). You'll find more details in the 
Wayland client API documentation:

http://wayland.freedesktop.org/docs/html/chap-Library.html#sect-Library-Client

Cheers,
Ander

>
>          // Terminate connection
>          wl_display_disconnect(display);
>
>          return 0;
>      }
>      catch(string &errstr) {
>          cout << "FATAL: " << errstr << endl;
>      }
> }
>
>
> João Jerónimo
>
>
>
>
>
>>
>> On 04/19, João Jerónimo 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?
>>>
>>> Sorry for my poor English (assuming that you think it's poor)....
>>> João Jerónimo
>>>
>>> _______________________________________________
>>> wayland-devel mailing list
>>> wayland-devel at lists.freedesktop.org
>>> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
>>>
>
>
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
>



More information about the wayland-devel mailing list