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 } |
887 // Clear focus if the display has been removed, but don't clear focus if | 894 // Clear focus if the display has been removed, but don't clear focus if |
888 // the destkop has been moved from one display to another | 895 // the destkop has been moved from one display to another |
889 // (mirror -> docked, docked -> single internal). | 896 // (mirror -> docked, docked -> single internal). |
890 bool clear_focus = | 897 bool clear_focus = |
891 !removed_displays.empty() && | 898 !removed_displays.empty() && |
892 !(removed_displays.size() == 1 && added_display_indices.size() == 1); | 899 !(removed_displays.size() == 1 && added_display_indices.size() == 1); |
893 if (delegate_) | 900 if (delegate_) |
894 delegate_->PreDisplayConfigurationChange(clear_focus); | 901 delegate_->PreDisplayConfigurationChange(clear_focus); |
895 | 902 |
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 | |
912 size_t updated_index; | 903 size_t updated_index; |
913 if (UpdateSecondaryDisplayBoundsForLayout(&new_displays, &updated_index) && | 904 if (UpdateSecondaryDisplayBoundsForLayout(&new_displays, &updated_index) && |
914 std::find(added_display_indices.begin(), | 905 std::find(added_display_indices.begin(), |
915 added_display_indices.end(), | 906 added_display_indices.end(), |
916 updated_index) == added_display_indices.end()) { | 907 updated_index) == added_display_indices.end()) { |
917 uint32_t metrics = gfx::DisplayObserver::DISPLAY_METRIC_BOUNDS | | 908 uint32_t metrics = gfx::DisplayObserver::DISPLAY_METRIC_BOUNDS | |
918 gfx::DisplayObserver::DISPLAY_METRIC_WORK_AREA; | 909 gfx::DisplayObserver::DISPLAY_METRIC_WORK_AREA; |
919 if (display_changes.find(updated_index) != display_changes.end()) | 910 if (display_changes.find(updated_index) != display_changes.end()) |
920 metrics |= display_changes[updated_index]; | 911 metrics |= display_changes[updated_index]; |
921 | 912 |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1268 new_secondary_origin.Offset(-secondary_bounds.width(), offset); | 1259 new_secondary_origin.Offset(-secondary_bounds.width(), offset); |
1269 break; | 1260 break; |
1270 } | 1261 } |
1271 gfx::Insets insets = secondary_display->GetWorkAreaInsets(); | 1262 gfx::Insets insets = secondary_display->GetWorkAreaInsets(); |
1272 secondary_display->set_bounds( | 1263 secondary_display->set_bounds( |
1273 gfx::Rect(new_secondary_origin, secondary_bounds.size())); | 1264 gfx::Rect(new_secondary_origin, secondary_bounds.size())); |
1274 secondary_display->UpdateWorkAreaFromInsets(insets); | 1265 secondary_display->UpdateWorkAreaFromInsets(insets); |
1275 } | 1266 } |
1276 | 1267 |
1277 } // namespace ash | 1268 } // namespace ash |
OLD | NEW |