Fixes #5492: Popup are now adjusted to their content or the window