diff options
author | sky <sky@chromium.org> | 2016-01-22 14:28:21 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-22 22:30:08 +0000 |
commit | a57d9927dcb3a8548eae83450c8fe1ee7e3b568b (patch) | |
tree | ed20b2dd59f8476606cd4393f9595791440d9ca4 /ash | |
parent | 8d82e2ce2bc8d95fbfe53f6e7f98c345bba2de01 (diff) | |
download | chromium_src-a57d9927dcb3a8548eae83450c8fe1ee7e3b568b.zip chromium_src-a57d9927dcb3a8548eae83450c8fe1ee7e3b568b.tar.gz chromium_src-a57d9927dcb3a8548eae83450c8fe1ee7e3b568b.tar.bz2 |
Start of display management for mus
This adds a DisplayManager interface that you get from mus. You can
then attach an observer to observe display related changes.
BUG=548429
TEST=none
R=ben@chromium.org
Committed: https://crrev.com/bc2281a7a7576f5b4da85986298322b3c9d2234e
Cr-Commit-Position: refs/heads/master@{#370880}
Review URL: https://codereview.chromium.org/1615023004
Cr-Commit-Position: refs/heads/master@{#371059}
Diffstat (limited to 'ash')
-rw-r--r-- | ash/display/screen_ash.cc | 47 |
1 files changed, 6 insertions, 41 deletions
diff --git a/ash/display/screen_ash.cc b/ash/display/screen_ash.cc index 6008922..477c710 100644 --- a/ash/display/screen_ash.cc +++ b/ash/display/screen_ash.cc @@ -17,6 +17,7 @@ #include "ui/aura/env.h" #include "ui/aura/window_event_dispatcher.h" #include "ui/gfx/display.h" +#include "ui/gfx/display_finder.h" #include "ui/gfx/screen.h" namespace ash { @@ -27,42 +28,6 @@ DisplayManager* GetDisplayManager() { return Shell::GetInstance()->display_manager(); } -gfx::Display FindDisplayNearestPoint(const std::vector<gfx::Display>& displays, - const gfx::Point& point) { - int min_distance = INT_MAX; - const gfx::Display* nearest_display = NULL; - for (std::vector<gfx::Display>::const_iterator iter = displays.begin(); - iter != displays.end(); ++iter) { - const gfx::Display& display = *iter; - int distance = display.bounds().ManhattanDistanceToPoint(point); - if (distance < min_distance) { - min_distance = distance; - nearest_display = &display; - } - } - // There should always be at least one display that is less than INT_MAX away. - DCHECK(nearest_display); - return *nearest_display; -} - -const gfx::Display* FindDisplayMatching( - const std::vector<gfx::Display>& displays, - const gfx::Rect& match_rect) { - int max_area = 0; - const gfx::Display* matching = NULL; - for (std::vector<gfx::Display>::const_iterator iter = displays.begin(); - iter != displays.end(); ++iter) { - const gfx::Display& display = *iter; - gfx::Rect intersect = gfx::IntersectRects(display.bounds(), match_rect); - int area = intersect.width() * intersect.height(); - if (area > max_area) { - max_area = area; - matching = &display; - } - } - return matching; -} - class ScreenForShutdown : public gfx::Screen { public: explicit ScreenForShutdown(ScreenAsh* screen_ash) @@ -84,11 +49,11 @@ class ScreenForShutdown : public gfx::Screen { return primary_display_; } gfx::Display GetDisplayNearestPoint(const gfx::Point& point) const override { - return FindDisplayNearestPoint(display_list_, point); + return *gfx::FindDisplayNearestPoint(display_list_, point); } gfx::Display GetDisplayMatching(const gfx::Rect& match_rect) const override { const gfx::Display* matching = - FindDisplayMatching(display_list_, match_rect); + gfx::FindDisplayWithBiggestIntersection(display_list_, match_rect); // Fallback to the primary display if there is no matching display. return matching ? *matching : GetPrimaryDisplay(); } @@ -187,14 +152,14 @@ gfx::Display ScreenAsh::GetDisplayNearestPoint(const gfx::Point& point) const { // Fallback to the display that has the shortest Manhattan distance from // the |point|. This is correct in the only areas that matter, namely in the // corners between the physical screens. - return FindDisplayNearestPoint(GetDisplayManager()->active_display_list(), - point); + return *gfx::FindDisplayNearestPoint( + GetDisplayManager()->active_display_list(), point); } gfx::Display ScreenAsh::GetDisplayMatching(const gfx::Rect& match_rect) const { if (match_rect.IsEmpty()) return GetDisplayNearestPoint(match_rect.origin()); - const gfx::Display* matching = FindDisplayMatching( + const gfx::Display* matching = gfx::FindDisplayWithBiggestIntersection( GetDisplayManager()->active_display_list(), match_rect); // Fallback to the primary display if there is no matching display. return matching ? *matching : GetPrimaryDisplay(); |