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 "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/wm/shelf_layout_manager.h" | 8 #include "ash/wm/shelf_layout_manager.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "ui/aura/env.h" | 10 #include "ui/aura/env.h" |
11 #include "ui/aura/monitor_manager.h" | 11 #include "ui/aura/monitor_manager.h" |
12 #include "ui/aura/root_window.h" | 12 #include "ui/aura/root_window.h" |
13 #include "ui/gfx/monitor.h" | 13 #include "ui/gfx/monitor.h" |
14 #include "ui/gfx/screen.h" | 14 #include "ui/gfx/screen.h" |
15 | 15 |
16 namespace ash { | 16 namespace ash { |
17 | 17 |
18 namespace { | 18 namespace { |
19 aura::MonitorManager* GetMonitorManager() { | 19 aura::MonitorManager* GetMonitorManager() { |
20 return aura::Env::GetInstance()->monitor_manager(); | 20 return aura::Env::GetInstance()->monitor_manager(); |
21 } | 21 } |
22 } // namespace | 22 } // namespace |
23 | 23 |
24 ScreenAsh::ScreenAsh(aura::RootWindow* root_window) | 24 ScreenAsh::ScreenAsh() { |
25 : root_window_(root_window) { | |
26 } | 25 } |
27 | 26 |
28 ScreenAsh::~ScreenAsh() { | 27 ScreenAsh::~ScreenAsh() { |
29 } | 28 } |
30 | 29 |
31 // static | 30 // static |
32 gfx::Rect ScreenAsh::GetMaximizedWindowBounds(aura::Window* window) { | 31 gfx::Rect ScreenAsh::GetMaximizedWindowBounds(aura::Window* window) { |
33 return Shell::GetInstance()->shelf()->GetMaximizedWindowBounds(window); | 32 if (window->GetRootWindow() == Shell::GetPrimaryRootWindow()) |
| 33 return Shell::GetInstance()->shelf()->GetMaximizedWindowBounds(window); |
| 34 else |
| 35 return gfx::Screen::GetMonitorNearestWindow(window).bounds(); |
34 } | 36 } |
35 | 37 |
36 // static | 38 // static |
37 gfx::Rect ScreenAsh::GetUnmaximizedWorkAreaBounds(aura::Window* window) { | 39 gfx::Rect ScreenAsh::GetUnmaximizedWorkAreaBounds(aura::Window* window) { |
38 return Shell::GetInstance()->shelf()->GetUnmaximizedWorkAreaBounds(window); | 40 if (window->GetRootWindow() == Shell::GetPrimaryRootWindow()) |
| 41 return Shell::GetInstance()->shelf()->GetUnmaximizedWorkAreaBounds(window); |
| 42 else |
| 43 return gfx::Screen::GetMonitorNearestWindow(window).work_area(); |
39 } | 44 } |
40 | 45 |
41 gfx::Point ScreenAsh::GetCursorScreenPoint() { | 46 gfx::Point ScreenAsh::GetCursorScreenPoint() { |
42 return root_window_->last_mouse_location(); | 47 // TODO(oshima): Support multiple root window. |
| 48 return Shell::GetPrimaryRootWindow()->last_mouse_location(); |
43 } | 49 } |
44 | 50 |
45 gfx::NativeWindow ScreenAsh::GetWindowAtCursorScreenPoint() { | 51 gfx::NativeWindow ScreenAsh::GetWindowAtCursorScreenPoint() { |
46 const gfx::Point point = gfx::Screen::GetCursorScreenPoint(); | 52 const gfx::Point point = gfx::Screen::GetCursorScreenPoint(); |
47 return root_window_->GetTopWindowContainingPoint(point); | 53 // TODO(oshima): convert point to relateive to the root window. |
| 54 return Shell::GetRootWindowAt(point)->GetTopWindowContainingPoint(point); |
48 } | 55 } |
49 | 56 |
50 int ScreenAsh::GetNumMonitors() { | 57 int ScreenAsh::GetNumMonitors() { |
51 return GetMonitorManager()->GetNumMonitors(); | 58 return GetMonitorManager()->GetNumMonitors(); |
52 } | 59 } |
53 | 60 |
54 gfx::Monitor ScreenAsh::GetMonitorNearestWindow(gfx::NativeView window) const { | 61 gfx::Monitor ScreenAsh::GetMonitorNearestWindow(gfx::NativeView window) const { |
55 return GetMonitorManager()->GetMonitorNearestWindow(window); | 62 return GetMonitorManager()->GetMonitorNearestWindow(window); |
56 } | 63 } |
57 | 64 |
58 gfx::Monitor ScreenAsh::GetMonitorNearestPoint(const gfx::Point& point) const { | 65 gfx::Monitor ScreenAsh::GetMonitorNearestPoint(const gfx::Point& point) const { |
59 return GetMonitorManager()->GetMonitorNearestPoint(point); | 66 return GetMonitorManager()->GetMonitorNearestPoint(point); |
60 } | 67 } |
61 | 68 |
62 gfx::Monitor ScreenAsh::GetPrimaryMonitor() const { | 69 gfx::Monitor ScreenAsh::GetPrimaryMonitor() const { |
63 return GetMonitorManager()->GetMonitorAt(0); | 70 return GetMonitorManager()->GetMonitorAt(0); |
64 } | 71 } |
65 | 72 |
66 } // namespace ash | 73 } // namespace ash |
OLD | NEW |