BWindow: Prevent CenterIn from moving the decorator bar offscreen.

The MoveTo() call is not restricted in any way; it can easily move the
window's titlebar offscreen, which is very confusing for users as if
they don't remember the window manipulation keyboard shortcuts,
dealing with such windows is often very tricky (or impossible
if the window is actually larger than the screen.)

Now we also call MoveOnScreen with DO_NOT_RESIZE and
MOVE_IF_PARTIALLY_OFFSCREEN set, which will simply get the size of
the decorator bar and then ensure it is entirely on-screen.

Fixes #11763.
This commit is contained in:
Augustin Cavalier 2018-12-21 12:37:10 -05:00
parent 5e54f6d4f9
commit 1ac98e3ab4

View File

@ -2619,6 +2619,7 @@ BWindow::CenterIn(const BRect& rect)
MoveTo(BLayoutUtils::AlignInFrame(rect, Size(),
BAlignment(B_ALIGN_HORIZONTAL_CENTER,
B_ALIGN_VERTICAL_CENTER)).LeftTop());
MoveOnScreen(B_DO_NOT_RESIZE_TO_FIT | B_MOVE_IF_PARTIALLY_OFFSCREEN);
}