Add smart positioning for the popup, to avoid getting in the way or showing outside the screen.