Well, I tried Alexx2000's method and found it worked perfectly, both in Lazarus and in a stand alone app running on a Ubuntu26.04 VM.
However, we must remember that libxcb is just an interface to X as is xlib. The nasty people who want to get rid of X will obviously remove libxcb when they finally have their way.
I tested my app on that U26.04 box, patched and it works fine, windows appear where they should be etc. So I then hid libxcb and my patched app crashed because it cannot find libxcb, I'd hoped it would fall back to xlib or even wayland.
So I tried an unpatched version, with libxcb hidden, it too crashed ! That means, even apps force to go via wayland have a dependency on libxcb ?? So, I read that as saying we are safe having a hard dependency on libxcb for the time being !
Better code might first test if libxcb is available before setting that env var, only a few more lines of code ...
IMHO.
Davo