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

Side by Side Diff: ash/display/multi_display_manager.cc

Issue 11269022: Add Vector2d classes that represent offsets, instead of using Point. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: inlines Created 8 years, 1 month 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "ash/display/multi_display_manager.h" 5 #include "ash/display/multi_display_manager.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/display/display_controller.h" 10 #include "ash/display/display_controller.h"
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 516
517 for (DisplayList::const_iterator iter = displays_.begin(); 517 for (DisplayList::const_iterator iter = displays_.begin();
518 iter != displays_.end(); ++iter) { 518 iter != displays_.end(); ++iter) {
519 const gfx::Rect& display_bounds = iter->bounds(); 519 const gfx::Rect& display_bounds = iter->bounds();
520 520
521 if (display_bounds.Contains(location_in_screen)) { 521 if (display_bounds.Contains(location_in_screen)) {
522 target_location = location_in_screen; 522 target_location = location_in_screen;
523 break; 523 break;
524 } 524 }
525 gfx::Point center = display_bounds.CenterPoint(); 525 gfx::Point center = display_bounds.CenterPoint();
526 gfx::Point diff = center.Subtract(location_in_screen);
527 // Use the distance from the center of the dislay. This is not 526 // Use the distance from the center of the dislay. This is not
528 // exactly "closest" display, but good enough to pick one 527 // exactly "closest" display, but good enough to pick one
529 // appropriate (and there are at most two displays). 528 // appropriate (and there are at most two displays).
530 int64 distance = diff.x() * diff.x() + diff.y() * diff.y(); 529 int64 distance = (center - location_in_screen).LengthSquared();
Peter Kasting 2012/10/29 23:06:33 Nit: Rename |distance_squared| (and maybe also |cl
danakj 2012/10/29 23:21:41 Done.
531 if (closest_distance < 0 || closest_distance > distance) { 530 if (closest_distance < 0 || closest_distance > distance) {
532 target_location = center; 531 target_location = center;
533 closest_distance = distance; 532 closest_distance = distance;
534 } 533 }
535 } 534 }
536 535
537 aura::RootWindow* root_window = Shell::GetPrimaryRootWindow(); 536 aura::RootWindow* root_window = Shell::GetPrimaryRootWindow();
538 aura::client::ScreenPositionClient* client = 537 aura::client::ScreenPositionClient* client =
539 aura::client::GetScreenPositionClient(root_window); 538 aura::client::GetScreenPositionClient(root_window);
540 client->ConvertPointFromScreen(root_window, &target_location); 539 client->ConvertPointFromScreen(root_window, &target_location);
541 540
542 root_window->MoveCursorTo(target_location); 541 root_window->MoveCursorTo(target_location);
543 } 542 }
544 543
545 void MultiDisplayManager::SetDisplayIdsForTest(DisplayList* to_update) const { 544 void MultiDisplayManager::SetDisplayIdsForTest(DisplayList* to_update) const {
546 DisplayList::iterator iter_to_update = to_update->begin(); 545 DisplayList::iterator iter_to_update = to_update->begin();
547 DisplayList::const_iterator iter = displays_.begin(); 546 DisplayList::const_iterator iter = displays_.begin();
548 for (; iter != displays_.end() && iter_to_update != to_update->end(); 547 for (; iter != displays_.end() && iter_to_update != to_update->end();
549 ++iter, ++iter_to_update) { 548 ++iter, ++iter_to_update) {
550 (*iter_to_update).set_id((*iter).id()); 549 (*iter_to_update).set_id((*iter).id());
551 } 550 }
552 } 551 }
553 552
554 } // namespace internal 553 } // namespace internal
555 } // namespace ash 554 } // namespace ash
OLDNEW
« no previous file with comments | « WATCHLISTS ('k') | ash/drag_drop/drag_drop_controller.h » ('j') | cc/gl_renderer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698