The question mentions this in the very second line? “Of course this isn't always possible, for example if the window came over a TCP connection.” The link is to the question and answer, not to just the title. (And there's already another thread right here in this HN discussion about the same thing, posted ~15 hours before your comment: https://news.ycombinator.com/item?id=38218800)
X11 is a network protocol. Windows can be created by things that aren't on the same machine as you, or aren't even processes at all. It's just packets.