summaryrefslogtreecommitdiffstats
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
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
-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
-rw-r--r--chrome/browser/extensions/api/system_info/system_info_api.cc11
-rw-r--r--chrome/browser/ui/ash/launcher/browser_status_monitor.cc10
-rw-r--r--chrome/browser/ui/ash/launcher/browser_status_monitor.h3
-rw-r--r--chrome/browser/ui/webui/options/chromeos/display_overscan_handler.cc8
-rw-r--r--chrome/browser/ui/webui/options/chromeos/display_overscan_handler.h3
-rw-r--r--content/browser/renderer_host/render_widget_host_view_aura.cc21
-rw-r--r--content/browser/renderer_host/render_widget_host_view_aura.h3
-rw-r--r--media/video/capture/linux/video_capture_device_chromeos.cc11
-rw-r--r--ui/gfx/display_observer.h16
-rw-r--r--ui/message_center/views/message_popup_collection.cc17
-rw-r--r--ui/message_center/views/message_popup_collection.h5
-rw-r--r--ui/message_center/views/toast_contents_view.cc13
-rw-r--r--ui/views/widget/desktop_aura/desktop_screen_x11.cc30
-rw-r--r--ui/views/widget/desktop_aura/desktop_screen_x11_unittest.cc102
37 files changed, 373 insertions, 149 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;
diff --git a/chrome/browser/extensions/api/system_info/system_info_api.cc b/chrome/browser/extensions/api/system_info/system_info_api.cc
index 7c76083..99f49f5 100644
--- a/chrome/browser/extensions/api/system_info/system_info_api.cc
+++ b/chrome/browser/extensions/api/system_info/system_info_api.cc
@@ -66,9 +66,10 @@ class SystemInfoEventRouter : public gfx::DisplayObserver,
private:
// 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;
// RemovableStorageObserver implementation.
virtual void OnRemovableStorageAttached(
@@ -182,16 +183,16 @@ void SystemInfoEventRouter::OnRemovableStorageDetached(
DispatchEvent(system_storage::OnDetached::kEventName, args.Pass());
}
-void SystemInfoEventRouter::OnDisplayBoundsChanged(
- const gfx::Display& display) {
+void SystemInfoEventRouter::OnDisplayAdded(const gfx::Display& new_display) {
OnDisplayChanged();
}
-void SystemInfoEventRouter::OnDisplayAdded(const gfx::Display& new_display) {
+void SystemInfoEventRouter::OnDisplayRemoved(const gfx::Display& old_display) {
OnDisplayChanged();
}
-void SystemInfoEventRouter::OnDisplayRemoved(const gfx::Display& old_display) {
+void SystemInfoEventRouter::OnDisplayMetricsChanged(const gfx::Display& display,
+ uint32_t metrics) {
OnDisplayChanged();
}
diff --git a/chrome/browser/ui/ash/launcher/browser_status_monitor.cc b/chrome/browser/ui/ash/launcher/browser_status_monitor.cc
index 36b1935..a2a296f 100644
--- a/chrome/browser/ui/ash/launcher/browser_status_monitor.cc
+++ b/chrome/browser/ui/ash/launcher/browser_status_monitor.cc
@@ -224,11 +224,6 @@ void BrowserStatusMonitor::OnBrowserRemoved(Browser* browser) {
UpdateBrowserItemState();
}
-void BrowserStatusMonitor::OnDisplayBoundsChanged(
- const gfx::Display& display) {
- // Do nothing here.
-}
-
void BrowserStatusMonitor::OnDisplayAdded(const gfx::Display& new_display) {
// Add a new RootWindow and its ActivationClient to observed list.
aura::Window* root_window = ash::Shell::GetInstance()->
@@ -249,6 +244,11 @@ void BrowserStatusMonitor::OnDisplayRemoved(const gfx::Display& old_display) {
// Do nothing here.
}
+void BrowserStatusMonitor::OnDisplayMetricsChanged(const gfx::Display&,
+ uint32_t) {
+ // Do nothing here.
+}
+
void BrowserStatusMonitor::ActiveTabChanged(content::WebContents* old_contents,
content::WebContents* new_contents,
int index,
diff --git a/chrome/browser/ui/ash/launcher/browser_status_monitor.h b/chrome/browser/ui/ash/launcher/browser_status_monitor.h
index 426ef6e..8b46002 100644
--- a/chrome/browser/ui/ash/launcher/browser_status_monitor.h
+++ b/chrome/browser/ui/ash/launcher/browser_status_monitor.h
@@ -67,9 +67,10 @@ class BrowserStatusMonitor : public aura::client::ActivationChangeObserver,
virtual void OnBrowserRemoved(Browser* browser) 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;
// TabStripModelObserver overrides:
virtual void ActiveTabChanged(content::WebContents* old_contents,
diff --git a/chrome/browser/ui/webui/options/chromeos/display_overscan_handler.cc b/chrome/browser/ui/webui/options/chromeos/display_overscan_handler.cc
index c176b0b..d7d5d92 100644
--- a/chrome/browser/ui/webui/options/chromeos/display_overscan_handler.cc
+++ b/chrome/browser/ui/webui/options/chromeos/display_overscan_handler.cc
@@ -81,10 +81,6 @@ void DisplayOverscanHandler::RegisterMessages() {
base::Unretained(this)));
}
-void DisplayOverscanHandler::OnDisplayBoundsChanged(
- const gfx::Display& display) {
-}
-
void DisplayOverscanHandler::OnDisplayAdded(const gfx::Display& new_display) {
web_ui()->CallJavascriptFunction(
"options.DisplayOverscan.onOverscanCanceled");
@@ -95,6 +91,10 @@ void DisplayOverscanHandler::OnDisplayRemoved(const gfx::Display& old_display) {
"options.DisplayOverscan.onOverscanCanceled");
}
+void DisplayOverscanHandler::OnDisplayMetricsChanged(const gfx::Display&,
+ uint32_t) {
+}
+
void DisplayOverscanHandler::HandleStart(const base::ListValue* args) {
int64 display_id = gfx::Display::kInvalidDisplayID;
std::string id_value;
diff --git a/chrome/browser/ui/webui/options/chromeos/display_overscan_handler.h b/chrome/browser/ui/webui/options/chromeos/display_overscan_handler.h
index 65658a0..dbb4787 100644
--- a/chrome/browser/ui/webui/options/chromeos/display_overscan_handler.h
+++ b/chrome/browser/ui/webui/options/chromeos/display_overscan_handler.h
@@ -34,9 +34,10 @@ class DisplayOverscanHandler : public ::options::OptionsPageUIHandler,
virtual void RegisterMessages() OVERRIDE;
// gfx::DisplayObserver implementation.
- 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:
// Handlers of JS messages.
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc
index 79a6e8f..08b5708 100644
--- a/content/browser/renderer_host/render_widget_host_view_aura.cc
+++ b/content/browser/renderer_host/render_widget_host_view_aura.cc
@@ -1529,16 +1529,6 @@ void RenderWidgetHostViewAura::OnCandidateWindowHidden() {
////////////////////////////////////////////////////////////////////////////////
// RenderWidgetHostViewAura, gfx::DisplayObserver implementation:
-void RenderWidgetHostViewAura::OnDisplayBoundsChanged(
- const gfx::Display& display) {
- gfx::Screen* screen = gfx::Screen::GetScreenFor(window_);
- if (display.id() == screen->GetDisplayNearestWindow(window_).id()) {
- UpdateScreenInfo(window_);
- current_cursor_.SetDisplayInfo(display);
- UpdateCursorIfOverSelf();
- }
-}
-
void RenderWidgetHostViewAura::OnDisplayAdded(
const gfx::Display& new_display) {
}
@@ -1547,6 +1537,17 @@ void RenderWidgetHostViewAura::OnDisplayRemoved(
const gfx::Display& old_display) {
}
+void RenderWidgetHostViewAura::OnDisplayMetricsChanged(
+ const gfx::Display& display, uint32_t metrics) {
+ // The screen info should be updated regardless of the metric change.
+ gfx::Screen* screen = gfx::Screen::GetScreenFor(window_);
+ if (display.id() == screen->GetDisplayNearestWindow(window_).id()) {
+ UpdateScreenInfo(window_);
+ current_cursor_.SetDisplayInfo(display);
+ UpdateCursorIfOverSelf();
+ }
+}
+
////////////////////////////////////////////////////////////////////////////////
// RenderWidgetHostViewAura, aura::WindowDelegate implementation:
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.h b/content/browser/renderer_host/render_widget_host_view_aura.h
index 9382b79..e5183f9 100644
--- a/content/browser/renderer_host/render_widget_host_view_aura.h
+++ b/content/browser/renderer_host/render_widget_host_view_aura.h
@@ -260,9 +260,10 @@ class CONTENT_EXPORT RenderWidgetHostViewAura
virtual void OnCandidateWindowHidden() 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;
// Overridden from aura::WindowDelegate:
virtual gfx::Size GetMinimumSize() const OVERRIDE;
diff --git a/media/video/capture/linux/video_capture_device_chromeos.cc b/media/video/capture/linux/video_capture_device_chromeos.cc
index 40e6eaa..fd213e0 100644
--- a/media/video/capture/linux/video_capture_device_chromeos.cc
+++ b/media/video/capture/linux/video_capture_device_chromeos.cc
@@ -45,13 +45,14 @@ class VideoCaptureDeviceChromeOS::ScreenObserverDelegate
DCHECK(!capture_device_);
}
- // gfx::DisplayObserver:
- virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE {
- SendDisplayRotation(display);
- }
-
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 (!(metrics & DISPLAY_METRIC_ROTATION))
+ return;
+ SendDisplayRotation(display);
+ }
void AddObserverOnUIThread() {
DCHECK(ui_task_runner_->BelongsToCurrentThread());
diff --git a/ui/gfx/display_observer.h b/ui/gfx/display_observer.h
index ca97247..0730f26 100644
--- a/ui/gfx/display_observer.h
+++ b/ui/gfx/display_observer.h
@@ -5,6 +5,8 @@
#ifndef UI_GFX_DISPLAY_OBSERVER_H_
#define UI_GFX_DISPLAY_OBSERVER_H_
+#include <stdint.h>
+
#include "ui/gfx/gfx_export.h"
namespace gfx {
@@ -15,8 +17,13 @@ class Display;
// |DisplaySettingsProvier|. crbug.com/122863.
class GFX_EXPORT DisplayObserver {
public:
- // Called when the |display|'s bound has changed.
- virtual void OnDisplayBoundsChanged(const Display& display) = 0;
+ enum DisplayMetric {
+ DISPLAY_METRIC_NONE = 0,
+ DISPLAY_METRIC_BOUNDS = 1 << 0,
+ DISPLAY_METRIC_WORK_AREA = 1 << 1,
+ DISPLAY_METRIC_DEVICE_SCALE_FACTOR = 1 << 2,
+ DISPLAY_METRIC_ROTATION = 1 << 3,
+ };
// Called when |new_display| has been added.
virtual void OnDisplayAdded(const Display& new_display) = 0;
@@ -24,6 +31,11 @@ class GFX_EXPORT DisplayObserver {
// Called when |old_display| has been removed.
virtual void OnDisplayRemoved(const Display& old_display) = 0;
+ // Called when a |display| has one or more metrics changed. |changed_metrics|
+ // will contain the information about the change, see |DisplayMetric|.
+ virtual void OnDisplayMetricsChanged(const Display& display,
+ uint32_t changed_metrics) = 0;
+
protected:
virtual ~DisplayObserver();
};
diff --git a/ui/message_center/views/message_popup_collection.cc b/ui/message_center/views/message_popup_collection.cc
index 4dd70a4..d1116d6 100644
--- a/ui/message_center/views/message_popup_collection.cc
+++ b/ui/message_center/views/message_popup_collection.cc
@@ -561,14 +561,6 @@ void MessagePopupCollection::SetDisplayInfo(const gfx::Rect& work_area,
RepositionWidgets();
}
-void MessagePopupCollection::OnDisplayBoundsChanged(
- const gfx::Display& display) {
- if (display.id() != display_id_)
- return;
-
- SetDisplayInfo(display.work_area(), display.bounds());
-}
-
void MessagePopupCollection::OnDisplayAdded(const gfx::Display& new_display) {
}
@@ -580,6 +572,15 @@ void MessagePopupCollection::OnDisplayRemoved(const gfx::Display& old_display) {
}
}
+void MessagePopupCollection::OnDisplayMetricsChanged(
+ const gfx::Display& display, uint32_t metrics) {
+ if (display.id() != display_id_)
+ return;
+
+ if (metrics & DISPLAY_METRIC_BOUNDS || metrics & DISPLAY_METRIC_WORK_AREA)
+ SetDisplayInfo(display.work_area(), display.bounds());
+}
+
views::Widget* MessagePopupCollection::GetWidgetForTest(const std::string& id)
const {
for (Toasts::const_iterator iter = toasts_.begin(); iter != toasts_.end();
diff --git a/ui/message_center/views/message_popup_collection.h b/ui/message_center/views/message_popup_collection.h
index 907274e..955af32 100644
--- a/ui/message_center/views/message_popup_collection.h
+++ b/ui/message_center/views/message_popup_collection.h
@@ -111,7 +111,7 @@ class MESSAGE_CENTER_EXPORT MessagePopupCollection
// Updates |work_area_| and re-calculates the alignment of notification toasts
// rearranging them if necessary.
- // This is separated from methods from OnDisplayBoundsChanged(), since
+ // This is separated from methods from OnDisplayMetricsChanged(), since
// sometimes the display info has to be specified directly. One example is
// shelf's auto-hide change. When the shelf in ChromeOS is temporarily shown
// from auto hide status, it doesn't change the display's work area but the
@@ -120,9 +120,10 @@ class MESSAGE_CENTER_EXPORT MessagePopupCollection
const gfx::Rect& screen_bounds);
// Overridden from gfx::DislayObserver:
- 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;
// Used by ToastContentsView to locate itself.
gfx::NativeView parent() const { return parent_; }
diff --git a/ui/message_center/views/toast_contents_view.cc b/ui/message_center/views/toast_contents_view.cc
index 52b29de..e9ca48e 100644
--- a/ui/message_center/views/toast_contents_view.cc
+++ b/ui/message_center/views/toast_contents_view.cc
@@ -28,6 +28,8 @@
#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
#endif
+using gfx::Screen;
+
namespace message_center {
namespace {
@@ -243,8 +245,10 @@ void ToastContentsView::OnDisplayChanged() {
if (!native_view || !collection_.get())
return;
- collection_->OnDisplayBoundsChanged(gfx::Screen::GetScreenFor(
- native_view)->GetDisplayNearestWindow(native_view));
+ collection_->OnDisplayMetricsChanged(
+ Screen::GetScreenFor(native_view)->GetDisplayNearestWindow(native_view),
+ gfx::DisplayObserver::DISPLAY_METRIC_BOUNDS |
+ gfx::DisplayObserver::DISPLAY_METRIC_WORK_AREA);
}
void ToastContentsView::OnWorkAreaChanged() {
@@ -256,8 +260,9 @@ void ToastContentsView::OnWorkAreaChanged() {
if (!native_view || !collection_.get())
return;
- collection_->OnDisplayBoundsChanged(gfx::Screen::GetScreenFor(
- native_view)->GetDisplayNearestWindow(native_view));
+ collection_->OnDisplayMetricsChanged(
+ Screen::GetScreenFor(native_view)->GetDisplayNearestWindow(native_view),
+ gfx::DisplayObserver::DISPLAY_METRIC_WORK_AREA);
}
// views::View
diff --git a/ui/views/widget/desktop_aura/desktop_screen_x11.cc b/ui/views/widget/desktop_aura/desktop_screen_x11.cc
index d927780..fef23aa 100644
--- a/ui/views/widget/desktop_aura/desktop_screen_x11.cc
+++ b/ui/views/widget/desktop_aura/desktop_screen_x11.cc
@@ -137,15 +137,31 @@ void DesktopScreenX11::ProcessDisplayChange(
bool found = false;
for (std::vector<gfx::Display>::const_iterator old_it =
old_displays.begin(); old_it != old_displays.end(); ++old_it) {
- if (new_it->id() == old_it->id()) {
- if (new_it->bounds() != old_it->bounds()) {
- FOR_EACH_OBSERVER(gfx::DisplayObserver, observer_list_,
- OnDisplayBoundsChanged(*new_it));
- }
+ if (new_it->id() != old_it->id())
+ continue;
- found = true;
- break;
+ uint32_t metrics = gfx::DisplayObserver::DISPLAY_METRIC_NONE;
+
+ if (new_it->bounds() != old_it->bounds())
+ metrics |= gfx::DisplayObserver::DISPLAY_METRIC_BOUNDS;
+
+ if (new_it->rotation() != old_it->rotation())
+ metrics |= gfx::DisplayObserver::DISPLAY_METRIC_ROTATION;
+
+ if (new_it->work_area() != old_it->work_area())
+ metrics |= gfx::DisplayObserver::DISPLAY_METRIC_WORK_AREA;
+
+ if (new_it->device_scale_factor() != old_it->device_scale_factor())
+ metrics |= gfx::DisplayObserver::DISPLAY_METRIC_DEVICE_SCALE_FACTOR;
+
+ if (metrics != gfx::DisplayObserver::DISPLAY_METRIC_NONE) {
+ FOR_EACH_OBSERVER(gfx::DisplayObserver,
+ observer_list_,
+ OnDisplayMetricsChanged(*new_it, metrics));
}
+
+ found = true;
+ break;
}
if (!found) {
diff --git a/ui/views/widget/desktop_aura/desktop_screen_x11_unittest.cc b/ui/views/widget/desktop_aura/desktop_screen_x11_unittest.cc
index 8a48ad1..c0f5d2f 100644
--- a/ui/views/widget/desktop_aura/desktop_screen_x11_unittest.cc
+++ b/ui/views/widget/desktop_aura/desktop_screen_x11_unittest.cc
@@ -176,10 +176,6 @@ class DesktopScreenX11Test : public views::ViewsTestBase,
private:
// Overridden from gfx::DisplayObserver:
- virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE {
- changed_display_.push_back(display);
- }
-
virtual void OnDisplayAdded(const gfx::Display& new_display) OVERRIDE {
added_display_.push_back(new_display);
}
@@ -188,6 +184,11 @@ class DesktopScreenX11Test : public views::ViewsTestBase,
removed_display_.push_back(old_display);
}
+ virtual void OnDisplayMetricsChanged(const gfx::Display& display,
+ uint32_t metrics) OVERRIDE {
+ changed_display_.push_back(display);
+ }
+
scoped_ptr<DesktopScreenX11> screen_;
DISALLOW_COPY_AND_ASSIGN(DesktopScreenX11Test);
@@ -455,4 +456,97 @@ TEST_F(DesktopScreenX11Test, RightClickDuringDoubleClickDoesntMaximize) {
widget->CloseNow();
}
+// Test that rotating the displays notifies the DisplayObservers.
+TEST_F(DesktopScreenX11Test, RotationChange) {
+ std::vector<gfx::Display> displays;
+ displays.push_back(gfx::Display(kFirstDisplay, gfx::Rect(0, 0, 640, 480)));
+ displays.push_back(
+ gfx::Display(kSecondDisplay, gfx::Rect(640, 0, 1024, 768)));
+ screen()->ProcessDisplayChange(displays);
+ ResetDisplayChanges();
+
+ displays[0].set_rotation(gfx::Display::ROTATE_90);
+ screen()->ProcessDisplayChange(displays);
+ EXPECT_EQ(1u, changed_display_.size());
+
+ displays[1].set_rotation(gfx::Display::ROTATE_90);
+ screen()->ProcessDisplayChange(displays);
+ EXPECT_EQ(2u, changed_display_.size());
+
+ displays[0].set_rotation(gfx::Display::ROTATE_270);
+ screen()->ProcessDisplayChange(displays);
+ EXPECT_EQ(3u, changed_display_.size());
+
+ displays[0].set_rotation(gfx::Display::ROTATE_270);
+ screen()->ProcessDisplayChange(displays);
+ EXPECT_EQ(3u, changed_display_.size());
+
+ displays[0].set_rotation(gfx::Display::ROTATE_0);
+ displays[1].set_rotation(gfx::Display::ROTATE_0);
+ screen()->ProcessDisplayChange(displays);
+ EXPECT_EQ(5u, changed_display_.size());
+}
+
+// Test that changing the displays workarea notifies the DisplayObservers.
+TEST_F(DesktopScreenX11Test, WorkareaChange) {
+ std::vector<gfx::Display> displays;
+ displays.push_back(gfx::Display(kFirstDisplay, gfx::Rect(0, 0, 640, 480)));
+ displays.push_back(
+ gfx::Display(kSecondDisplay, gfx::Rect(640, 0, 1024, 768)));
+ screen()->ProcessDisplayChange(displays);
+ ResetDisplayChanges();
+
+ displays[0].set_work_area(gfx::Rect(0, 0, 300, 300));
+ screen()->ProcessDisplayChange(displays);
+ EXPECT_EQ(1u, changed_display_.size());
+
+ displays[1].set_work_area(gfx::Rect(0, 0, 300, 300));
+ screen()->ProcessDisplayChange(displays);
+ EXPECT_EQ(2u, changed_display_.size());
+
+ displays[0].set_work_area(gfx::Rect(0, 0, 300, 300));
+ screen()->ProcessDisplayChange(displays);
+ EXPECT_EQ(2u, changed_display_.size());
+
+ displays[1].set_work_area(gfx::Rect(0, 0, 300, 300));
+ screen()->ProcessDisplayChange(displays);
+ EXPECT_EQ(2u, changed_display_.size());
+
+ displays[0].set_work_area(gfx::Rect(0, 0, 640, 480));
+ displays[1].set_work_area(gfx::Rect(640, 0, 1024, 768));
+ screen()->ProcessDisplayChange(displays);
+ EXPECT_EQ(4u, changed_display_.size());
+}
+
+// Test that changing the device scale factor notifies the DisplayObservers.
+TEST_F(DesktopScreenX11Test, DeviceScaleFactorChange) {
+ std::vector<gfx::Display> displays;
+ displays.push_back(gfx::Display(kFirstDisplay, gfx::Rect(0, 0, 640, 480)));
+ displays.push_back(
+ gfx::Display(kSecondDisplay, gfx::Rect(640, 0, 1024, 768)));
+ screen()->ProcessDisplayChange(displays);
+ ResetDisplayChanges();
+
+ displays[0].set_device_scale_factor(2.5f);
+ screen()->ProcessDisplayChange(displays);
+ EXPECT_EQ(1u, changed_display_.size());
+
+ displays[1].set_device_scale_factor(2.5f);
+ screen()->ProcessDisplayChange(displays);
+ EXPECT_EQ(2u, changed_display_.size());
+
+ displays[0].set_device_scale_factor(2.5f);
+ screen()->ProcessDisplayChange(displays);
+ EXPECT_EQ(2u, changed_display_.size());
+
+ displays[1].set_device_scale_factor(2.5f);
+ screen()->ProcessDisplayChange(displays);
+ EXPECT_EQ(2u, changed_display_.size());
+
+ displays[0].set_device_scale_factor(1.f);
+ displays[1].set_device_scale_factor(1.f);
+ screen()->ProcessDisplayChange(displays);
+ EXPECT_EQ(4u, changed_display_.size());
+}
+
} // namespace views