workaround libxcb bug

Signed-off-by: Axel Davy <axel.davy@ens.fr>
Complete Thread safety implementation.

It should be safe to more than two threads now.

Signed-off-by: Axel Davy <axel.davy@ens.fr>