Chromium Code Reviews| Index: chrome/browser/ui/views/app_list/app_list_controller_win.cc |
| diff --git a/chrome/browser/ui/views/app_list/app_list_controller_win.cc b/chrome/browser/ui/views/app_list/app_list_controller_win.cc |
| index c9d334dc1268905c01990cebccd1549c037e2df9..498cac3f5516670c4b7663ac54e0e86cb7434651 100644 |
| --- a/chrome/browser/ui/views/app_list/app_list_controller_win.cc |
| +++ b/chrome/browser/ui/views/app_list/app_list_controller_win.cc |
| @@ -545,6 +545,8 @@ bool GetTaskbarRect(gfx::Rect* rect) { |
| // |anchor| thus, using the location of the point in |point|, the distance |
| // to move the view from |point| in |offset|, and the direction to move |
| // represented in |direction|. |
| +// The function will also ensure the view is within |offset| of the screen |
| +// edges. |
| // To position relative to a screen corner, the absolute values of |direction|.x |
| // and |direction.y| should both be 1. To position relative to some point on the |
| // taskbar, one of the absolute values of |direction.x| and |direction.y| should |
| @@ -552,9 +554,22 @@ bool GetTaskbarRect(gfx::Rect* rect) { |
| void FloatFromPoint(const gfx::Point& point, |
| const gfx::Size& offset, |
| const gfx::Point& direction, |
| + const gfx::Rect& screen_rect, |
|
tapted
2013/02/27 08:41:59
bounds_rect, Then,
|
| gfx::Point* anchor) { |
| anchor->set_x(point.x() + direction.x() * offset.width()); |
| anchor->set_y(point.y() + direction.y() * offset.height()); |
| + |
| + if (anchor->x() - offset.width() < screen_rect.x()) |
|
tapted
2013/02/27 08:41:59
I think these 11 lines can be just
anchor.ClampTo
|
| + anchor->set_x(screen_rect.x() + offset.width()); |
| + |
| + if (anchor->x() + offset.width() > screen_rect.right()) |
| + anchor->set_x(screen_rect.right() - offset.width()); |
| + |
| + if (anchor->y() - offset.height() < screen_rect.y()) |
| + anchor->set_y(screen_rect.y() + offset.height()); |
| + |
| + if (anchor->y() + offset.height() > screen_rect.bottom()) |
| + anchor->set_y(screen_rect.bottom() - offset.height()); |
| } |
| void AppListController::SnapArrowLocationToTaskbarEdge( |
| @@ -569,6 +584,8 @@ void AppListController::SnapArrowLocationToTaskbarEdge( |
| float_offset.set_height(float_offset.height() / 2); |
| float_offset.Enlarge(kSnapOffset, kSnapOffset); |
|
tapted
2013/02/27 08:42:30
[ I think with this Enlarge, it also gets a margin
|
| + const gfx::Rect& screen_rect = display.bounds(); |
|
tapted
2013/02/27 08:41:59
With
gfx::Rect& bounds_rect = display.bounds();
b
tapted
2013/02/27 08:41:59
Does it need to take into account the taskbar, to
|
| + |
| // If we can't find the taskbar, snap to the bottom left. |
| // If the display size is the same as the work area, and does not contain the |
| // taskbar, either the taskbar is hidden or on another monitor, so just snap |
| @@ -579,12 +596,11 @@ void AppListController::SnapArrowLocationToTaskbarEdge( |
| FloatFromPoint(display.work_area().bottom_left(), |
| float_offset, |
| gfx::Point(1, -1), |
| + screen_rect, |
| anchor); |
| return; |
| } |
| - const gfx::Rect& screen_rect = display.bounds(); |
| - |
| // Snap to the taskbar edge. If the cursor is greater than kSnapDistance away, |
| // also move to the left (for horizontal taskbars) or top (for vertical). |
| @@ -595,6 +611,7 @@ void AppListController::SnapArrowLocationToTaskbarEdge( |
| FloatFromPoint(gfx::Point(screen_rect.x(), taskbar_rect.y()), |
| float_offset, |
| gfx::Point(1, -1), |
| + screen_rect, |
| anchor); |
| return; |
| } |
| @@ -602,6 +619,7 @@ void AppListController::SnapArrowLocationToTaskbarEdge( |
| FloatFromPoint(gfx::Point(anchor->x(), taskbar_rect.y()), |
| float_offset, |
| gfx::Point(0, -1), |
| + screen_rect, |
| anchor); |
| return; |
| } |
| @@ -611,6 +629,7 @@ void AppListController::SnapArrowLocationToTaskbarEdge( |
| FloatFromPoint(gfx::Point(screen_rect.x(), taskbar_rect.bottom()), |
| float_offset, |
| gfx::Point(1, 1), |
| + screen_rect, |
| anchor); |
| return; |
| } |
| @@ -618,6 +637,7 @@ void AppListController::SnapArrowLocationToTaskbarEdge( |
| FloatFromPoint(gfx::Point(anchor->x(), taskbar_rect.bottom()), |
| float_offset, |
| gfx::Point(0, 1), |
| + screen_rect, |
| anchor); |
| return; |
| } |
| @@ -628,6 +648,7 @@ void AppListController::SnapArrowLocationToTaskbarEdge( |
| FloatFromPoint(gfx::Point(taskbar_rect.right(), screen_rect.y()), |
| float_offset, |
| gfx::Point(1, 1), |
| + screen_rect, |
| anchor); |
| return; |
| } |
| @@ -635,6 +656,7 @@ void AppListController::SnapArrowLocationToTaskbarEdge( |
| FloatFromPoint(gfx::Point(taskbar_rect.right(), anchor->y()), |
| float_offset, |
| gfx::Point(1, 0), |
| + screen_rect, |
| anchor); |
| return; |
| } |
| @@ -644,6 +666,7 @@ void AppListController::SnapArrowLocationToTaskbarEdge( |
| FloatFromPoint(gfx::Point(taskbar_rect.x(), screen_rect.y()), |
| float_offset, |
| gfx::Point(-1, 1), |
| + screen_rect, |
| anchor); |
| return; |
| } |
| @@ -651,6 +674,7 @@ void AppListController::SnapArrowLocationToTaskbarEdge( |
| FloatFromPoint(gfx::Point(taskbar_rect.x(), anchor->y()), |
| float_offset, |
| gfx::Point(-1, 0), |
| + screen_rect, |
| anchor); |
| } |