| Index: ash/display/display_manager.cc
|
| diff --git a/ash/display/display_manager.cc b/ash/display/display_manager.cc
|
| index 0f3bddaaf140c5b186d3b2de6a8ee3b1d3d5c211..750c07f7623e702be73b8b7ba014edefc9794fba 100644
|
| --- a/ash/display/display_manager.cc
|
| +++ b/ash/display/display_manager.cc
|
| @@ -27,6 +27,7 @@
|
| #include "ui/base/layout.h"
|
| #include "ui/base/resource/resource_bundle.h"
|
| #include "ui/gfx/display.h"
|
| +#include "ui/gfx/display_observer.h"
|
| #include "ui/gfx/rect.h"
|
| #include "ui/gfx/screen.h"
|
| #include "ui/gfx/size_conversions.h"
|
| @@ -347,8 +348,10 @@ void DisplayManager::SetLayoutForCurrentDisplays(
|
|
|
| // Primary's bounds stay the same. Just notify bounds change
|
| // on the secondary.
|
| - screen_ash_->NotifyBoundsChanged(
|
| - ScreenUtil::GetSecondaryDisplay());
|
| + int metrics = gfx::DisplayObserver::DISPLAY_METRICS_BOUNDS |
|
| + gfx::DisplayObserver::DISPLAY_METRICS_WORK_AREA;
|
| + screen_ash_->NotifyMetricsChanged(ScreenUtil::GetSecondaryDisplay(),
|
| + static_cast<gfx::DisplayObserver::DisplayMetrics>(metrics));
|
| if (delegate_)
|
| delegate_->PostDisplayConfigurationChange();
|
| }
|
| @@ -645,7 +648,7 @@ void DisplayManager::UpdateDisplays(
|
| new_display_info_list.end(),
|
| DisplayInfoSortFunctor());
|
| DisplayList removed_displays;
|
| - std::vector<size_t> changed_display_indices;
|
| + std::map<size_t, gfx::DisplayObserver::DisplayMetrics> display_changes;
|
| std::vector<size_t> added_display_indices;
|
|
|
| DisplayList::iterator curr_iter = displays_.begin();
|
| @@ -715,18 +718,35 @@ void DisplayManager::UpdateDisplays(
|
| CreateDisplayFromDisplayInfoById(new_info_iter->id());
|
| const DisplayInfo& new_display_info = GetDisplayInfo(new_display.id());
|
|
|
| - bool host_window_bounds_changed =
|
| - current_display_info.bounds_in_native() !=
|
| - new_display_info.bounds_in_native();
|
| + int metrics = gfx::DisplayObserver::DISPLAY_METRICS_NONE;
|
|
|
| + // At that point the new Display objects we have are not entirely updated,
|
| + // they are missing the translation related to the Display disposition in
|
| + // the layout.
|
| + // Using display.bounds() and display.work_area() would fail most of the
|
| + // time.
|
| if (force_bounds_changed_ ||
|
| - host_window_bounds_changed ||
|
| - (current_display.device_scale_factor() !=
|
| - new_display.device_scale_factor()) ||
|
| + (current_display_info.bounds_in_native() !=
|
| + new_display_info.bounds_in_native()) ||
|
| (current_display_info.size_in_pixel() !=
|
| - new_display.GetSizeInPixel()) ||
|
| - (current_display.rotation() != new_display.rotation())) {
|
| - changed_display_indices.push_back(new_displays.size());
|
| + new_display.GetSizeInPixel())) {
|
| + metrics |= gfx::DisplayObserver::DISPLAY_METRICS_BOUNDS |
|
| + gfx::DisplayObserver::DISPLAY_METRICS_WORK_AREA;
|
| + }
|
| +
|
| + if (current_display.device_scale_factor() !=
|
| + new_display.device_scale_factor()) {
|
| + metrics |= gfx::DisplayObserver::DISPLAY_METRICS_DEVICE_SCALE_FACTOR;
|
| + }
|
| +
|
| + if (current_display.rotation() != new_display.rotation())
|
| + metrics |= gfx::DisplayObserver::DISPLAY_METRICS_ROTATION;
|
| +
|
| + if (metrics != gfx::DisplayObserver::DISPLAY_METRICS_NONE) {
|
| + display_changes.insert(
|
| + std::pair<size_t, gfx::DisplayObserver::DisplayMetrics>(
|
| + new_displays.size(),
|
| + static_cast<gfx::DisplayObserver::DisplayMetrics>(metrics)));
|
| }
|
|
|
| new_display.UpdateWorkAreaFromInsets(current_display.GetWorkAreaInsets());
|
| @@ -753,7 +773,7 @@ void DisplayManager::UpdateDisplays(
|
| // Do not update |displays_| if there's nothing to be updated. Without this,
|
| // it will not update the display layout, which causes the bug
|
| // http://crbug.com/155948.
|
| - if (changed_display_indices.empty() && added_display_indices.empty() &&
|
| + if (display_changes.empty() && added_display_indices.empty() &&
|
| removed_displays.empty()) {
|
| return;
|
| }
|
| @@ -770,11 +790,14 @@ void DisplayManager::UpdateDisplays(
|
| if (UpdateSecondaryDisplayBoundsForLayout(&new_displays, &updated_index) &&
|
| std::find(added_display_indices.begin(),
|
| added_display_indices.end(),
|
| - updated_index) == added_display_indices.end() &&
|
| - std::find(changed_display_indices.begin(),
|
| - changed_display_indices.end(),
|
| - updated_index) == changed_display_indices.end()) {
|
| - changed_display_indices.push_back(updated_index);
|
| + updated_index) == added_display_indices.end()) {
|
| + int metrics = gfx::DisplayObserver::DISPLAY_METRICS_BOUNDS |
|
| + gfx::DisplayObserver::DISPLAY_METRICS_WORK_AREA;
|
| + if (display_changes.find(updated_index) != display_changes.end())
|
| + metrics |= display_changes[updated_index];
|
| +
|
| + display_changes[updated_index] =
|
| + static_cast<gfx::DisplayObserver::DisplayMetrics>(metrics);
|
| }
|
|
|
| displays_ = new_displays;
|
| @@ -803,15 +826,16 @@ void DisplayManager::UpdateDisplays(
|
| // it can mirror the display newly added. This can happen when switching
|
| // from dock mode to software mirror mode.
|
| non_desktop_display_updater.reset();
|
| - for (std::vector<size_t>::iterator iter = changed_display_indices.begin();
|
| - iter != changed_display_indices.end(); ++iter) {
|
| - screen_ash_->NotifyBoundsChanged(displays_[*iter]);
|
| + for (std::map<size_t, gfx::DisplayObserver::DisplayMetrics>::iterator iter =
|
| + display_changes.begin();
|
| + iter != display_changes.end(); ++iter) {
|
| + screen_ash_->NotifyMetricsChanged(displays_[iter->first], iter->second);
|
| }
|
| if (delegate_)
|
| delegate_->PostDisplayConfigurationChange();
|
|
|
| #if defined(USE_X11) && defined(OS_CHROMEOS)
|
| - if (!changed_display_indices.empty() && base::SysInfo::IsRunningOnChromeOS())
|
| + if (!display_changes.empty() && base::SysInfo::IsRunningOnChromeOS())
|
| ui::ClearX11DefaultRootWindow();
|
| #endif
|
| }
|
| @@ -955,7 +979,8 @@ bool DisplayManager::UpdateDisplayBounds(int64 display_id,
|
| return false;
|
| gfx::Display* display = FindDisplayForId(display_id);
|
| display->SetSize(display_info_[display_id].size_in_pixel());
|
| - screen_ash_->NotifyBoundsChanged(*display);
|
| + screen_ash_->NotifyMetricsChanged(*display,
|
| + gfx::DisplayObserver::DISPLAY_METRICS_BOUNDS);
|
| return true;
|
| }
|
| return false;
|
|
|