<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Sep 30, 2015 at 8:59 AM, Derek Foreman <span dir="ltr"><<a href="mailto:derekf@osg.samsung.com" target="_blank">derekf@osg.samsung.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Having an invalid serial number is quite useful - for example, we can<br>
have protocol requests that optionally take a serial number or 0<br>
instead of having two similar requests.<br>
<br>
Signed-off-by: Derek Foreman <<a href="mailto:derekf@osg.samsung.com">derekf@osg.samsung.com</a>><br>
---<br>
<br>
Well, let's see where this goes ;)<br></blockquote><div><br></div><div>I certainly hope this sort of thing is accepted.<br><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I do wonder if we should have a wl_serial_compare() as part of wayland<br>
but the semantics are tricky (a big serial and a small serial may actually<br>
have happened quite close to eachother if the small happened after a<br>
wrap around).<br></blockquote><div><br></div><div>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:<br><br></div><div> SIGNED_SERIAL_T(a-b) < 0<br><br>This sets the "arbitrary distance" to 1/2 the entire serial space.<br><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
--- a/src/wayland-server.c<br>
+++ b/src/wayland-server.c<br>
@@ -826,7 +826,7 @@ wl_display_create(void)<br>
wl_signal_init(&display->destroy_signal);<br>
<br>
display->id = 1;<br>
- display->serial = 0;<br>
+ display->serial = 1;<br>
<br>
wl_array_init(&display->additional_shm_formats);<br>
<br>
@@ -979,6 +979,9 @@ wl_display_next_serial(struct wl_display *display)<br>
{<br>
display->serial++;<br>
<br>
+ if (display->serial == 0)<br>
+ display->serial++;<br>
+<br>
return display->serial;<br>
}<br></blockquote><div><br></div><div>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.<br><br></div></div></div></div>