- if ( !rectDisplay.Contains(rect.GetBottomRight()) )
- {
- // check if we can move the window so that the bottom right corner
- // is visible without hiding the top left one
- int dx = rectDisplay.GetRight() - rect.GetRight();
- int dy = rectDisplay.GetBottom() - rect.GetBottom();
- rect.Offset(dx, dy);
- }
- //else: the window top left and bottom right corner are both visible,
- // although the window might still be not entirely on screen (with
- // 2 staggered displays for example) we wouldn't be able to
- // improve the layout much in such case, so just leave it as is
+ // move the window just enough to make the corner visible
+ int dx = rectDisplay.GetLeft() - rect.GetLeft();
+ int dy = rectDisplay.GetTop() - rect.GetTop();
+ rect.Offset(dx > 0 ? dx : 0, dy > 0 ? dy : 0);