[weston,1/3] window: use roundtrip instead of dispatch after get_registry

Submitted by Marek Chalupa on Dec. 5, 2014, 12:49 p.m.

Details

Message ID 1417783782-12792-1-git-send-email-mchqwerty@gmail.com
State Accepted
Commit a519d06a53962704f81030967fc0b892376356e9
Headers show

Not browsing as part of any series.

Commit Message

Marek Chalupa Dec. 5, 2014, 12:49 p.m.
wl_display_dispatch() just dispatches events that are in
default and display queues and if there are no events,
then it will wait for them. But only dispatching
the events doesn't guarantee that we got all the global announcements,
we need to do sync too. Therefore use wl_display_roundtrip() instead
of wl_display_dispatch().

Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
---
 clients/window.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/clients/window.c b/clients/window.c
index cc1e272..c5082ba 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -5527,7 +5527,7 @@  display_create(int *argc, char *argv[])
 	d->registry = wl_display_get_registry(d->display);
 	wl_registry_add_listener(d->registry, &registry_listener, d);
 
-	if (wl_display_dispatch(d->display) < 0) {
+	if (wl_display_roundtrip(d->display) < 0) {
 		fprintf(stderr, "Failed to process Wayland connection: %m\n");
 		return NULL;
 	}

Comments

On Fri,  5 Dec 2014 13:49:40 +0100
Marek Chalupa <mchqwerty@gmail.com> wrote:

> wl_display_dispatch() just dispatches events that are in
> default and display queues and if there are no events,
> then it will wait for them. But only dispatching
> the events doesn't guarantee that we got all the global announcements,
> we need to do sync too. Therefore use wl_display_roundtrip() instead
> of wl_display_dispatch().
> 
> Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
> ---
>  clients/window.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/clients/window.c b/clients/window.c
> index cc1e272..c5082ba 100644
> --- a/clients/window.c
> +++ b/clients/window.c
> @@ -5527,7 +5527,7 @@ display_create(int *argc, char *argv[])
>  	d->registry = wl_display_get_registry(d->display);
>  	wl_registry_add_listener(d->registry, &registry_listener, d);
>  
> -	if (wl_display_dispatch(d->display) < 0) {
> +	if (wl_display_roundtrip(d->display) < 0) {
>  		fprintf(stderr, "Failed to process Wayland connection: %m\n");
>  		return NULL;
>  	}

Very true, pushed.

I tried to look quickly, but I couldn't see it; the globals that send
initial events on bind, like wl_shm.format - do we have the 2nd
roundtrip for those somewhere?


Thanks,
pq
On 12 December 2014 at 13:24, Pekka Paalanen <ppaalanen@gmail.com> wrote:
>
> On Fri,  5 Dec 2014 13:49:40 +0100
> Marek Chalupa <mchqwerty@gmail.com> wrote:
>
> > wl_display_dispatch() just dispatches events that are in
> > default and display queues and if there are no events,
> > then it will wait for them. But only dispatching
> > the events doesn't guarantee that we got all the global announcements,
> > we need to do sync too. Therefore use wl_display_roundtrip() instead
> > of wl_display_dispatch().
> >
> > Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
> > ---
> >  clients/window.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/clients/window.c b/clients/window.c
> > index cc1e272..c5082ba 100644
> > --- a/clients/window.c
> > +++ b/clients/window.c
> > @@ -5527,7 +5527,7 @@ display_create(int *argc, char *argv[])
> >       d->registry = wl_display_get_registry(d->display);
> >       wl_registry_add_listener(d->registry, &registry_listener, d);
> >
> > -     if (wl_display_dispatch(d->display) < 0) {
> > +     if (wl_display_roundtrip(d->display) < 0) {
> >               fprintf(stderr, "Failed to process Wayland connection:
> %m\n");
> >               return NULL;
> >       }
>
> Very true, pushed.
>
> I tried to look quickly, but I couldn't see it; the globals that send
> initial events on bind, like wl_shm.format - do we have the 2nd
> roundtrip for those somewhere?
>
>
Nope, not in display_create() (or functions called from it). However, in
the current code everything that depends
on the wl_shm.format (which is the only bind in global handler) is called
from some handler (if I haven't overlooked something),
so it works, because the handler is called after the wl_shm.format is
processed.

Nevertheless, In the future it could get broken, because some functions
that depend on wl_shm.format
are not static, so if programmer use them right after display_create(), the
wl_shm.format events do not need to be
dispatched by that time.

So maybe follow-up patch would be good.


>
> Thanks,
> pq
>

Regards,
Marek