diff options
52 files changed, 512 insertions, 518 deletions
diff --git a/ash/dip_unittest.cc b/ash/dip_unittest.cc index 2c465cfb..118350d 100644 --- a/ash/dip_unittest.cc +++ b/ash/dip_unittest.cc @@ -18,8 +18,8 @@ #include "ui/aura/root_window.h" #include "ui/aura/window.h" #include "ui/compositor/layer.h" +#include "ui/gfx/display.h" #include "ui/gfx/insets.h" -#include "ui/gfx/monitor.h" #include "ui/gfx/screen.h" #include "ui/views/widget/widget.h" @@ -39,31 +39,31 @@ TEST_F(DIPTest, MAYBE_WorkArea) { ChangeMonitorConfig(1.0f, gfx::Rect(0, 0, 1000, 900)); aura::RootWindow* root = Shell::GetPrimaryRootWindow(); - const gfx::Monitor monitor = gfx::Screen::GetMonitorNearestWindow(root); + const gfx::Display display = gfx::Screen::GetMonitorNearestWindow(root); - EXPECT_EQ("0,0 1000x900", monitor.bounds().ToString()); - gfx::Rect work_area = monitor.work_area(); + EXPECT_EQ("0,0 1000x900", display.bounds().ToString()); + gfx::Rect work_area = display.work_area(); EXPECT_EQ("0,0 1000x852", work_area.ToString()); - EXPECT_EQ("0,0,48,0", monitor.bounds().InsetsFrom(work_area).ToString()); + EXPECT_EQ("0,0,48,0", display.bounds().InsetsFrom(work_area).ToString()); ChangeMonitorConfig(2.0f, gfx::Rect(0, 0, 2000, 1800)); - const gfx::Monitor monitor_2x = gfx::Screen::GetMonitorNearestWindow(root); + const gfx::Display display_2x = gfx::Screen::GetMonitorNearestWindow(root); // The |bounds_in_pixel()| should report bounds in pixel coordinate. - EXPECT_EQ("0,0 2000x1800", monitor_2x.bounds_in_pixel().ToString()); + EXPECT_EQ("0,0 2000x1800", display_2x.bounds_in_pixel().ToString()); // Aura and views coordinates are in DIP, so they their bounds do not change. - EXPECT_EQ("0,0 1000x900", monitor_2x.bounds().ToString()); - work_area = monitor_2x.work_area(); + EXPECT_EQ("0,0 1000x900", display_2x.bounds().ToString()); + work_area = display_2x.work_area(); EXPECT_EQ("0,0 1000x852", work_area.ToString()); - EXPECT_EQ("0,0,48,0", monitor_2x.bounds().InsetsFrom(work_area).ToString()); + EXPECT_EQ("0,0,48,0", display_2x.bounds().InsetsFrom(work_area).ToString()); // Sanity check if the workarea's inset hight is same as // the launcher's height. Launcher* launcher = Shell::GetInstance()->launcher(); EXPECT_EQ( - monitor_2x.bounds().InsetsFrom(work_area).height(), + display_2x.bounds().InsetsFrom(work_area).height(), launcher->widget()->GetNativeView()->layer()->bounds().height()); } diff --git a/ash/monitor/monitor_controller.cc b/ash/monitor/monitor_controller.cc index 1440daf..f430db7 100644 --- a/ash/monitor/monitor_controller.cc +++ b/ash/monitor/monitor_controller.cc @@ -9,7 +9,7 @@ #include "ui/aura/env.h" #include "ui/aura/root_window.h" #include "ui/aura/window.h" -#include "ui/gfx/monitor.h" +#include "ui/gfx/display.h" namespace ash { namespace internal { @@ -39,31 +39,31 @@ void MonitorController::GetAllRootWindows( windows->push_back(it->second); } -void MonitorController::OnMonitorBoundsChanged(const gfx::Monitor& monitor) { - root_windows_[monitor.id()]->SetHostBounds(monitor.bounds_in_pixel()); +void MonitorController::OnDisplayBoundsChanged(const gfx::Display& display) { + root_windows_[display.id()]->SetHostBounds(display.bounds_in_pixel()); } -void MonitorController::OnMonitorAdded(const gfx::Monitor& monitor) { +void MonitorController::OnDisplayAdded(const gfx::Display& display) { if (root_windows_.empty()) { - root_windows_[monitor.id()] = Shell::GetPrimaryRootWindow(); - Shell::GetPrimaryRootWindow()->SetHostBounds(monitor.bounds_in_pixel()); + root_windows_[display.id()] = Shell::GetPrimaryRootWindow(); + Shell::GetPrimaryRootWindow()->SetHostBounds(display.bounds_in_pixel()); return; } aura::RootWindow* root = aura::Env::GetInstance()->monitor_manager()-> - CreateRootWindowForMonitor(monitor); - root_windows_[monitor.id()] = root; + CreateRootWindowForMonitor(display); + root_windows_[display.id()] = root; Shell::GetInstance()->InitRootWindowForSecondaryMonitor(root); } -void MonitorController::OnMonitorRemoved(const gfx::Monitor& monitor) { - aura::RootWindow* root = root_windows_[monitor.id()]; +void MonitorController::OnDisplayRemoved(const gfx::Display& display) { + aura::RootWindow* root = root_windows_[display.id()]; DCHECK(root); // Primary monitor should never be removed by MonitorManager. DCHECK(root != Shell::GetPrimaryRootWindow()); // Monitor for root window will be deleted when the Primary RootWindow // is deleted by the Shell. if (root != Shell::GetPrimaryRootWindow()) { - root_windows_.erase(monitor.id()); + root_windows_.erase(display.id()); delete root; } } @@ -72,15 +72,15 @@ void MonitorController::Init() { aura::MonitorManager* monitor_manager = aura::Env::GetInstance()->monitor_manager(); for (size_t i = 0; i < monitor_manager->GetNumMonitors(); ++i) { - const gfx::Monitor& monitor = monitor_manager->GetMonitorAt(i); + const gfx::Display& display = monitor_manager->GetMonitorAt(i); if (i == 0) { // Primary monitor - root_windows_[monitor.id()] = Shell::GetPrimaryRootWindow(); - Shell::GetPrimaryRootWindow()->SetHostBounds(monitor.bounds_in_pixel()); + root_windows_[display.id()] = Shell::GetPrimaryRootWindow(); + Shell::GetPrimaryRootWindow()->SetHostBounds(display.bounds_in_pixel()); } else { aura::RootWindow* root = - monitor_manager->CreateRootWindowForMonitor(monitor); - root_windows_[monitor.id()] = root; + monitor_manager->CreateRootWindowForMonitor(display); + root_windows_[display.id()] = root; Shell::GetInstance()->InitRootWindowForSecondaryMonitor(root); } } diff --git a/ash/monitor/monitor_controller.h b/ash/monitor/monitor_controller.h index abe6a13..0af1b60 100644 --- a/ash/monitor/monitor_controller.h +++ b/ash/monitor/monitor_controller.h @@ -11,11 +11,11 @@ #include "base/basictypes.h" #include "base/compiler_specific.h" +#include "ui/aura/display_observer.h" #include "ui/aura/monitor_manager.h" -#include "ui/aura/monitor_observer.h" namespace aura { -class Monitor; +class Display; class RootWindow; } @@ -24,7 +24,7 @@ namespace internal { // MonitorController creates and maintains RootWindows for each // attached monitor, keeping them in sync with monitor configuration changes. -class MonitorController : public aura::MonitorObserver { +class MonitorController : public aura::DisplayObserver { public: MonitorController(); virtual ~MonitorController(); @@ -32,11 +32,11 @@ class MonitorController : public aura::MonitorObserver { // Gets all of the root windows. void GetAllRootWindows(std::vector<aura::RootWindow*>* windows); - // aura::MonitorObserver overrides: - virtual void OnMonitorBoundsChanged( - const gfx::Monitor& monitor) OVERRIDE; - virtual void OnMonitorAdded(const gfx::Monitor& monitor) OVERRIDE; - virtual void OnMonitorRemoved(const gfx::Monitor& monitor) OVERRIDE; + // aura::DisplayObserver overrides: + virtual void OnDisplayBoundsChanged( + const gfx::Display& display) OVERRIDE; + virtual void OnDisplayAdded(const gfx::Display& display) OVERRIDE; + virtual void OnDisplayRemoved(const gfx::Display& display) OVERRIDE; private: void Init(); diff --git a/ash/monitor/multi_monitor_manager.cc b/ash/monitor/multi_monitor_manager.cc index e7ace37..1b97b02 100644 --- a/ash/monitor/multi_monitor_manager.cc +++ b/ash/monitor/multi_monitor_manager.cc @@ -15,7 +15,7 @@ #include "ui/aura/root_window.h" #include "ui/aura/root_window_host.h" #include "ui/aura/window_property.h" -#include "ui/gfx/monitor.h" +#include "ui/gfx/display.h" #include "ui/gfx/rect.h" DECLARE_WINDOW_PROPERTY_TYPE(int); @@ -23,15 +23,16 @@ DECLARE_WINDOW_PROPERTY_TYPE(int); namespace ash { namespace internal { namespace { -gfx::Monitor& GetInvalidMonitor() { - static gfx::Monitor* invalid_monitor = new gfx::Monitor(); - return *invalid_monitor; + +gfx::Display& GetInvalidDisplay() { + static gfx::Display* invalid_display = new gfx::Display(); + return *invalid_display; } + } // namespace using aura::RootWindow; using aura::Window; -using gfx::Monitor; using std::string; using std::vector; @@ -64,8 +65,8 @@ void MultiMonitorManager::CycleMonitor() { } void MultiMonitorManager::OnNativeMonitorsChanged( - const std::vector<Monitor>& new_monitors) { - size_t min = std::min(monitors_.size(), new_monitors.size()); + const std::vector<gfx::Display>& new_displays) { + size_t min = std::min(displays_.size(), new_displays.size()); // For m19, we only care about 1st monitor as primary, and // don't differentiate the rest of monitors as all secondary @@ -76,57 +77,57 @@ void MultiMonitorManager::OnNativeMonitorsChanged( // and keep a content on one monitor stays on the same monitor // when a monitor is added or removed. for (size_t i = 0; i < min; ++i) { - Monitor& current_monitor = monitors_[i]; - const Monitor& new_monitor = new_monitors[i]; - if (current_monitor.bounds_in_pixel() != new_monitor.bounds_in_pixel()) { - current_monitor.SetScaleAndBounds(new_monitor.device_scale_factor(), - new_monitor.bounds_in_pixel()); - NotifyBoundsChanged(current_monitor); + gfx::Display& current_display = displays_[i]; + const gfx::Display& new_display = new_displays[i]; + if (current_display.bounds_in_pixel() != new_display.bounds_in_pixel()) { + current_display.SetScaleAndBounds(new_display.device_scale_factor(), + new_display.bounds_in_pixel()); + NotifyBoundsChanged(current_display); } } - if (monitors_.size() < new_monitors.size()) { + if (displays_.size() < new_displays.size()) { // New monitors added - for (size_t i = min; i < new_monitors.size(); ++i) { - const gfx::Monitor& new_monitor = new_monitors[i]; - monitors_.push_back(Monitor(new_monitor.id())); - gfx::Monitor& monitor = monitors_.back(); - monitor.SetScaleAndBounds(new_monitor.device_scale_factor(), - new_monitor.bounds_in_pixel()); - NotifyMonitorAdded(monitor); + for (size_t i = min; i < new_displays.size(); ++i) { + const gfx::Display& new_display = new_displays[i]; + displays_.push_back(gfx::Display(new_display.id())); + gfx::Display& display = displays_.back(); + display.SetScaleAndBounds(new_display.device_scale_factor(), + new_display.bounds_in_pixel()); + NotifyDisplayAdded(display); } } else { // Monitors are removed. We keep the monitor for the primary // monitor (at index 0) because it needs the monitor information // even if it doesn't exit. - while (monitors_.size() > new_monitors.size() && monitors_.size() > 1) { - Monitors::reverse_iterator iter = monitors_.rbegin(); - NotifyMonitorRemoved(*iter); - monitors_.erase(iter.base() - 1); + while (displays_.size() > new_displays.size() && displays_.size() > 1) { + Displays::reverse_iterator iter = displays_.rbegin(); + NotifyDisplayRemoved(*iter); + displays_.erase(iter.base() - 1); } } } RootWindow* MultiMonitorManager::CreateRootWindowForMonitor( - const Monitor& monitor) { - RootWindow* root_window = new RootWindow(monitor.bounds_in_pixel()); + const gfx::Display& display) { + RootWindow* root_window = new RootWindow(display.bounds_in_pixel()); // No need to remove RootWindowObserver because // the MonitorManager object outlives RootWindow objects. root_window->AddRootWindowObserver(this); - root_window->SetProperty(kMonitorIdKey, monitor.id()); + root_window->SetProperty(kMonitorIdKey, display.id()); root_window->Init(); return root_window; } -const Monitor& MultiMonitorManager::GetMonitorAt(size_t index) { - return index < monitors_.size() ? monitors_[index] : GetInvalidMonitor(); +const gfx::Display& MultiMonitorManager::GetMonitorAt(size_t index) { + return index < displays_.size() ? displays_[index] : GetInvalidDisplay(); } size_t MultiMonitorManager::GetNumMonitors() const { - return monitors_.size(); + return displays_.size(); } -const Monitor& MultiMonitorManager::GetMonitorNearestWindow( +const gfx::Display& MultiMonitorManager::GetMonitorNearestWindow( const Window* window) const { if (!window) { MultiMonitorManager* manager = const_cast<MultiMonitorManager*>(this); @@ -135,11 +136,11 @@ const Monitor& MultiMonitorManager::GetMonitorNearestWindow( const RootWindow* root = window->GetRootWindow(); MultiMonitorManager* that = const_cast<MultiMonitorManager*>(this); return root ? - that->FindMonitorById(root->GetProperty(kMonitorIdKey)) : - GetInvalidMonitor(); + that->FindDisplayById(root->GetProperty(kMonitorIdKey)) : + GetInvalidDisplay(); } -const Monitor& MultiMonitorManager::GetMonitorNearestPoint( +const gfx::Display& MultiMonitorManager::GetMonitorNearestPoint( const gfx::Point& point) const { // TODO(oshima): For m19, mouse is constrained within // the primary window. @@ -151,9 +152,9 @@ void MultiMonitorManager::OnRootWindowResized(const aura::RootWindow* root, const gfx::Size& old_size) { if (!use_fullscreen_host_window()) { int monitor_id = root->GetProperty(kMonitorIdKey); - Monitor& monitor = FindMonitorById(monitor_id); - monitor.SetSize(root->GetHostSize()); - NotifyBoundsChanged(monitor); + gfx::Display& display = FindDisplayById(monitor_id); + display.SetSize(root->GetHostSize()); + NotifyBoundsChanged(display); } } @@ -161,10 +162,10 @@ bool MultiMonitorManager::UpdateWorkAreaOfMonitorNearestWindow( const aura::Window* window, const gfx::Insets& insets) { const RootWindow* root = window->GetRootWindow(); - Monitor& monitor = FindMonitorById(root->GetProperty(kMonitorIdKey)); - gfx::Rect old_work_area = monitor.work_area(); - monitor.UpdateWorkAreaFromInsets(insets); - return old_work_area != monitor.work_area(); + gfx::Display& display = FindDisplayById(root->GetProperty(kMonitorIdKey)); + gfx::Rect old_work_area = display.work_area(); + display.UpdateWorkAreaFromInsets(insets); + return old_work_area != display.work_area(); } void MultiMonitorManager::Init() { @@ -175,65 +176,65 @@ void MultiMonitorManager::Init() { base::SplitString(size_str, ',', &parts); for (vector<string>::const_iterator iter = parts.begin(); iter != parts.end(); ++iter) { - monitors_.push_back(CreateMonitorFromSpec(*iter)); + displays_.push_back(CreateMonitorFromSpec(*iter)); } - if (monitors_.empty()) - monitors_.push_back(CreateMonitorFromSpec("" /* default */)); + if (displays_.empty()) + displays_.push_back(CreateMonitorFromSpec("" /* default */)); } void MultiMonitorManager::AddRemoveMonitorImpl() { - std::vector<Monitor> new_monitors; - if (monitors_.size() > 1) { - // Remove if there is more than one monitor. - int count = monitors_.size() - 1; - for (Monitors::const_iterator iter = monitors_.begin(); count-- > 0; ++iter) - new_monitors.push_back(*iter); + std::vector<gfx::Display> new_displays; + if (displays_.size() > 1) { + // Remove if there is more than one display. + int count = displays_.size() - 1; + for (Displays::const_iterator iter = displays_.begin(); count-- > 0; ++iter) + new_displays.push_back(*iter); } else { - // Add if there is only one monitor. - new_monitors.push_back(monitors_[0]); - new_monitors.push_back(CreateMonitorFromSpec("50+50-1280x768")); + // Add if there is only one display. + new_displays.push_back(displays_[0]); + new_displays.push_back(CreateMonitorFromSpec("50+50-1280x768")); } - if (new_monitors.size()) - OnNativeMonitorsChanged(new_monitors); + if (new_displays.size()) + OnNativeMonitorsChanged(new_displays); } void MultiMonitorManager::CycleMonitorImpl() { - if (monitors_.size() > 1) { - std::vector<Monitor> new_monitors; - for (Monitors::const_iterator iter = monitors_.begin() + 1; - iter != monitors_.end(); ++iter) { - gfx::Monitor monitor = *iter; - new_monitors.push_back(monitor); + if (displays_.size() > 1) { + std::vector<gfx::Display> new_displays; + for (Displays::const_iterator iter = displays_.begin() + 1; + iter != displays_.end(); ++iter) { + gfx::Display display = *iter; + new_displays.push_back(display); } - new_monitors.push_back(monitors_.front()); - OnNativeMonitorsChanged(new_monitors); + new_displays.push_back(displays_.front()); + OnNativeMonitorsChanged(new_displays); } } void MultiMonitorManager::ScaleMonitorImpl() { - if (monitors_.size() > 0) { - std::vector<Monitor> new_monitors; - for (Monitors::const_iterator iter = monitors_.begin(); - iter != monitors_.end(); ++iter) { - gfx::Monitor monitor = *iter; - float factor = monitor.device_scale_factor() == 1.0f ? 2.0f : 1.0f; - monitor.SetScaleAndBounds( - factor, gfx::Rect(monitor.bounds_in_pixel().origin(), - monitor.size().Scale(factor))); - new_monitors.push_back(monitor); + if (displays_.size() > 0) { + std::vector<gfx::Display> new_displays; + for (Displays::const_iterator iter = displays_.begin(); + iter != displays_.end(); ++iter) { + gfx::Display display = *iter; + float factor = display.device_scale_factor() == 1.0f ? 2.0f : 1.0f; + display.SetScaleAndBounds( + factor, gfx::Rect(display.bounds_in_pixel().origin(), + display.size().Scale(factor))); + new_displays.push_back(display); } - OnNativeMonitorsChanged(new_monitors); + OnNativeMonitorsChanged(new_displays); } } -gfx::Monitor& MultiMonitorManager::FindMonitorById(int id) { - for (Monitors::iterator iter = monitors_.begin(); - iter != monitors_.end(); ++iter) { +gfx::Display& MultiMonitorManager::FindDisplayById(int id) { + for (Displays::iterator iter = displays_.begin(); + iter != displays_.end(); ++iter) { if ((*iter).id() == id) return *iter; } - DLOG(FATAL) << "Could not find monitor by id:" << id; - return GetInvalidMonitor(); + DLOG(FATAL) << "Could not find display by id:" << id; + return GetInvalidDisplay(); } } // namespace internal diff --git a/ash/monitor/multi_monitor_manager.h b/ash/monitor/multi_monitor_manager.h index 3d81752..381bba8 100644 --- a/ash/monitor/multi_monitor_manager.h +++ b/ash/monitor/multi_monitor_manager.h @@ -16,7 +16,7 @@ namespace gfx { class Insets; -class Monitor; +class Display; } namespace ash { @@ -45,15 +45,15 @@ class ASH_EXPORT MultiMonitorManager : public aura::MonitorManager, // MonitorManager overrides: virtual void OnNativeMonitorsChanged( - const std::vector<gfx::Monitor>& monitors) OVERRIDE; + const std::vector<gfx::Display>& displays) OVERRIDE; virtual aura::RootWindow* CreateRootWindowForMonitor( - const gfx::Monitor& monitor) OVERRIDE; - virtual const gfx::Monitor& GetMonitorAt(size_t index) OVERRIDE; + const gfx::Display& display) OVERRIDE; + virtual const gfx::Display& GetMonitorAt(size_t index) OVERRIDE; virtual size_t GetNumMonitors() const OVERRIDE; - virtual const gfx::Monitor& GetMonitorNearestPoint( + virtual const gfx::Display& GetMonitorNearestPoint( const gfx::Point& point) const OVERRIDE; - virtual const gfx::Monitor& GetMonitorNearestWindow( + virtual const gfx::Display& GetMonitorNearestWindow( const aura::Window* window) const OVERRIDE; // RootWindowObserver overrides: @@ -61,15 +61,15 @@ class ASH_EXPORT MultiMonitorManager : public aura::MonitorManager, const gfx::Size& new_size) OVERRIDE; private: - typedef std::vector<gfx::Monitor> Monitors; + typedef std::vector<gfx::Display> Displays; void Init(); void AddRemoveMonitorImpl(); void CycleMonitorImpl(); void ScaleMonitorImpl(); - gfx::Monitor& FindMonitorById(int id); + gfx::Display& FindDisplayById(int id); - Monitors monitors_; + Displays displays_; DISALLOW_COPY_AND_ASSIGN(MultiMonitorManager); }; diff --git a/ash/monitor/multi_monitor_manager_unittest.cc b/ash/monitor/multi_monitor_manager_unittest.cc index 5ba3ebd..7850f77 100644 --- a/ash/monitor/multi_monitor_manager_unittest.cc +++ b/ash/monitor/multi_monitor_manager_unittest.cc @@ -9,37 +9,36 @@ #include "base/format_macros.h" #include "base/string_split.h" #include "base/stringprintf.h" +#include "ui/aura/display_observer.h" #include "ui/aura/env.h" -#include "ui/aura/monitor_observer.h" #include "ui/aura/root_window.h" #include "ui/aura/window_observer.h" -#include "ui/gfx/monitor.h" +#include "ui/gfx/display.h" namespace ash { namespace test { using std::vector; using std::string; -using gfx::Monitor; namespace { -vector<Monitor> CreateMonitorsFromString( +vector<gfx::Display> CreateDisplaysFromString( const std::string specs) { - vector<Monitor> monitors; + vector<gfx::Display> displays; vector<string> parts; base::SplitString(specs, ',', &parts); for (vector<string>::const_iterator iter = parts.begin(); iter != parts.end(); ++iter) { - monitors.push_back(aura::MonitorManager::CreateMonitorFromSpec(*iter)); + displays.push_back(aura::MonitorManager::CreateMonitorFromSpec(*iter)); } - return monitors; + return displays; } } // namespace class MultiMonitorManagerTest : public test::AshTestBase, - public aura::MonitorObserver, + public aura::DisplayObserver, public aura::WindowObserver { public: MultiMonitorManagerTest() @@ -62,8 +61,8 @@ class MultiMonitorManagerTest : public test::AshTestBase, aura::MonitorManager* monitor_manager() { return aura::Env::GetInstance()->monitor_manager(); } - const vector<Monitor>& changed() const { return changed_; } - const vector<Monitor>& added() const { return added_; } + const vector<gfx::Display>& changed() const { return changed_; } + const vector<gfx::Display>& added() const { return added_; } string GetCountSummary() const { return StringPrintf("%"PRIuS" %"PRIuS" %"PRIuS, @@ -81,14 +80,14 @@ class MultiMonitorManagerTest : public test::AshTestBase, return root_window_destroyed_; } - // aura::MonitorObserver overrides: - virtual void OnMonitorBoundsChanged(const Monitor& monitor) OVERRIDE { - changed_.push_back(monitor); + // aura::DisplayObserver overrides: + virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE { + changed_.push_back(display); } - virtual void OnMonitorAdded(const Monitor& new_monitor) OVERRIDE { - added_.push_back(new_monitor); + virtual void OnDisplayAdded(const gfx::Display& new_display) OVERRIDE { + added_.push_back(new_display); } - virtual void OnMonitorRemoved(const Monitor& old_monitor) OVERRIDE { + virtual void OnDisplayRemoved(const gfx::Display& old_display) OVERRIDE { ++removed_count_; } @@ -99,13 +98,13 @@ class MultiMonitorManagerTest : public test::AshTestBase, } void UpdateMonitor(const std::string str) { - vector<Monitor> monitors = CreateMonitorsFromString(str); - monitor_manager()->OnNativeMonitorsChanged(monitors); + vector<gfx::Display> displays = CreateDisplaysFromString(str); + monitor_manager()->OnNativeMonitorsChanged(displays); } private: - vector<Monitor> changed_; - vector<Monitor> added_; + vector<gfx::Display> changed_; + vector<gfx::Display> added_; size_t removed_count_; bool root_window_destroyed_; @@ -157,8 +156,8 @@ TEST_F(MultiMonitorManagerTest, NativeMonitorTest) { EXPECT_EQ("0,0 800x300", changed()[0].bounds().ToString()); reset(); - // # of monitor can go to zero when screen is off. - const vector<Monitor> empty; + // # 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("0 0 0", GetCountSummary()); diff --git a/ash/screen_ash.cc b/ash/screen_ash.cc index c7d9cb9..71df546 100644 --- a/ash/screen_ash.cc +++ b/ash/screen_ash.cc @@ -10,7 +10,7 @@ #include "ui/aura/env.h" #include "ui/aura/monitor_manager.h" #include "ui/aura/root_window.h" -#include "ui/gfx/monitor.h" +#include "ui/gfx/display.h" #include "ui/gfx/screen.h" namespace ash { @@ -58,15 +58,15 @@ int ScreenAsh::GetNumMonitors() { return GetMonitorManager()->GetNumMonitors(); } -gfx::Monitor ScreenAsh::GetMonitorNearestWindow(gfx::NativeView window) const { +gfx::Display ScreenAsh::GetMonitorNearestWindow(gfx::NativeView window) const { return GetMonitorManager()->GetMonitorNearestWindow(window); } -gfx::Monitor ScreenAsh::GetMonitorNearestPoint(const gfx::Point& point) const { +gfx::Display ScreenAsh::GetMonitorNearestPoint(const gfx::Point& point) const { return GetMonitorManager()->GetMonitorNearestPoint(point); } -gfx::Monitor ScreenAsh::GetPrimaryMonitor() const { +gfx::Display ScreenAsh::GetPrimaryMonitor() const { return GetMonitorManager()->GetMonitorAt(0); } diff --git a/ash/screen_ash.h b/ash/screen_ash.h index 7dd31fa..bfe29b3 100644 --- a/ash/screen_ash.h +++ b/ash/screen_ash.h @@ -6,8 +6,8 @@ #define ASH_SCREEN_ASH_H_ #pragma once -#include "base/compiler_specific.h" #include "ash/ash_export.h" +#include "base/compiler_specific.h" #include "ui/gfx/insets.h" #include "ui/gfx/rect.h" #include "ui/gfx/screen_impl.h" @@ -33,11 +33,11 @@ class ASH_EXPORT ScreenAsh : public gfx::ScreenImpl { virtual gfx::NativeWindow GetWindowAtCursorScreenPoint() OVERRIDE; virtual int GetNumMonitors() OVERRIDE; - virtual gfx::Monitor GetMonitorNearestWindow( + virtual gfx::Display GetMonitorNearestWindow( gfx::NativeView view) const OVERRIDE; - virtual gfx::Monitor GetMonitorNearestPoint( + virtual gfx::Display GetMonitorNearestPoint( const gfx::Point& point) const OVERRIDE; - virtual gfx::Monitor GetPrimaryMonitor() const OVERRIDE; + virtual gfx::Display GetPrimaryMonitor() const OVERRIDE; private: DISALLOW_COPY_AND_ASSIGN(ScreenAsh); diff --git a/ash/shell.cc b/ash/shell.cc index dc67178..c818be5 100644 --- a/ash/shell.cc +++ b/ash/shell.cc @@ -83,8 +83,8 @@ #include "ui/aura/window.h" #include "ui/compositor/layer.h" #include "ui/compositor/layer_animator.h" +#include "ui/gfx/display.h" #include "ui/gfx/image/image_skia.h" -#include "ui/gfx/monitor.h" #include "ui/gfx/screen.h" #include "ui/gfx/size.h" #include "ui/ui_controls/ui_controls.h" diff --git a/ash/shell.h b/ash/shell.h index 5848d29..abc7612 100644 --- a/ash/shell.h +++ b/ash/shell.h @@ -26,7 +26,6 @@ class CommandLine; namespace aura { class EventFilter; class FocusManager; -class Monitor; class RootWindow; class Window; namespace client { diff --git a/ash/test/ash_test_base.cc b/ash/test/ash_test_base.cc index 744ada4..ad9066b 100644 --- a/ash/test/ash_test_base.cc +++ b/ash/test/ash_test_base.cc @@ -14,7 +14,7 @@ #include "ui/aura/root_window.h" #include "ui/base/ime/text_input_test_support.h" #include "ui/compositor/layer_animator.h" -#include "ui/gfx/monitor.h" +#include "ui/gfx/display.h" #include "ui/gfx/screen.h" namespace ash { @@ -57,12 +57,12 @@ void AshTestBase::TearDown() { void AshTestBase::ChangeMonitorConfig(float scale, const gfx::Rect& bounds_in_pixel) { - gfx::Monitor monitor = gfx::Monitor(gfx::Screen::GetPrimaryMonitor().id()); - monitor.SetScaleAndBounds(scale, bounds_in_pixel); - std::vector<gfx::Monitor> monitors; - monitors.push_back(monitor); + gfx::Display display = gfx::Display(gfx::Screen::GetPrimaryMonitor().id()); + display.SetScaleAndBounds(scale, bounds_in_pixel); + std::vector<gfx::Display> displays; + displays.push_back(display); aura::Env::GetInstance()->monitor_manager()->OnNativeMonitorsChanged( - monitors); + displays); } void AshTestBase::RunAllPendingInMessageLoop() { diff --git a/ash/touch/touch_observer_hud.cc b/ash/touch/touch_observer_hud.cc index 2b976d2..c9372aa 100644 --- a/ash/touch/touch_observer_hud.cc +++ b/ash/touch/touch_observer_hud.cc @@ -11,7 +11,7 @@ #include "third_party/skia/include/core/SkXfermode.h" #include "ui/aura/event.h" #include "ui/gfx/canvas.h" -#include "ui/gfx/monitor.h" +#include "ui/gfx/display.h" #include "ui/gfx/rect.h" #include "ui/gfx/screen.h" #include "ui/gfx/size.h" @@ -42,8 +42,8 @@ class TouchHudCanvas : public views::View { : owner_(owner), path_index_(0), color_index_(0) { - gfx::Monitor monitor = gfx::Screen::GetPrimaryMonitor(); - gfx::Rect bounds = monitor.bounds(); + gfx::Display display = gfx::Screen::GetPrimaryMonitor(); + gfx::Rect bounds = display.bounds(); size_.set_width(bounds.width() / kScale); size_.set_height(bounds.height() / kScale); } diff --git a/ash/wm/shelf_layout_manager_unittest.cc b/ash/wm/shelf_layout_manager_unittest.cc index d90d05f..cd88130 100644 --- a/ash/wm/shelf_layout_manager_unittest.cc +++ b/ash/wm/shelf_layout_manager_unittest.cc @@ -21,7 +21,7 @@ #include "ui/base/animation/animation_container_element.h" #include "ui/compositor/layer.h" #include "ui/compositor/layer_animator.h" -#include "ui/gfx/monitor.h" +#include "ui/gfx/display.h" #include "ui/gfx/screen.h" #include "ui/views/widget/widget.h" @@ -94,12 +94,12 @@ TEST_F(ShelfLayoutManagerTest, MAYBE_SetVisible) { const aura::MonitorManager* manager = aura::Env::GetInstance()->monitor_manager(); - const gfx::Monitor& monitor = + const gfx::Display& display = manager->GetMonitorNearestWindow(Shell::GetPrimaryRootWindow()); - ASSERT_NE(-1, monitor.id()); + ASSERT_NE(-1, display.id()); // Bottom inset should be the max of widget heights. EXPECT_EQ(shelf_height, - monitor.bounds().bottom() - monitor.work_area().bottom()); + display.bounds().bottom() - display.work_area().bottom()); // Hide the shelf. SetState(shelf, ShelfLayoutManager::HIDDEN); @@ -108,7 +108,7 @@ TEST_F(ShelfLayoutManagerTest, MAYBE_SetVisible) { StepWidgetLayerAnimatorToEnd(shelf->status()); EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state()); EXPECT_EQ(0, - monitor.bounds().bottom() - monitor.work_area().bottom()); + display.bounds().bottom() - display.work_area().bottom()); // Make sure the bounds of the two widgets changed. EXPECT_GE(shelf->launcher_widget()->GetNativeView()->bounds().y(), @@ -123,7 +123,7 @@ TEST_F(ShelfLayoutManagerTest, MAYBE_SetVisible) { StepWidgetLayerAnimatorToEnd(shelf->status()); EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); EXPECT_EQ(shelf_height, - monitor.bounds().bottom() - monitor.work_area().bottom()); + display.bounds().bottom() - display.work_area().bottom()); // Make sure the bounds of the two widgets changed. launcher_bounds = shelf->launcher_widget()->GetNativeView()->bounds(); @@ -146,14 +146,14 @@ TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) { const aura::MonitorManager* manager = aura::Env::GetInstance()->monitor_manager(); - const gfx::Monitor& monitor = + const gfx::Display& display = manager->GetMonitorNearestWindow(Shell::GetPrimaryRootWindow()); // Hide the shelf. SetState(shelf, ShelfLayoutManager::HIDDEN); shelf->LayoutShelf(); EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state()); - EXPECT_EQ(0, monitor.bounds().bottom() - monitor.work_area().bottom()); + EXPECT_EQ(0, display.bounds().bottom() - display.work_area().bottom()); // Make sure the bounds of the two widgets changed. EXPECT_GE(shelf->launcher_widget()->GetNativeView()->bounds().y(), @@ -503,11 +503,11 @@ TEST_F(ShelfLayoutManagerTest, SetAlignment) { gfx::Rect launcher_bounds(shelf->launcher_widget()->GetWindowScreenBounds()); const aura::MonitorManager* manager = aura::Env::GetInstance()->monitor_manager(); - gfx::Monitor monitor = + gfx::Display display = manager->GetMonitorNearestWindow(Shell::GetPrimaryRootWindow()); - ASSERT_NE(-1, monitor.id()); + ASSERT_NE(-1, display.id()); EXPECT_EQ(shelf->GetIdealBounds().width(), - monitor.GetWorkAreaInsets().left()); + display.GetWorkAreaInsets().left()); EXPECT_GE( launcher_bounds.width(), shelf->launcher_widget()->GetContentsView()->GetPreferredSize().width()); @@ -517,20 +517,20 @@ TEST_F(ShelfLayoutManagerTest, SetAlignment) { EXPECT_GE(status_bounds.width(), shelf->status()->GetContentsView()->GetPreferredSize().width()); EXPECT_EQ(shelf->GetIdealBounds().width(), - monitor.GetWorkAreaInsets().left()); - EXPECT_EQ(0, monitor.GetWorkAreaInsets().top()); - EXPECT_EQ(0, monitor.GetWorkAreaInsets().bottom()); - EXPECT_EQ(0, monitor.GetWorkAreaInsets().right()); - EXPECT_EQ(monitor.bounds().x(), launcher_bounds.x()); - EXPECT_EQ(monitor.bounds().y(), launcher_bounds.y()); - EXPECT_EQ(monitor.bounds().height(), launcher_bounds.height()); + display.GetWorkAreaInsets().left()); + EXPECT_EQ(0, display.GetWorkAreaInsets().top()); + EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); + EXPECT_EQ(0, display.GetWorkAreaInsets().right()); + EXPECT_EQ(display.bounds().x(), launcher_bounds.x()); + EXPECT_EQ(display.bounds().y(), launcher_bounds.y()); + EXPECT_EQ(display.bounds().height(), launcher_bounds.height()); shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); launcher_bounds = shelf->launcher_widget()->GetWindowScreenBounds(); - monitor = manager->GetMonitorNearestWindow(Shell::GetPrimaryRootWindow()); - ASSERT_NE(-1, monitor.id()); + display = manager->GetMonitorNearestWindow(Shell::GetPrimaryRootWindow()); + ASSERT_NE(-1, display.id()); EXPECT_EQ(shelf->GetIdealBounds().width(), - monitor.GetWorkAreaInsets().right()); + display.GetWorkAreaInsets().right()); EXPECT_GE( launcher_bounds.width(), shelf->launcher_widget()->GetContentsView()->GetPreferredSize().width()); @@ -540,13 +540,13 @@ TEST_F(ShelfLayoutManagerTest, SetAlignment) { EXPECT_GE(status_bounds.width(), shelf->status()->GetContentsView()->GetPreferredSize().width()); EXPECT_EQ(shelf->GetIdealBounds().width(), - monitor.GetWorkAreaInsets().right()); - EXPECT_EQ(0, monitor.GetWorkAreaInsets().top()); - EXPECT_EQ(0, monitor.GetWorkAreaInsets().bottom()); - EXPECT_EQ(0, monitor.GetWorkAreaInsets().left()); - EXPECT_EQ(monitor.work_area().right(), launcher_bounds.x()); - EXPECT_EQ(monitor.bounds().y(), launcher_bounds.y()); - EXPECT_EQ(monitor.bounds().height(), launcher_bounds.height()); + display.GetWorkAreaInsets().right()); + EXPECT_EQ(0, display.GetWorkAreaInsets().top()); + EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); + EXPECT_EQ(0, display.GetWorkAreaInsets().left()); + EXPECT_EQ(display.work_area().right(), launcher_bounds.x()); + EXPECT_EQ(display.bounds().y(), launcher_bounds.y()); + EXPECT_EQ(display.bounds().height(), launcher_bounds.height()); } } // namespace internal diff --git a/ash/wm/window_util.cc b/ash/wm/window_util.cc index 9b0da78..5ac2f11 100644 --- a/ash/wm/window_util.cc +++ b/ash/wm/window_util.cc @@ -12,7 +12,7 @@ #include "ui/aura/root_window.h" #include "ui/aura/window.h" #include "ui/base/ui_base_types.h" -#include "ui/gfx/monitor.h" +#include "ui/gfx/display.h" #include "ui/gfx/screen.h" namespace ash { @@ -94,8 +94,8 @@ void RestoreWindow(aura::Window* window) { } void CenterWindow(aura::Window* window) { - const gfx::Monitor monitor = gfx::Screen::GetMonitorNearestWindow(window); - gfx::Rect center = monitor.work_area().Center(window->bounds().size()); + const gfx::Display display = gfx::Screen::GetMonitorNearestWindow(window); + gfx::Rect center = display.work_area().Center(window->bounds().size()); window->SetBounds(center); } diff --git a/chrome/browser/ui/panels/display_settings_provider.cc b/chrome/browser/ui/panels/display_settings_provider.cc index 13ed0ad..32b3955 100644 --- a/chrome/browser/ui/panels/display_settings_provider.cc +++ b/chrome/browser/ui/panels/display_settings_provider.cc @@ -78,15 +78,15 @@ gfx::Rect DisplaySettingsProvider::GetWorkArea() const { // screen (and overlap Dock). And we also want to exclude the system menu // area. Note that the rect returned from gfx::Screen util functions is in // platform-independent screen coordinates with (0, 0) as the top-left corner. - gfx::Monitor monitor = gfx::Screen::GetPrimaryMonitor(); - gfx::Rect monitor_area = monitor.bounds(); - gfx::Rect work_area = monitor.work_area(); - int system_menu_height = work_area.y() - monitor_area.y(); + gfx::Display display = gfx::Screen::GetPrimaryMonitor(); + gfx::Rect display_area = display.bounds(); + gfx::Rect work_area = display.work_area(); + int system_menu_height = work_area.y() - display_area.y(); if (system_menu_height > 0) { - monitor_area.set_y(monitor_area.y() + system_menu_height); - monitor_area.set_height(monitor_area.height() - system_menu_height); + display_area.set_y(display_area.y() + system_menu_height); + display_area.set_height(display_area.height() - system_menu_height); } - return monitor_area; + return display_area; #else gfx::Rect work_area = gfx::Screen::GetPrimaryMonitor().work_area(); #endif diff --git a/chrome/browser/ui/webui/options2/chromeos/internet_options_handler2.cc b/chrome/browser/ui/webui/options2/chromeos/internet_options_handler2.cc index 7912627..a905055 100644 --- a/chrome/browser/ui/webui/options2/chromeos/internet_options_handler2.cc +++ b/chrome/browser/ui/webui/options2/chromeos/internet_options_handler2.cc @@ -54,8 +54,8 @@ #include "grit/theme_resources.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" +#include "ui/gfx/display.h" #include "ui/gfx/image/image_skia.h" -#include "ui/gfx/monitor.h" #include "ui/gfx/screen.h" #include "ui/views/widget/widget.h" @@ -1137,8 +1137,8 @@ Browser* InternetOptionsHandler::GetAppropriateBrowser() { float InternetOptionsHandler::GetIconScaleFactor() { gfx::NativeWindow window = GetNativeWindow(); - gfx::Monitor monitor = gfx::Screen::GetMonitorNearestWindow(window); - return monitor.device_scale_factor(); + gfx::Display display = gfx::Screen::GetMonitorNearestWindow(window); + return display.device_scale_factor(); } void InternetOptionsHandler::NetworkCommandCallback(const ListValue* args) { diff --git a/content/browser/renderer_host/dip_util.cc b/content/browser/renderer_host/dip_util.cc index df0ec63..8a42e74 100644 --- a/content/browser/renderer_host/dip_util.cc +++ b/content/browser/renderer_host/dip_util.cc @@ -5,7 +5,7 @@ #include "content/browser/renderer_host/dip_util.h" #include "content/public/browser/render_widget_host_view.h" -#include "ui/gfx/monitor.h" +#include "ui/gfx/display.h" #include "ui/gfx/point.h" #include "ui/gfx/rect.h" #include "ui/gfx/screen.h" @@ -19,9 +19,9 @@ float GetDIPScaleFactor(const RenderWidgetHostView* view) { // TODO(pkotwicz): Fix this. (crbug.com/129409). #if !defined(OS_MACOSX) if (gfx::Screen::IsDIPEnabled()) { - gfx::Monitor monitor = gfx::Screen::GetMonitorNearestWindow( + gfx::Display display = gfx::Screen::GetMonitorNearestWindow( view ? view->GetNativeView() : NULL); - return monitor.device_scale_factor(); + return display.device_scale_factor(); } #endif return 1.0f; diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc index e96b017..02d13ee 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc @@ -41,7 +41,7 @@ #include "ui/compositor/compositor.h" #include "ui/compositor/layer.h" #include "ui/gfx/canvas.h" -#include "ui/gfx/monitor.h" +#include "ui/gfx/display.h" #include "ui/gfx/screen.h" #include "ui/gfx/skia_util.h" @@ -113,16 +113,16 @@ bool CanRendererHandleEvent(const aura::MouseEvent* event) { void GetScreenInfoForWindow(WebKit::WebScreenInfo* results, aura::Window* window) { - const gfx::Monitor monitor = window ? + const gfx::Display display = window ? gfx::Screen::GetMonitorNearestWindow(window) : gfx::Screen::GetPrimaryMonitor(); - const gfx::Size size = monitor.size(); + const gfx::Size size = display.size(); results->rect = WebKit::WebRect(0, 0, size.width(), size.height()); results->availableRect = results->rect; - // TODO(derat|oshima): Don't hardcode this. Get this from monitor object. + // TODO(derat|oshima): Don't hardcode this. Get this from display object. results->depth = 24; results->depthPerComponent = 8; - int default_dpi = monitor.device_scale_factor() * 160; + int default_dpi = display.device_scale_factor() * 160; results->verticalDPI = default_dpi; results->horizontalDPI = default_dpi; } diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc index 9c73981..3c0cdd7 100644 --- a/content/browser/web_contents/web_contents_impl.cc +++ b/content/browser/web_contents/web_contents_impl.cc @@ -70,7 +70,7 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" #include "ui/base/layout.h" #include "ui/base/ui_base_switches.h" -#include "ui/gfx/monitor.h" +#include "ui/gfx/display.h" #include "ui/gfx/screen.h" #include "webkit/glue/web_intent_data.h" #include "webkit/glue/web_intent_service_data.h" diff --git a/ui/aura/aura.gyp b/ui/aura/aura.gyp index 0ddb6e5..9581844 100644 --- a/ui/aura/aura.gyp +++ b/ui/aura/aura.gyp @@ -73,6 +73,8 @@ 'dispatcher_linux.cc', 'dispatcher_linux.h', 'dispatcher_win.cc', + 'display_observer.cc', + 'display_observer.h', 'env.cc', 'env.h', 'env_observer.h', @@ -90,8 +92,6 @@ 'monitor_change_observer_x11.h', 'monitor_manager.cc', 'monitor_manager.h', - 'monitor_observer.cc', - 'monitor_observer.h', 'root_window_host.h', 'root_window_host_linux.cc', 'root_window_host_linux.h', diff --git a/ui/aura/desktop/desktop_screen_win.cc b/ui/aura/desktop/desktop_screen_win.cc index fdf1f8f..1eebb68 100644 --- a/ui/aura/desktop/desktop_screen_win.cc +++ b/ui/aura/desktop/desktop_screen_win.cc @@ -8,7 +8,7 @@ #include "ui/aura/desktop/desktop_screen.h" #include "ui/aura/root_window.h" #include "ui/aura/root_window_host.h" -#include "ui/gfx/monitor.h" +#include "ui/gfx/display.h" namespace { @@ -19,11 +19,11 @@ MONITORINFO GetMonitorInfoForMonitor(HMONITOR monitor) { return monitor_info; } -gfx::Monitor GetMonitor(MONITORINFO& monitor_info) { +gfx::Display GetDisplay(MONITORINFO& monitor_info) { // TODO(oshima): Implement ID and Observer. - gfx::Monitor monitor(0, gfx::Rect(monitor_info.rcMonitor)); - monitor.set_work_area(gfx::Rect(monitor_info.rcWork)); - return monitor; + gfx::Display display(0, gfx::Rect(monitor_info.rcMonitor)); + display.set_work_area(gfx::Rect(monitor_info.rcWork)); + return display; } } // namespace @@ -62,7 +62,7 @@ int DesktopScreenWin::GetNumMonitors() { return GetSystemMetrics(SM_CMONITORS); } -gfx::Monitor DesktopScreenWin::GetMonitorNearestWindow( +gfx::Display DesktopScreenWin::GetMonitorNearestWindow( gfx::NativeView window) const { gfx::AcceleratedWidget accelerated_window = window->GetRootWindow()->GetAcceleratedWidget(); @@ -71,27 +71,27 @@ gfx::Monitor DesktopScreenWin::GetMonitorNearestWindow( GetMonitorInfo(MonitorFromWindow(accelerated_window, MONITOR_DEFAULTTONEAREST), &monitor_info); - return GetMonitor(monitor_info); + return GetDisplay(monitor_info); } -gfx::Monitor DesktopScreenWin::GetMonitorNearestPoint( +gfx::Display DesktopScreenWin::GetMonitorNearestPoint( const gfx::Point& point) const { POINT initial_loc = { point.x(), point.y() }; HMONITOR monitor = MonitorFromPoint(initial_loc, MONITOR_DEFAULTTONEAREST); MONITORINFO mi = {0}; mi.cbSize = sizeof(mi); if (monitor && GetMonitorInfo(monitor, &mi)) - return GetMonitor(mi); - return gfx::Monitor(); + return GetDisplay(mi); + return gfx::Display(); } -gfx::Monitor DesktopScreenWin::GetPrimaryMonitor() const { +gfx::Display DesktopScreenWin::GetPrimaryMonitor() const { MONITORINFO mi = GetMonitorInfoForMonitor( MonitorFromWindow(NULL, MONITOR_DEFAULTTOPRIMARY)); - gfx::Monitor monitor = GetMonitor(mi); - DCHECK_EQ(GetSystemMetrics(SM_CXSCREEN), monitor.size().width()); - DCHECK_EQ(GetSystemMetrics(SM_CYSCREEN), monitor.size().height()); - return monitor; + gfx::Display display = GetDisplay(mi); + DCHECK_EQ(GetSystemMetrics(SM_CXSCREEN), display.size().width()); + DCHECK_EQ(GetSystemMetrics(SM_CYSCREEN), display.size().height()); + return display; } //////////////////////////////////////////////////////////////////////////////// diff --git a/ui/aura/desktop/desktop_screen_win.h b/ui/aura/desktop/desktop_screen_win.h index da0b1f9..02c2af1 100644 --- a/ui/aura/desktop/desktop_screen_win.h +++ b/ui/aura/desktop/desktop_screen_win.h @@ -20,11 +20,11 @@ public: virtual gfx::Point GetCursorScreenPoint() OVERRIDE; virtual gfx::NativeWindow GetWindowAtCursorScreenPoint() OVERRIDE; virtual int GetNumMonitors() OVERRIDE; - virtual gfx::Monitor GetMonitorNearestWindow( + virtual gfx::Display GetMonitorNearestWindow( gfx::NativeView window) const OVERRIDE; - virtual gfx::Monitor GetMonitorNearestPoint( + virtual gfx::Display GetMonitorNearestPoint( const gfx::Point& point) const OVERRIDE; - virtual gfx::Monitor GetPrimaryMonitor() const OVERRIDE; + virtual gfx::Display GetPrimaryMonitor() const OVERRIDE; private: DISALLOW_COPY_AND_ASSIGN(DesktopScreenWin); diff --git a/ui/aura/desktop/desktop_screen_x11.cc b/ui/aura/desktop/desktop_screen_x11.cc index 59b6f19..97faee8 100644 --- a/ui/aura/desktop/desktop_screen_x11.cc +++ b/ui/aura/desktop/desktop_screen_x11.cc @@ -13,7 +13,7 @@ #include "ui/aura/root_window.h" #include "ui/aura/root_window_host.h" #include "ui/base/x/x11_util.h" -#include "ui/gfx/monitor.h" +#include "ui/gfx/display.h" #include "ui/gfx/native_widget_types.h" #include "ui/gfx/screen_impl.h" @@ -39,11 +39,11 @@ class DesktopScreenX11 : public gfx::ScreenImpl { virtual gfx::Point GetCursorScreenPoint() OVERRIDE; virtual gfx::NativeWindow GetWindowAtCursorScreenPoint() OVERRIDE; virtual int GetNumMonitors() OVERRIDE; - virtual gfx::Monitor GetMonitorNearestWindow( + virtual gfx::Display GetMonitorNearestWindow( gfx::NativeView window) const OVERRIDE; - virtual gfx::Monitor GetMonitorNearestPoint( + virtual gfx::Display GetMonitorNearestPoint( const gfx::Point& point) const OVERRIDE; - virtual gfx::Monitor GetPrimaryMonitor() const OVERRIDE; + virtual gfx::Display GetPrimaryMonitor() const OVERRIDE; private: DISALLOW_COPY_AND_ASSIGN(DesktopScreenX11); @@ -92,21 +92,21 @@ int DesktopScreenX11::GetNumMonitors() { return 1; } -gfx::Monitor DesktopScreenX11::GetMonitorNearestWindow( +gfx::Display DesktopScreenX11::GetMonitorNearestWindow( gfx::NativeView window) const { // TODO(erg): Do the right thing once we know what that is. - return gfx::Monitor(0, gfx::Rect(GetPrimaryMonitorSize())); + return gfx::Display(0, gfx::Rect(GetPrimaryMonitorSize())); } -gfx::Monitor DesktopScreenX11::GetMonitorNearestPoint( +gfx::Display DesktopScreenX11::GetMonitorNearestPoint( const gfx::Point& point) const { // TODO(erg): Do the right thing once we know what that is. - return gfx::Monitor(0, gfx::Rect(GetPrimaryMonitorSize())); + return gfx::Display(0, gfx::Rect(GetPrimaryMonitorSize())); } -gfx::Monitor DesktopScreenX11::GetPrimaryMonitor() const { +gfx::Display DesktopScreenX11::GetPrimaryMonitor() const { // TODO(erg): Do the right thing once we know what that is. - return gfx::Monitor(0, gfx::Rect(GetPrimaryMonitorSize())); + return gfx::Display(0, gfx::Rect(GetPrimaryMonitorSize())); } } // namespace diff --git a/ui/aura/monitor_observer.cc b/ui/aura/display_observer.cc index aa1cf0f..d9120fd 100644 --- a/ui/aura/monitor_observer.cc +++ b/ui/aura/display_observer.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ui/aura/monitor_observer.h" +#include "ui/aura/display_observer.h" namespace aura { -MonitorObserver::~MonitorObserver() { +DisplayObserver::~DisplayObserver() { } } // namespace aura diff --git a/ui/aura/monitor_observer.h b/ui/aura/display_observer.h index dbbc53a..282241d 100644 --- a/ui/aura/monitor_observer.h +++ b/ui/aura/display_observer.h @@ -9,25 +9,25 @@ #include "ui/aura/aura_export.h" namespace gfx { -class Monitor; +class Display; } namespace aura { -// Observers for monitor configuration changes. -class AURA_EXPORT MonitorObserver { +// Observers for display configuration changes. +class AURA_EXPORT DisplayObserver { public: - // Called when the |monitor|'s bound has changed. - virtual void OnMonitorBoundsChanged(const gfx::Monitor& monitor) = 0; + // Called when the |display|'s bound has changed. + virtual void OnDisplayBoundsChanged(const gfx::Display& display) = 0; // Called when |new_monitor| has been added. - virtual void OnMonitorAdded(const gfx::Monitor& new_monitor) = 0; + virtual void OnDisplayAdded(const gfx::Display& new_display) = 0; - // Called when |old_monitor| has been removed. - virtual void OnMonitorRemoved(const gfx::Monitor& old_monitor) = 0; + // Called when |old_display| has been removed. + virtual void OnDisplayRemoved(const gfx::Display& old_display) = 0; protected: - virtual ~MonitorObserver(); + virtual ~DisplayObserver(); }; } // namespace aura diff --git a/ui/aura/env.cc b/ui/aura/env.cc index 58eea0a..18aac53 100644 --- a/ui/aura/env.cc +++ b/ui/aura/env.cc @@ -61,7 +61,7 @@ void Env::SetMonitorManager(MonitorManager* monitor_manager) { monitor_manager_.reset(monitor_manager); #if defined(USE_X11) // Update the monitor manager with latest info. - monitor_change_observer_->NotifyMonitorChange(); + monitor_change_observer_->NotifyDisplayChange(); #endif } diff --git a/ui/aura/monitor_change_observer_x11.cc b/ui/aura/monitor_change_observer_x11.cc index 3187e0b..b6e7303 100644 --- a/ui/aura/monitor_change_observer_x11.cc +++ b/ui/aura/monitor_change_observer_x11.cc @@ -12,11 +12,11 @@ #include <X11/extensions/Xrandr.h> #include "base/message_pump_aurax11.h" -#include "ui/aura/env.h" #include "ui/aura/dispatcher_linux.h" +#include "ui/aura/env.h" #include "ui/aura/monitor_manager.h" #include "ui/compositor/dip_util.h" -#include "ui/gfx/monitor.h" +#include "ui/gfx/display.h" namespace aura { namespace internal { @@ -43,7 +43,7 @@ XRRModeInfo* FindMode(XRRScreenResources* screen_resources, XID current_mode) { return NULL; } -bool CompareMonitorY(const gfx::Monitor& lhs, const gfx::Monitor& rhs) { +bool CompareDisplayY(const gfx::Display& lhs, const gfx::Display& rhs) { return lhs.bounds_in_pixel().y() > rhs.bounds_in_pixel().y(); } @@ -66,12 +66,12 @@ MonitorChangeObserverX11::~MonitorChangeObserverX11() { bool MonitorChangeObserverX11::Dispatch(const base::NativeEvent& event) { if (event->type - xrandr_event_base_ == RRScreenChangeNotify) { - NotifyMonitorChange(); + NotifyDisplayChange(); } return true; } -void MonitorChangeObserverX11::NotifyMonitorChange() { +void MonitorChangeObserverX11::NotifyDisplayChange() { if (!MonitorManager::use_fullscreen_host_window()) return; // Use the default monitor that monitor manager determined. @@ -86,7 +86,7 @@ void MonitorChangeObserverX11::NotifyMonitorChange() { crtc_info_map[crtc_id] = crtc_info; } - std::vector<gfx::Monitor> monitors; + std::vector<gfx::Display> displays; std::set<int> y_coords; for (int o = 0; o < screen_resources->noutput; o++) { XRROutputInfo *output_info = @@ -108,7 +108,7 @@ void MonitorChangeObserverX11::NotifyMonitorChange() { if (y_coords.find(crtc_info->y) != y_coords.end()) continue; // TODO(oshima): Create unique ID for the monitor. - monitors.push_back(gfx::Monitor( + displays.push_back(gfx::Display( 0, gfx::Rect(crtc_info->x, crtc_info->y, mode->width, mode->height))); @@ -118,7 +118,7 @@ void MonitorChangeObserverX11::NotifyMonitorChange() { kHighDensityDIPThreshold) { device_scale_factor = 2.0f; } - monitors.back().set_device_scale_factor(device_scale_factor); + displays.back().set_device_scale_factor(device_scale_factor); y_coords.insert(crtc_info->y); XRRFreeOutputInfo(output_info); } @@ -132,15 +132,14 @@ void MonitorChangeObserverX11::NotifyMonitorChange() { // PowerManager lays out the outputs vertically. Sort them by Y // coordinates. - std::sort(monitors.begin(), monitors.end(), CompareMonitorY); + std::sort(displays.begin(), displays.end(), CompareDisplayY); // TODO(oshima): Assisgn index as ID for now. Use unique ID. int id = 0; - for (std::vector<gfx::Monitor>::iterator iter = monitors.begin(); - iter != monitors.end(); ++iter, ++id) + for (std::vector<gfx::Display>::iterator iter = displays.begin(); + iter != displays.end(); ++iter, ++id) (*iter).set_id(id); - Env::GetInstance()->monitor_manager() - ->OnNativeMonitorsChanged(monitors); + Env::GetInstance()->monitor_manager()->OnNativeMonitorsChanged(displays); } } // namespace internal diff --git a/ui/aura/monitor_change_observer_x11.h b/ui/aura/monitor_change_observer_x11.h index 45ff332..4160860 100644 --- a/ui/aura/monitor_change_observer_x11.h +++ b/ui/aura/monitor_change_observer_x11.h @@ -27,9 +27,9 @@ class MonitorChangeObserverX11 : public MessageLoop::Dispatcher { // Overridden from Dispatcher overrides: virtual bool Dispatch(const base::NativeEvent& xev) OVERRIDE; - // Reads monitor configurations from the system and notifies + // Reads display configurations from the system and notifies // |monitor_manager_| about the change. - void NotifyMonitorChange(); + void NotifyDisplayChange(); private: Display* xdisplay_; diff --git a/ui/aura/monitor_manager.cc b/ui/aura/monitor_manager.cc index 3f3b980..206a5c6 100644 --- a/ui/aura/monitor_manager.cc +++ b/ui/aura/monitor_manager.cc @@ -7,32 +7,32 @@ #include <stdio.h> #include "base/logging.h" +#include "ui/aura/display_observer.h" #include "ui/aura/env.h" -#include "ui/aura/monitor_observer.h" #include "ui/aura/root_window.h" #include "ui/aura/root_window_host.h" -#include "ui/gfx/monitor.h" +#include "ui/gfx/display.h" #include "ui/gfx/rect.h" namespace aura { namespace { // Default bounds for a monitor. -static const int kDefaultHostWindowX = 200; -static const int kDefaultHostWindowY = 200; -static const int kDefaultHostWindowWidth = 1280; -static const int kDefaultHostWindowHeight = 1024; +const int kDefaultHostWindowX = 200; +const int kDefaultHostWindowY = 200; +const int kDefaultHostWindowWidth = 1280; +const int kDefaultHostWindowHeight = 1024; } // namespace // static bool MonitorManager::use_fullscreen_host_window_ = false; // static -gfx::Monitor MonitorManager::CreateMonitorFromSpec(const std::string& spec) { +gfx::Display MonitorManager::CreateMonitorFromSpec(const std::string& spec) { static int synthesized_monitor_id = 1000; gfx::Rect bounds(kDefaultHostWindowX, kDefaultHostWindowY, kDefaultHostWindowWidth, kDefaultHostWindowHeight); int x = 0, y = 0, width, height; - float scale = gfx::Monitor::GetDefaultDeviceScaleFactor(); + float scale = gfx::Display::GetDefaultDeviceScaleFactor(); if (sscanf(spec.c_str(), "%dx%d*%f", &width, &height, &scale) >= 2) { bounds.set_size(gfx::Size(width, height)); } else if (sscanf(spec.c_str(), "%d+%d-%dx%d*%f", &x, &y, &width, &height, @@ -41,10 +41,10 @@ gfx::Monitor MonitorManager::CreateMonitorFromSpec(const std::string& spec) { } else if (use_fullscreen_host_window_) { bounds = gfx::Rect(aura::RootWindowHost::GetNativeScreenSize()); } - gfx::Monitor monitor(synthesized_monitor_id++); - monitor.SetScaleAndBounds(scale, bounds); - DVLOG(1) << "Monitor bounds=" << bounds.ToString() << ", scale=" << scale; - return monitor; + gfx::Display display(synthesized_monitor_id++); + display.SetScaleAndBounds(scale, bounds); + DVLOG(1) << "Display bounds=" << bounds.ToString() << ", scale=" << scale; + return display; } // static @@ -63,27 +63,25 @@ MonitorManager::MonitorManager() { MonitorManager::~MonitorManager() { } -void MonitorManager::AddObserver(MonitorObserver* observer) { +void MonitorManager::AddObserver(DisplayObserver* observer) { observers_.AddObserver(observer); } -void MonitorManager::RemoveObserver(MonitorObserver* observer) { +void MonitorManager::RemoveObserver(DisplayObserver* observer) { observers_.RemoveObserver(observer); } -void MonitorManager::NotifyBoundsChanged(const gfx::Monitor& monitor) { - FOR_EACH_OBSERVER(MonitorObserver, observers_, - OnMonitorBoundsChanged(monitor)); +void MonitorManager::NotifyBoundsChanged(const gfx::Display& display) { + FOR_EACH_OBSERVER(DisplayObserver, observers_, + OnDisplayBoundsChanged(display)); } -void MonitorManager::NotifyMonitorAdded(const gfx::Monitor& monitor) { - FOR_EACH_OBSERVER(MonitorObserver, observers_, - OnMonitorAdded(monitor)); +void MonitorManager::NotifyDisplayAdded(const gfx::Display& display) { + FOR_EACH_OBSERVER(DisplayObserver, observers_, OnDisplayAdded(display)); } -void MonitorManager::NotifyMonitorRemoved(const gfx::Monitor& monitor) { - FOR_EACH_OBSERVER(MonitorObserver, observers_, - OnMonitorRemoved(monitor)); +void MonitorManager::NotifyDisplayRemoved(const gfx::Display& display) { + FOR_EACH_OBSERVER(DisplayObserver, observers_, OnDisplayRemoved(display)); } } // namespace aura diff --git a/ui/aura/monitor_manager.h b/ui/aura/monitor_manager.h index d677243..701cc35 100644 --- a/ui/aura/monitor_manager.h +++ b/ui/aura/monitor_manager.h @@ -14,18 +14,18 @@ #include "ui/aura/aura_export.h" namespace gfx { -class Monitor; +class Display; class Point; class Size; } namespace aura { -class MonitorObserver; +class DisplayObserver; class RootWindow; class Window; // MonitorManager creates, deletes and updates Monitor objects when -// monitor configuration changes, and notifies MonitorObservers about +// monitor configuration changes, and notifies DisplayObservers about // the change. This is owned by Env and its lifetime is longer than // any windows. class AURA_EXPORT MonitorManager { @@ -43,8 +43,8 @@ class AURA_EXPORT MonitorManager { // monitor at the origin of the screen. An empty string creates // the monitor with default size. // The device scale factor can be specified by "*", like "1280x780*2", - // or |gfx::Monitor::GetDefaultDeviceScaleFactor()| will be used if omitted. - static gfx::Monitor CreateMonitorFromSpec(const std::string& spec); + // or |gfx::Display::GetDefaultDeviceScaleFactor()| will be used if omitted. + static gfx::Display CreateMonitorFromSpec(const std::string& spec); // A utility function to create a root window for primary monitor. static RootWindow* CreateRootWindowForPrimaryMonitor(); @@ -52,39 +52,38 @@ class AURA_EXPORT MonitorManager { MonitorManager(); virtual ~MonitorManager(); - // Adds/removes MonitorObservers. - void AddObserver(MonitorObserver* observer); - void RemoveObserver(MonitorObserver* observer); + // Adds/removes DisplayObservers. + void AddObserver(DisplayObserver* observer); + void RemoveObserver(DisplayObserver* observer); // Called when monitor configuration has changed. The new monitor // configurations is passed as a vector of Monitor object, which // contains each monitor's new infomration. virtual void OnNativeMonitorsChanged( - const std::vector<gfx::Monitor>& monitors) = 0; + const std::vector<gfx::Display>& display) = 0; // Create a root window for given |monitor|. virtual RootWindow* CreateRootWindowForMonitor( - const gfx::Monitor& monitor) = 0; + const gfx::Display& display) = 0; - // Returns the monitor at |index|. The monitor at 0 is considered - // "primary". - virtual const gfx::Monitor& GetMonitorAt(size_t index) = 0; + // Returns the display at |index|. The display at 0 is considered "primary". + virtual const gfx::Display& GetMonitorAt(size_t index) = 0; virtual size_t GetNumMonitors() const = 0; - // Returns the monitor object nearest given |window|. - virtual const gfx::Monitor& GetMonitorNearestWindow( + // Returns the display object nearest given |window|. + virtual const gfx::Display& GetMonitorNearestWindow( const Window* window) const = 0; // Returns the monitor object nearest given |pint|. - virtual const gfx::Monitor& GetMonitorNearestPoint( + virtual const gfx::Display& GetMonitorNearestPoint( const gfx::Point& point) const = 0; protected: - // Calls observers' OnMonitorBoundsChanged methods. - void NotifyBoundsChanged(const gfx::Monitor& monitor); - void NotifyMonitorAdded(const gfx::Monitor& monitor); - void NotifyMonitorRemoved(const gfx::Monitor& monitor); + // Calls observers' OnDisplayBoundsChanged methods. + void NotifyBoundsChanged(const gfx::Display& display); + void NotifyDisplayAdded(const gfx::Display& display); + void NotifyDisplayRemoved(const gfx::Display& display); private: // If set before the RootWindow is created, the host window will cover the @@ -92,7 +91,7 @@ class AURA_EXPORT MonitorManager { // switches::kAuraHostWindowSize flag. static bool use_fullscreen_host_window_; - ObserverList<MonitorObserver> observers_; + ObserverList<DisplayObserver> observers_; DISALLOW_COPY_AND_ASSIGN(MonitorManager); }; diff --git a/ui/aura/root_window.cc b/ui/aura/root_window.cc index 88e9f89..3a360b9 100644 --- a/ui/aura/root_window.cc +++ b/ui/aura/root_window.cc @@ -31,7 +31,7 @@ #include "ui/compositor/dip_util.h" #include "ui/compositor/layer.h" #include "ui/compositor/layer_animator.h" -#include "ui/gfx/monitor.h" +#include "ui/gfx/display.h" #include "ui/gfx/point3.h" #include "ui/gfx/screen.h" diff --git a/ui/aura/single_monitor_manager.cc b/ui/aura/single_monitor_manager.cc index 443b9397..12c484f 100644 --- a/ui/aura/single_monitor_manager.cc +++ b/ui/aura/single_monitor_manager.cc @@ -10,7 +10,7 @@ #include "ui/aura/aura_switches.h" #include "ui/aura/root_window.h" #include "ui/aura/root_window_host.h" -#include "ui/gfx/monitor.h" +#include "ui/gfx/display.h" #include "ui/gfx/rect.h" namespace aura { @@ -19,11 +19,11 @@ using std::string; namespace { // Default bounds for the primary monitor. -static const int kDefaultHostWindowX = 200; -static const int kDefaultHostWindowY = 200; -static const int kDefaultHostWindowWidth = 1280; -static const int kDefaultHostWindowHeight = 1024; -} +const int kDefaultHostWindowX = 200; +const int kDefaultHostWindowY = 200; +const int kDefaultHostWindowWidth = 1280; +const int kDefaultHostWindowHeight = 1024; +} // namespace SingleMonitorManager::SingleMonitorManager() : root_window_(NULL) { @@ -36,47 +36,47 @@ SingleMonitorManager::~SingleMonitorManager() { } void SingleMonitorManager::OnNativeMonitorsChanged( - const std::vector<gfx::Monitor>& monitors) { - DCHECK(monitors.size() > 0); + const std::vector<gfx::Display>& displays) { + DCHECK(displays.size() > 0); if (use_fullscreen_host_window()) { - monitor_.SetSize(monitors[0].bounds().size()); - NotifyBoundsChanged(monitor_); + display_.SetSize(displays[0].bounds().size()); + NotifyBoundsChanged(display_); } } RootWindow* SingleMonitorManager::CreateRootWindowForMonitor( - const gfx::Monitor& monitor) { + const gfx::Display& display) { DCHECK(!root_window_); - DCHECK_EQ(monitor_.id(), monitor.id()); - root_window_ = new RootWindow(monitor.bounds()); + DCHECK_EQ(display_.id(), display.id()); + root_window_ = new RootWindow(display.bounds()); root_window_->AddObserver(this); root_window_->Init(); return root_window_; } -const gfx::Monitor& SingleMonitorManager::GetMonitorAt(size_t index) { - return monitor_; +const gfx::Display& SingleMonitorManager::GetMonitorAt(size_t index) { + return display_; } size_t SingleMonitorManager::GetNumMonitors() const { return 1; } -const gfx::Monitor& SingleMonitorManager::GetMonitorNearestWindow( +const gfx::Display& SingleMonitorManager::GetMonitorNearestWindow( const Window* window) const { - return monitor_; + return display_; } -const gfx::Monitor& SingleMonitorManager::GetMonitorNearestPoint( +const gfx::Display& SingleMonitorManager::GetMonitorNearestPoint( const gfx::Point& point) const { - return monitor_; + return display_; } void SingleMonitorManager::OnWindowBoundsChanged( Window* window, const gfx::Rect& old_bounds, const gfx::Rect& new_bounds) { if (!use_fullscreen_host_window()) { Update(new_bounds.size()); - NotifyBoundsChanged(monitor_); + NotifyBoundsChanged(display_); } } @@ -88,11 +88,11 @@ void SingleMonitorManager::OnWindowDestroying(Window* window) { void SingleMonitorManager::Init() { const string size_str = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( switches::kAuraHostWindowSize); - monitor_ = CreateMonitorFromSpec(size_str); + display_ = CreateMonitorFromSpec(size_str); } void SingleMonitorManager::Update(const gfx::Size size) { - monitor_.SetSize(size); + display_.SetSize(size); } } // namespace aura diff --git a/ui/aura/single_monitor_manager.h b/ui/aura/single_monitor_manager.h index b7557ca..fb92140 100644 --- a/ui/aura/single_monitor_manager.h +++ b/ui/aura/single_monitor_manager.h @@ -10,7 +10,7 @@ #include "ui/aura/aura_export.h" #include "ui/aura/monitor_manager.h" #include "ui/aura/window_observer.h" -#include "ui/gfx/monitor.h" +#include "ui/gfx/display.h" namespace gfx { class Rect; @@ -27,16 +27,16 @@ class AURA_EXPORT SingleMonitorManager : public MonitorManager, // MonitorManager overrides: virtual void OnNativeMonitorsChanged( - const std::vector<gfx::Monitor>& monitors) OVERRIDE; + const std::vector<gfx::Display>& display) OVERRIDE; virtual RootWindow* CreateRootWindowForMonitor( - const gfx::Monitor& monitor) OVERRIDE; - virtual const gfx::Monitor& GetMonitorAt(size_t index) OVERRIDE; + const gfx::Display& display) OVERRIDE; + virtual const gfx::Display& GetMonitorAt(size_t index) OVERRIDE; virtual size_t GetNumMonitors() const OVERRIDE; - virtual const gfx::Monitor& GetMonitorNearestWindow( + virtual const gfx::Display& GetMonitorNearestWindow( const Window* window) const OVERRIDE; - virtual const gfx::Monitor& GetMonitorNearestPoint( + virtual const gfx::Display& GetMonitorNearestPoint( const gfx::Point& point) const OVERRIDE; // WindowObserver overrides: @@ -50,7 +50,7 @@ class AURA_EXPORT SingleMonitorManager : public MonitorManager, void Update(const gfx::Size size); RootWindow* root_window_; - gfx::Monitor monitor_; + gfx::Display display_; DISALLOW_COPY_AND_ASSIGN(SingleMonitorManager); }; diff --git a/ui/aura/test/test_screen.cc b/ui/aura/test/test_screen.cc index d242d78..7968e52 100644 --- a/ui/aura/test/test_screen.cc +++ b/ui/aura/test/test_screen.cc @@ -32,21 +32,21 @@ int TestScreen::GetNumMonitors() { return 1; } -gfx::Monitor TestScreen::GetMonitorNearestWindow( +gfx::Display TestScreen::GetMonitorNearestWindow( gfx::NativeWindow window) const { return GetMonitor(); } -gfx::Monitor TestScreen::GetMonitorNearestPoint(const gfx::Point& point) const { +gfx::Display TestScreen::GetMonitorNearestPoint(const gfx::Point& point) const { return GetMonitor(); } -gfx::Monitor TestScreen::GetPrimaryMonitor() const { +gfx::Display TestScreen::GetPrimaryMonitor() const { return GetMonitor(); } -gfx::Monitor TestScreen::GetMonitor() const { - return gfx::Monitor(0, root_window_->bounds()); +gfx::Display TestScreen::GetMonitor() const { + return gfx::Display(0, root_window_->bounds()); } } // namespace aura diff --git a/ui/aura/test/test_screen.h b/ui/aura/test/test_screen.h index 1aedda7..13b29b3 100644 --- a/ui/aura/test/test_screen.h +++ b/ui/aura/test/test_screen.h @@ -23,14 +23,14 @@ class TestScreen : public gfx::ScreenImpl { virtual gfx::Point GetCursorScreenPoint() OVERRIDE; virtual gfx::NativeWindow GetWindowAtCursorScreenPoint() OVERRIDE; virtual int GetNumMonitors() OVERRIDE; - virtual gfx::Monitor GetMonitorNearestWindow( + virtual gfx::Display GetMonitorNearestWindow( gfx::NativeView view) const OVERRIDE; - virtual gfx::Monitor GetMonitorNearestPoint( + virtual gfx::Display GetMonitorNearestPoint( const gfx::Point& point) const OVERRIDE; - virtual gfx::Monitor GetPrimaryMonitor() const OVERRIDE; + virtual gfx::Display GetPrimaryMonitor() const OVERRIDE; private: - gfx::Monitor GetMonitor() const; + gfx::Display GetMonitor() const; aura::RootWindow* root_window_; diff --git a/ui/base/x/events_x.cc b/ui/base/x/events_x.cc index 35f583d..936947a 100644 --- a/ui/base/x/events_x.cc +++ b/ui/base/x/events_x.cc @@ -4,21 +4,21 @@ #include "ui/base/events.h" -#include <X11/Xlib.h> +#include <string.h> #include <X11/extensions/XInput.h> #include <X11/extensions/XInput2.h> -#include <string.h> +#include <X11/Xlib.h> #include "base/command_line.h" #include "base/logging.h" #include "base/message_pump_aurax11.h" #include "ui/base/keycodes/keyboard_code_conversion_x.h" -#include "ui/base/ui_base_switches.h" #include "ui/base/touch/touch_factory.h" +#include "ui/base/ui_base_switches.h" #include "ui/base/x/valuators.h" #include "ui/base/x/x11_util.h" +#include "ui/gfx/display.h" #include "ui/gfx/point.h" -#include "ui/gfx/monitor.h" #include "ui/gfx/rect.h" #include "ui/gfx/screen.h" diff --git a/ui/compositor/dip_util.cc b/ui/compositor/dip_util.cc index c02203a..eff86e2 100644 --- a/ui/compositor/dip_util.cc +++ b/ui/compositor/dip_util.cc @@ -9,10 +9,10 @@ #include "ui/compositor/compositor.h" #include "ui/compositor/compositor_switches.h" #include "ui/compositor/layer.h" -#include "ui/gfx/monitor.h" +#include "ui/gfx/display.h" #include "ui/gfx/point.h" -#include "ui/gfx/size.h" #include "ui/gfx/rect.h" +#include "ui/gfx/size.h" namespace ui { diff --git a/ui/compositor/layer.cc b/ui/compositor/layer.cc index 1031bf1..4ccc9fc 100644 --- a/ui/compositor/layer.cc +++ b/ui/compositor/layer.cc @@ -23,9 +23,9 @@ #include "ui/compositor/dip_util.h" #include "ui/compositor/layer_animator.h" #include "ui/gfx/canvas.h" +#include "ui/gfx/display.h" #include "ui/gfx/interpolated_transform.h" #include "ui/gfx/point3.h" -#include "ui/gfx/monitor.h" namespace { diff --git a/ui/gfx/monitor.cc b/ui/gfx/display.cc index 12d4dab..451cb84 100644 --- a/ui/gfx/monitor.cc +++ b/ui/gfx/display.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ui/gfx/monitor.h" +#include "ui/gfx/display.h" #include "base/command_line.h" #include "base/logging.h" @@ -29,23 +29,23 @@ float GetDefaultDeviceScaleFactorImpl() { } // namespace // static -float Monitor::GetDefaultDeviceScaleFactor() { +float Display::GetDefaultDeviceScaleFactor() { static const float kDefaultDeviceScaleFactor = GetDefaultDeviceScaleFactorImpl(); return kDefaultDeviceScaleFactor; } -Monitor::Monitor() +Display::Display() : id_(-1), device_scale_factor_(GetDefaultDeviceScaleFactor()) { } -Monitor::Monitor(int id) +Display::Display(int id) : id_(id), device_scale_factor_(GetDefaultDeviceScaleFactor()) { } -Monitor::Monitor(int id, const gfx::Rect& bounds) +Display::Display(int id, const gfx::Rect& bounds) : id_(id), bounds_(bounds), work_area_(bounds), @@ -55,17 +55,17 @@ Monitor::Monitor(int id, const gfx::Rect& bounds) #endif } -Monitor::~Monitor() { +Display::~Display() { } -Insets Monitor::GetWorkAreaInsets() const { +Insets Display::GetWorkAreaInsets() const { return gfx::Insets(work_area_.y() - bounds_.y(), work_area_.x() - bounds_.x(), bounds_.bottom() - work_area_.bottom(), bounds_.right() - work_area_.right()); } -void Monitor::SetScaleAndBounds( +void Display::SetScaleAndBounds( float device_scale_factor, const gfx::Rect& bounds_in_pixel) { Insets insets = bounds_.InsetsFrom(work_area_); @@ -73,15 +73,15 @@ void Monitor::SetScaleAndBounds( #if defined(USE_AURA) bounds_in_pixel_ = bounds_in_pixel; #endif - // TODO(oshima): For m19, work area/monitor bounds that chrome/webapps sees + // TODO(oshima): For m19, work area/display bounds that chrome/webapps sees // has (0, 0) origin because it's simpler and enough. Fix this when - // real multi monitor support is implemented. + // real multi display support is implemented. bounds_ = gfx::Rect( bounds_in_pixel.size().Scale(1.0f / device_scale_factor_)); UpdateWorkAreaFromInsets(insets); } -void Monitor::SetSize(const gfx::Size& size_in_pixel) { +void Display::SetSize(const gfx::Size& size_in_pixel) { SetScaleAndBounds( device_scale_factor_, #if defined(USE_AURA) @@ -91,17 +91,17 @@ void Monitor::SetSize(const gfx::Size& size_in_pixel) { #endif } -void Monitor::UpdateWorkAreaFromInsets(const gfx::Insets& insets) { +void Display::UpdateWorkAreaFromInsets(const gfx::Insets& insets) { work_area_ = bounds_; work_area_.Inset(insets); } -gfx::Size Monitor::GetSizeInPixel() const { +gfx::Size Display::GetSizeInPixel() const { return size().Scale(device_scale_factor_); } -std::string Monitor::ToString() const { - return base::StringPrintf("Monitor[%d] bounds=%s, workarea=%s, scale=%f", +std::string Display::ToString() const { + return base::StringPrintf("Display[%d] bounds=%s, workarea=%s, scale=%f", id_, bounds_.ToString().c_str(), work_area_.ToString().c_str(), diff --git a/ui/gfx/monitor.h b/ui/gfx/display.h index 7428771..13aaa8f 100644 --- a/ui/gfx/monitor.h +++ b/ui/gfx/display.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef UI_GFX_MONITOR_H_ -#define UI_GFX_MONITOR_H_ +#ifndef UI_GFX_DISPLAY_H_ +#define UI_GFX_DISPLAY_H_ #pragma once #include "base/basictypes.h" @@ -13,43 +13,43 @@ namespace gfx { -// Note: The screen and monitor currently uses pixel coordinate +// Note: The screen and display currently uses pixel coordinate // system. For platforms that support DIP (density independent pixel), // |bounds()| and |work_area| will return values in DIP coordinate // system, not in backing pixels. -class UI_EXPORT Monitor { +class UI_EXPORT Display { public: // Returns the default value for the device scale factor, which is // given by "--default-device-scale-factor". static float GetDefaultDeviceScaleFactor(); - // Creates a monitor with invalid id(-1) as default. - Monitor(); - explicit Monitor(int id); - Monitor(int id, const Rect& bounds); - ~Monitor(); + // Creates a display with invalid id(-1) as default. + Display(); + explicit Display(int id); + Display(int id, const Rect& bounds); + ~Display(); - // Sets/Gets unique identifier associated with the monitor. + // Sets/Gets unique identifier associated with the display. int id() const { return id_; } void set_id(int id) { id_ = id; } - // Gets/Sets the monitor's bounds in gfx::Screen's coordinates. - // -1 means invalid monitor and it doesn't not exit. + // Gets/Sets the display's bounds in gfx::Screen's coordinates. + // -1 means invalid display and it doesn't not exit. const Rect& bounds() const { return bounds_; } void set_bounds(const Rect& bounds) { bounds_ = bounds; } - // Gets/Sets the monitor's work area in gfx::Screen's coordinates. + // Gets/Sets the display's work area in gfx::Screen's coordinates. const Rect& work_area() const { return work_area_; } void set_work_area(const Rect& work_area) { work_area_ = work_area; } // Output device's pixel scale factor. This specifies how much the // UI should be scaled when the actual output has more pixels than - // standard monitors (which is around 100~120dpi.) The potential return + // standard displays (which is around 100~120dpi.) The potential return // values depend on each platforms. float device_scale_factor() const { return device_scale_factor_; } void set_device_scale_factor(float scale) { device_scale_factor_ = scale; } - // Utility functions that just return the size of monitor and + // Utility functions that just return the size of display and // work area. const Size& size() const { return bounds_.size(); } const Size& work_area_size() const { return work_area_.size(); } @@ -57,32 +57,32 @@ class UI_EXPORT Monitor { // Returns the work area insets. Insets GetWorkAreaInsets() const; - // Sets the device scale factor and monitor bounds in pixel. This + // Sets the device scale factor and display bounds in pixel. This // updates the work are using the same insets between old bounds and // work area. void SetScaleAndBounds(float device_scale_factor, const gfx::Rect& bounds_in_pixel); - // Sets the monitor's size. This updates the work area using the same insets + // Sets the display's size. This updates the work area using the same insets // between old bounds and work area. void SetSize(const gfx::Size& size_in_pixel); - // Computes and updates the monitor's work are using + // Computes and updates the display's work are using // |work_area_insets| and the bounds. void UpdateWorkAreaFromInsets(const gfx::Insets& work_area_insets); - // Returns the monitor's size in pixel coordinates. + // Returns the display's size in pixel coordinates. gfx::Size GetSizeInPixel() const; #if defined(USE_AURA) // TODO(oshima): |bounds()| on ash is not screen's coordinate and // this is an workaround for this. This will be removed when ash - // has true multi monitor support. crbug.com/119268. - // Returns the monitor's bounds in pixel coordinates. + // has true multi display support. crbug.com/119268. + // Returns the display's bounds in pixel coordinates. const Rect& bounds_in_pixel() const { return bounds_in_pixel_; } #endif - // Returns a string representation of the monitor; + // Returns a string representation of the display; std::string ToString() const; private: @@ -97,4 +97,4 @@ class UI_EXPORT Monitor { } // namespace gfx -#endif // UI_GFX_MONITOR_H_ +#endif // UI_GFX_DISPLAY_H_ diff --git a/ui/gfx/display_unittest.cc b/ui/gfx/display_unittest.cc new file mode 100644 index 0000000..39a5fb6 --- /dev/null +++ b/ui/gfx/display_unittest.cc @@ -0,0 +1,49 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ui/gfx/display.h" + +#include "testing/gtest/include/gtest/gtest.h" +#include "ui/gfx/insets.h" + +namespace { + +TEST(DisplayTest, WorkArea) { + gfx::Display display(0, gfx::Rect(0, 0, 100, 100)); + EXPECT_EQ("0,0 100x100", display.bounds().ToString()); + EXPECT_EQ("0,0 100x100", display.work_area().ToString()); + + display.set_work_area(gfx::Rect(3, 4, 90, 80)); + EXPECT_EQ("0,0 100x100", display.bounds().ToString()); + EXPECT_EQ("3,4 90x80", display.work_area().ToString()); + + display.SetScaleAndBounds(1.0f, gfx::Rect(10, 20, 50, 50)); + EXPECT_EQ("0,0 50x50", display.bounds().ToString()); + EXPECT_EQ("3,4 40x30", display.work_area().ToString()); + + display.SetSize(gfx::Size(200, 200)); + EXPECT_EQ("3,4 190x180", display.work_area().ToString()); + + display.UpdateWorkAreaFromInsets(gfx::Insets(3, 4, 5, 6)); + EXPECT_EQ("4,3 190x192", display.work_area().ToString()); +} + +TEST(DisplayTest, Scale) { + gfx::Display display(0, gfx::Rect(0, 0, 100, 100)); + display.set_work_area(gfx::Rect(10, 10, 80, 80)); + EXPECT_EQ("0,0 100x100", display.bounds().ToString()); + EXPECT_EQ("10,10 80x80", display.work_area().ToString()); + + // Scale it back to 2x + display.SetScaleAndBounds(2.0f, gfx::Rect(0, 0, 140, 140)); + EXPECT_EQ("0,0 70x70", display.bounds().ToString()); + EXPECT_EQ("10,10 50x50", display.work_area().ToString()); + + // Scale it back to 1x + display.SetScaleAndBounds(1.0f, gfx::Rect(0, 0, 100, 100)); + EXPECT_EQ("0,0 100x100", display.bounds().ToString()); + EXPECT_EQ("10,10 80x80", display.work_area().ToString()); +} + +} diff --git a/ui/gfx/monitor_unittest.cc b/ui/gfx/monitor_unittest.cc deleted file mode 100644 index ae129d4..0000000 --- a/ui/gfx/monitor_unittest.cc +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ui/gfx/monitor.h" - -#include "testing/gtest/include/gtest/gtest.h" -#include "ui/gfx/insets.h" - -namespace { - -TEST(MonitorTest, WorkArea) { - gfx::Monitor monitor(0, gfx::Rect(0, 0, 100, 100)); - EXPECT_EQ("0,0 100x100", monitor.bounds().ToString()); - EXPECT_EQ("0,0 100x100", monitor.work_area().ToString()); - - monitor.set_work_area(gfx::Rect(3, 4, 90, 80)); - EXPECT_EQ("0,0 100x100", monitor.bounds().ToString()); - EXPECT_EQ("3,4 90x80", monitor.work_area().ToString()); - - monitor.SetScaleAndBounds(1.0f, gfx::Rect(10, 20, 50, 50)); - EXPECT_EQ("0,0 50x50", monitor.bounds().ToString()); - EXPECT_EQ("3,4 40x30", monitor.work_area().ToString()); - - monitor.SetSize(gfx::Size(200, 200)); - EXPECT_EQ("3,4 190x180", monitor.work_area().ToString()); - - monitor.UpdateWorkAreaFromInsets(gfx::Insets(3, 4, 5, 6)); - EXPECT_EQ("4,3 190x192", monitor.work_area().ToString()); -} - -TEST(MonitorTest, Scale) { - gfx::Monitor monitor(0, gfx::Rect(0, 0, 100, 100)); - monitor.set_work_area(gfx::Rect(10, 10, 80, 80)); - EXPECT_EQ("0,0 100x100", monitor.bounds().ToString()); - EXPECT_EQ("10,10 80x80", monitor.work_area().ToString()); - - // Scale it back to 2x - monitor.SetScaleAndBounds(2.0f, gfx::Rect(0, 0, 140, 140)); - EXPECT_EQ("0,0 70x70", monitor.bounds().ToString()); - EXPECT_EQ("10,10 50x50", monitor.work_area().ToString()); - - // Scale it back to 1x - monitor.SetScaleAndBounds(1.0f, gfx::Rect(0, 0, 100, 100)); - EXPECT_EQ("0,0 100x100", monitor.bounds().ToString()); - EXPECT_EQ("10,10 80x80", monitor.work_area().ToString()); -} - -} diff --git a/ui/gfx/screen.h b/ui/gfx/screen.h index 286ef94..12ecb6c 100644 --- a/ui/gfx/screen.h +++ b/ui/gfx/screen.h @@ -7,8 +7,8 @@ #pragma once #include "ui/base/ui_export.h" +#include "ui/gfx/display.h" #include "ui/gfx/native_widget_types.h" -#include "ui/gfx/monitor.h" #include "ui/gfx/point.h" namespace gfx { @@ -42,17 +42,17 @@ class UI_EXPORT Screen { // number of distinct, usable displays. static int GetNumMonitors(); - // Returns the monitor nearest the specified window. - static gfx::Monitor GetMonitorNearestWindow(gfx::NativeView view); + // Returns the display nearest the specified window. + static gfx::Display GetMonitorNearestWindow(gfx::NativeView view); - // Returns the the monitor nearest the specified point. - static gfx::Monitor GetMonitorNearestPoint(const gfx::Point& point); + // Returns the the display nearest the specified point. + static gfx::Display GetMonitorNearestPoint(const gfx::Point& point); // Returns the bounds of the work area of the primary monitor. - static gfx::Monitor GetPrimaryMonitor(); + static gfx::Display GetPrimaryMonitor(); - // Returns the monitor that most closely intersects the provided bounds. - static gfx::Monitor GetMonitorMatching(const gfx::Rect& match_rect); + // Returns the display that most closely intersects the provided bounds. + static gfx::Display GetMonitorMatching(const gfx::Rect& match_rect); }; } // namespace gfx diff --git a/ui/gfx/screen_android.cc b/ui/gfx/screen_android.cc index cbeb6c7..fa30aef 100644 --- a/ui/gfx/screen_android.cc +++ b/ui/gfx/screen_android.cc @@ -5,7 +5,7 @@ #include "ui/gfx/screen.h" #include "base/logging.h" -#include "ui/gfx/monitor.h" +#include "ui/gfx/display.h" namespace gfx { @@ -15,13 +15,13 @@ bool Screen::IsDIPEnabled() { } // static -gfx::Monitor Screen::GetPrimaryMonitor() { +gfx::Display Screen::GetPrimaryMonitor() { NOTIMPLEMENTED() << "crbug.com/117839 tracks implementation"; - return gfx::Monitor(0, gfx::Rect(0, 0, 1, 1)); + return gfx::Display(0, gfx::Rect(0, 0, 1, 1)); } // static -gfx::Monitor Screen::GetMonitorNearestWindow(gfx::NativeView view) { +gfx::Display Screen::GetMonitorNearestWindow(gfx::NativeView view) { return GetPrimaryMonitor(); } diff --git a/ui/gfx/screen_aura.cc b/ui/gfx/screen_aura.cc index 7341a0e..3298ba1 100644 --- a/ui/gfx/screen_aura.cc +++ b/ui/gfx/screen_aura.cc @@ -5,7 +5,7 @@ #include "ui/gfx/screen.h" #include "base/logging.h" -#include "ui/gfx/monitor.h" +#include "ui/gfx/display.h" #include "ui/gfx/native_widget_types.h" #include "ui/gfx/screen_impl.h" @@ -47,22 +47,22 @@ int Screen::GetNumMonitors() { } // static -Monitor Screen::GetMonitorNearestWindow(NativeView window) { +Display Screen::GetMonitorNearestWindow(NativeView window) { return g_instance_->GetMonitorNearestWindow(window); } // static -Monitor Screen::GetMonitorNearestPoint(const Point& point) { +Display Screen::GetMonitorNearestPoint(const Point& point) { return g_instance_->GetMonitorNearestPoint(point); } // static -Monitor Screen::GetPrimaryMonitor() { +Display Screen::GetPrimaryMonitor() { return g_instance_->GetPrimaryMonitor(); } // static -Monitor Screen::GetMonitorMatching(const gfx::Rect& match_rect) { +Display Screen::GetMonitorMatching(const gfx::Rect& match_rect) { return g_instance_->GetMonitorNearestPoint(match_rect.CenterPoint()); } diff --git a/ui/gfx/screen_gtk.cc b/ui/gfx/screen_gtk.cc index 4df13b6..1bc577f 100644 --- a/ui/gfx/screen_gtk.cc +++ b/ui/gfx/screen_gtk.cc @@ -8,7 +8,7 @@ #include <gtk/gtk.h> #include "base/logging.h" -#include "ui/gfx/monitor.h" +#include "ui/gfx/display.h" namespace { @@ -103,7 +103,7 @@ gfx::NativeWindow Screen::GetWindowAtCursorScreenPoint() { } // static -gfx::Monitor Screen::GetMonitorNearestWindow(gfx::NativeView view) { +gfx::Display Screen::GetMonitorNearestWindow(gfx::NativeView view) { gfx::Rect bounds = GetMonitorAreaNearestWindow(view); // Do not use the _NET_WORKAREA here, this is supposed to be an area on a // specific monitor, and _NET_WORKAREA is a hint from the WM that generally @@ -113,38 +113,38 @@ gfx::Monitor Screen::GetMonitorNearestWindow(gfx::NativeView view) { // area, but it is a rect that we should be computing. The standard means // to compute this rect would be to watch all windows with // _NET_WM_STRUT(_PARTIAL) hints, and subtract their space from the physical - // area of the monitor to construct a work area. + // area of the display to construct a work area. // TODO(oshima): Implement ID and Observer. - return gfx::Monitor(0, bounds); + return gfx::Display(0, bounds); } // static -gfx::Monitor Screen::GetMonitorNearestPoint(const gfx::Point& point) { +gfx::Display Screen::GetMonitorNearestPoint(const gfx::Point& point) { GdkScreen* screen = gdk_screen_get_default(); gint monitor = gdk_screen_get_monitor_at_point(screen, point.x(), point.y()); GdkRectangle bounds; gdk_screen_get_monitor_geometry(screen, monitor, &bounds); // TODO(oshima): Implement ID and Observer. - return gfx::Monitor(0, gfx::Rect(bounds)); + return gfx::Display(0, gfx::Rect(bounds)); } // static -gfx::Monitor Screen::GetPrimaryMonitor() { +gfx::Display Screen::GetPrimaryMonitor() { gfx::Rect bounds = NativePrimaryMonitorBounds(); // TODO(oshima): Implement ID and Observer. - gfx::Monitor monitor(0, bounds); + gfx::Display display(0, bounds); gfx::Rect rect; if (GetScreenWorkArea(&rect)) { - monitor.set_work_area(rect.Intersect(bounds)); + display.set_work_area(rect.Intersect(bounds)); } else { // Return the best we've got. - monitor.set_work_area(bounds); + display.set_work_area(bounds); } - return monitor; + return display; } // static -gfx::Monitor Screen::GetMonitorMatching(const gfx::Rect& match_rect) { +gfx::Display Screen::GetMonitorMatching(const gfx::Rect& match_rect) { // TODO(thestig) Implement multi-monitor support. return GetPrimaryMonitor(); } diff --git a/ui/gfx/screen_impl.h b/ui/gfx/screen_impl.h index 2511541..26bd02d 100644 --- a/ui/gfx/screen_impl.h +++ b/ui/gfx/screen_impl.h @@ -6,8 +6,8 @@ #define UI_GFX_SCREEN_IMPL_H_ #pragma once +#include "ui/gfx/display.h" #include "ui/gfx/native_widget_types.h" -#include "ui/gfx/monitor.h" #include "ui/gfx/point.h" namespace gfx { @@ -21,11 +21,11 @@ class UI_EXPORT ScreenImpl { virtual gfx::NativeWindow GetWindowAtCursorScreenPoint() = 0; virtual int GetNumMonitors() = 0; - virtual gfx::Monitor GetMonitorNearestWindow( + virtual gfx::Display GetMonitorNearestWindow( gfx::NativeView window) const = 0; - virtual gfx::Monitor GetMonitorNearestPoint( + virtual gfx::Display GetMonitorNearestPoint( const gfx::Point& point) const = 0; - virtual gfx::Monitor GetPrimaryMonitor() const = 0; + virtual gfx::Display GetPrimaryMonitor() const = 0; }; } // namespace gfx diff --git a/ui/gfx/screen_mac.mm b/ui/gfx/screen_mac.mm index 1ef154e..5c6d3a1 100644 --- a/ui/gfx/screen_mac.mm +++ b/ui/gfx/screen_mac.mm @@ -12,7 +12,7 @@ @end #include "base/logging.h" -#include "ui/gfx/monitor.h" +#include "ui/gfx/display.h" namespace { @@ -45,10 +45,10 @@ NSScreen* GetMatchingScreen(const gfx::Rect& match_rect) { return max_screen; } -gfx::Monitor GetMonitorForScreen(NSScreen* screen, bool is_primary) { +gfx::Display GetDisplayForScreen(NSScreen* screen, bool is_primary) { NSRect frame = [screen frame]; // TODO(oshima): Implement ID and Observer. - gfx::Monitor monitor(0, gfx::Rect(NSRectToCGRect(frame))); + gfx::Display display(0, gfx::Rect(NSRectToCGRect(frame))); NSRect visible_frame = [screen visibleFrame]; @@ -57,17 +57,17 @@ gfx::Monitor GetMonitorForScreen(NSScreen* screen, bool is_primary) { gfx::Rect work_area = gfx::Rect(NSRectToCGRect(visible_frame)); work_area.set_y(frame.size.height - visible_frame.origin.y - visible_frame.size.height); - monitor.set_work_area(work_area); + display.set_work_area(work_area); } else { - monitor.set_work_area(ConvertCoordinateSystem(visible_frame)); + display.set_work_area(ConvertCoordinateSystem(visible_frame)); } CGFloat scale; if ([screen respondsToSelector:@selector(backingScaleFactor)]) scale = [screen backingScaleFactor]; else scale = [screen userSpaceScaleFactor]; - monitor.set_device_scale_factor(scale); - return monitor; + display.set_device_scale_factor(scale); + return display; } } // namespace @@ -89,27 +89,27 @@ gfx::Point Screen::GetCursorScreenPoint() { } // static -gfx::Monitor Screen::GetMonitorNearestWindow(gfx::NativeView view) { +gfx::Display Screen::GetMonitorNearestWindow(gfx::NativeView view) { NSWindow* window = [view window]; if (!window) return GetPrimaryMonitor(); NSScreen* match_screen = [window screen]; - return GetMonitorForScreen(match_screen, false /* may not be primary */); + return GetDisplayForScreen(match_screen, false /* may not be primary */); } // static -gfx::Monitor Screen::GetPrimaryMonitor() { - // Primary monitor is defined as the monitor with the menubar, +gfx::Display Screen::GetPrimaryMonitor() { + // Primary display is defined as the display with the menubar, // which is always at index 0. NSScreen* primary = [[NSScreen screens] objectAtIndex:0]; - gfx::Monitor monitor = GetMonitorForScreen(primary, true /* primary */); - return monitor; + gfx::Display display = GetDisplayForScreen(primary, true /* primary */); + return display; } // static -gfx::Monitor Screen::GetMonitorMatching(const gfx::Rect& match_rect) { +gfx::Display Screen::GetMonitorMatching(const gfx::Rect& match_rect) { NSScreen* match_screen = GetMatchingScreen(match_rect); - return GetMonitorForScreen(match_screen, false /* may not be primary */); + return GetDisplayForScreen(match_screen, false /* may not be primary */); } // static diff --git a/ui/gfx/screen_win.cc b/ui/gfx/screen_win.cc index 3c868c6..ee24bdd 100644 --- a/ui/gfx/screen_win.cc +++ b/ui/gfx/screen_win.cc @@ -7,7 +7,7 @@ #include <windows.h> #include "base/logging.h" -#include "ui/gfx/monitor.h" +#include "ui/gfx/display.h" namespace { @@ -18,11 +18,11 @@ MONITORINFO GetMonitorInfoForMonitor(HMONITOR monitor) { return monitor_info; } -gfx::Monitor GetMonitor(MONITORINFO& monitor_info) { +gfx::Display GetDisplay(MONITORINFO& monitor_info) { // TODO(oshima): Implement ID and Observer. - gfx::Monitor monitor(0, gfx::Rect(monitor_info.rcMonitor)); - monitor.set_work_area(gfx::Rect(monitor_info.rcWork)); - return monitor; + gfx::Display display(0, gfx::Rect(monitor_info.rcMonitor)); + display.set_work_area(gfx::Rect(monitor_info.rcWork)); + return display; } } // namespace @@ -53,41 +53,41 @@ int Screen::GetNumMonitors() { } // static -gfx::Monitor Screen::GetMonitorNearestWindow(gfx::NativeView window) { +gfx::Display Screen::GetMonitorNearestWindow(gfx::NativeView window) { MONITORINFO monitor_info; monitor_info.cbSize = sizeof(monitor_info); GetMonitorInfo(MonitorFromWindow(window, MONITOR_DEFAULTTONEAREST), &monitor_info); - return GetMonitor(monitor_info); + return GetDisplay(monitor_info); } // static -gfx::Monitor Screen::GetMonitorNearestPoint(const gfx::Point& point) { +gfx::Display Screen::GetMonitorNearestPoint(const gfx::Point& point) { POINT initial_loc = { point.x(), point.y() }; HMONITOR monitor = MonitorFromPoint(initial_loc, MONITOR_DEFAULTTONEAREST); MONITORINFO mi = {0}; mi.cbSize = sizeof(mi); if (monitor && GetMonitorInfo(monitor, &mi)) - return GetMonitor(mi); - return gfx::Monitor(); + return GetDisplay(mi); + return gfx::Display(); } // static -gfx::Monitor Screen::GetPrimaryMonitor() { +gfx::Display Screen::GetPrimaryMonitor() { MONITORINFO mi = GetMonitorInfoForMonitor( MonitorFromWindow(NULL, MONITOR_DEFAULTTOPRIMARY)); - gfx::Monitor monitor = GetMonitor(mi); - DCHECK_EQ(GetSystemMetrics(SM_CXSCREEN), monitor.size().width()); - DCHECK_EQ(GetSystemMetrics(SM_CYSCREEN), monitor.size().height()); - return monitor; + gfx::Display display = GetDisplay(mi); + DCHECK_EQ(GetSystemMetrics(SM_CXSCREEN), display.size().width()); + DCHECK_EQ(GetSystemMetrics(SM_CYSCREEN), display.size().height()); + return display; } // static -gfx::Monitor Screen::GetMonitorMatching(const gfx::Rect& match_rect) { +gfx::Display Screen::GetMonitorMatching(const gfx::Rect& match_rect) { RECT other_bounds_rect = match_rect.ToRECT(); MONITORINFO monitor_info = GetMonitorInfoForMonitor(MonitorFromRect( &other_bounds_rect, MONITOR_DEFAULTTONEAREST)); - return GetMonitor(monitor_info); + return GetDisplay(monitor_info); } } // namespace gfx @@ -321,6 +321,8 @@ 'gfx/color_analysis.h', 'gfx/color_utils.cc', 'gfx/color_utils.h', + 'gfx/display.cc', + 'gfx/display.h', 'gfx/favicon_size.cc', 'gfx/favicon_size.h', 'gfx/font.h', @@ -345,8 +347,6 @@ 'gfx/mac/nsimage_cache.h', 'gfx/mac/nsimage_cache.mm', 'gfx/mac/scoped_ns_disable_screen_updates.h', - 'gfx/monitor.cc', - 'gfx/monitor.h', 'gfx/native_widget_types.h', 'gfx/pango_util.h', 'gfx/pango_util.cc', diff --git a/ui/ui_unittests.gypi b/ui/ui_unittests.gypi index f05215c..ef3dfb1 100644 --- a/ui/ui_unittests.gypi +++ b/ui/ui_unittests.gypi @@ -91,6 +91,7 @@ 'gfx/codec/png_codec_unittest.cc', 'gfx/color_analysis_unittest.cc', 'gfx/color_utils_unittest.cc', + 'gfx/display_unittest.cc', 'gfx/font_list_unittest.cc', 'gfx/font_unittest.cc', 'gfx/image/image_mac_unittest.mm', @@ -98,7 +99,6 @@ 'gfx/image/image_unittest_util.cc', 'gfx/image/image_unittest_util.h', 'gfx/insets_unittest.cc', - 'gfx/monitor_unittest.cc', 'gfx/rect_unittest.cc', 'gfx/screen_unittest.cc', 'gfx/shadow_value_unittest.cc', diff --git a/ui/views/widget/native_widget_aura.h b/ui/views/widget/native_widget_aura.h index 8b4c7c5..1907e08 100644 --- a/ui/views/widget/native_widget_aura.h +++ b/ui/views/widget/native_widget_aura.h @@ -16,7 +16,6 @@ #include "ui/views/widget/native_widget_private.h" namespace aura { -class Monitor; class Window; } namespace gfx { |