Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "chrome/browser/ui/app_list/app_list_service_mac.h" | 5 #import "chrome/browser/ui/app_list/app_list_service_mac.h" |
| 6 | 6 |
| 7 #include <ApplicationServices/ApplicationServices.h> | 7 #include <ApplicationServices/ApplicationServices.h> |
| 8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
| 9 | 9 |
| 10 #include "apps/app_shim/app_shim_mac.h" | 10 #include "apps/app_shim/app_shim_mac.h" |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 273 | 273 |
| 274 // static | 274 // static |
| 275 void AppListServiceMac::FindAnchorPoint(const gfx::Size& window_size, | 275 void AppListServiceMac::FindAnchorPoint(const gfx::Size& window_size, |
| 276 const gfx::Display& display, | 276 const gfx::Display& display, |
| 277 int primary_display_height, | 277 int primary_display_height, |
| 278 bool cursor_is_visible, | 278 bool cursor_is_visible, |
| 279 const gfx::Point& cursor, | 279 const gfx::Point& cursor, |
| 280 NSPoint* target_origin, | 280 NSPoint* target_origin, |
| 281 NSPoint* start_origin) { | 281 NSPoint* start_origin) { |
| 282 AppListPositioner positioner(display, window_size, 0); | 282 AppListPositioner positioner(display, window_size, 0); |
| 283 AppListPositioner::ScreenEdge dock_location = | 283 AppListPositioner::ScreenEdge dock_location = DockLocationInDisplay(display); |
| 284 AppListPositioner::SCREEN_EDGE_UNKNOWN; | 284 |
| 285 gfx::Point anchor; | 285 gfx::Point anchor; |
| 286 if (!cursor_is_visible) { | 286 // Snap to the dock edge. If the cursor is greater than the window |
| 287 // width/height away or not visible, anchor to the center of the dock. | |
| 288 // Otherwise, anchor to the cursor position. | |
| 289 if (dock_location == AppListPositioner::SCREEN_EDGE_UNKNOWN) { | |
| 287 anchor = positioner.GetAnchorPointForScreenCorner( | 290 anchor = positioner.GetAnchorPointForScreenCorner( |
| 288 AppListPositioner::SCREEN_CORNER_BOTTOM_LEFT); | 291 AppListPositioner::SCREEN_CORNER_BOTTOM_LEFT); |
| 289 } else { | 292 } else { |
| 290 dock_location = DockLocationInDisplay(display); | 293 int snap_distance = |
| 291 | 294 dock_location == AppListPositioner::SCREEN_EDGE_BOTTOM || |
| 292 // Snap to the dock edge, anchored to the cursor position. | 295 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
| |
| 293 if (dock_location == AppListPositioner::SCREEN_EDGE_UNKNOWN) { | 296 window_size.height() : |
| 294 anchor = positioner.GetAnchorPointForScreenCorner( | 297 window_size.width(); |
| 295 AppListPositioner::SCREEN_CORNER_BOTTOM_LEFT); | 298 // Subtract the dock area since the display's default work_area will not |
| 299 // subtract it if the dock is set to auto-hide, and the app list should | |
| 300 // never overlap the dock. | |
| 301 AdjustWorkAreaForDock(display, &positioner, dock_location); | |
| 302 if (!cursor_is_visible || positioner.GetCursorDistanceFromShelf( | |
| 303 dock_location, cursor) > snap_distance) { | |
| 304 anchor = positioner.GetAnchorPointForShelfCenter(dock_location); | |
| 296 } else { | 305 } else { |
| 297 // Subtract the dock area since the display's default work_area will not | |
| 298 // subtract it if the dock is set to auto-hide, and the app list should | |
| 299 // never overlap the dock. | |
| 300 AdjustWorkAreaForDock(display, &positioner, dock_location); | |
| 301 anchor = positioner.GetAnchorPointForShelfCursor(dock_location, cursor); | 306 anchor = positioner.GetAnchorPointForShelfCursor(dock_location, cursor); |
| 302 } | 307 } |
| 303 } | 308 } |
| 304 | 309 |
| 305 *target_origin = NSMakePoint( | 310 *target_origin = NSMakePoint( |
| 306 anchor.x() - window_size.width() / 2, | 311 anchor.x() - window_size.width() / 2, |
| 307 primary_display_height - anchor.y() - window_size.height() / 2); | 312 primary_display_height - anchor.y() - window_size.height() / 2); |
| 308 *start_origin = *target_origin; | 313 *start_origin = *target_origin; |
| 309 | 314 |
| 310 switch (dock_location) { | 315 switch (dock_location) { |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 543 | 548 |
| 544 - (void)animationDidEnd:(NSAnimation*)animation { | 549 - (void)animationDidEnd:(NSAnimation*)animation { |
| 545 [window_ close]; | 550 [window_ close]; |
| 546 window_.reset(); | 551 window_.reset(); |
| 547 animation_.reset(); | 552 animation_.reset(); |
| 548 | 553 |
| 549 apps::AppShimHandler::MaybeTerminate(); | 554 apps::AppShimHandler::MaybeTerminate(); |
| 550 } | 555 } |
| 551 | 556 |
| 552 @end | 557 @end |
| OLD | NEW |