| 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 |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 } | 454 } |
| 455 } | 455 } |
| 456 if (display_manager->GetNumDisplays() > 1) { | 456 if (display_manager->GetNumDisplays() > 1) { |
| 457 UpdateDisplayBoundsForLayout(); | 457 UpdateDisplayBoundsForLayout(); |
| 458 DisplayIdPair pair = GetCurrentDisplayIdPair(); | 458 DisplayIdPair pair = GetCurrentDisplayIdPair(); |
| 459 DisplayLayout layout = GetCurrentDisplayLayout(); | 459 DisplayLayout layout = GetCurrentDisplayLayout(); |
| 460 SetPrimaryDisplayId( | 460 SetPrimaryDisplayId( |
| 461 layout.primary_id == gfx::Display::kInvalidDisplayID ? | 461 layout.primary_id == gfx::Display::kInvalidDisplayID ? |
| 462 pair.first : layout.primary_id); | 462 pair.first : layout.primary_id); |
| 463 } | 463 } |
| 464 UpdateHostWindowNames(); |
| 464 } | 465 } |
| 465 | 466 |
| 466 void DisplayController::AddObserver(Observer* observer) { | 467 void DisplayController::AddObserver(Observer* observer) { |
| 467 observers_.AddObserver(observer); | 468 observers_.AddObserver(observer); |
| 468 } | 469 } |
| 469 | 470 |
| 470 void DisplayController::RemoveObserver(Observer* observer) { | 471 void DisplayController::RemoveObserver(Observer* observer) { |
| 471 observers_.RemoveObserver(observer); | 472 observers_.RemoveObserver(observer); |
| 472 } | 473 } |
| 473 | 474 |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1010 primary_id == gfx::Display::kInvalidDisplayID ? | 1011 primary_id == gfx::Display::kInvalidDisplayID ? |
| 1011 pair.first : primary_id); | 1012 pair.first : primary_id); |
| 1012 // Update the primary_id in case the above call is | 1013 // Update the primary_id in case the above call is |
| 1013 // ignored. Happens when a) default layout's primary id | 1014 // ignored. Happens when a) default layout's primary id |
| 1014 // doesn't exist, or b) the primary_id has already been | 1015 // doesn't exist, or b) the primary_id has already been |
| 1015 // set to the same and didn't update it. | 1016 // set to the same and didn't update it. |
| 1016 paired_layouts_[pair].primary_id = GetPrimaryDisplay().id(); | 1017 paired_layouts_[pair].primary_id = GetPrimaryDisplay().id(); |
| 1017 } | 1018 } |
| 1018 } | 1019 } |
| 1019 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayConfigurationChanged()); | 1020 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayConfigurationChanged()); |
| 1021 UpdateHostWindowNames(); |
| 1020 } | 1022 } |
| 1021 | 1023 |
| 1022 void DisplayController::RegisterLayoutForDisplayIdPairInternal( | 1024 void DisplayController::RegisterLayoutForDisplayIdPairInternal( |
| 1023 int64 id1, | 1025 int64 id1, |
| 1024 int64 id2, | 1026 int64 id2, |
| 1025 const DisplayLayout& layout, | 1027 const DisplayLayout& layout, |
| 1026 bool override) { | 1028 bool override) { |
| 1027 DisplayIdPair pair = std::make_pair(id1, id2); | 1029 DisplayIdPair pair = std::make_pair(id1, id2); |
| 1028 if (override || paired_layouts_.find(pair) == paired_layouts_.end()) | 1030 if (override || paired_layouts_.find(pair) == paired_layouts_.end()) |
| 1029 paired_layouts_[pair] = layout; | 1031 paired_layouts_[pair] = layout; |
| 1030 } | 1032 } |
| 1031 | 1033 |
| 1032 void DisplayController::OnFadeOutForSwapDisplayFinished() { | 1034 void DisplayController::OnFadeOutForSwapDisplayFinished() { |
| 1033 #if defined(OS_CHROMEOS) && defined(USE_X11) | 1035 #if defined(OS_CHROMEOS) && defined(USE_X11) |
| 1034 SetPrimaryDisplay(ScreenAsh::GetSecondaryDisplay()); | 1036 SetPrimaryDisplay(ScreenAsh::GetSecondaryDisplay()); |
| 1035 Shell::GetInstance()->output_configurator_animation()->StartFadeInAnimation(); | 1037 Shell::GetInstance()->output_configurator_animation()->StartFadeInAnimation(); |
| 1036 #endif | 1038 #endif |
| 1037 } | 1039 } |
| 1038 | 1040 |
| 1041 void DisplayController::UpdateHostWindowNames() { |
| 1042 #if defined(USE_X11) |
| 1043 // crbug.com/120229 - set the window title for the primary dislpay |
| 1044 // to "aura_root_0" so gtalk can find the primary root window to broadcast. |
| 1045 // TODO(jhorwich) Remove this once Chrome supports window-based broadcasting. |
| 1046 aura::RootWindow* primary = Shell::GetPrimaryRootWindow(); |
| 1047 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 1048 for (size_t i = 0; i < root_windows.size(); ++i) { |
| 1049 std::string name = |
| 1050 root_windows[i] == primary ? "aura_root_0" : "aura_root_x"; |
| 1051 gfx::AcceleratedWidget xwindow = root_windows[i]->GetAcceleratedWidget(); |
| 1052 XStoreName(ui::GetXDisplay(), xwindow, name.c_str()); |
| 1053 } |
| 1054 #endif |
| 1055 } |
| 1056 |
| 1039 } // namespace ash | 1057 } // namespace ash |
| OLD | NEW |