OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/display/screen_ash.h" | 5 #include "ash/display/screen_ash.h" |
6 | 6 |
7 #include "ash/display/display_controller.h" | 7 #include "ash/display/display_controller.h" |
8 #include "ash/display/display_manager.h" | 8 #include "ash/display/display_manager.h" |
9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
10 #include "ash/root_window_settings.h" | 10 #include "ash/root_window_settings.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 }; | 106 }; |
107 | 107 |
108 } // namespace | 108 } // namespace |
109 | 109 |
110 ScreenAsh::ScreenAsh() { | 110 ScreenAsh::ScreenAsh() { |
111 } | 111 } |
112 | 112 |
113 ScreenAsh::~ScreenAsh() { | 113 ScreenAsh::~ScreenAsh() { |
114 } | 114 } |
115 | 115 |
116 // static | |
117 gfx::Display ScreenAsh::FindDisplayContainingPoint(const gfx::Point& point) { | |
118 return GetDisplayManager()->FindDisplayContainingPoint(point); | |
119 } | |
120 | |
121 // static | |
122 gfx::Rect ScreenAsh::GetMaximizedWindowBoundsInParent(aura::Window* window) { | |
123 if (GetRootWindowController(window->GetRootWindow())->shelf()) | |
124 return GetDisplayWorkAreaBoundsInParent(window); | |
125 else | |
126 return GetDisplayBoundsInParent(window); | |
127 } | |
128 | |
129 // static | |
130 gfx::Rect ScreenAsh::GetDisplayBoundsInParent(aura::Window* window) { | |
131 return ConvertRectFromScreen( | |
132 window->parent(), | |
133 Shell::GetScreen()->GetDisplayNearestWindow(window).bounds()); | |
134 } | |
135 | |
136 // static | |
137 gfx::Rect ScreenAsh::GetDisplayWorkAreaBoundsInParent(aura::Window* window) { | |
138 return ConvertRectFromScreen( | |
139 window->parent(), | |
140 Shell::GetScreen()->GetDisplayNearestWindow(window).work_area()); | |
141 } | |
142 | |
143 // static | |
144 gfx::Rect ScreenAsh::ConvertRectToScreen(aura::Window* window, | |
145 const gfx::Rect& rect) { | |
146 gfx::Point point = rect.origin(); | |
147 aura::client::GetScreenPositionClient(window->GetRootWindow())-> | |
148 ConvertPointToScreen(window, &point); | |
149 return gfx::Rect(point, rect.size()); | |
150 } | |
151 | |
152 // static | |
153 gfx::Rect ScreenAsh::ConvertRectFromScreen(aura::Window* window, | |
154 const gfx::Rect& rect) { | |
155 gfx::Point point = rect.origin(); | |
156 aura::client::GetScreenPositionClient(window->GetRootWindow())-> | |
157 ConvertPointFromScreen(window, &point); | |
158 return gfx::Rect(point, rect.size()); | |
159 } | |
160 | |
161 // static | |
162 const gfx::Display& ScreenAsh::GetSecondaryDisplay() { | |
163 DisplayManager* display_manager = GetDisplayManager(); | |
164 CHECK_EQ(2U, display_manager->GetNumDisplays()); | |
165 return display_manager->GetDisplayAt(0).id() == | |
166 Shell::GetScreen()->GetPrimaryDisplay().id() ? | |
167 display_manager->GetDisplayAt(1) : display_manager->GetDisplayAt(0); | |
168 } | |
169 | |
170 // static | |
171 const gfx::Display& ScreenAsh::GetDisplayForId(int64 display_id) { | |
172 return GetDisplayManager()->GetDisplayForId(display_id); | |
173 } | |
174 | |
175 void ScreenAsh::NotifyMetricsChanged(const gfx::Display& display, | 116 void ScreenAsh::NotifyMetricsChanged(const gfx::Display& display, |
176 uint32_t metrics) { | 117 uint32_t metrics) { |
177 FOR_EACH_OBSERVER(gfx::DisplayObserver, | 118 FOR_EACH_OBSERVER(gfx::DisplayObserver, |
178 observers_, | 119 observers_, |
179 OnDisplayMetricsChanged(display, metrics)); | 120 OnDisplayMetricsChanged(display, metrics)); |
180 } | 121 } |
181 | 122 |
182 void ScreenAsh::NotifyDisplayAdded(const gfx::Display& display) { | 123 void ScreenAsh::NotifyDisplayAdded(const gfx::Display& display) { |
183 FOR_EACH_OBSERVER(gfx::DisplayObserver, observers_, OnDisplayAdded(display)); | 124 FOR_EACH_OBSERVER(gfx::DisplayObserver, observers_, OnDisplayAdded(display)); |
184 } | 125 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 | 201 |
261 void ScreenAsh::RemoveObserver(gfx::DisplayObserver* observer) { | 202 void ScreenAsh::RemoveObserver(gfx::DisplayObserver* observer) { |
262 observers_.RemoveObserver(observer); | 203 observers_.RemoveObserver(observer); |
263 } | 204 } |
264 | 205 |
265 gfx::Screen* ScreenAsh::CloneForShutdown() { | 206 gfx::Screen* ScreenAsh::CloneForShutdown() { |
266 return new ScreenForShutdown(this); | 207 return new ScreenForShutdown(this); |
267 } | 208 } |
268 | 209 |
269 } // namespace ash | 210 } // namespace ash |
OLD | NEW |