I had overlooked that X11 windows may be re-created from a different thread than their owner thread. This is the case in the test which calls UpdateLayeredWindow from a different thread, which triggers a `whole_window` recreation.
v4/v5 should address this and use a separate flag to indicate that the parent window has been invalidated. All other accesses should be from the owner thread and don't need to be guarded. I removed the atomic increment/decrement to make it possibly more obvious.