Skip to content

Commit

Permalink
Rename gfx::Screen::GetMonitorXXXX to gfx::Screen::GetDisplayXXX.
Browse files Browse the repository at this point in the history
BUG=130828
R=oshima@chromium.org
TBR=sky@chromium.org

Review URL: https://chromiumcodereview.appspot.com/10540123

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142631 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
tfarina@chromium.org committed Jun 17, 2012
1 parent 0e62ba1 commit 42c0a0c
Show file tree
Hide file tree
Showing 89 changed files with 280 additions and 279 deletions.
4 changes: 2 additions & 2 deletions ash/dip_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ TEST_F(DIPTest, MAYBE_WorkArea) {
ChangeMonitorConfig(1.0f, gfx::Rect(0, 0, 1000, 900));

aura::RootWindow* root = Shell::GetPrimaryRootWindow();
const gfx::Display display = gfx::Screen::GetMonitorNearestWindow(root);
const gfx::Display display = gfx::Screen::GetDisplayNearestWindow(root);

EXPECT_EQ("0,0 1000x900", display.bounds().ToString());
gfx::Rect work_area = display.work_area();
Expand All @@ -48,7 +48,7 @@ TEST_F(DIPTest, MAYBE_WorkArea) {

ChangeMonitorConfig(2.0f, gfx::Rect(0, 0, 2000, 1800));

const gfx::Display display_2x = gfx::Screen::GetMonitorNearestWindow(root);
const gfx::Display display_2x = gfx::Screen::GetDisplayNearestWindow(root);

// The |bounds_in_pixel()| should report bounds in pixel coordinate.
EXPECT_EQ("0,0 2000x1800", display_2x.bounds_in_pixel().ToString());
Expand Down
6 changes: 3 additions & 3 deletions ash/monitor/monitor_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ MonitorController::~MonitorController() {
void MonitorController::InitPrimaryDisplay() {
aura::MonitorManager* monitor_manager =
aura::Env::GetInstance()->monitor_manager();
const gfx::Display& display = monitor_manager->GetMonitorAt(0);
const gfx::Display& display = monitor_manager->GetDisplayAt(0);
DCHECK_EQ(0, display.id());
aura::RootWindow* root =
monitor_manager->CreateRootWindowForMonitor(display);
Expand All @@ -61,8 +61,8 @@ void MonitorController::InitPrimaryDisplay() {
void MonitorController::InitSecondaryDisplays() {
aura::MonitorManager* monitor_manager =
aura::Env::GetInstance()->monitor_manager();
for (size_t i = 1; i < monitor_manager->GetNumMonitors(); ++i) {
const gfx::Display& display = monitor_manager->GetMonitorAt(i);
for (size_t i = 1; i < monitor_manager->GetNumDisplays(); ++i) {
const gfx::Display& display = monitor_manager->GetDisplayAt(i);
aura::RootWindow* root =
monitor_manager->CreateRootWindowForMonitor(display);
root_windows_[display.id()] = root;
Expand Down
12 changes: 6 additions & 6 deletions ash/monitor/multi_monitor_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,19 +124,19 @@ RootWindow* MultiMonitorManager::CreateRootWindowForMonitor(
return root_window;
}

const gfx::Display& MultiMonitorManager::GetMonitorAt(size_t index) {
const gfx::Display& MultiMonitorManager::GetDisplayAt(size_t index) {
return index < displays_.size() ? displays_[index] : GetInvalidDisplay();
}

size_t MultiMonitorManager::GetNumMonitors() const {
size_t MultiMonitorManager::GetNumDisplays() const {
return displays_.size();
}

const gfx::Display& MultiMonitorManager::GetMonitorNearestWindow(
const gfx::Display& MultiMonitorManager::GetDisplayNearestWindow(
const Window* window) const {
if (!window) {
MultiMonitorManager* manager = const_cast<MultiMonitorManager*>(this);
return manager->GetMonitorAt(0);
return manager->GetDisplayAt(0);
}
const RootWindow* root = window->GetRootWindow();
MultiMonitorManager* that = const_cast<MultiMonitorManager*>(this);
Expand All @@ -145,12 +145,12 @@ const gfx::Display& MultiMonitorManager::GetMonitorNearestWindow(
GetInvalidDisplay();
}

const gfx::Display& MultiMonitorManager::GetMonitorNearestPoint(
const gfx::Display& MultiMonitorManager::GetDisplayNearestPoint(
const gfx::Point& point) const {
// TODO(oshima): For m19, mouse is constrained within
// the primary window.
MultiMonitorManager* manager = const_cast<MultiMonitorManager*>(this);
return manager->GetMonitorAt(0);
return manager->GetDisplayAt(0);
}

void MultiMonitorManager::OnRootWindowResized(const aura::RootWindow* root,
Expand Down
8 changes: 4 additions & 4 deletions ash/monitor/multi_monitor_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ class ASH_EXPORT MultiMonitorManager : public aura::MonitorManager,
const std::vector<gfx::Display>& displays) OVERRIDE;
virtual aura::RootWindow* CreateRootWindowForMonitor(
const gfx::Display& display) OVERRIDE;
virtual const gfx::Display& GetMonitorAt(size_t index) OVERRIDE;
virtual const gfx::Display& GetDisplayAt(size_t index) OVERRIDE;

virtual size_t GetNumMonitors() const OVERRIDE;
virtual const gfx::Display& GetMonitorNearestPoint(
virtual size_t GetNumDisplays() const OVERRIDE;
virtual const gfx::Display& GetDisplayNearestPoint(
const gfx::Point& point) const OVERRIDE;
virtual const gfx::Display& GetMonitorNearestWindow(
virtual const gfx::Display& GetDisplayNearestWindow(
const aura::Window* window) const OVERRIDE;

// RootWindowObserver overrides:
Expand Down
44 changes: 22 additions & 22 deletions ash/monitor/multi_monitor_manager_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ class MultiMonitorManagerTest : public test::AshTestBase,
TEST_F(MultiMonitorManagerTest, NativeMonitorTest) {
aura::MonitorManager::set_use_fullscreen_host_window(true);

EXPECT_EQ(1U, monitor_manager()->GetNumMonitors());
EXPECT_EQ(1U, monitor_manager()->GetNumDisplays());

// Update primary and add seconary.
UpdateMonitor("0+0-500x500,0+501-400x400");
EXPECT_EQ(2U, monitor_manager()->GetNumMonitors());
EXPECT_EQ(2U, monitor_manager()->GetNumDisplays());
EXPECT_EQ("1 1 0", GetCountSummary());
EXPECT_EQ(monitor_manager()->GetMonitorAt(0).id(), changed()[0].id());
EXPECT_EQ(monitor_manager()->GetMonitorAt(1).id(), added()[0].id());
EXPECT_EQ(monitor_manager()->GetDisplayAt(0).id(), changed()[0].id());
EXPECT_EQ(monitor_manager()->GetDisplayAt(1).id(), added()[0].id());
EXPECT_EQ("0,0 500x500", changed()[0].bounds().ToString());
EXPECT_EQ("0,0 400x400", added()[0].bounds().ToString());
EXPECT_EQ("0,501 400x400", added()[0].bounds_in_pixel().ToString());
Expand All @@ -113,41 +113,41 @@ TEST_F(MultiMonitorManagerTest, NativeMonitorTest) {
// Change primary.
UpdateMonitor("0+0-1000x600");
EXPECT_EQ("1 0 0", GetCountSummary());
EXPECT_EQ(monitor_manager()->GetMonitorAt(0).id(), changed()[0].id());
EXPECT_EQ(monitor_manager()->GetDisplayAt(0).id(), changed()[0].id());
EXPECT_EQ("0,0 1000x600", changed()[0].bounds().ToString());
reset();

// Add secondary.
UpdateMonitor("0+0-1000x600,1001+0-600x400");
EXPECT_EQ(2U, monitor_manager()->GetNumMonitors());
EXPECT_EQ(2U, monitor_manager()->GetNumDisplays());
EXPECT_EQ("0 1 0", GetCountSummary());
EXPECT_EQ(monitor_manager()->GetMonitorAt(1).id(), added()[0].id());
EXPECT_EQ(monitor_manager()->GetDisplayAt(1).id(), added()[0].id());
EXPECT_EQ("0,0 600x400", added()[0].bounds().ToString());
EXPECT_EQ("1001,0 600x400", added()[0].bounds_in_pixel().ToString());
reset();

// Secondary removed, primary changed.
UpdateMonitor("0+0-800x300");
EXPECT_EQ(1U, monitor_manager()->GetNumMonitors());
EXPECT_EQ(1U, monitor_manager()->GetNumDisplays());
EXPECT_EQ("1 0 1", GetCountSummary());
EXPECT_EQ(monitor_manager()->GetMonitorAt(0).id(), changed()[0].id());
EXPECT_EQ(monitor_manager()->GetDisplayAt(0).id(), changed()[0].id());
EXPECT_EQ("0,0 800x300", changed()[0].bounds().ToString());
reset();

// # of display can go to zero when screen is off.
const vector<gfx::Display> empty;
monitor_manager()->OnNativeMonitorsChanged(empty);
EXPECT_EQ(1U, monitor_manager()->GetNumMonitors());
EXPECT_EQ(1U, monitor_manager()->GetNumDisplays());
EXPECT_EQ("0 0 0", GetCountSummary());
EXPECT_FALSE(root_window_destroyed());
// Monitor configuration stays the same
EXPECT_EQ("0,0 800x300",
monitor_manager()->GetMonitorAt(0).bounds().ToString());
monitor_manager()->GetDisplayAt(0).bounds().ToString());
reset();

// Connect to monitor again
UpdateMonitor("100+100-500x400");
EXPECT_EQ(1U, monitor_manager()->GetNumMonitors());
EXPECT_EQ(1U, monitor_manager()->GetNumDisplays());
EXPECT_EQ("1 0 0", GetCountSummary());
EXPECT_FALSE(root_window_destroyed());
EXPECT_EQ("0,0 500x400", changed()[0].bounds().ToString());
Expand All @@ -156,31 +156,31 @@ TEST_F(MultiMonitorManagerTest, NativeMonitorTest) {

// Go back to zero and wake up with multiple monitors.
monitor_manager()->OnNativeMonitorsChanged(empty);
EXPECT_EQ(1U, monitor_manager()->GetNumMonitors());
EXPECT_EQ(1U, monitor_manager()->GetNumDisplays());
EXPECT_FALSE(root_window_destroyed());
reset();

// Add secondary.
UpdateMonitor("0+0-1000x600,1000+0-600x400");
EXPECT_EQ(2U, monitor_manager()->GetNumMonitors());
EXPECT_EQ(2U, monitor_manager()->GetNumDisplays());
EXPECT_EQ("0,0 1000x600",
monitor_manager()->GetMonitorAt(0).bounds().ToString());
monitor_manager()->GetDisplayAt(0).bounds().ToString());
EXPECT_EQ("0,0 600x400",
monitor_manager()->GetMonitorAt(1).bounds().ToString());
monitor_manager()->GetDisplayAt(1).bounds().ToString());
EXPECT_EQ("1000,0 600x400",
monitor_manager()->GetMonitorAt(1).bounds_in_pixel().ToString());
monitor_manager()->GetDisplayAt(1).bounds_in_pixel().ToString());
reset();

aura::MonitorManager::set_use_fullscreen_host_window(false);
}

// Test in emulation mode (use_fullscreen_host_window=false)
TEST_F(MultiMonitorManagerTest, EmulatorTest) {
EXPECT_EQ(1U, monitor_manager()->GetNumMonitors());
EXPECT_EQ(1U, monitor_manager()->GetNumDisplays());

internal::MultiMonitorManager::AddRemoveMonitor();
// Update primary and add seconary.
EXPECT_EQ(2U, monitor_manager()->GetNumMonitors());
EXPECT_EQ(2U, monitor_manager()->GetNumDisplays());
#if defined(OS_WIN)
// TODO(oshima): Windows receives resize event for some reason.
EXPECT_EQ("1 1 0", GetCountSummary());
Expand All @@ -190,7 +190,7 @@ TEST_F(MultiMonitorManagerTest, EmulatorTest) {
reset();

internal::MultiMonitorManager::CycleMonitor();
EXPECT_EQ(2U, monitor_manager()->GetNumMonitors());
EXPECT_EQ(2U, monitor_manager()->GetNumDisplays());
// Observer gets called twice in this mode because
// it gets notified both from |OnNativeMonitorChagned|
// and from |RootWindowObserver|, which is the consequence of
Expand All @@ -199,12 +199,12 @@ TEST_F(MultiMonitorManagerTest, EmulatorTest) {
reset();

internal::MultiMonitorManager::AddRemoveMonitor();
EXPECT_EQ(1U, monitor_manager()->GetNumMonitors());
EXPECT_EQ(1U, monitor_manager()->GetNumDisplays());
EXPECT_EQ("0 0 1", GetCountSummary());
reset();

internal::MultiMonitorManager::CycleMonitor();
EXPECT_EQ(1U, monitor_manager()->GetNumMonitors());
EXPECT_EQ(1U, monitor_manager()->GetNumDisplays());
EXPECT_EQ("0 0 0", GetCountSummary());
reset();
}
Expand Down
20 changes: 10 additions & 10 deletions ash/screen_ash.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ gfx::Rect ScreenAsh::GetMaximizedWindowBounds(aura::Window* window) {
if (window->GetRootWindow() == Shell::GetPrimaryRootWindow())
return Shell::GetInstance()->shelf()->GetMaximizedWindowBounds(window);
else
return gfx::Screen::GetMonitorNearestWindow(window).bounds();
return gfx::Screen::GetDisplayNearestWindow(window).bounds();
}

// static
gfx::Rect ScreenAsh::GetUnmaximizedWorkAreaBounds(aura::Window* window) {
if (window->GetRootWindow() == Shell::GetPrimaryRootWindow())
return Shell::GetInstance()->shelf()->GetUnmaximizedWorkAreaBounds(window);
else
return gfx::Screen::GetMonitorNearestWindow(window).work_area();
return gfx::Screen::GetDisplayNearestWindow(window).work_area();
}

gfx::Point ScreenAsh::GetCursorScreenPoint() {
Expand All @@ -54,20 +54,20 @@ gfx::NativeWindow ScreenAsh::GetWindowAtCursorScreenPoint() {
return Shell::GetRootWindowAt(point)->GetTopWindowContainingPoint(point);
}

int ScreenAsh::GetNumMonitors() {
return GetMonitorManager()->GetNumMonitors();
int ScreenAsh::GetNumDisplays() {
return GetMonitorManager()->GetNumDisplays();
}

gfx::Display ScreenAsh::GetMonitorNearestWindow(gfx::NativeView window) const {
return GetMonitorManager()->GetMonitorNearestWindow(window);
gfx::Display ScreenAsh::GetDisplayNearestWindow(gfx::NativeView window) const {
return GetMonitorManager()->GetDisplayNearestWindow(window);
}

gfx::Display ScreenAsh::GetMonitorNearestPoint(const gfx::Point& point) const {
return GetMonitorManager()->GetMonitorNearestPoint(point);
gfx::Display ScreenAsh::GetDisplayNearestPoint(const gfx::Point& point) const {
return GetMonitorManager()->GetDisplayNearestPoint(point);
}

gfx::Display ScreenAsh::GetPrimaryMonitor() const {
return GetMonitorManager()->GetMonitorAt(0);
gfx::Display ScreenAsh::GetPrimaryDisplay() const {
return GetMonitorManager()->GetDisplayAt(0);
}

} // namespace ash
8 changes: 4 additions & 4 deletions ash/screen_ash.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ class ASH_EXPORT ScreenAsh : public gfx::ScreenImpl {
virtual gfx::Point GetCursorScreenPoint() OVERRIDE;
virtual gfx::NativeWindow GetWindowAtCursorScreenPoint() OVERRIDE;

virtual int GetNumMonitors() OVERRIDE;
virtual gfx::Display GetMonitorNearestWindow(
virtual int GetNumDisplays() OVERRIDE;
virtual gfx::Display GetDisplayNearestWindow(
gfx::NativeView view) const OVERRIDE;
virtual gfx::Display GetMonitorNearestPoint(
virtual gfx::Display GetDisplayNearestPoint(
const gfx::Point& point) const OVERRIDE;
virtual gfx::Display GetPrimaryMonitor() const OVERRIDE;
virtual gfx::Display GetPrimaryDisplay() const OVERRIDE;

private:
DISALLOW_COPY_AND_ASSIGN(ScreenAsh);
Expand Down
6 changes: 3 additions & 3 deletions ash/screensaver/screensaver_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
#include "base/logging.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "ui/gfx/screen.h"
#include "ui/aura/root_window.h"
#include "ui/views/layout/fill_layout.h"
#include "ui/gfx/screen.h"
#include "ui/views/controls/webview/webview.h"
#include "ui/views/layout/fill_layout.h"
#include "ui/views/widget/widget.h"

using content::BrowserThread;
Expand Down Expand Up @@ -129,7 +129,7 @@ void ScreensaverView::LoadScreensaver() {
void ScreensaverView::ShowWindow() {
aura::RootWindow* root_window = ash::Shell::GetPrimaryRootWindow();
gfx::Rect screen_rect =
gfx::Screen::GetMonitorNearestWindow(root_window).bounds();
gfx::Screen::GetDisplayNearestWindow(root_window).bounds();

// We want to be the fullscreen topmost child of the root window.
// There should be nothing ever really that should show up on top of us.
Expand Down
2 changes: 1 addition & 1 deletion ash/system/tray/tray_bubble_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ gfx::Rect TrayBubbleView::GetAnchorRect() {
rect = host_->GetAnchorRect();
// TODO(jennyz): May need to add left/right alignment in the following code.
if (rect.IsEmpty()) {
rect = gfx::Screen::GetPrimaryMonitor().bounds();
rect = gfx::Screen::GetPrimaryDisplay().bounds();
rect = gfx::Rect(
base::i18n::IsRTL() ? kPaddingFromRightEdgeOfScreenBottomAlignment :
rect.width() - kPaddingFromRightEdgeOfScreenBottomAlignment,
Expand Down
2 changes: 1 addition & 1 deletion ash/test/ash_test_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void AshTestBase::TearDown() {

void AshTestBase::ChangeMonitorConfig(float scale,
const gfx::Rect& bounds_in_pixel) {
gfx::Display display = gfx::Display(gfx::Screen::GetPrimaryMonitor().id());
gfx::Display display = gfx::Display(gfx::Screen::GetPrimaryDisplay().id());
display.SetScaleAndBounds(scale, bounds_in_pixel);
std::vector<gfx::Display> displays;
displays.push_back(display);
Expand Down
4 changes: 2 additions & 2 deletions ash/tooltips/tooltip_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ int GetMaxWidth(int x, int y) {
// TODO(varunjain): implementation duplicated in tooltip_manager_aura. Figure
// out a way to merge.
gfx::Rect monitor_bounds =
gfx::Screen::GetMonitorNearestPoint(gfx::Point(x, y)).bounds();
gfx::Screen::GetDisplayNearestPoint(gfx::Point(x, y)).bounds();
return (monitor_bounds.width() + 1) / 2;
}

Expand Down Expand Up @@ -156,7 +156,7 @@ class TooltipController::Tooltip {

tooltip_rect.Offset(kCursorOffsetX, kCursorOffsetY);
gfx::Rect monitor_bounds =
gfx::Screen::GetMonitorNearestPoint(tooltip_rect.origin()).bounds();
gfx::Screen::GetDisplayNearestPoint(tooltip_rect.origin()).bounds();

// If tooltip is out of bounds on the x axis, we simply shift it
// horizontally by the offset.
Expand Down
2 changes: 1 addition & 1 deletion ash/touch/touch_observer_hud.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class TouchHudCanvas : public views::View {
: owner_(owner),
path_index_(0),
color_index_(0) {
gfx::Display display = gfx::Screen::GetPrimaryMonitor();
gfx::Display display = gfx::Screen::GetPrimaryDisplay();
gfx::Rect bounds = display.bounds();
size_.set_width(bounds.width() / kScale);
size_.set_height(bounds.height() / kScale);
Expand Down
8 changes: 4 additions & 4 deletions ash/wm/base_layout_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void BaseLayoutManager::SetChildBounds(aura::Window* child,
if (wm::IsWindowMaximized(child))
child_bounds = ScreenAsh::GetMaximizedWindowBounds(child);
else if (wm::IsWindowFullscreen(child))
child_bounds = gfx::Screen::GetMonitorNearestWindow(child).bounds();
child_bounds = gfx::Screen::GetDisplayNearestWindow(child).bounds();
SetChildBoundsDirect(child, child_bounds);
}

Expand Down Expand Up @@ -198,7 +198,7 @@ void BaseLayoutManager::UpdateBoundsFromShowState(aura::Window* window,
// Don't animate the full-screen window transition.
// TODO(jamescook): Use animation here. Be sure the lock screen works.
SetChildBoundsDirect(
window, gfx::Screen::GetMonitorNearestWindow(window).bounds());
window, gfx::Screen::GetDisplayNearestWindow(window).bounds());
break;

default:
Expand Down Expand Up @@ -235,11 +235,11 @@ void BaseLayoutManager::AdjustWindowSizesForScreenChange() {
SetChildBoundsDirect(window, ScreenAsh::GetMaximizedWindowBounds(window));
} else if (wm::IsWindowFullscreen(window)) {
SetChildBoundsDirect(
window, gfx::Screen::GetMonitorNearestWindow(window).bounds());
window, gfx::Screen::GetDisplayNearestWindow(window).bounds());
} else {
// The work area may be smaller than the full screen.
gfx::Rect monitor_rect =
gfx::Screen::GetMonitorNearestWindow(window).work_area();
gfx::Screen::GetDisplayNearestWindow(window).work_area();
// Put as much of the window as possible within the monitor area.
window->SetBounds(window->bounds().AdjustToFit(monitor_rect));
}
Expand Down
Loading

0 comments on commit 42c0a0c

Please sign in to comment.