The code above appears to just draw each subpolygon as a filled polygon with no reference to the other subpolygons. This means that complex polygons containing holes cannot be drawn correctly. Having searched for information on drawing complex polygons with X11 it seems there is no way to do this. The XFillPolygon documentation talks about complex polygon but gives no way to actually draw one.
Yes, unfortunately, it seems to be impossible to do directly in X11.