| 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 <cmath> | 7 #include <cmath> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 NOTREACHED() << "DisplayLayout is requested for single display"; | 292 NOTREACHED() << "DisplayLayout is requested for single display"; |
| 293 // On release build, just fallback to default instead of blowing up. | 293 // On release build, just fallback to default instead of blowing up. |
| 294 DisplayLayout layout = | 294 DisplayLayout layout = |
| 295 layout_store_->default_display_layout(); | 295 layout_store_->default_display_layout(); |
| 296 layout.primary_id = displays_[0].id(); | 296 layout.primary_id = displays_[0].id(); |
| 297 return layout; | 297 return layout; |
| 298 } | 298 } |
| 299 | 299 |
| 300 DisplayIdPair DisplayManager::GetCurrentDisplayIdPair() const { | 300 DisplayIdPair DisplayManager::GetCurrentDisplayIdPair() const { |
| 301 if (IsMirrored()) { | 301 if (IsMirrored()) { |
| 302 if (software_mirroring_enabled()) { | 302 if (SoftwareMirroringEnabled()) { |
| 303 CHECK_EQ(2u, num_connected_displays()); | 303 CHECK_EQ(2u, num_connected_displays()); |
| 304 // This comment is to make it easy to distinguish the crash | 304 // This comment is to make it easy to distinguish the crash |
| 305 // between two checks. | 305 // between two checks. |
| 306 CHECK_EQ(1u, displays_.size()); | 306 CHECK_EQ(1u, displays_.size()); |
| 307 } | 307 } |
| 308 return std::make_pair(displays_[0].id(), mirrored_display_id_); | 308 return std::make_pair(displays_[0].id(), mirrored_display_id_); |
| 309 } else { | 309 } else { |
| 310 CHECK_GE(2u, displays_.size()); | 310 CHECK_GE(2u, displays_.size()); |
| 311 int64 id_at_zero = displays_[0].id(); | 311 int64 id_at_zero = displays_[0].id(); |
| 312 if (id_at_zero == gfx::Display::InternalDisplayId() || | 312 if (id_at_zero == gfx::Display::InternalDisplayId() || |
| (...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 942 second_display_mode_ = mode; | 942 second_display_mode_ = mode; |
| 943 mirrored_display_id_ = gfx::Display::kInvalidDisplayID; | 943 mirrored_display_id_ = gfx::Display::kInvalidDisplayID; |
| 944 non_desktop_display_ = gfx::Display(); | 944 non_desktop_display_ = gfx::Display(); |
| 945 } | 945 } |
| 946 | 946 |
| 947 bool DisplayManager::UpdateDisplayBounds(int64 display_id, | 947 bool DisplayManager::UpdateDisplayBounds(int64 display_id, |
| 948 const gfx::Rect& new_bounds) { | 948 const gfx::Rect& new_bounds) { |
| 949 if (change_display_upon_host_resize_) { | 949 if (change_display_upon_host_resize_) { |
| 950 display_info_[display_id].SetBounds(new_bounds); | 950 display_info_[display_id].SetBounds(new_bounds); |
| 951 // Don't notify observers if the mirrored window has changed. | 951 // Don't notify observers if the mirrored window has changed. |
| 952 if (software_mirroring_enabled() && mirrored_display_id_ == display_id) | 952 if (SoftwareMirroringEnabled() && mirrored_display_id_ == display_id) |
| 953 return false; | 953 return false; |
| 954 gfx::Display* display = FindDisplayForId(display_id); | 954 gfx::Display* display = FindDisplayForId(display_id); |
| 955 display->SetSize(display_info_[display_id].size_in_pixel()); | 955 display->SetSize(display_info_[display_id].size_in_pixel()); |
| 956 screen_ash_->NotifyBoundsChanged(*display); | 956 screen_ash_->NotifyBoundsChanged(*display); |
| 957 return true; | 957 return true; |
| 958 } | 958 } |
| 959 return false; | 959 return false; |
| 960 } | 960 } |
| 961 | 961 |
| 962 void DisplayManager::CreateMirrorWindowIfAny() { | 962 void DisplayManager::CreateMirrorWindowIfAny() { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 982 iter != displays_.end(); ++iter) { | 982 iter != displays_.end(); ++iter) { |
| 983 if ((*iter).id() == id) | 983 if ((*iter).id() == id) |
| 984 return &(*iter); | 984 return &(*iter); |
| 985 } | 985 } |
| 986 DLOG(WARNING) << "Could not find display:" << id; | 986 DLOG(WARNING) << "Could not find display:" << id; |
| 987 return NULL; | 987 return NULL; |
| 988 } | 988 } |
| 989 | 989 |
| 990 void DisplayManager::AddMirrorDisplayInfoIfAny( | 990 void DisplayManager::AddMirrorDisplayInfoIfAny( |
| 991 std::vector<DisplayInfo>* display_info_list) { | 991 std::vector<DisplayInfo>* display_info_list) { |
| 992 if (software_mirroring_enabled() && IsMirrored()) | 992 if (SoftwareMirroringEnabled() && IsMirrored()) |
| 993 display_info_list->push_back(GetDisplayInfo(mirrored_display_id_)); | 993 display_info_list->push_back(GetDisplayInfo(mirrored_display_id_)); |
| 994 } | 994 } |
| 995 | 995 |
| 996 void DisplayManager::InsertAndUpdateDisplayInfo(const DisplayInfo& new_info) { | 996 void DisplayManager::InsertAndUpdateDisplayInfo(const DisplayInfo& new_info) { |
| 997 std::map<int64, DisplayInfo>::iterator info = | 997 std::map<int64, DisplayInfo>::iterator info = |
| 998 display_info_.find(new_info.id()); | 998 display_info_.find(new_info.id()); |
| 999 if (info != display_info_.end()) { | 999 if (info != display_info_.end()) { |
| 1000 info->second.Copy(new_info); | 1000 info->second.Copy(new_info); |
| 1001 } else { | 1001 } else { |
| 1002 display_info_[new_info.id()] = new_info; | 1002 display_info_[new_info.id()] = new_info; |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1115 new_secondary_origin.Offset(-secondary_bounds.width(), offset); | 1115 new_secondary_origin.Offset(-secondary_bounds.width(), offset); |
| 1116 break; | 1116 break; |
| 1117 } | 1117 } |
| 1118 gfx::Insets insets = secondary_display->GetWorkAreaInsets(); | 1118 gfx::Insets insets = secondary_display->GetWorkAreaInsets(); |
| 1119 secondary_display->set_bounds( | 1119 secondary_display->set_bounds( |
| 1120 gfx::Rect(new_secondary_origin, secondary_bounds.size())); | 1120 gfx::Rect(new_secondary_origin, secondary_bounds.size())); |
| 1121 secondary_display->UpdateWorkAreaFromInsets(insets); | 1121 secondary_display->UpdateWorkAreaFromInsets(insets); |
| 1122 } | 1122 } |
| 1123 | 1123 |
| 1124 } // namespace ash | 1124 } // namespace ash |
| OLD | NEW |