mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:17:44 +00:00
WindowServer: If a menu can't fit on screen, at least put it at y=0
We're gonna need to handle overflow better than this, but at least this way we can see the top of the menu, even if we can't scroll down to see the rest of it. For #1043.
This commit is contained in:
parent
73788d7305
commit
4d77cdf9a8
1 changed files with 9 additions and 5 deletions
|
@ -409,11 +409,15 @@ void WSMenu::popup(const Point& position, bool is_submenu)
|
|||
|
||||
const int margin = 30;
|
||||
Point adjusted_pos = position;
|
||||
if (adjusted_pos.x() + window.width() >= WSScreen::the().width() - margin) {
|
||||
adjusted_pos = adjusted_pos.translated(-window.width(), 0);
|
||||
}
|
||||
if (adjusted_pos.y() + window.height() >= WSScreen::the().height() - margin) {
|
||||
adjusted_pos = adjusted_pos.translated(0, -window.height());
|
||||
if (window.height() >= WSScreen::the().height()) {
|
||||
adjusted_pos.set_y(0);
|
||||
} else {
|
||||
if (adjusted_pos.x() + window.width() >= WSScreen::the().width() - margin) {
|
||||
adjusted_pos = adjusted_pos.translated(-window.width(), 0);
|
||||
}
|
||||
if (adjusted_pos.y() + window.height() >= WSScreen::the().height() - margin) {
|
||||
adjusted_pos = adjusted_pos.translated(0, -window.height());
|
||||
}
|
||||
}
|
||||
|
||||
window.move_to(adjusted_pos);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue