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/display/display_controller.h" | 5 #include "ash/display/display_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <map> | 9 #include <map> |
10 | 10 |
11 #include "ash/ash_switches.h" | 11 #include "ash/ash_switches.h" |
12 #include "ash/display/cursor_window_controller.h" | 12 #include "ash/display/cursor_window_controller.h" |
13 #include "ash/display/display_layout_store.h" | 13 #include "ash/display/display_layout_store.h" |
14 #include "ash/display/display_manager.h" | 14 #include "ash/display/display_manager.h" |
15 #include "ash/display/mirror_window_controller.h" | 15 #include "ash/display/mirror_window_controller.h" |
16 #include "ash/display/root_window_transformers.h" | 16 #include "ash/display/root_window_transformers.h" |
17 #include "ash/display/virtual_keyboard_window_controller.h" | 17 #include "ash/display/virtual_keyboard_window_controller.h" |
18 #include "ash/host/ash_window_tree_host.h" | 18 #include "ash/host/ash_window_tree_host.h" |
19 #include "ash/host/ash_window_tree_host_init_params.h" | 19 #include "ash/host/ash_window_tree_host_init_params.h" |
20 #include "ash/host/root_window_transformer.h" | 20 #include "ash/host/root_window_transformer.h" |
21 #include "ash/root_window_controller.h" | 21 #include "ash/root_window_controller.h" |
22 #include "ash/root_window_settings.h" | 22 #include "ash/root_window_settings.h" |
23 #include "ash/screen_util.h" | 23 #include "ash/screen_util.h" |
24 #include "ash/shell.h" | 24 #include "ash/shell.h" |
25 #include "ash/shell_delegate.h" | 25 #include "ash/shell_delegate.h" |
26 #include "ash/wm/coordinate_conversion.h" | 26 #include "ash/wm/coordinate_conversion.h" |
27 #include "base/command_line.h" | 27 #include "base/command_line.h" |
28 #include "base/stl_util.h" | |
28 #include "base/strings/stringprintf.h" | 29 #include "base/strings/stringprintf.h" |
29 #include "base/strings/utf_string_conversions.h" | 30 #include "base/strings/utf_string_conversions.h" |
30 #include "ui/aura/client/capture_client.h" | 31 #include "ui/aura/client/capture_client.h" |
31 #include "ui/aura/client/focus_client.h" | 32 #include "ui/aura/client/focus_client.h" |
32 #include "ui/aura/client/screen_position_client.h" | 33 #include "ui/aura/client/screen_position_client.h" |
33 #include "ui/aura/window.h" | 34 #include "ui/aura/window.h" |
34 #include "ui/aura/window_event_dispatcher.h" | 35 #include "ui/aura/window_event_dispatcher.h" |
35 #include "ui/aura/window_property.h" | 36 #include "ui/aura/window_property.h" |
36 #include "ui/aura/window_tracker.h" | 37 #include "ui/aura/window_tracker.h" |
37 #include "ui/aura/window_tree_host.h" | 38 #include "ui/aura/window_tree_host.h" |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
259 void DisplayController::Shutdown() { | 260 void DisplayController::Shutdown() { |
260 // Unset the display manager's delegate here because | 261 // Unset the display manager's delegate here because |
261 // DisplayManager outlives DisplayController. | 262 // DisplayManager outlives DisplayController. |
262 Shell::GetInstance()->display_manager()->set_delegate(NULL); | 263 Shell::GetInstance()->display_manager()->set_delegate(NULL); |
263 | 264 |
264 cursor_window_controller_.reset(); | 265 cursor_window_controller_.reset(); |
265 mirror_window_controller_.reset(); | 266 mirror_window_controller_.reset(); |
266 virtual_keyboard_window_controller_.reset(); | 267 virtual_keyboard_window_controller_.reset(); |
267 | 268 |
268 Shell::GetScreen()->RemoveObserver(this); | 269 Shell::GetScreen()->RemoveObserver(this); |
269 // Delete all root window controllers, which deletes root window | 270 |
270 // from the last so that the primary root window gets deleted last. | 271 int64 primary_id = Shell::GetScreen()->GetPrimaryDisplay().id(); |
oshima
2014/08/30 00:50:36
This comment was wrong, although deleting primary
| |
271 for (WindowTreeHostMap::const_reverse_iterator it = | 272 |
272 window_tree_hosts_.rbegin(); | 273 // Delete non primary root window controllers first, then |
273 it != window_tree_hosts_.rend(); | 274 // delete the primary root window controller. |
274 ++it) { | 275 aura::Window::Windows root_windows = DisplayController::GetAllRootWindows(); |
275 RootWindowController* controller = | 276 std::vector<RootWindowController*> to_delete; |
276 GetRootWindowController(GetWindow(it->second)); | 277 RootWindowController* primary_rwc = NULL; |
277 DCHECK(controller); | 278 for (aura::Window::Windows::iterator iter = root_windows.begin(); |
278 delete controller; | 279 iter != root_windows.end(); |
280 ++iter) { | |
281 RootWindowController* rwc = GetRootWindowController(*iter); | |
282 if (GetRootWindowSettings(*iter)->display_id == primary_id) | |
283 primary_rwc = rwc; | |
284 else | |
285 to_delete.push_back(rwc); | |
279 } | 286 } |
287 CHECK(primary_rwc); | |
288 | |
289 STLDeleteElements(&to_delete); | |
290 delete primary_rwc; | |
280 } | 291 } |
281 | 292 |
282 void DisplayController::CreatePrimaryHost( | 293 void DisplayController::CreatePrimaryHost( |
283 const AshWindowTreeHostInitParams& init_params) { | 294 const AshWindowTreeHostInitParams& init_params) { |
284 const gfx::Display& primary_candidate = | 295 const gfx::Display& primary_candidate = |
285 GetDisplayManager()->GetPrimaryDisplayCandidate(); | 296 GetDisplayManager()->GetPrimaryDisplayCandidate(); |
286 primary_display_id = primary_candidate.id(); | 297 primary_display_id = primary_candidate.id(); |
287 CHECK_NE(gfx::Display::kInvalidDisplayID, primary_display_id); | 298 CHECK_NE(gfx::Display::kInvalidDisplayID, primary_display_id); |
288 AddWindowTreeHostForDisplay(primary_candidate, init_params); | 299 AddWindowTreeHostForDisplay(primary_candidate, init_params); |
289 } | 300 } |
(...skipping 28 matching lines...) Expand all Loading... | |
318 int64 DisplayController::GetPrimaryDisplayId() { | 329 int64 DisplayController::GetPrimaryDisplayId() { |
319 CHECK_NE(gfx::Display::kInvalidDisplayID, primary_display_id); | 330 CHECK_NE(gfx::Display::kInvalidDisplayID, primary_display_id); |
320 return primary_display_id; | 331 return primary_display_id; |
321 } | 332 } |
322 | 333 |
323 aura::Window* DisplayController::GetPrimaryRootWindow() { | 334 aura::Window* DisplayController::GetPrimaryRootWindow() { |
324 return GetRootWindowForDisplayId(primary_display_id); | 335 return GetRootWindowForDisplayId(primary_display_id); |
325 } | 336 } |
326 | 337 |
327 aura::Window* DisplayController::GetRootWindowForDisplayId(int64 id) { | 338 aura::Window* DisplayController::GetRootWindowForDisplayId(int64 id) { |
328 DCHECK_EQ(1u, window_tree_hosts_.count(id)); | 339 CHECK_EQ(1u, window_tree_hosts_.count(id)); |
oshima
2014/08/30 00:50:36
I changed to CHECK to catch the error early in rel
| |
329 AshWindowTreeHost* host = window_tree_hosts_[id]; | 340 AshWindowTreeHost* host = window_tree_hosts_[id]; |
330 CHECK(host); | 341 CHECK(host); |
331 return GetWindow(host); | 342 return GetWindow(host); |
332 } | 343 } |
333 | 344 |
334 void DisplayController::CloseChildWindows() { | 345 void DisplayController::CloseChildWindows() { |
335 for (WindowTreeHostMap::const_iterator it = window_tree_hosts_.begin(); | 346 for (WindowTreeHostMap::const_iterator it = window_tree_hosts_.begin(); |
336 it != window_tree_hosts_.end(); | 347 it != window_tree_hosts_.end(); |
337 ++it) { | 348 ++it) { |
338 aura::Window* root_window = GetWindow(it->second); | 349 aura::Window* root_window = GetWindow(it->second); |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
775 std::string name = | 786 std::string name = |
776 root_windows[i] == primary ? "aura_root_0" : "aura_root_x"; | 787 root_windows[i] == primary ? "aura_root_0" : "aura_root_x"; |
777 gfx::AcceleratedWidget xwindow = | 788 gfx::AcceleratedWidget xwindow = |
778 root_windows[i]->GetHost()->GetAcceleratedWidget(); | 789 root_windows[i]->GetHost()->GetAcceleratedWidget(); |
779 XStoreName(gfx::GetXDisplay(), xwindow, name.c_str()); | 790 XStoreName(gfx::GetXDisplay(), xwindow, name.c_str()); |
780 } | 791 } |
781 #endif | 792 #endif |
782 } | 793 } |
783 | 794 |
784 } // namespace ash | 795 } // namespace ash |
OLD | NEW |