Allow the popover host to be something other than a window.

Also fix an analyzer warning.