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/display_layout_store.h" | 12 #include "ash/display/display_layout_store.h" |
13 #include "ash/display/display_manager.h" | 13 #include "ash/display/display_manager.h" |
14 #include "ash/display/mirror_window_controller.h" | 14 #include "ash/display/mirror_window_controller.h" |
15 #include "ash/display/root_window_transformers.h" | 15 #include "ash/display/root_window_transformers.h" |
16 #include "ash/host/root_window_host_factory.h" | 16 #include "ash/host/root_window_host_factory.h" |
17 #include "ash/root_window_controller.h" | 17 #include "ash/root_window_controller.h" |
18 #include "ash/root_window_settings.h" | 18 #include "ash/root_window_settings.h" |
19 #include "ash/screen_ash.h" | 19 #include "ash/screen_ash.h" |
20 #include "ash/shell.h" | 20 #include "ash/shell.h" |
21 #include "ash/wm/coordinate_conversion.h" | 21 #include "ash/wm/coordinate_conversion.h" |
22 #include "ash/wm/property_util.h" | |
23 #include "base/command_line.h" | 22 #include "base/command_line.h" |
24 #include "base/strings/stringprintf.h" | 23 #include "base/strings/stringprintf.h" |
25 #include "third_party/skia/include/utils/SkMatrix44.h" | 24 #include "third_party/skia/include/utils/SkMatrix44.h" |
26 #include "ui/aura/client/activation_client.h" | 25 #include "ui/aura/client/activation_client.h" |
27 #include "ui/aura/client/capture_client.h" | 26 #include "ui/aura/client/capture_client.h" |
28 #include "ui/aura/client/cursor_client.h" | 27 #include "ui/aura/client/cursor_client.h" |
29 #include "ui/aura/client/focus_client.h" | 28 #include "ui/aura/client/focus_client.h" |
30 #include "ui/aura/client/screen_position_client.h" | 29 #include "ui/aura/client/screen_position_client.h" |
31 #include "ui/aura/root_window.h" | 30 #include "ui/aura/root_window.h" |
32 #include "ui/aura/root_window_transformer.h" | 31 #include "ui/aura/root_window_transformer.h" |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 primary_display_for_shutdown = new gfx::Display( | 252 primary_display_for_shutdown = new gfx::Display( |
254 GetDisplayManager()->GetDisplayForId(primary_display_id)); | 253 GetDisplayManager()->GetDisplayForId(primary_display_id)); |
255 num_displays_for_shutdown = GetDisplayManager()->GetNumDisplays(); | 254 num_displays_for_shutdown = GetDisplayManager()->GetNumDisplays(); |
256 | 255 |
257 Shell::GetScreen()->RemoveObserver(this); | 256 Shell::GetScreen()->RemoveObserver(this); |
258 // Delete all root window controllers, which deletes root window | 257 // Delete all root window controllers, which deletes root window |
259 // from the last so that the primary root window gets deleted last. | 258 // from the last so that the primary root window gets deleted last. |
260 for (std::map<int64, aura::RootWindow*>::const_reverse_iterator it = | 259 for (std::map<int64, aura::RootWindow*>::const_reverse_iterator it = |
261 root_windows_.rbegin(); it != root_windows_.rend(); ++it) { | 260 root_windows_.rbegin(); it != root_windows_.rend(); ++it) { |
262 internal::RootWindowController* controller = | 261 internal::RootWindowController* controller = |
263 GetRootWindowController(it->second); | 262 internal::GetRootWindowController(it->second); |
264 DCHECK(controller); | 263 DCHECK(controller); |
265 delete controller; | 264 delete controller; |
266 } | 265 } |
267 } | 266 } |
268 | 267 |
269 // static | 268 // static |
270 const gfx::Display& DisplayController::GetPrimaryDisplay() { | 269 const gfx::Display& DisplayController::GetPrimaryDisplay() { |
271 DCHECK_NE(primary_display_id, gfx::Display::kInvalidDisplayID); | 270 DCHECK_NE(primary_display_id, gfx::Display::kInvalidDisplayID); |
272 if (primary_display_for_shutdown) | 271 if (primary_display_for_shutdown) |
273 return *primary_display_for_shutdown; | 272 return *primary_display_for_shutdown; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 | 314 |
316 aura::RootWindow* DisplayController::GetRootWindowForDisplayId(int64 id) { | 315 aura::RootWindow* DisplayController::GetRootWindowForDisplayId(int64 id) { |
317 return root_windows_[id]; | 316 return root_windows_[id]; |
318 } | 317 } |
319 | 318 |
320 void DisplayController::CloseChildWindows() { | 319 void DisplayController::CloseChildWindows() { |
321 for (std::map<int64, aura::RootWindow*>::const_iterator it = | 320 for (std::map<int64, aura::RootWindow*>::const_iterator it = |
322 root_windows_.begin(); it != root_windows_.end(); ++it) { | 321 root_windows_.begin(); it != root_windows_.end(); ++it) { |
323 aura::RootWindow* root_window = it->second; | 322 aura::RootWindow* root_window = it->second; |
324 internal::RootWindowController* controller = | 323 internal::RootWindowController* controller = |
325 GetRootWindowController(root_window); | 324 internal::GetRootWindowController(root_window); |
326 if (controller) { | 325 if (controller) { |
327 controller->CloseChildWindows(); | 326 controller->CloseChildWindows(); |
328 } else { | 327 } else { |
329 while (!root_window->children().empty()) { | 328 while (!root_window->children().empty()) { |
330 aura::Window* child = root_window->children()[0]; | 329 aura::Window* child = root_window->children()[0]; |
331 delete child; | 330 delete child; |
332 } | 331 } |
333 } | 332 } |
334 } | 333 } |
335 } | 334 } |
336 | 335 |
337 std::vector<aura::RootWindow*> DisplayController::GetAllRootWindows() { | 336 std::vector<aura::RootWindow*> DisplayController::GetAllRootWindows() { |
338 std::vector<aura::RootWindow*> windows; | 337 std::vector<aura::RootWindow*> windows; |
339 for (std::map<int64, aura::RootWindow*>::const_iterator it = | 338 for (std::map<int64, aura::RootWindow*>::const_iterator it = |
340 root_windows_.begin(); it != root_windows_.end(); ++it) { | 339 root_windows_.begin(); it != root_windows_.end(); ++it) { |
341 DCHECK(it->second); | 340 DCHECK(it->second); |
342 if (GetRootWindowController(it->second)) | 341 if (internal::GetRootWindowController(it->second)) |
343 windows.push_back(it->second); | 342 windows.push_back(it->second); |
344 } | 343 } |
345 return windows; | 344 return windows; |
346 } | 345 } |
347 | 346 |
348 gfx::Insets DisplayController::GetOverscanInsets(int64 display_id) const { | 347 gfx::Insets DisplayController::GetOverscanInsets(int64 display_id) const { |
349 return GetDisplayManager()->GetOverscanInsets(display_id); | 348 return GetDisplayManager()->GetOverscanInsets(display_id); |
350 } | 349 } |
351 | 350 |
352 void DisplayController::SetOverscanInsets(int64 display_id, | 351 void DisplayController::SetOverscanInsets(int64 display_id, |
353 const gfx::Insets& insets_in_dip) { | 352 const gfx::Insets& insets_in_dip) { |
354 GetDisplayManager()->SetOverscanInsets(display_id, insets_in_dip); | 353 GetDisplayManager()->SetOverscanInsets(display_id, insets_in_dip); |
355 } | 354 } |
356 | 355 |
357 std::vector<internal::RootWindowController*> | 356 std::vector<internal::RootWindowController*> |
358 DisplayController::GetAllRootWindowControllers() { | 357 DisplayController::GetAllRootWindowControllers() { |
359 std::vector<internal::RootWindowController*> controllers; | 358 std::vector<internal::RootWindowController*> controllers; |
360 for (std::map<int64, aura::RootWindow*>::const_iterator it = | 359 for (std::map<int64, aura::RootWindow*>::const_iterator it = |
361 root_windows_.begin(); it != root_windows_.end(); ++it) { | 360 root_windows_.begin(); it != root_windows_.end(); ++it) { |
362 internal::RootWindowController* controller = | 361 internal::RootWindowController* controller = |
363 GetRootWindowController(it->second); | 362 internal::GetRootWindowController(it->second); |
364 if (controller) | 363 if (controller) |
365 controllers.push_back(controller); | 364 controllers.push_back(controller); |
366 } | 365 } |
367 return controllers; | 366 return controllers; |
368 } | 367 } |
369 | 368 |
370 void DisplayController::SetLayoutForCurrentDisplays( | 369 void DisplayController::SetLayoutForCurrentDisplays( |
371 const DisplayLayout& layout_relative_to_primary) { | 370 const DisplayLayout& layout_relative_to_primary) { |
372 DCHECK_EQ(2U, GetDisplayManager()->GetNumDisplays()); | 371 DCHECK_EQ(2U, GetDisplayManager()->GetNumDisplays()); |
373 if (GetDisplayManager()->GetNumDisplays() < 2) | 372 if (GetDisplayManager()->GetNumDisplays() < 2) |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 | 676 |
678 // Setup primary root. | 677 // Setup primary root. |
679 root_windows_[primary_display_id] = primary_root; | 678 root_windows_[primary_display_id] = primary_root; |
680 internal::GetRootWindowSettings(primary_root)->display_id = | 679 internal::GetRootWindowSettings(primary_root)->display_id = |
681 primary_display_id; | 680 primary_display_id; |
682 | 681 |
683 OnDisplayBoundsChanged( | 682 OnDisplayBoundsChanged( |
684 GetDisplayManager()->GetDisplayForId(primary_display_id)); | 683 GetDisplayManager()->GetDisplayForId(primary_display_id)); |
685 } | 684 } |
686 internal::RootWindowController* controller = | 685 internal::RootWindowController* controller = |
687 GetRootWindowController(root_to_delete); | 686 internal::GetRootWindowController(root_to_delete); |
688 DCHECK(controller); | 687 DCHECK(controller); |
689 controller->MoveWindowsTo(GetPrimaryRootWindow()); | 688 controller->MoveWindowsTo(GetPrimaryRootWindow()); |
690 // Delete most of root window related objects, but don't delete | 689 // Delete most of root window related objects, but don't delete |
691 // root window itself yet because the stack may be using it. | 690 // root window itself yet because the stack may be using it. |
692 controller->Shutdown(); | 691 controller->Shutdown(); |
693 base::MessageLoop::current()->DeleteSoon(FROM_HERE, controller); | 692 base::MessageLoop::current()->DeleteSoon(FROM_HERE, controller); |
694 } | 693 } |
695 | 694 |
696 void DisplayController::OnRootWindowHostResized(const aura::RootWindow* root) { | 695 void DisplayController::OnRootWindowHostResized(const aura::RootWindow* root) { |
697 internal::DisplayManager* display_manager = GetDisplayManager(); | 696 internal::DisplayManager* display_manager = GetDisplayManager(); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 for (size_t i = 0; i < root_windows.size(); ++i) { | 820 for (size_t i = 0; i < root_windows.size(); ++i) { |
822 std::string name = | 821 std::string name = |
823 root_windows[i] == primary ? "aura_root_0" : "aura_root_x"; | 822 root_windows[i] == primary ? "aura_root_0" : "aura_root_x"; |
824 gfx::AcceleratedWidget xwindow = root_windows[i]->GetAcceleratedWidget(); | 823 gfx::AcceleratedWidget xwindow = root_windows[i]->GetAcceleratedWidget(); |
825 XStoreName(ui::GetXDisplay(), xwindow, name.c_str()); | 824 XStoreName(ui::GetXDisplay(), xwindow, name.c_str()); |
826 } | 825 } |
827 #endif | 826 #endif |
828 } | 827 } |
829 | 828 |
830 } // namespace ash | 829 } // namespace ash |
OLD | NEW |