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" |
11 #include "ash/shelf/shelf_layout_manager.h" | 11 #include "ash/shelf/shelf_layout_manager.h" |
12 #include "ash/shelf/shelf_widget.h" | 12 #include "ash/shelf/shelf_widget.h" |
13 #include "ash/shell.h" | 13 #include "ash/shell.h" |
14 #include "ash/wm/coordinate_conversion.h" | 14 #include "ash/wm/coordinate_conversion.h" |
15 #include "base/logging.h" | 15 #include "base/logging.h" |
16 #include "ui/aura/client/screen_position_client.h" | 16 #include "ui/aura/client/screen_position_client.h" |
17 #include "ui/aura/env.h" | 17 #include "ui/aura/env.h" |
18 #include "ui/aura/window_event_dispatcher.h" | 18 #include "ui/aura/window_event_dispatcher.h" |
19 #include "ui/gfx/display.h" | 19 #include "ui/gfx/display.h" |
20 #include "ui/gfx/screen.h" | 20 #include "ui/gfx/screen.h" |
21 | 21 |
22 namespace ash { | 22 namespace ash { |
23 | 23 |
24 namespace { | 24 namespace { |
25 | 25 |
26 internal::DisplayManager* GetDisplayManager() { | 26 DisplayManager* GetDisplayManager() { |
27 return Shell::GetInstance()->display_manager(); | 27 return Shell::GetInstance()->display_manager(); |
28 } | 28 } |
29 | 29 |
30 gfx::Display FindDisplayNearestPoint(const std::vector<gfx::Display>& displays, | 30 gfx::Display FindDisplayNearestPoint(const std::vector<gfx::Display>& displays, |
31 const gfx::Point& point) { | 31 const gfx::Point& point) { |
32 int min_distance = INT_MAX; | 32 int min_distance = INT_MAX; |
33 const gfx::Display* nearest_display = NULL; | 33 const gfx::Display* nearest_display = NULL; |
34 for (std::vector<gfx::Display>::const_iterator iter = displays.begin(); | 34 for (std::vector<gfx::Display>::const_iterator iter = displays.begin(); |
35 iter != displays.end(); ++iter) { | 35 iter != displays.end(); ++iter) { |
36 const gfx::Display& display = *iter; | 36 const gfx::Display& display = *iter; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 ScreenAsh::~ScreenAsh() { | 129 ScreenAsh::~ScreenAsh() { |
130 } | 130 } |
131 | 131 |
132 // static | 132 // static |
133 gfx::Display ScreenAsh::FindDisplayContainingPoint(const gfx::Point& point) { | 133 gfx::Display ScreenAsh::FindDisplayContainingPoint(const gfx::Point& point) { |
134 return GetDisplayManager()->FindDisplayContainingPoint(point); | 134 return GetDisplayManager()->FindDisplayContainingPoint(point); |
135 } | 135 } |
136 | 136 |
137 // static | 137 // static |
138 gfx::Rect ScreenAsh::GetMaximizedWindowBoundsInParent(aura::Window* window) { | 138 gfx::Rect ScreenAsh::GetMaximizedWindowBoundsInParent(aura::Window* window) { |
139 if (internal::GetRootWindowController(window->GetRootWindow())->shelf()) | 139 if (GetRootWindowController(window->GetRootWindow())->shelf()) |
140 return GetDisplayWorkAreaBoundsInParent(window); | 140 return GetDisplayWorkAreaBoundsInParent(window); |
141 else | 141 else |
142 return GetDisplayBoundsInParent(window); | 142 return GetDisplayBoundsInParent(window); |
143 } | 143 } |
144 | 144 |
145 // static | 145 // static |
146 gfx::Rect ScreenAsh::GetDisplayBoundsInParent(aura::Window* window) { | 146 gfx::Rect ScreenAsh::GetDisplayBoundsInParent(aura::Window* window) { |
147 return ConvertRectFromScreen( | 147 return ConvertRectFromScreen( |
148 window->parent(), | 148 window->parent(), |
149 Shell::GetScreen()->GetDisplayNearestWindow(window).bounds()); | 149 Shell::GetScreen()->GetDisplayNearestWindow(window).bounds()); |
(...skipping 19 matching lines...) Expand all Loading... |
169 gfx::Rect ScreenAsh::ConvertRectFromScreen(aura::Window* window, | 169 gfx::Rect ScreenAsh::ConvertRectFromScreen(aura::Window* window, |
170 const gfx::Rect& rect) { | 170 const gfx::Rect& rect) { |
171 gfx::Point point = rect.origin(); | 171 gfx::Point point = rect.origin(); |
172 aura::client::GetScreenPositionClient(window->GetRootWindow())-> | 172 aura::client::GetScreenPositionClient(window->GetRootWindow())-> |
173 ConvertPointFromScreen(window, &point); | 173 ConvertPointFromScreen(window, &point); |
174 return gfx::Rect(point, rect.size()); | 174 return gfx::Rect(point, rect.size()); |
175 } | 175 } |
176 | 176 |
177 // static | 177 // static |
178 const gfx::Display& ScreenAsh::GetSecondaryDisplay() { | 178 const gfx::Display& ScreenAsh::GetSecondaryDisplay() { |
179 internal::DisplayManager* display_manager = GetDisplayManager(); | 179 DisplayManager* display_manager = GetDisplayManager(); |
180 CHECK_EQ(2U, display_manager->GetNumDisplays()); | 180 CHECK_EQ(2U, display_manager->GetNumDisplays()); |
181 return display_manager->GetDisplayAt(0).id() == | 181 return display_manager->GetDisplayAt(0).id() == |
182 Shell::GetScreen()->GetPrimaryDisplay().id() ? | 182 Shell::GetScreen()->GetPrimaryDisplay().id() ? |
183 display_manager->GetDisplayAt(1) : display_manager->GetDisplayAt(0); | 183 display_manager->GetDisplayAt(1) : display_manager->GetDisplayAt(0); |
184 } | 184 } |
185 | 185 |
186 // static | 186 // static |
187 const gfx::Display& ScreenAsh::GetDisplayForId(int64 display_id) { | 187 const gfx::Display& ScreenAsh::GetDisplayForId(int64 display_id) { |
188 return GetDisplayManager()->GetDisplayForId(display_id); | 188 return GetDisplayManager()->GetDisplayForId(display_id); |
189 } | 189 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 std::vector<gfx::Display> ScreenAsh::GetAllDisplays() const { | 225 std::vector<gfx::Display> ScreenAsh::GetAllDisplays() const { |
226 return GetDisplayManager()->displays(); | 226 return GetDisplayManager()->displays(); |
227 } | 227 } |
228 | 228 |
229 gfx::Display ScreenAsh::GetDisplayNearestWindow(gfx::NativeView window) const { | 229 gfx::Display ScreenAsh::GetDisplayNearestWindow(gfx::NativeView window) const { |
230 if (!window) | 230 if (!window) |
231 return GetPrimaryDisplay(); | 231 return GetPrimaryDisplay(); |
232 const aura::Window* root_window = window->GetRootWindow(); | 232 const aura::Window* root_window = window->GetRootWindow(); |
233 if (!root_window) | 233 if (!root_window) |
234 return GetPrimaryDisplay(); | 234 return GetPrimaryDisplay(); |
235 const internal::RootWindowSettings* rws = | 235 const RootWindowSettings* rws = GetRootWindowSettings(root_window); |
236 internal::GetRootWindowSettings(root_window); | |
237 if (rws->shutdown) | 236 if (rws->shutdown) |
238 return gfx::Display(1); | 237 return gfx::Display(1); |
239 int64 id = rws->display_id; | 238 int64 id = rws->display_id; |
240 // if id is |kInvaildDisplayID|, it's being deleted. | 239 // if id is |kInvaildDisplayID|, it's being deleted. |
241 DCHECK(id != gfx::Display::kInvalidDisplayID); | 240 DCHECK(id != gfx::Display::kInvalidDisplayID); |
242 | 241 |
243 internal::DisplayManager* display_manager = GetDisplayManager(); | 242 DisplayManager* display_manager = GetDisplayManager(); |
244 // RootWindow needs Display to determine its device scale factor | 243 // RootWindow needs Display to determine its device scale factor |
245 // for non desktop display. | 244 // for non desktop display. |
246 if (display_manager->non_desktop_display().id() == id) | 245 if (display_manager->non_desktop_display().id() == id) |
247 return display_manager->non_desktop_display(); | 246 return display_manager->non_desktop_display(); |
248 return display_manager->GetDisplayForId(id); | 247 return display_manager->GetDisplayForId(id); |
249 } | 248 } |
250 | 249 |
251 gfx::Display ScreenAsh::GetDisplayNearestPoint(const gfx::Point& point) const { | 250 gfx::Display ScreenAsh::GetDisplayNearestPoint(const gfx::Point& point) const { |
252 const gfx::Display& display = | 251 const gfx::Display& display = |
253 GetDisplayManager()->FindDisplayContainingPoint(point); | 252 GetDisplayManager()->FindDisplayContainingPoint(point); |
(...skipping 25 matching lines...) Expand all Loading... |
279 | 278 |
280 void ScreenAsh::RemoveObserver(gfx::DisplayObserver* observer) { | 279 void ScreenAsh::RemoveObserver(gfx::DisplayObserver* observer) { |
281 observers_.RemoveObserver(observer); | 280 observers_.RemoveObserver(observer); |
282 } | 281 } |
283 | 282 |
284 gfx::Screen* ScreenAsh::CloneForShutdown() { | 283 gfx::Screen* ScreenAsh::CloneForShutdown() { |
285 return new ScreenForShutdown(this); | 284 return new ScreenForShutdown(this); |
286 } | 285 } |
287 | 286 |
288 } // namespace ash | 287 } // namespace ash |
OLD | NEW |