summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authormlamouri@chromium.org <mlamouri@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-22 01:26:01 +0000
committermlamouri@chromium.org <mlamouri@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-22 01:26:01 +0000
commit0c5703d1a2552eb3d15a7c589f34e3acb6bfc881 (patch)
tree0ad7e6718c9e33056f316ad099bcd3602be8c9d4 /ash
parent2418349939b669d4b6b626ad18b67dba6862ac24 (diff)
downloadchromium_src-0c5703d1a2552eb3d15a7c589f34e3acb6bfc881.zip
chromium_src-0c5703d1a2552eb3d15a7c589f34e3acb6bfc881.tar.gz
chromium_src-0c5703d1a2552eb3d15a7c589f34e3acb6bfc881.tar.bz2
Add OnDisplayMetricsChanged in DisplayObserver.
This replaces OnDisplayBoundsChanged and add a MetricsType parameter so consumers can now which metrics has changed. The current set of MetricsType include bounds, workarea and rotation. BUG=162827 Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=271768 Review URL: https://codereview.chromium.org/259253002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272040 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/display/display_controller.cc28
-rw-r--r--ash/display/display_controller.h6
-rw-r--r--ash/display/display_controller_unittest.cc42
-rw-r--r--ash/display/display_manager.cc69
-rw-r--r--ash/display/display_manager.h2
-rw-r--r--ash/display/display_manager_unittest.cc21
-rw-r--r--ash/display/resolution_notification_controller.cc8
-rw-r--r--ash/display/resolution_notification_controller.h3
-rw-r--r--ash/display/screen_ash.cc8
-rw-r--r--ash/display/screen_ash.h3
-rw-r--r--ash/shelf/shelf_window_watcher.cc7
-rw-r--r--ash/shelf/shelf_window_watcher.h3
-rw-r--r--ash/shell/window_watcher.cc6
-rw-r--r--ash/shell/window_watcher.h3
-rw-r--r--ash/system/web_notification/web_notification_tray.cc5
-rw-r--r--ash/touch/touch_hud_debug.cc7
-rw-r--r--ash/touch/touch_hud_debug.h3
-rw-r--r--ash/touch/touch_observer_hud.cc14
-rw-r--r--ash/touch/touch_observer_hud.h3
-rw-r--r--ash/wm/maximize_mode/maximize_mode_window_manager.cc10
-rw-r--r--ash/wm/maximize_mode/maximize_mode_window_manager.h6
-rw-r--r--ash/wm/overview/window_selector.cc9
-rw-r--r--ash/wm/overview/window_selector.h3
23 files changed, 179 insertions, 90 deletions
diff --git a/ash/display/display_controller.cc b/ash/display/display_controller.cc
index 99c997f..aebe47c 100644
--- a/ash/display/display_controller.cc
+++ b/ash/display/display_controller.cc
@@ -549,15 +549,6 @@ bool DisplayController::UpdateWorkAreaOfDisplayNearestWindow(
return GetDisplayManager()->UpdateWorkAreaOfDisplay(id, insets);
}
-void DisplayController::OnDisplayBoundsChanged(const gfx::Display& display) {
- const DisplayInfo& display_info =
- GetDisplayManager()->GetDisplayInfo(display.id());
- DCHECK(!display_info.bounds_in_native().IsEmpty());
- AshWindowTreeHost* ash_host = window_tree_hosts_[display.id()];
- ash_host->AsWindowTreeHost()->SetBounds(display_info.bounds_in_native());
- SetDisplayPropertiesOnHost(ash_host, display);
-}
-
void DisplayController::OnDisplayAdded(const gfx::Display& display) {
if (primary_tree_host_for_replace_) {
DCHECK(window_tree_hosts_.empty());
@@ -612,8 +603,9 @@ void DisplayController::OnDisplayRemoved(const gfx::Display& display) {
GetRootWindowSettings(GetWindow(primary_host))->display_id =
primary_display_id;
- OnDisplayBoundsChanged(
- GetDisplayManager()->GetDisplayForId(primary_display_id));
+ OnDisplayMetricsChanged(
+ GetDisplayManager()->GetDisplayForId(primary_display_id),
+ DISPLAY_METRIC_BOUNDS);
}
RootWindowController* controller =
GetRootWindowController(GetWindow(host_to_delete));
@@ -625,6 +617,20 @@ void DisplayController::OnDisplayRemoved(const gfx::Display& display) {
base::MessageLoop::current()->DeleteSoon(FROM_HERE, controller);
}
+void DisplayController::OnDisplayMetricsChanged(const gfx::Display& display,
+ uint32_t metrics) {
+ if (!(metrics & (DISPLAY_METRIC_BOUNDS | DISPLAY_METRIC_ROTATION |
+ DISPLAY_METRIC_DEVICE_SCALE_FACTOR)))
+ return;
+
+ const DisplayInfo& display_info =
+ GetDisplayManager()->GetDisplayInfo(display.id());
+ DCHECK(!display_info.bounds_in_native().IsEmpty());
+ AshWindowTreeHost* ash_host = window_tree_hosts_[display.id()];
+ ash_host->AsWindowTreeHost()->SetBounds(display_info.bounds_in_native());
+ SetDisplayPropertiesOnHost(ash_host, display);
+}
+
void DisplayController::OnHostResized(const aura::WindowTreeHost* host) {
gfx::Display display = Shell::GetScreen()->GetDisplayNearestWindow(
const_cast<aura::Window*>(host->window()));
diff --git a/ash/display/display_controller.h b/ash/display/display_controller.h
index 00c1ac6..dd92ab3 100644
--- a/ash/display/display_controller.h
+++ b/ash/display/display_controller.h
@@ -147,11 +147,11 @@ class ASH_EXPORT DisplayController : public gfx::DisplayObserver,
// Sets the work area's |insets| to the display assigned to |window|.
bool UpdateWorkAreaOfDisplayNearestWindow(const aura::Window* window,
const gfx::Insets& insets);
- // aura::DisplayObserver overrides:
- virtual void OnDisplayBoundsChanged(
- const gfx::Display& display) OVERRIDE;
+ // gfx::DisplayObserver overrides:
virtual void OnDisplayAdded(const gfx::Display& display) OVERRIDE;
virtual void OnDisplayRemoved(const gfx::Display& display) OVERRIDE;
+ virtual void OnDisplayMetricsChanged(const gfx::Display& display,
+ uint32_t metrics) OVERRIDE;
// aura::WindowTreeHostObserver overrides:
virtual void OnHostResized(const aura::WindowTreeHost* host) OVERRIDE;
diff --git a/ash/display/display_controller_unittest.cc b/ash/display/display_controller_unittest.cc
index 95b7af6..5ee4cae 100644
--- a/ash/display/display_controller_unittest.cc
+++ b/ash/display/display_controller_unittest.cc
@@ -67,6 +67,8 @@ class TestObserver : public DisplayController::Observer,
: changing_count_(0),
changed_count_(0),
bounds_changed_count_(0),
+ rotation_changed_count_(0),
+ workarea_changed_count_(0),
changed_display_id_(0),
focus_changed_count_(0),
activation_changed_count_(0) {
@@ -96,9 +98,15 @@ class TestObserver : public DisplayController::Observer,
}
// Overrideen from gfx::DisplayObserver
- virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE {
+ virtual void OnDisplayMetricsChanged(const gfx::Display& display,
+ uint32_t metrics) OVERRIDE {
changed_display_id_ = display.id();
- bounds_changed_count_ ++;
+ if (metrics & DISPLAY_METRIC_BOUNDS)
+ ++bounds_changed_count_;
+ if (metrics & DISPLAY_METRIC_ROTATION)
+ ++rotation_changed_count_;
+ if (metrics & DISPLAY_METRIC_WORK_AREA)
+ ++workarea_changed_count_;
}
virtual void OnDisplayAdded(const gfx::Display& new_display) OVERRIDE {
}
@@ -131,6 +139,14 @@ class TestObserver : public DisplayController::Observer,
return Resetter<int>(&bounds_changed_count_).value();
}
+ int64 GetRotationChangedCountAndReset() {
+ return Resetter<int>(&rotation_changed_count_).value();
+ }
+
+ int64 GetWorkareaChangedCountAndReset() {
+ return Resetter<int>(&workarea_changed_count_).value();
+ }
+
int64 GetChangedDisplayIdAndReset() {
return Resetter<int64>(&changed_display_id_).value();
}
@@ -148,6 +164,8 @@ class TestObserver : public DisplayController::Observer,
int changed_count_;
int bounds_changed_count_;
+ int rotation_changed_count_;
+ int workarea_changed_count_;
int64 changed_display_id_;
int focus_changed_count_;
@@ -387,6 +405,7 @@ TEST_F(DisplayControllerTest, SecondaryDisplayLayout) {
UpdateDisplay("500x500,400x400");
EXPECT_EQ(1, observer.CountAndReset()); // resize and add
EXPECT_EQ(1, observer.GetBoundsChangedCountAndReset());
+ EXPECT_EQ(1, observer.GetWorkareaChangedCountAndReset());
EXPECT_EQ(0, observer.GetFocusChangedCountAndReset());
EXPECT_EQ(0, observer.GetActivationChangedCountAndReset());
gfx::Insets insets(5, 5, 5, 5);
@@ -405,6 +424,7 @@ TEST_F(DisplayControllerTest, SecondaryDisplayLayout) {
SetSecondaryDisplayLayout(DisplayLayout::BOTTOM);
EXPECT_EQ(1, observer.CountAndReset());
EXPECT_EQ(1, observer.GetBoundsChangedCountAndReset());
+ EXPECT_EQ(1, observer.GetWorkareaChangedCountAndReset());
EXPECT_EQ(0, observer.GetFocusChangedCountAndReset());
EXPECT_EQ(0, observer.GetActivationChangedCountAndReset());
EXPECT_EQ(secondary_display_id, observer.GetChangedDisplayIdAndReset());
@@ -416,6 +436,7 @@ TEST_F(DisplayControllerTest, SecondaryDisplayLayout) {
SetSecondaryDisplayLayout(DisplayLayout::LEFT);
EXPECT_EQ(1, observer.CountAndReset());
EXPECT_EQ(1, observer.GetBoundsChangedCountAndReset());
+ EXPECT_EQ(1, observer.GetWorkareaChangedCountAndReset());
EXPECT_EQ(0, observer.GetFocusChangedCountAndReset());
EXPECT_EQ(0, observer.GetActivationChangedCountAndReset());
EXPECT_EQ(secondary_display_id, observer.GetChangedDisplayIdAndReset());
@@ -427,6 +448,7 @@ TEST_F(DisplayControllerTest, SecondaryDisplayLayout) {
SetSecondaryDisplayLayout(DisplayLayout::TOP);
EXPECT_EQ(1, observer.CountAndReset());
EXPECT_EQ(1, observer.GetBoundsChangedCountAndReset());
+ EXPECT_EQ(1, observer.GetWorkareaChangedCountAndReset());
EXPECT_EQ(0, observer.GetFocusChangedCountAndReset());
EXPECT_EQ(0, observer.GetActivationChangedCountAndReset());
EXPECT_EQ(secondary_display_id, observer.GetChangedDisplayIdAndReset());
@@ -438,6 +460,7 @@ TEST_F(DisplayControllerTest, SecondaryDisplayLayout) {
SetSecondaryDisplayLayoutAndOffset(DisplayLayout::RIGHT, 300);
EXPECT_EQ(1, observer.CountAndReset()); // resize and add
EXPECT_EQ(1, observer.GetBoundsChangedCountAndReset());
+ EXPECT_EQ(1, observer.GetWorkareaChangedCountAndReset());
EXPECT_EQ(0, observer.GetFocusChangedCountAndReset());
EXPECT_EQ(0, observer.GetActivationChangedCountAndReset());
EXPECT_EQ(secondary_display_id, observer.GetChangedDisplayIdAndReset());
@@ -448,6 +471,7 @@ TEST_F(DisplayControllerTest, SecondaryDisplayLayout) {
SetSecondaryDisplayLayoutAndOffset(DisplayLayout::RIGHT, 490);
EXPECT_EQ(1, observer.CountAndReset()); // resize and add
EXPECT_EQ(1, observer.GetBoundsChangedCountAndReset());
+ EXPECT_EQ(1, observer.GetWorkareaChangedCountAndReset());
EXPECT_EQ(0, observer.GetFocusChangedCountAndReset());
EXPECT_EQ(0, observer.GetActivationChangedCountAndReset());
EXPECT_EQ(secondary_display_id, observer.GetChangedDisplayIdAndReset());
@@ -457,6 +481,7 @@ TEST_F(DisplayControllerTest, SecondaryDisplayLayout) {
SetSecondaryDisplayLayoutAndOffset(DisplayLayout::RIGHT, -400);
EXPECT_EQ(secondary_display_id, observer.GetChangedDisplayIdAndReset());
EXPECT_EQ(1, observer.GetBoundsChangedCountAndReset());
+ EXPECT_EQ(1, observer.GetWorkareaChangedCountAndReset());
EXPECT_EQ(1, observer.CountAndReset()); // resize and add
EXPECT_EQ(0, observer.GetFocusChangedCountAndReset());
EXPECT_EQ(0, observer.GetActivationChangedCountAndReset());
@@ -467,6 +492,7 @@ TEST_F(DisplayControllerTest, SecondaryDisplayLayout) {
SetSecondaryDisplayLayoutAndOffset(DisplayLayout::BOTTOM, -200);
EXPECT_EQ(secondary_display_id, observer.GetChangedDisplayIdAndReset());
EXPECT_EQ(1, observer.GetBoundsChangedCountAndReset());
+ EXPECT_EQ(1, observer.GetWorkareaChangedCountAndReset());
EXPECT_EQ(1, observer.CountAndReset()); // resize and add
EXPECT_EQ(0, observer.GetFocusChangedCountAndReset());
EXPECT_EQ(0, observer.GetActivationChangedCountAndReset());
@@ -477,6 +503,7 @@ TEST_F(DisplayControllerTest, SecondaryDisplayLayout) {
SetSecondaryDisplayLayoutAndOffset(DisplayLayout::BOTTOM, 490);
EXPECT_EQ(secondary_display_id, observer.GetChangedDisplayIdAndReset());
EXPECT_EQ(1, observer.GetBoundsChangedCountAndReset());
+ EXPECT_EQ(1, observer.GetWorkareaChangedCountAndReset());
EXPECT_EQ(1, observer.CountAndReset()); // resize and add
EXPECT_EQ(0, observer.GetFocusChangedCountAndReset());
EXPECT_EQ(0, observer.GetActivationChangedCountAndReset());
@@ -486,6 +513,7 @@ TEST_F(DisplayControllerTest, SecondaryDisplayLayout) {
SetSecondaryDisplayLayoutAndOffset(DisplayLayout::BOTTOM, -400);
EXPECT_EQ(secondary_display_id, observer.GetChangedDisplayIdAndReset());
EXPECT_EQ(1, observer.GetBoundsChangedCountAndReset());
+ EXPECT_EQ(1, observer.GetWorkareaChangedCountAndReset());
EXPECT_EQ(1, observer.CountAndReset()); // resize and add
EXPECT_EQ(0, observer.GetFocusChangedCountAndReset());
EXPECT_EQ(0, observer.GetActivationChangedCountAndReset());
@@ -496,6 +524,7 @@ TEST_F(DisplayControllerTest, SecondaryDisplayLayout) {
SetSecondaryDisplayLayoutAndOffset(DisplayLayout::BOTTOM, -400);
EXPECT_EQ(0, observer.GetChangedDisplayIdAndReset());
EXPECT_EQ(0, observer.GetBoundsChangedCountAndReset());
+ EXPECT_EQ(0, observer.GetWorkareaChangedCountAndReset());
EXPECT_EQ(0, observer.CountAndReset()); // resize and add
EXPECT_EQ(0, observer.GetFocusChangedCountAndReset());
EXPECT_EQ(0, observer.GetActivationChangedCountAndReset());
@@ -559,6 +588,7 @@ TEST_F(DisplayControllerTest, MirrorToDockedWithFullscreen) {
EXPECT_EQ(1U, display_manager->num_connected_displays());
EXPECT_EQ(0, observer.GetChangedDisplayIdAndReset());
EXPECT_EQ(0, observer.GetBoundsChangedCountAndReset());
+ EXPECT_EQ(0, observer.GetWorkareaChangedCountAndReset());
EXPECT_EQ(1, observer.CountAndReset());
EXPECT_EQ(0, observer.GetFocusChangedCountAndReset());
EXPECT_EQ(0, observer.GetActivationChangedCountAndReset());
@@ -627,12 +657,15 @@ TEST_F(DisplayControllerTest, BoundsUpdated) {
EXPECT_EQ(0, observer.GetActivationChangedCountAndReset());
// Rotation
+ observer.GetRotationChangedCountAndReset(); // we only want to reset.
int64 primary_id = GetPrimaryDisplay().id();
display_manager->SetDisplayRotation(primary_id, gfx::Display::ROTATE_90);
+ EXPECT_EQ(1, observer.GetRotationChangedCountAndReset());
EXPECT_EQ(1, observer.CountAndReset());
EXPECT_EQ(0, observer.GetFocusChangedCountAndReset());
EXPECT_EQ(0, observer.GetActivationChangedCountAndReset());
display_manager->SetDisplayRotation(primary_id, gfx::Display::ROTATE_90);
+ EXPECT_EQ(0, observer.GetRotationChangedCountAndReset());
EXPECT_EQ(0, observer.CountAndReset());
EXPECT_EQ(0, observer.GetFocusChangedCountAndReset());
EXPECT_EQ(0, observer.GetActivationChangedCountAndReset());
@@ -1032,6 +1065,7 @@ TEST_F(DisplayControllerTest, Rotate) {
aura::Window::Windows root_windows = Shell::GetAllRootWindows();
aura::test::EventGenerator generator1(root_windows[0]);
+ TestObserver observer;
EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString());
EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString());
EXPECT_EQ("120,0 150x200",
@@ -1040,6 +1074,7 @@ TEST_F(DisplayControllerTest, Rotate) {
EXPECT_EQ("50,40", event_handler.GetLocationAndReset());
EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display1.id()));
EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display2_id));
+ EXPECT_EQ(0, observer.GetRotationChangedCountAndReset());
display_manager->SetDisplayRotation(display1.id(),
gfx::Display::ROTATE_90);
@@ -1051,6 +1086,7 @@ TEST_F(DisplayControllerTest, Rotate) {
EXPECT_EQ("40,69", event_handler.GetLocationAndReset());
EXPECT_EQ(gfx::Display::ROTATE_90, GetStoredRotation(display1.id()));
EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display2_id));
+ EXPECT_EQ(1, observer.GetRotationChangedCountAndReset());
DisplayLayout display_layout(DisplayLayout::BOTTOM, 50);
display_manager->SetLayoutForCurrentDisplays(display_layout);
@@ -1065,6 +1101,7 @@ TEST_F(DisplayControllerTest, Rotate) {
ScreenUtil::GetSecondaryDisplay().bounds().ToString());
EXPECT_EQ(gfx::Display::ROTATE_90, GetStoredRotation(display1.id()));
EXPECT_EQ(gfx::Display::ROTATE_270, GetStoredRotation(display2_id));
+ EXPECT_EQ(1, observer.GetRotationChangedCountAndReset());
#if !defined(OS_WIN)
aura::test::EventGenerator generator2(root_windows[1]);
@@ -1080,6 +1117,7 @@ TEST_F(DisplayControllerTest, Rotate) {
ScreenUtil::GetSecondaryDisplay().bounds().ToString());
EXPECT_EQ(gfx::Display::ROTATE_180, GetStoredRotation(display1.id()));
EXPECT_EQ(gfx::Display::ROTATE_270, GetStoredRotation(display2_id));
+ EXPECT_EQ(1, observer.GetRotationChangedCountAndReset());
generator1.MoveMouseToInHost(50, 40);
EXPECT_EQ("69,159", event_handler.GetLocationAndReset());
diff --git a/ash/display/display_manager.cc b/ash/display/display_manager.cc
index 9b96cd6..1a981a4 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());
+ screen_ash_->NotifyMetricsChanged(
+ ScreenUtil::GetSecondaryDisplay(),
+ gfx::DisplayObserver::DISPLAY_METRIC_BOUNDS |
+ gfx::DisplayObserver::DISPLAY_METRIC_WORK_AREA);
if (delegate_)
delegate_->PostDisplayConfigurationChange();
}
@@ -643,7 +646,7 @@ void DisplayManager::UpdateDisplays(
new_display_info_list.end(),
DisplayInfoSortFunctor());
DisplayList removed_displays;
- std::vector<size_t> changed_display_indices;
+ std::map<size_t, uint32_t> display_changes;
std::vector<size_t> added_display_indices;
DisplayList::iterator curr_iter = displays_.begin();
@@ -713,18 +716,32 @@ 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();
+ uint32_t metrics = gfx::DisplayObserver::DISPLAY_METRIC_NONE;
- if (force_bounds_changed_ ||
- host_window_bounds_changed ||
- (current_display.device_scale_factor() !=
- new_display.device_scale_factor()) ||
+ // 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_ || (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_METRIC_BOUNDS |
+ gfx::DisplayObserver::DISPLAY_METRIC_WORK_AREA;
+ }
+
+ if (current_display.device_scale_factor() !=
+ new_display.device_scale_factor()) {
+ metrics |= gfx::DisplayObserver::DISPLAY_METRIC_DEVICE_SCALE_FACTOR;
+ }
+
+ if (current_display.rotation() != new_display.rotation())
+ metrics |= gfx::DisplayObserver::DISPLAY_METRIC_ROTATION;
+
+ if (metrics != gfx::DisplayObserver::DISPLAY_METRIC_NONE) {
+ display_changes.insert(
+ std::pair<size_t, uint32_t>(new_displays.size(), metrics));
}
new_display.UpdateWorkAreaFromInsets(current_display.GetWorkAreaInsets());
@@ -751,7 +768,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;
}
@@ -768,11 +785,13 @@ 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()) {
+ uint32_t metrics = gfx::DisplayObserver::DISPLAY_METRIC_BOUNDS |
+ gfx::DisplayObserver::DISPLAY_METRIC_WORK_AREA;
+ if (display_changes.find(updated_index) != display_changes.end())
+ metrics |= display_changes[updated_index];
+
+ display_changes[updated_index] = metrics;
}
displays_ = new_displays;
@@ -801,15 +820,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, uint32_t>::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
}
@@ -957,7 +977,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_METRIC_BOUNDS);
return true;
}
return false;
diff --git a/ash/display/display_manager.h b/ash/display/display_manager.h
index afc6286..cb18507 100644
--- a/ash/display/display_manager.h
+++ b/ash/display/display_manager.h
@@ -105,7 +105,7 @@ class ASH_EXPORT DisplayManager
void set_delegate(Delegate* delegate) { delegate_ = delegate; }
- // When set to true, the MonitorManager calls OnDisplayBoundsChanged
+ // When set to true, the MonitorManager calls OnDisplayMetricsChanged
// even if the display's bounds didn't change. Used to swap primary
// display.
void set_force_bounds_changed(bool force_bounds_changed) {
diff --git a/ash/display/display_manager_unittest.cc b/ash/display/display_manager_unittest.cc
index 3c811d7c..7db5ba9 100644
--- a/ash/display/display_manager_unittest.cc
+++ b/ash/display/display_manager_unittest.cc
@@ -98,7 +98,8 @@ class DisplayManagerTest : public test::AshTestBase,
}
// aura::DisplayObserver overrides:
- virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE {
+ virtual void OnDisplayMetricsChanged(const gfx::Display& display,
+ uint32_t) OVERRIDE {
changed_.push_back(display);
}
virtual void OnDisplayAdded(const gfx::Display& new_display) OVERRIDE {
@@ -387,8 +388,11 @@ TEST_F(DisplayManagerTest, TestDeviceScaleOnlyChange) {
EXPECT_EQ(1, host->compositor()->device_scale_factor());
EXPECT_EQ("1000x600",
Shell::GetPrimaryRootWindow()->bounds().size().ToString());
+ EXPECT_EQ("1 0 0", GetCountSummary());
+
UpdateDisplay("1000x600*2");
EXPECT_EQ(2, host->compositor()->device_scale_factor());
+ EXPECT_EQ("2 0 0", GetCountSummary());
EXPECT_EQ("500x300",
Shell::GetPrimaryRootWindow()->bounds().size().ToString());
}
@@ -846,19 +850,25 @@ TEST_F(DisplayManagerTest, Rotate) {
EXPECT_EQ("2 0 0", GetCountSummary());
reset();
- // Updating tothe same configuration should report no changes.
+ // Updating to the same configuration should report no changes.
UpdateDisplay("100x200/l,300x400");
EXPECT_EQ("0 0 0", GetCountSummary());
reset();
- UpdateDisplay("100x200/l,300x400");
- EXPECT_EQ("0 0 0", GetCountSummary());
+ // Rotating 180 degrees should report one change.
+ UpdateDisplay("100x200/r,300x400");
+ EXPECT_EQ("1 0 0", GetCountSummary());
reset();
UpdateDisplay("200x200");
EXPECT_EQ("1 0 1", GetCountSummary());
reset();
+ // Rotating 180 degrees should report one change.
+ UpdateDisplay("200x200/u");
+ EXPECT_EQ("1 0 0", GetCountSummary());
+ reset();
+
UpdateDisplay("200x200/l");
EXPECT_EQ("1 0 0", GetCountSummary());
}
@@ -1047,8 +1057,7 @@ class TestDisplayObserver : public gfx::DisplayObserver {
virtual ~TestDisplayObserver() {}
// gfx::DisplayObserver overrides:
- virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE {
- }
+ virtual void OnDisplayMetricsChanged(const gfx::Display&,uint32_t) OVERRIDE {}
virtual void OnDisplayAdded(const gfx::Display& new_display) OVERRIDE {
// Mirror window should already be delete before restoring
// the external display.
diff --git a/ash/display/resolution_notification_controller.cc b/ash/display/resolution_notification_controller.cc
index 2c45402..315dd5a 100644
--- a/ash/display/resolution_notification_controller.cc
+++ b/ash/display/resolution_notification_controller.cc
@@ -285,10 +285,6 @@ void ResolutionNotificationController::RevertResolutionChange() {
display_id, old_resolution);
}
-void ResolutionNotificationController::OnDisplayBoundsChanged(
- const gfx::Display& display) {
-}
-
void ResolutionNotificationController::OnDisplayAdded(
const gfx::Display& new_display) {
}
@@ -299,6 +295,10 @@ void ResolutionNotificationController::OnDisplayRemoved(
RevertResolutionChange();
}
+void ResolutionNotificationController::OnDisplayMetricsChanged(
+ const gfx::Display&, uint32_t) {
+}
+
void ResolutionNotificationController::OnDisplayConfigurationChanged() {
if (!change_info_)
return;
diff --git a/ash/display/resolution_notification_controller.h b/ash/display/resolution_notification_controller.h
index 23a582d..9fe4026 100644
--- a/ash/display/resolution_notification_controller.h
+++ b/ash/display/resolution_notification_controller.h
@@ -79,9 +79,10 @@ class ASH_EXPORT ResolutionNotificationController
void OnTimerTick();
// gfx::DisplayObserver overrides:
- virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE;
virtual void OnDisplayAdded(const gfx::Display& new_display) OVERRIDE;
virtual void OnDisplayRemoved(const gfx::Display& old_display) OVERRIDE;
+ virtual void OnDisplayMetricsChanged(const gfx::Display& display,
+ uint32_t metrics) OVERRIDE;
// DisplayController::Observer overrides:
virtual void OnDisplayConfigurationChanged() OVERRIDE;
diff --git a/ash/display/screen_ash.cc b/ash/display/screen_ash.cc
index 9d42e49e..0348cbe 100644
--- a/ash/display/screen_ash.cc
+++ b/ash/display/screen_ash.cc
@@ -188,9 +188,11 @@ const gfx::Display& ScreenAsh::GetDisplayForId(int64 display_id) {
return GetDisplayManager()->GetDisplayForId(display_id);
}
-void ScreenAsh::NotifyBoundsChanged(const gfx::Display& display) {
- FOR_EACH_OBSERVER(gfx::DisplayObserver, observers_,
- OnDisplayBoundsChanged(display));
+void ScreenAsh::NotifyMetricsChanged(const gfx::Display& display,
+ uint32_t metrics) {
+ FOR_EACH_OBSERVER(gfx::DisplayObserver,
+ observers_,
+ OnDisplayMetricsChanged(display, metrics));
}
void ScreenAsh::NotifyDisplayAdded(const gfx::Display& display) {
diff --git a/ash/display/screen_ash.h b/ash/display/screen_ash.h
index 08011b2..c5f4b85 100644
--- a/ash/display/screen_ash.h
+++ b/ash/display/screen_ash.h
@@ -8,6 +8,7 @@
#include "ash/ash_export.h"
#include "base/compiler_specific.h"
#include "base/observer_list.h"
+#include "ui/gfx/display_observer.h"
#include "ui/gfx/screen.h"
namespace gfx {
@@ -81,7 +82,7 @@ class ASH_EXPORT ScreenAsh : public gfx::Screen {
friend class DisplayManager;
// Notifies observers of display configuration changes.
- void NotifyBoundsChanged(const gfx::Display& display);
+ void NotifyMetricsChanged(const gfx::Display& display, uint32_t metrics);
void NotifyDisplayAdded(const gfx::Display& display);
void NotifyDisplayRemoved(const gfx::Display& display);
diff --git a/ash/shelf/shelf_window_watcher.cc b/ash/shelf/shelf_window_watcher.cc
index b16deea..8cc31b6 100644
--- a/ash/shelf/shelf_window_watcher.cc
+++ b/ash/shelf/shelf_window_watcher.cc
@@ -267,9 +267,6 @@ void ShelfWindowWatcher::OnWindowPropertyChanged(aura::Window* window,
AddShelfItem(window);
}
-void ShelfWindowWatcher::OnDisplayBoundsChanged(const gfx::Display& display) {
-}
-
void ShelfWindowWatcher::OnDisplayAdded(const gfx::Display& new_display) {
// Add a new RootWindow and its ActivationClient to observed list.
aura::Window* root_window = Shell::GetInstance()->display_controller()->
@@ -288,4 +285,8 @@ void ShelfWindowWatcher::OnDisplayRemoved(const gfx::Display& old_display) {
// Do nothing here.
}
+void ShelfWindowWatcher::OnDisplayMetricsChanged(const gfx::Display&,
+ uint32_t) {
+}
+
} // namespace ash
diff --git a/ash/shelf/shelf_window_watcher.h b/ash/shelf/shelf_window_watcher.h
index cb99bc7..da16e54 100644
--- a/ash/shelf/shelf_window_watcher.h
+++ b/ash/shelf/shelf_window_watcher.h
@@ -115,9 +115,10 @@ class ShelfWindowWatcher : public aura::client::ActivationChangeObserver,
intptr_t old) OVERRIDE;
// gfx::DisplayObserver overrides:
- virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE;
virtual void OnDisplayAdded(const gfx::Display& display) OVERRIDE;
virtual void OnDisplayRemoved(const gfx::Display& old_display) OVERRIDE;
+ virtual void OnDisplayMetricsChanged(const gfx::Display& display,
+ uint32_t metrics) OVERRIDE;
// Owned by Shell.
ShelfModel* model_;
diff --git a/ash/shell/window_watcher.cc b/ash/shell/window_watcher.cc
index 55231cf..44edaa4 100644
--- a/ash/shell/window_watcher.cc
+++ b/ash/shell/window_watcher.cc
@@ -138,9 +138,6 @@ void WindowWatcher::OnWillRemoveWindow(aura::Window* window) {
}
}
-void WindowWatcher::OnDisplayBoundsChanged(const gfx::Display& display) {
-}
-
void WindowWatcher::OnDisplayAdded(const gfx::Display& new_display) {
aura::Window* root = Shell::GetInstance()->display_controller()->
GetRootWindowForDisplayId(new_display.id());
@@ -152,5 +149,8 @@ void WindowWatcher::OnDisplayRemoved(const gfx::Display& old_display) {
// remove observers.
}
+void WindowWatcher::OnDisplayMetricsChanged(const gfx::Display&, uint32_t) {
+}
+
} // namespace shell
} // namespace ash
diff --git a/ash/shell/window_watcher.h b/ash/shell/window_watcher.h
index 2d94b77..50cd9e4 100644
--- a/ash/shell/window_watcher.h
+++ b/ash/shell/window_watcher.h
@@ -38,9 +38,10 @@ class WindowWatcher : public aura::WindowObserver,
virtual void OnWillRemoveWindow(aura::Window* window) OVERRIDE;
// gfx::DisplayObserver overrides:
- virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE;
virtual void OnDisplayAdded(const gfx::Display& new_display) OVERRIDE;
virtual void OnDisplayRemoved(const gfx::Display& old_display) OVERRIDE;
+ virtual void OnDisplayMetricsChanged(const gfx::Display& display,
+ uint32_t metrics) OVERRIDE;
private:
class WorkspaceWindowWatcher;
diff --git a/ash/system/web_notification/web_notification_tray.cc b/ash/system/web_notification/web_notification_tray.cc
index a4bc850..45280f9 100644
--- a/ash/system/web_notification/web_notification_tray.cc
+++ b/ash/system/web_notification/web_notification_tray.cc
@@ -158,9 +158,10 @@ void WorkAreaObserver::StopObserving() {
void WorkAreaObserver::OnDisplayWorkAreaInsetsChanged() {
UpdateShelf();
- collection_->OnDisplayBoundsChanged(
+ collection_->OnDisplayMetricsChanged(
Shell::GetScreen()->GetDisplayNearestWindow(
- shelf_->shelf_widget()->GetNativeView()));
+ shelf_->shelf_widget()->GetNativeView()),
+ gfx::DisplayObserver::DISPLAY_METRIC_WORK_AREA);
}
void WorkAreaObserver::OnAutoHideStateChanged(ShelfAutoHideState new_state) {
diff --git a/ash/touch/touch_hud_debug.cc b/ash/touch/touch_hud_debug.cc
index 983d86b..20fab48 100644
--- a/ash/touch/touch_hud_debug.cc
+++ b/ash/touch/touch_hud_debug.cc
@@ -465,10 +465,11 @@ void TouchHudDebug::OnTouchEvent(ui::TouchEvent* event) {
label_container_->SetSize(label_container_->GetPreferredSize());
}
-void TouchHudDebug::OnDisplayBoundsChanged(const gfx::Display& display) {
- TouchObserverHUD::OnDisplayBoundsChanged(display);
+void TouchHudDebug::OnDisplayMetricsChanged(const gfx::Display& display,
+ uint32_t metrics) {
+ TouchObserverHUD::OnDisplayMetricsChanged(display, metrics);
- if (display.id() != display_id())
+ if (display.id() != display_id() || !(metrics & DISPLAY_METRIC_BOUNDS))
return;
const gfx::Size& size = display.size();
canvas_->SetSize(size);
diff --git a/ash/touch/touch_hud_debug.h b/ash/touch/touch_hud_debug.h
index 2cac294..12ba64a 100644
--- a/ash/touch/touch_hud_debug.h
+++ b/ash/touch/touch_hud_debug.h
@@ -60,7 +60,8 @@ class ASH_EXPORT TouchHudDebug : public TouchObserverHUD {
// Overriden from TouchObserverHUD.
virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE;
- virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE;
+ virtual void OnDisplayMetricsChanged(const gfx::Display& display,
+ uint32_t metrics) OVERRIDE;
virtual void SetHudForRootWindowController(
RootWindowController* controller) OVERRIDE;
virtual void UnsetHudForRootWindowController(
diff --git a/ash/touch/touch_observer_hud.cc b/ash/touch/touch_observer_hud.cc
index 87d6d4e..f3f0b35 100644
--- a/ash/touch/touch_observer_hud.cc
+++ b/ash/touch/touch_observer_hud.cc
@@ -86,12 +86,6 @@ void TouchObserverHUD::OnWidgetDestroying(views::Widget* widget) {
delete this;
}
-void TouchObserverHUD::OnDisplayBoundsChanged(const gfx::Display& display) {
- if (display.id() != display_id_)
- return;
- widget_->SetSize(display.size());
-}
-
void TouchObserverHUD::OnDisplayAdded(const gfx::Display& new_display) {}
void TouchObserverHUD::OnDisplayRemoved(const gfx::Display& old_display) {
@@ -100,6 +94,14 @@ void TouchObserverHUD::OnDisplayRemoved(const gfx::Display& old_display) {
widget_->CloseNow();
}
+void TouchObserverHUD::OnDisplayMetricsChanged(const gfx::Display& display,
+ uint32_t metrics) {
+ if (display.id() != display_id_ || !(metrics & DISPLAY_METRIC_BOUNDS))
+ return;
+
+ widget_->SetSize(display.size());
+}
+
#if defined(OS_CHROMEOS)
void TouchObserverHUD::OnDisplayModeChanged(
const ui::DisplayConfigurator::DisplayStateList& outputs) {
diff --git a/ash/touch/touch_observer_hud.h b/ash/touch/touch_observer_hud.h
index 2bfbb0d..816fb98 100644
--- a/ash/touch/touch_observer_hud.h
+++ b/ash/touch/touch_observer_hud.h
@@ -59,9 +59,10 @@ class ASH_EXPORT TouchObserverHUD : public ui::EventHandler,
virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE;
// Overridden from gfx::DisplayObserver.
- virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE;
virtual void OnDisplayAdded(const gfx::Display& new_display) OVERRIDE;
virtual void OnDisplayRemoved(const gfx::Display& old_display) OVERRIDE;
+ virtual void OnDisplayMetricsChanged(const gfx::Display& display,
+ uint32_t metrics) OVERRIDE;
#if defined(OS_CHROMEOS)
// Overriden from ui::DisplayConfigurator::Observer.
diff --git a/ash/wm/maximize_mode/maximize_mode_window_manager.cc b/ash/wm/maximize_mode/maximize_mode_window_manager.cc
index 15d1ca2..15278bf 100644
--- a/ash/wm/maximize_mode/maximize_mode_window_manager.cc
+++ b/ash/wm/maximize_mode/maximize_mode_window_manager.cc
@@ -115,11 +115,6 @@ void MaximizeModeWindowManager::OnWindowBoundsChanged(
}
}
-void MaximizeModeWindowManager::OnDisplayBoundsChanged(
- const gfx::Display& display) {
- // Nothing to do here.
-}
-
void MaximizeModeWindowManager::OnDisplayAdded(const gfx::Display& display) {
DisplayConfigurationChanged();
}
@@ -128,6 +123,11 @@ void MaximizeModeWindowManager::OnDisplayRemoved(const gfx::Display& display) {
DisplayConfigurationChanged();
}
+void MaximizeModeWindowManager::OnDisplayMetricsChanged(const gfx::Display&,
+ uint32_t) {
+ // Nothing to do here.
+}
+
void MaximizeModeWindowManager::OnTouchEvent(ui::TouchEvent* event) {
if (event->type() != ui::ET_TOUCH_PRESSED)
return;
diff --git a/ash/wm/maximize_mode/maximize_mode_window_manager.h b/ash/wm/maximize_mode/maximize_mode_window_manager.h
index 2b421c5..8bc851a 100644
--- a/ash/wm/maximize_mode/maximize_mode_window_manager.h
+++ b/ash/wm/maximize_mode/maximize_mode_window_manager.h
@@ -56,11 +56,11 @@ class ASH_EXPORT MaximizeModeWindowManager : public aura::WindowObserver,
const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) OVERRIDE;
- // aura::DisplayObserver overrides:
- virtual void OnDisplayBoundsChanged(
- const gfx::Display& display) OVERRIDE;
+ // gfx::DisplayObserver overrides:
virtual void OnDisplayAdded(const gfx::Display& display) OVERRIDE;
virtual void OnDisplayRemoved(const gfx::Display& display) OVERRIDE;
+ virtual void OnDisplayMetricsChanged(const gfx::Display& display,
+ uint32_t metrics) OVERRIDE;
// ui::EventHandler override:
virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE;
diff --git a/ash/wm/overview/window_selector.cc b/ash/wm/overview/window_selector.cc
index 3e9a478..04fbccb 100644
--- a/ash/wm/overview/window_selector.cc
+++ b/ash/wm/overview/window_selector.cc
@@ -325,16 +325,17 @@ void WindowSelector::OnTouchEvent(ui::TouchEvent* event) {
SelectWindow(target);
}
-void WindowSelector::OnDisplayBoundsChanged(const gfx::Display& display) {
- PositionWindows(/* animate */ false);
-}
-
void WindowSelector::OnDisplayAdded(const gfx::Display& display) {
}
void WindowSelector::OnDisplayRemoved(const gfx::Display& display) {
}
+void WindowSelector::OnDisplayMetricsChanged(const gfx::Display& display,
+ uint32_t metrics) {
+ PositionWindows(/* animate */ false);
+}
+
void WindowSelector::OnWindowAdded(aura::Window* new_window) {
if (new_window->type() != ui::wm::WINDOW_TYPE_NORMAL &&
new_window->type() != ui::wm::WINDOW_TYPE_PANEL) {
diff --git a/ash/wm/overview/window_selector.h b/ash/wm/overview/window_selector.h
index 9356b13..bfb0c14 100644
--- a/ash/wm/overview/window_selector.h
+++ b/ash/wm/overview/window_selector.h
@@ -68,9 +68,10 @@ class ASH_EXPORT WindowSelector
virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE;
// gfx::DisplayObserver:
- virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE;
virtual void OnDisplayAdded(const gfx::Display& display) OVERRIDE;
virtual void OnDisplayRemoved(const gfx::Display& display) OVERRIDE;
+ virtual void OnDisplayMetricsChanged(const gfx::Display& display,
+ uint32_t metrics) OVERRIDE;
// aura::WindowObserver:
virtual void OnWindowAdded(aura::Window* new_window) OVERRIDE;