On Wed, Sep 30, 2015 at 8:59 AM, Derek Foreman <der...@osg.samsung.com> wrote:
> Having an invalid serial number is quite useful - for example, we can > have protocol requests that optionally take a serial number or 0 > instead of having two similar requests. > > Signed-off-by: Derek Foreman <der...@osg.samsung.com> > --- > > Well, let's see where this goes ;) > I certainly hope this sort of thing is accepted. I do wonder if we should have a wl_serial_compare() as part of wayland > but the semantics are tricky (a big serial and a small serial may actually > have happened quite close to eachother if the small happened after a > wrap around). > Just let the programmers use signed arithmetic. There is no reason to make this too complicated. If SIGNED_SERIAL_T is the signed equivalent to the serial number, then the following will detect if a is before b: SIGNED_SERIAL_T(a-b) < 0 This sets the "arbitrary distance" to 1/2 the entire serial space. --- a/src/wayland-server.c > +++ b/src/wayland-server.c > @@ -826,7 +826,7 @@ wl_display_create(void) > wl_signal_init(&display->destroy_signal); > > display->id = 1; > - display->serial = 0; > + display->serial = 1; > > wl_array_init(&display->additional_shm_formats); > > @@ -979,6 +979,9 @@ wl_display_next_serial(struct wl_display *display) > { > display->serial++; > > + if (display->serial == 0) > + display->serial++; > + > return display->serial; > } > I suspect this causes the first event to have a serial number of 2, not 1. Not a big deal, but it might be better to initialize the serial number to zero, or you can initialize it to -1 if you want the structure to always have a valid serial number.
_______________________________________________ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel