Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: chrome/browser/ui/app_list/app_list_service_mac.mm

Issue 93863002: Mac App Launcher is positioned on center of dock in certain cases. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Goddamn Reitveld. Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 targetOrigin:(NSPoint)targetOrigin 68 targetOrigin:(NSPoint)targetOrigin
69 closing:(BOOL)closing; 69 closing:(BOOL)closing;
70 70
71 @end 71 @end
72 72
73 namespace { 73 namespace {
74 74
75 // Version of the app list shortcut version installed. 75 // Version of the app list shortcut version installed.
76 const int kShortcutVersion = 1; 76 const int kShortcutVersion = 1;
77 77
78 // If the mouse cursor is less than this distance, in pixels, away from the
79 // dock, it is considered to be in the dock for the purpose of anchoring.
80 const int kSnapDistance = 50;
tapted 2013/11/29 02:12:51 I think this should be at least window width for a
tapted 2013/11/29 06:05:59 Did you see this?
Matt Giuca 2013/12/02 05:02:03 Yes, I made a note to get to it on Monday. Yes, I
81
78 // Duration of show and hide animations. 82 // Duration of show and hide animations.
79 const NSTimeInterval kAnimationDuration = 0.2; 83 const NSTimeInterval kAnimationDuration = 0.2;
80 84
81 // Distance towards the screen edge that the app list moves from when showing. 85 // Distance towards the screen edge that the app list moves from when showing.
82 const CGFloat kDistanceMovedOnShow = 20; 86 const CGFloat kDistanceMovedOnShow = 20;
83 87
84 ShellIntegration::ShortcutInfo GetAppListShortcutInfo( 88 ShellIntegration::ShortcutInfo GetAppListShortcutInfo(
85 const base::FilePath& profile_path) { 89 const base::FilePath& profile_path) {
86 ShellIntegration::ShortcutInfo shortcut_info; 90 ShellIntegration::ShortcutInfo shortcut_info;
87 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); 91 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel();
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 277
274 // static 278 // static
275 void AppListServiceMac::FindAnchorPoint(const gfx::Size& window_size, 279 void AppListServiceMac::FindAnchorPoint(const gfx::Size& window_size,
276 const gfx::Display& display, 280 const gfx::Display& display,
277 int primary_display_height, 281 int primary_display_height,
278 bool cursor_is_visible, 282 bool cursor_is_visible,
279 const gfx::Point& cursor, 283 const gfx::Point& cursor,
280 NSPoint* target_origin, 284 NSPoint* target_origin,
281 NSPoint* start_origin) { 285 NSPoint* start_origin) {
282 AppListPositioner positioner(display, window_size, 0); 286 AppListPositioner positioner(display, window_size, 0);
283 AppListPositioner::ScreenEdge dock_location = 287 AppListPositioner::ScreenEdge dock_location = DockLocationInDisplay(display);
284 AppListPositioner::SCREEN_EDGE_UNKNOWN; 288
285 gfx::Point anchor; 289 gfx::Point anchor;
286 if (!cursor_is_visible) { 290 // Snap to the dock edge. If the cursor is greater than kSnapDistance away or
291 // not visible, anchor to the center of the dock. Otherwise, anchor to the
292 // cursor position.
293 if (dock_location == AppListPositioner::SCREEN_EDGE_UNKNOWN) {
287 anchor = positioner.GetAnchorPointForScreenCorner( 294 anchor = positioner.GetAnchorPointForScreenCorner(
288 AppListPositioner::SCREEN_CORNER_BOTTOM_LEFT); 295 AppListPositioner::SCREEN_CORNER_BOTTOM_LEFT);
289 } else { 296 } else {
290 dock_location = DockLocationInDisplay(display); 297 // Subtract the dock area since the display's default work_area will not
291 298 // subtract it if the dock is set to auto-hide, and the app list should
292 // Snap to the dock edge, anchored to the cursor position. 299 // never overlap the dock.
293 if (dock_location == AppListPositioner::SCREEN_EDGE_UNKNOWN) { 300 AdjustWorkAreaForDock(display, &positioner, dock_location);
294 anchor = positioner.GetAnchorPointForScreenCorner( 301 if (!cursor_is_visible || positioner.GetCursorDistanceFromShelf(
295 AppListPositioner::SCREEN_CORNER_BOTTOM_LEFT); 302 dock_location, cursor) > kSnapDistance) {
303 anchor = positioner.GetAnchorPointForShelfCenter(dock_location);
296 } else { 304 } 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); 305 anchor = positioner.GetAnchorPointForShelfCursor(dock_location, cursor);
302 } 306 }
303 } 307 }
304 308
305 *target_origin = NSMakePoint( 309 *target_origin = NSMakePoint(
306 anchor.x() - window_size.width() / 2, 310 anchor.x() - window_size.width() / 2,
307 primary_display_height - anchor.y() - window_size.height() / 2); 311 primary_display_height - anchor.y() - window_size.height() / 2);
308 *start_origin = *target_origin; 312 *start_origin = *target_origin;
309 313
310 switch (dock_location) { 314 switch (dock_location) {
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 547
544 - (void)animationDidEnd:(NSAnimation*)animation { 548 - (void)animationDidEnd:(NSAnimation*)animation {
545 [window_ close]; 549 [window_ close];
546 window_.reset(); 550 window_.reset();
547 animation_.reset(); 551 animation_.reset();
548 552
549 apps::AppShimHandler::MaybeTerminate(); 553 apps::AppShimHandler::MaybeTerminate();
550 } 554 }
551 555
552 @end 556 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698