OK, after my experiments with X's Primary, there is the advise: Verify EVERYTHING.
If it works in GTK applications, check Qt. And Wx too. Maybe even FLTK.
There's also an X text editor named CoolEdit. Its GUI seems to be not made with any typical library (although looks MOTIF-ish), the authors...