[Xcb] How to properly discard socket-handoff GetInputFocus requests?

Clemens Eisserer linuxhippy at gmail.com
Mon Feb 26 08:07:00 UTC 2018


Hi Uli,

> The last argument to xcb_take_socket gives you the sequence number. It
> is just the number of requests that were sent on the connection. So the
> sequence number of the first request that you generate on your own is
> <that number> + 1, etc.

Strange, I tried calling xcb_discard_reply64(sent + 1) and it didn't work.

> Hence, the rule of "the first request has to cause a reply" is mostly
> just a safe over-approximation over some internal information that xcb
> does not hand out.

Good to know, thanks for the confirmation.
I now implemented issuing xcb_get_input_focus right before requesting
the socket and it seems to work fine.

> So... why don't you just batch things outside of xcb (in a similar way
> as you do know) and then use e.g. xcb_send_request() to send the
> resulting requests when you really want to? Or alternatively, batch them
> as you do know and then use the normal wrapper functions provided by xcb
> to send the request? Why do you need to take the socket to batch requests?

The most important aspect is maintenance.
I only work on a tiny fraction of the whole Java/X11 code - there are
tons of other code around, sometimes legacy stuff which is better not
touched.

If I would do batching myself, I would have to find all the right
spots where/when to flush my buffers / end a batch.
XCBs socket handoff is beneath all that, so whoever calls into Xlib, I
am notified and can properly clean up.


> Google gave me
> http://hg.openjdk.java.net/xrender/xrender/jdk/rev/0522a2e793b2 at which
> point there is too much code for me to quickly understand. At least I
> see that Java_sun_java2d_xr_XRBackendJava_takeSocket ignores the "sent"
> variable that would provide it with sequence numbers.

I remember :)
Back then the goal was to avoid Java->C interface overhead, however
this didn't work out - and the batching idea was not on my radar.

Thanks again for the confirmation and best regards, Clemens


More information about the Xcb mailing list