| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/screen_ash.h" | 5 #include "ash/screen_ash.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "ui/aura/env.h" |
| 9 #include "ui/aura/monitor.h" |
| 10 #include "ui/aura/monitor_manager.h" |
| 8 #include "ui/aura/root_window.h" | 11 #include "ui/aura/root_window.h" |
| 9 #include "ui/aura/window.h" | |
| 10 #include "ui/gfx/native_widget_types.h" | |
| 11 | 12 |
| 12 namespace ash { | 13 namespace ash { |
| 13 | 14 |
| 15 namespace { |
| 16 const aura::MonitorManager* GetMonitorManager() { |
| 17 return aura::Env::GetInstance()->monitor_manager(); |
| 18 } |
| 19 } // namespace |
| 20 |
| 14 ScreenAsh::ScreenAsh(aura::RootWindow* root_window) | 21 ScreenAsh::ScreenAsh(aura::RootWindow* root_window) |
| 15 : root_window_(root_window) { | 22 : root_window_(root_window) { |
| 16 } | 23 } |
| 17 | 24 |
| 18 ScreenAsh::~ScreenAsh() { | 25 ScreenAsh::~ScreenAsh() { |
| 19 } | 26 } |
| 20 | 27 |
| 21 gfx::Point ScreenAsh::GetCursorScreenPointImpl() { | 28 gfx::Point ScreenAsh::GetCursorScreenPointImpl() { |
| 22 return root_window_->last_mouse_location(); | 29 return root_window_->last_mouse_location(); |
| 23 } | 30 } |
| 24 | 31 |
| 25 gfx::Rect ScreenAsh::GetMonitorWorkAreaNearestWindowImpl( | 32 gfx::Rect ScreenAsh::GetMonitorWorkAreaNearestWindowImpl( |
| 26 gfx::NativeWindow window) { | 33 gfx::NativeWindow window) { |
| 27 return GetWorkAreaBounds(); | 34 return GetMonitorManager()->GetMonitorNearestWindow(window)-> |
| 35 GetWorkAreaBounds(); |
| 28 } | 36 } |
| 29 | 37 |
| 30 gfx::Rect ScreenAsh::GetMonitorAreaNearestWindowImpl( | 38 gfx::Rect ScreenAsh::GetMonitorAreaNearestWindowImpl( |
| 31 gfx::NativeWindow window) { | 39 gfx::NativeWindow window) { |
| 32 return GetBounds(); | 40 return GetMonitorManager()->GetMonitorNearestWindow(window)->bounds(); |
| 33 } | 41 } |
| 34 | 42 |
| 35 gfx::Rect ScreenAsh::GetMonitorWorkAreaNearestPointImpl( | 43 gfx::Rect ScreenAsh::GetMonitorWorkAreaNearestPointImpl( |
| 36 const gfx::Point& point) { | 44 const gfx::Point& point) { |
| 37 return GetWorkAreaBounds(); | 45 return GetMonitorManager()->GetMonitorNearestPoint(point)-> |
| 46 GetWorkAreaBounds(); |
| 38 } | 47 } |
| 39 | 48 |
| 40 gfx::Rect ScreenAsh::GetMonitorAreaNearestPointImpl(const gfx::Point& point) { | 49 gfx::Rect ScreenAsh::GetMonitorAreaNearestPointImpl(const gfx::Point& point) { |
| 41 return GetBounds(); | 50 return GetMonitorManager()->GetMonitorNearestPoint(point)->bounds(); |
| 42 } | 51 } |
| 43 | 52 |
| 44 gfx::NativeWindow ScreenAsh::GetWindowAtCursorScreenPointImpl() { | 53 gfx::NativeWindow ScreenAsh::GetWindowAtCursorScreenPointImpl() { |
| 45 const gfx::Point point = GetCursorScreenPoint(); | 54 const gfx::Point point = GetCursorScreenPoint(); |
| 46 return root_window_->GetTopWindowContainingPoint(point); | 55 return root_window_->GetTopWindowContainingPoint(point); |
| 47 } | 56 } |
| 48 | 57 |
| 49 gfx::Rect ScreenAsh::GetBounds() { | |
| 50 return gfx::Rect(root_window_->bounds().size()); | |
| 51 } | |
| 52 | |
| 53 gfx::Rect ScreenAsh::GetWorkAreaBounds() { | |
| 54 gfx::Rect bounds(GetBounds()); | |
| 55 bounds.Inset(work_area_insets_); | |
| 56 return bounds; | |
| 57 } | |
| 58 | |
| 59 gfx::Size ScreenAsh::GetPrimaryMonitorSizeImpl() { | 58 gfx::Size ScreenAsh::GetPrimaryMonitorSizeImpl() { |
| 60 return GetMonitorWorkAreaNearestPoint(gfx::Point()).size(); | 59 return GetMonitorManager()->GetPrimaryMonitor()->size(); |
| 61 } | 60 } |
| 62 | 61 |
| 63 int ScreenAsh::GetNumMonitorsImpl() { | 62 int ScreenAsh::GetNumMonitorsImpl() { |
| 64 return 1; | 63 return GetMonitorManager()->GetNumMonitors(); |
| 65 } | 64 } |
| 66 | 65 |
| 67 } // namespace ash | 66 } // namespace ash |
| OLD | NEW |