OpenXR: Refactor wait frame function to avoid setting state before we should.