WindowServer: Constrain popup menu Y position within screen rect

This fixes an issue where large popup menus would open upwards despite
there not being enough space for that.
This commit is contained in:
Andreas Kling 2021-05-09 12:27:41 +02:00
parent 4c6e3d0c59
commit c53e937014

View file

@ -590,7 +590,7 @@ void Menu::do_popup(const Gfx::IntPoint& position, bool make_input, bool as_subm
adjusted_pos = adjusted_pos.translated(-window.width(), 0);
}
if (adjusted_pos.y() + window.height() >= Screen::the().height() - margin) {
adjusted_pos = adjusted_pos.translated(0, -window.height());
adjusted_pos = adjusted_pos.translated(0, -min(window.height(), adjusted_pos.y()));
if (as_submenu)
adjusted_pos = adjusted_pos.translated(0, item_height());
}