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_manager.h" | 5 #include "ash/display/display_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
877 InsertAndUpdateDisplayInfo(*new_info_iter); | 877 InsertAndUpdateDisplayInfo(*new_info_iter); |
878 new_displays.push_back( | 878 new_displays.push_back( |
879 CreateDisplayFromDisplayInfoById(new_info_iter->id())); | 879 CreateDisplayFromDisplayInfoById(new_info_iter->id())); |
880 ++new_info_iter; | 880 ++new_info_iter; |
881 } | 881 } |
882 } | 882 } |
883 | 883 |
884 scoped_ptr<NonDesktopDisplayUpdater> non_desktop_display_updater( | 884 scoped_ptr<NonDesktopDisplayUpdater> non_desktop_display_updater( |
885 new NonDesktopDisplayUpdater(this, delegate_)); | 885 new NonDesktopDisplayUpdater(this, delegate_)); |
886 | 886 |
887 // Do not update |displays_| if there's nothing to be updated. Without this, | |
888 // it will not update the display layout, which causes the bug | |
889 // http://crbug.com/155948. | |
890 if (display_changes.empty() && added_display_indices.empty() && | |
891 removed_displays.empty()) { | |
892 return; | |
893 } | |
894 // Clear focus if the display has been removed, but don't clear focus if | 887 // Clear focus if the display has been removed, but don't clear focus if |
895 // the destkop has been moved from one display to another | 888 // the destkop has been moved from one display to another |
896 // (mirror -> docked, docked -> single internal). | 889 // (mirror -> docked, docked -> single internal). |
897 bool clear_focus = | 890 bool clear_focus = |
898 !removed_displays.empty() && | 891 !removed_displays.empty() && |
899 !(removed_displays.size() == 1 && added_display_indices.size() == 1); | 892 !(removed_displays.size() == 1 && added_display_indices.size() == 1); |
900 if (delegate_) | 893 if (delegate_) |
901 delegate_->PreDisplayConfigurationChange(clear_focus); | 894 delegate_->PreDisplayConfigurationChange(clear_focus); |
902 | 895 |
| 896 // Do not update |displays_| if there's nothing to be updated. Without this, |
| 897 // it will not update the display layout, which causes the bug |
| 898 // http://crbug.com/155948. |
| 899 if (display_changes.empty() && added_display_indices.empty() && |
| 900 removed_displays.empty()) { |
| 901 // When changing from software mirroring mode to sinlge display mode, it |
| 902 // is possible there is no need to update |displays_| and we early out |
| 903 // here. But we still want to run the PostDisplayConfigurationChange() |
| 904 // cause there are some clients need to act on this, e.g. |
| 905 // TouchTransformerController needs to adjust the TouchTransformer when |
| 906 // switching from dual displays to single display. |
| 907 if (delegate_) |
| 908 delegate_->PostDisplayConfigurationChange(); |
| 909 return; |
| 910 } |
| 911 |
903 size_t updated_index; | 912 size_t updated_index; |
904 if (UpdateSecondaryDisplayBoundsForLayout(&new_displays, &updated_index) && | 913 if (UpdateSecondaryDisplayBoundsForLayout(&new_displays, &updated_index) && |
905 std::find(added_display_indices.begin(), | 914 std::find(added_display_indices.begin(), |
906 added_display_indices.end(), | 915 added_display_indices.end(), |
907 updated_index) == added_display_indices.end()) { | 916 updated_index) == added_display_indices.end()) { |
908 uint32_t metrics = gfx::DisplayObserver::DISPLAY_METRIC_BOUNDS | | 917 uint32_t metrics = gfx::DisplayObserver::DISPLAY_METRIC_BOUNDS | |
909 gfx::DisplayObserver::DISPLAY_METRIC_WORK_AREA; | 918 gfx::DisplayObserver::DISPLAY_METRIC_WORK_AREA; |
910 if (display_changes.find(updated_index) != display_changes.end()) | 919 if (display_changes.find(updated_index) != display_changes.end()) |
911 metrics |= display_changes[updated_index]; | 920 metrics |= display_changes[updated_index]; |
912 | 921 |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1259 new_secondary_origin.Offset(-secondary_bounds.width(), offset); | 1268 new_secondary_origin.Offset(-secondary_bounds.width(), offset); |
1260 break; | 1269 break; |
1261 } | 1270 } |
1262 gfx::Insets insets = secondary_display->GetWorkAreaInsets(); | 1271 gfx::Insets insets = secondary_display->GetWorkAreaInsets(); |
1263 secondary_display->set_bounds( | 1272 secondary_display->set_bounds( |
1264 gfx::Rect(new_secondary_origin, secondary_bounds.size())); | 1273 gfx::Rect(new_secondary_origin, secondary_bounds.size())); |
1265 secondary_display->UpdateWorkAreaFromInsets(insets); | 1274 secondary_display->UpdateWorkAreaFromInsets(insets); |
1266 } | 1275 } |
1267 | 1276 |
1268 } // namespace ash | 1277 } // namespace ash |
OLD | NEW |