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

Unified Diff: ash/display/screen_ash.cc

Issue 1615023004: Start of display management for mus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix crash and add back getting constants Created 4 years, 11 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/threading/thread_restrictions.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/display/screen_ash.cc
diff --git a/ash/display/screen_ash.cc b/ash/display/screen_ash.cc
index 60089223bac1059192798b8089e8cffb8559919c..477c7106baa716823984f078f5b2fe2255f25058 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();
« no previous file with comments | « no previous file | base/threading/thread_restrictions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698