Index: chrome/browser/ui/app_list/app_list_service_mac.mm |
diff --git a/chrome/browser/ui/app_list/app_list_service_mac.mm b/chrome/browser/ui/app_list/app_list_service_mac.mm |
index 01130b30b4209c53af62cf2c8cd103a2a1156021..8fdcd88ef0897151eb5af7d537eee41884b0f0a4 100644 |
--- a/chrome/browser/ui/app_list/app_list_service_mac.mm |
+++ b/chrome/browser/ui/app_list/app_list_service_mac.mm |
@@ -280,24 +280,29 @@ void AppListServiceMac::FindAnchorPoint(const gfx::Size& window_size, |
NSPoint* target_origin, |
NSPoint* start_origin) { |
AppListPositioner positioner(display, window_size, 0); |
- AppListPositioner::ScreenEdge dock_location = |
- AppListPositioner::SCREEN_EDGE_UNKNOWN; |
+ AppListPositioner::ScreenEdge dock_location = DockLocationInDisplay(display); |
+ |
gfx::Point anchor; |
- if (!cursor_is_visible) { |
+ // Snap to the dock edge. If the cursor is greater than the window |
+ // width/height away or not visible, anchor to the center of the dock. |
+ // Otherwise, anchor to the cursor position. |
+ if (dock_location == AppListPositioner::SCREEN_EDGE_UNKNOWN) { |
anchor = positioner.GetAnchorPointForScreenCorner( |
AppListPositioner::SCREEN_CORNER_BOTTOM_LEFT); |
} else { |
- dock_location = DockLocationInDisplay(display); |
- |
- // Snap to the dock edge, anchored to the cursor position. |
- if (dock_location == AppListPositioner::SCREEN_EDGE_UNKNOWN) { |
- anchor = positioner.GetAnchorPointForScreenCorner( |
- AppListPositioner::SCREEN_CORNER_BOTTOM_LEFT); |
+ int snap_distance = |
+ dock_location == AppListPositioner::SCREEN_EDGE_BOTTOM || |
+ dock_location == AppListPositioner::SCREEN_EDGE_TOP ? |
tapted
2013/12/02 06:28:38
nit: maybe don't worry about _TOP here? since ther
Matt Giuca
2013/12/03 02:21:53
I would prefer for this code to not implicitly map
|
+ window_size.height() : |
+ window_size.width(); |
+ // Subtract the dock area since the display's default work_area will not |
+ // subtract it if the dock is set to auto-hide, and the app list should |
+ // never overlap the dock. |
+ AdjustWorkAreaForDock(display, &positioner, dock_location); |
+ if (!cursor_is_visible || positioner.GetCursorDistanceFromShelf( |
+ dock_location, cursor) > snap_distance) { |
+ anchor = positioner.GetAnchorPointForShelfCenter(dock_location); |
} else { |
- // Subtract the dock area since the display's default work_area will not |
- // subtract it if the dock is set to auto-hide, and the app list should |
- // never overlap the dock. |
- AdjustWorkAreaForDock(display, &positioner, dock_location); |
anchor = positioner.GetAnchorPointForShelfCursor(dock_location, cursor); |
} |
} |