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/aura/wm_window_aura.h" | 7 #include "ash/aura/wm_window_aura.h" |
8 #include "ash/common/shelf/shelf_widget.h" | 8 #include "ash/common/shelf/shelf_widget.h" |
9 #include "ash/common/wm/root_window_finder.h" | 9 #include "ash/common/wm/root_window_finder.h" |
10 #include "ash/display/display_manager.h" | |
11 #include "ash/display/window_tree_host_manager.h" | 10 #include "ash/display/window_tree_host_manager.h" |
12 #include "ash/root_window_controller.h" | 11 #include "ash/root_window_controller.h" |
13 #include "ash/root_window_settings.h" | 12 #include "ash/root_window_settings.h" |
14 #include "ash/shell.h" | 13 #include "ash/shell.h" |
15 #include "base/logging.h" | 14 #include "base/logging.h" |
16 #include "ui/aura/client/screen_position_client.h" | 15 #include "ui/aura/client/screen_position_client.h" |
17 #include "ui/aura/env.h" | 16 #include "ui/aura/env.h" |
18 #include "ui/aura/window_event_dispatcher.h" | 17 #include "ui/aura/window_event_dispatcher.h" |
19 #include "ui/display/display.h" | 18 #include "ui/display/display.h" |
20 #include "ui/display/display_finder.h" | 19 #include "ui/display/display_finder.h" |
| 20 #include "ui/display/manager/display_manager.h" |
21 #include "ui/display/screen.h" | 21 #include "ui/display/screen.h" |
22 | 22 |
23 namespace ash { | 23 namespace ash { |
24 | 24 |
25 namespace { | 25 namespace { |
26 | 26 |
27 // We need to keep this in order for unittests to tell if | 27 // We need to keep this in order for unittests to tell if |
28 // the object in display::Screen::GetScreenByType is for shutdown. | 28 // the object in display::Screen::GetScreenByType is for shutdown. |
29 display::Screen* screen_for_shutdown = nullptr; | 29 display::Screen* screen_for_shutdown = nullptr; |
30 | 30 |
31 DisplayManager* GetDisplayManager() { | 31 display::DisplayManager* GetDisplayManager() { |
32 return Shell::GetInstance()->display_manager(); | 32 return Shell::GetInstance()->display_manager(); |
33 } | 33 } |
34 | 34 |
35 class ScreenForShutdown : public display::Screen { | 35 class ScreenForShutdown : public display::Screen { |
36 public: | 36 public: |
37 explicit ScreenForShutdown(display::Screen* screen_ash) | 37 explicit ScreenForShutdown(display::Screen* screen_ash) |
38 : display_list_(screen_ash->GetAllDisplays()), | 38 : display_list_(screen_ash->GetAllDisplays()), |
39 primary_display_(screen_ash->GetPrimaryDisplay()) {} | 39 primary_display_(screen_ash->GetPrimaryDisplay()) {} |
40 | 40 |
41 // display::Screen overrides: | 41 // display::Screen overrides: |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 const aura::Window* root_window = window->GetRootWindow(); | 121 const aura::Window* root_window = window->GetRootWindow(); |
122 if (!root_window) | 122 if (!root_window) |
123 return GetPrimaryDisplay(); | 123 return GetPrimaryDisplay(); |
124 const RootWindowSettings* rws = GetRootWindowSettings(root_window); | 124 const RootWindowSettings* rws = GetRootWindowSettings(root_window); |
125 int64_t id = rws->display_id; | 125 int64_t id = rws->display_id; |
126 // if id is |kInvaildDisplayID|, it's being deleted. | 126 // if id is |kInvaildDisplayID|, it's being deleted. |
127 DCHECK(id != display::Display::kInvalidDisplayID); | 127 DCHECK(id != display::Display::kInvalidDisplayID); |
128 if (id == display::Display::kInvalidDisplayID) | 128 if (id == display::Display::kInvalidDisplayID) |
129 return GetPrimaryDisplay(); | 129 return GetPrimaryDisplay(); |
130 | 130 |
131 DisplayManager* display_manager = GetDisplayManager(); | 131 display::DisplayManager* display_manager = GetDisplayManager(); |
132 // RootWindow needs Display to determine its device scale factor | 132 // RootWindow needs Display to determine its device scale factor |
133 // for non desktop display. | 133 // for non desktop display. |
134 display::Display mirroring_display = | 134 display::Display mirroring_display = |
135 display_manager->GetMirroringDisplayById(id); | 135 display_manager->GetMirroringDisplayById(id); |
136 if (mirroring_display.is_valid()) | 136 if (mirroring_display.is_valid()) |
137 return mirroring_display; | 137 return mirroring_display; |
138 return display_manager->GetDisplayForId(id); | 138 return display_manager->GetDisplayForId(id); |
139 } | 139 } |
140 | 140 |
141 display::Display ScreenAsh::GetDisplayNearestPoint( | 141 display::Display ScreenAsh::GetDisplayNearestPoint( |
(...skipping 27 matching lines...) Expand all Loading... |
169 | 169 |
170 void ScreenAsh::AddObserver(display::DisplayObserver* observer) { | 170 void ScreenAsh::AddObserver(display::DisplayObserver* observer) { |
171 GetDisplayManager()->AddObserver(observer); | 171 GetDisplayManager()->AddObserver(observer); |
172 } | 172 } |
173 | 173 |
174 void ScreenAsh::RemoveObserver(display::DisplayObserver* observer) { | 174 void ScreenAsh::RemoveObserver(display::DisplayObserver* observer) { |
175 GetDisplayManager()->RemoveObserver(observer); | 175 GetDisplayManager()->RemoveObserver(observer); |
176 } | 176 } |
177 | 177 |
178 // static | 178 // static |
179 DisplayManager* ScreenAsh::CreateDisplayManager() { | 179 display::DisplayManager* ScreenAsh::CreateDisplayManager() { |
180 std::unique_ptr<ScreenAsh> screen(new ScreenAsh); | 180 std::unique_ptr<ScreenAsh> screen(new ScreenAsh); |
181 | 181 |
182 display::Screen* current = display::Screen::GetScreen(); | 182 display::Screen* current = display::Screen::GetScreen(); |
183 // If there is no native, or the native was for shutdown, | 183 // If there is no native, or the native was for shutdown, |
184 // use ash's screen. | 184 // use ash's screen. |
185 if (!current || current == screen_for_shutdown) | 185 if (!current || current == screen_for_shutdown) |
186 display::Screen::SetScreenInstance(screen.get()); | 186 display::Screen::SetScreenInstance(screen.get()); |
187 return new DisplayManager(std::move(screen)); | 187 return new display::DisplayManager(std::move(screen)); |
188 } | 188 } |
189 | 189 |
190 // static | 190 // static |
191 void ScreenAsh::CreateScreenForShutdown() { | 191 void ScreenAsh::CreateScreenForShutdown() { |
192 delete screen_for_shutdown; | 192 delete screen_for_shutdown; |
193 screen_for_shutdown = new ScreenForShutdown(display::Screen::GetScreen()); | 193 screen_for_shutdown = new ScreenForShutdown(display::Screen::GetScreen()); |
194 display::Screen::SetScreenInstance(screen_for_shutdown); | 194 display::Screen::SetScreenInstance(screen_for_shutdown); |
195 } | 195 } |
196 | 196 |
197 } // namespace ash | 197 } // namespace ash |
OLD | NEW |