Using libweston with GTK/GDK

Pekka Paalanen ppaalanen at gmail.com
Fri May 17 08:10:20 UTC 2019


On Fri, 17 May 2019 03:45:10 +0100
adlo <adloconwy at gmail.com> wrote:

> On Thu, 2019-05-16 at 11:58 +0300, Pekka Paalanen wrote:
> > 
> > you should run an actual event loop in the client, which will then
> > flush your requests to the compositor. Your issue seems to be a
> > missing
> > flush.
> > 
> > See also https://wayland.freedesktop.org/extras.html "Protocol
> > dumpers"
> > and the link "is not enough".
> > 
> > See: wl_display_flush()
> >   
> 
> I'm not sure exactly what you mean. I tried the following, but it still
> doesn't work:
> 
> void global_add(void *our_data,
>         struct wl_registry *registry,
>         uint32_t name,
>         const char *interface,
>         uint32_t version) {
> 
>          if (strcmp(interface, "xyz_shell") == 0) {
>           struct xyz_shell *xshell = NULL;
>           xshell = wl_registry_bind (registry, 1, &xyz_shell_interface,
>                                1);

Hi,

you forgot to use 'name'.

>           wl_display_flush (display);
> 
>           }
> 
> }
> 
> ...
> 
> void idle ()
> {
>   registry = wl_display_get_registry (display);
> 
>   wl_registry_add_listener(registry, &registry_listener, NULL);
> 
>   wl_display_flush (display);
>   wl_display_dispatch (display);
>   wl_display_dispatch (display);
>   wl_display_flush (display);

Please see create_display() from simple-shm.c in Weston repository for
a much better way to handle the initial registry setup and for the
explanation why.

> }
> 
> 
> int main (int    argc,
>           char **argv)
> {
> 
>   struct wl_event_loop *event_loop = wl_event_loop_create ();
>   wl_event_loop_add_idle (event_loop, idle, NULL);
> 
>   while (true)
>     {
>       wl_event_loop_dispatch (event_loop, 0);
>     }

This is not a client event loop.

wl_event_loop is a Wayland server thing.

See main() from simple-shm.c for an example of the trivial event loop.

> 
>   return 0;
> }
> 
> I also tried wl_display_get_event_loop() and tried to add_idle() to
> that, but that caused the client to segfault.

wl_display_get_event_loop() is a server function.

You should be getting compiler warnings about this when you do not
#include <wayland-server.h>, and you should not include that in a
client program.

struct wl_display is completely different on client vs. server side. It
just has the same name on both sides, which in hindsight is really
unfortunate and confusing.


Thanks,
pq
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20190517/f5cd1772/attachment.sig>


More information about the wayland-devel mailing list