summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzea@chromium.org <zea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-20 23:28:26 +0000
committerzea@chromium.org <zea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-20 23:28:26 +0000
commitde40134baeebb2428b11e7ea64d60f707cd23045 (patch)
tree8db57df432ed8fd60a2bd07cb981d93554eb3c1f
parent051ec4a92dc44356dbf55b568978ada2d056be85 (diff)
downloadchromium_src-de40134baeebb2428b11e7ea64d60f707cd23045.zip
chromium_src-de40134baeebb2428b11e7ea64d60f707cd23045.tar.gz
chromium_src-de40134baeebb2428b11e7ea64d60f707cd23045.tar.bz2
Revert of Add OnDisplayMetricsChanged in DisplayObserver. (https://codereview.chromium.org/259253002/)
Reason for revert: Breaks DesktopScreenX11Test.RemoveMonitorOnRight and AddMonitorToTheRight on Linux Tests TBR=mlamouri@chromium.org NOTRY=true NOTREECHECKS=true http://build.chromium.org/p/chromium.linux/buildstatus?builder=Linux%20Tests&number=11092 Original issue's description: > 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/294963004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@271782 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.cc106
37 files changed, 151 insertions, 375 deletions
diff --git a/ash/display/display_controller.cc b/ash/display/display_controller.cc
index aebe47c..99c997f 100644
--- a/ash/display/display_controller.cc
+++ b/ash/display/display_controller.cc
@@ -549,6 +549,15 @@ 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());
@@ -603,9 +612,8 @@ void DisplayController::OnDisplayRemoved(const gfx::Display& display) {
GetRootWindowSettings(GetWindow(primary_host))->display_id =
primary_display_id;
- OnDisplayMetricsChanged(
- GetDisplayManager()->GetDisplayForId(primary_display_id),
- DISPLAY_METRIC_BOUNDS);
+ OnDisplayBoundsChanged(
+ GetDisplayManager()->GetDisplayForId(primary_display_id));
}
RootWindowController* controller =
GetRootWindowController(GetWindow(host_to_delete));
@@ -617,20 +625,6 @@ 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 dd92ab3..00c1ac6 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);
- // gfx::DisplayObserver overrides:
+ // aura::DisplayObserver overrides:
+ 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::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 5ee4cae..95b7af6 100644
--- a/ash/display/display_controller_unittest.cc
+++ b/ash/display/display_controller_unittest.cc
@@ -67,8 +67,6 @@ 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) {
@@ -98,15 +96,9 @@ class TestObserver : public DisplayController::Observer,
}
// Overrideen from gfx::DisplayObserver
- virtual void OnDisplayMetricsChanged(const gfx::Display& display,
- uint32_t metrics) OVERRIDE {
+ virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE {
changed_display_id_ = display.id();
- 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_;
+ bounds_changed_count_ ++;
}
virtual void OnDisplayAdded(const gfx::Display& new_display) OVERRIDE {
}
@@ -139,14 +131,6 @@ 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();
}
@@ -164,8 +148,6 @@ 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_;
@@ -405,7 +387,6 @@ 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);
@@ -424,7 +405,6 @@ 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());
@@ -436,7 +416,6 @@ 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());
@@ -448,7 +427,6 @@ 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());
@@ -460,7 +438,6 @@ 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());
@@ -471,7 +448,6 @@ 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());
@@ -481,7 +457,6 @@ 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());
@@ -492,7 +467,6 @@ 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());
@@ -503,7 +477,6 @@ 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());
@@ -513,7 +486,6 @@ 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());
@@ -524,7 +496,6 @@ 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());
@@ -588,7 +559,6 @@ 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());
@@ -657,15 +627,12 @@ 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());
@@ -1065,7 +1032,6 @@ 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",
@@ -1074,7 +1040,6 @@ 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);
@@ -1086,7 +1051,6 @@ 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);
@@ -1101,7 +1065,6 @@ 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]);
@@ -1117,7 +1080,6 @@ 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 1a981a4..9b96cd6 100644
--- a/ash/display/display_manager.cc
+++ b/ash/display/display_manager.cc
@@ -27,7 +27,6 @@
#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"
@@ -348,10 +347,8 @@ void DisplayManager::SetLayoutForCurrentDisplays(
// Primary's bounds stay the same. Just notify bounds change
// on the secondary.
- screen_ash_->NotifyMetricsChanged(
- ScreenUtil::GetSecondaryDisplay(),
- gfx::DisplayObserver::DISPLAY_METRIC_BOUNDS |
- gfx::DisplayObserver::DISPLAY_METRIC_WORK_AREA);
+ screen_ash_->NotifyBoundsChanged(
+ ScreenUtil::GetSecondaryDisplay());
if (delegate_)
delegate_->PostDisplayConfigurationChange();
}
@@ -646,7 +643,7 @@ void DisplayManager::UpdateDisplays(
new_display_info_list.end(),
DisplayInfoSortFunctor());
DisplayList removed_displays;
- std::map<size_t, uint32_t> display_changes;
+ std::vector<size_t> changed_display_indices;
std::vector<size_t> added_display_indices;
DisplayList::iterator curr_iter = displays_.begin();
@@ -716,32 +713,18 @@ void DisplayManager::UpdateDisplays(
CreateDisplayFromDisplayInfoById(new_info_iter->id());
const DisplayInfo& new_display_info = GetDisplayInfo(new_display.id());
- uint32_t metrics = gfx::DisplayObserver::DISPLAY_METRIC_NONE;
+ bool host_window_bounds_changed =
+ current_display_info.bounds_in_native() !=
+ new_display_info.bounds_in_native();
- // 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()) ||
+ if (force_bounds_changed_ ||
+ host_window_bounds_changed ||
+ (current_display.device_scale_factor() !=
+ new_display.device_scale_factor()) ||
(current_display_info.size_in_pixel() !=
- 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.GetSizeInPixel()) ||
+ (current_display.rotation() != new_display.rotation())) {
+ changed_display_indices.push_back(new_displays.size());
}
new_display.UpdateWorkAreaFromInsets(current_display.GetWorkAreaInsets());
@@ -768,7 +751,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 (display_changes.empty() && added_display_indices.empty() &&
+ if (changed_display_indices.empty() && added_display_indices.empty() &&
removed_displays.empty()) {
return;
}
@@ -785,13 +768,11 @@ 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()) {
- 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;
+ 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);
}
displays_ = new_displays;
@@ -820,16 +801,15 @@ 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::map<size_t, uint32_t>::iterator iter = display_changes.begin();
- iter != display_changes.end();
- ++iter) {
- screen_ash_->NotifyMetricsChanged(displays_[iter->first], iter->second);
+ for (std::vector<size_t>::iterator iter = changed_display_indices.begin();
+ iter != changed_display_indices.end(); ++iter) {
+ screen_ash_->NotifyBoundsChanged(displays_[*iter]);
}
if (delegate_)
delegate_->PostDisplayConfigurationChange();
#if defined(USE_X11) && defined(OS_CHROMEOS)
- if (!display_changes.empty() && base::SysInfo::IsRunningOnChromeOS())
+ if (!changed_display_indices.empty() && base::SysInfo::IsRunningOnChromeOS())
ui::ClearX11DefaultRootWindow();
#endif
}
@@ -977,8 +957,7 @@ 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_->NotifyMetricsChanged(
- *display, gfx::DisplayObserver::DISPLAY_METRIC_BOUNDS);
+ screen_ash_->NotifyBoundsChanged(*display);
return true;
}
return false;
diff --git a/ash/display/display_manager.h b/ash/display/display_manager.h
index cb18507..afc6286 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 OnDisplayMetricsChanged
+ // When set to true, the MonitorManager calls OnDisplayBoundsChanged
// 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 7db5ba9..3c811d7c 100644
--- a/ash/display/display_manager_unittest.cc
+++ b/ash/display/display_manager_unittest.cc
@@ -98,8 +98,7 @@ class DisplayManagerTest : public test::AshTestBase,
}
// aura::DisplayObserver overrides:
- virtual void OnDisplayMetricsChanged(const gfx::Display& display,
- uint32_t) OVERRIDE {
+ virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE {
changed_.push_back(display);
}
virtual void OnDisplayAdded(const gfx::Display& new_display) OVERRIDE {
@@ -388,11 +387,8 @@ 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());
}
@@ -850,25 +846,19 @@ TEST_F(DisplayManagerTest, Rotate) {
EXPECT_EQ("2 0 0", GetCountSummary());
reset();
- // Updating to the same configuration should report no changes.
+ // Updating tothe same configuration should report no changes.
UpdateDisplay("100x200/l,300x400");
EXPECT_EQ("0 0 0", GetCountSummary());
reset();
- // Rotating 180 degrees should report one change.
- UpdateDisplay("100x200/r,300x400");
- EXPECT_EQ("1 0 0", GetCountSummary());
+ UpdateDisplay("100x200/l,300x400");
+ EXPECT_EQ("0 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());
}
@@ -1057,7 +1047,8 @@ class TestDisplayObserver : public gfx::DisplayObserver {
virtual ~TestDisplayObserver() {}
// gfx::DisplayObserver overrides:
- virtual void OnDisplayMetricsChanged(const gfx::Display&,uint32_t) OVERRIDE {}
+ virtual void OnDisplayBoundsChanged(const gfx::Display& display) 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 315dd5a..2c45402 100644
--- a/ash/display/resolution_notification_controller.cc
+++ b/ash/display/resolution_notification_controller.cc
@@ -285,6 +285,10 @@ void ResolutionNotificationController::RevertResolutionChange() {
display_id, old_resolution);
}
+void ResolutionNotificationController::OnDisplayBoundsChanged(
+ const gfx::Display& display) {
+}
+
void ResolutionNotificationController::OnDisplayAdded(
const gfx::Display& new_display) {
}
@@ -295,10 +299,6 @@ 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 9fe4026..23a582d 100644
--- a/ash/display/resolution_notification_controller.h
+++ b/ash/display/resolution_notification_controller.h
@@ -79,10 +79,9 @@ 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 0348cbe..9d42e49e 100644
--- a/ash/display/screen_ash.cc
+++ b/ash/display/screen_ash.cc
@@ -188,11 +188,9 @@ const gfx::Display& ScreenAsh::GetDisplayForId(int64 display_id) {
return GetDisplayManager()->GetDisplayForId(display_id);
}
-void ScreenAsh::NotifyMetricsChanged(const gfx::Display& display,
- uint32_t metrics) {
- FOR_EACH_OBSERVER(gfx::DisplayObserver,
- observers_,
- OnDisplayMetricsChanged(display, metrics));
+void ScreenAsh::NotifyBoundsChanged(const gfx::Display& display) {
+ FOR_EACH_OBSERVER(gfx::DisplayObserver, observers_,
+ OnDisplayBoundsChanged(display));
}
void ScreenAsh::NotifyDisplayAdded(const gfx::Display& display) {
diff --git a/ash/display/screen_ash.h b/ash/display/screen_ash.h
index c5f4b85..08011b2 100644
--- a/ash/display/screen_ash.h
+++ b/ash/display/screen_ash.h
@@ -8,7 +8,6 @@
#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 {
@@ -82,7 +81,7 @@ class ASH_EXPORT ScreenAsh : public gfx::Screen {
friend class DisplayManager;
// Notifies observers of display configuration changes.
- void NotifyMetricsChanged(const gfx::Display& display, uint32_t metrics);
+ void NotifyBoundsChanged(const gfx::Display& display);
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 8cc31b6..b16deea 100644
--- a/ash/shelf/shelf_window_watcher.cc
+++ b/ash/shelf/shelf_window_watcher.cc
@@ -267,6 +267,9 @@ 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()->
@@ -285,8 +288,4 @@ 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 da16e54..cb99bc7 100644
--- a/ash/shelf/shelf_window_watcher.h
+++ b/ash/shelf/shelf_window_watcher.h
@@ -115,10 +115,9 @@ 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 44edaa4..55231cf 100644
--- a/ash/shell/window_watcher.cc
+++ b/ash/shell/window_watcher.cc
@@ -138,6 +138,9 @@ 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());
@@ -149,8 +152,5 @@ 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 50cd9e4..2d94b77 100644
--- a/ash/shell/window_watcher.h
+++ b/ash/shell/window_watcher.h
@@ -38,10 +38,9 @@ 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 45280f9..a4bc850 100644
--- a/ash/system/web_notification/web_notification_tray.cc
+++ b/ash/system/web_notification/web_notification_tray.cc
@@ -158,10 +158,9 @@ void WorkAreaObserver::StopObserving() {
void WorkAreaObserver::OnDisplayWorkAreaInsetsChanged() {
UpdateShelf();
- collection_->OnDisplayMetricsChanged(
+ collection_->OnDisplayBoundsChanged(
Shell::GetScreen()->GetDisplayNearestWindow(
- shelf_->shelf_widget()->GetNativeView()),
- gfx::DisplayObserver::DISPLAY_METRIC_WORK_AREA);
+ shelf_->shelf_widget()->GetNativeView()));
}
void WorkAreaObserver::OnAutoHideStateChanged(ShelfAutoHideState new_state) {
diff --git a/ash/touch/touch_hud_debug.cc b/ash/touch/touch_hud_debug.cc
index 20fab48..983d86b 100644
--- a/ash/touch/touch_hud_debug.cc
+++ b/ash/touch/touch_hud_debug.cc
@@ -465,11 +465,10 @@ void TouchHudDebug::OnTouchEvent(ui::TouchEvent* event) {
label_container_->SetSize(label_container_->GetPreferredSize());
}
-void TouchHudDebug::OnDisplayMetricsChanged(const gfx::Display& display,
- uint32_t metrics) {
- TouchObserverHUD::OnDisplayMetricsChanged(display, metrics);
+void TouchHudDebug::OnDisplayBoundsChanged(const gfx::Display& display) {
+ TouchObserverHUD::OnDisplayBoundsChanged(display);
- if (display.id() != display_id() || !(metrics & DISPLAY_METRIC_BOUNDS))
+ if (display.id() != display_id())
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 12ba64a..2cac294 100644
--- a/ash/touch/touch_hud_debug.h
+++ b/ash/touch/touch_hud_debug.h
@@ -60,8 +60,7 @@ class ASH_EXPORT TouchHudDebug : public TouchObserverHUD {
// Overriden from TouchObserverHUD.
virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE;
- virtual void OnDisplayMetricsChanged(const gfx::Display& display,
- uint32_t metrics) OVERRIDE;
+ virtual void OnDisplayBoundsChanged(const gfx::Display& display) 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 f3f0b35..87d6d4e 100644
--- a/ash/touch/touch_observer_hud.cc
+++ b/ash/touch/touch_observer_hud.cc
@@ -86,6 +86,12 @@ 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) {
@@ -94,14 +100,6 @@ 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 816fb98..2bfbb0d 100644
--- a/ash/touch/touch_observer_hud.h
+++ b/ash/touch/touch_observer_hud.h
@@ -59,10 +59,9 @@ 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 15278bf..15d1ca2 100644
--- a/ash/wm/maximize_mode/maximize_mode_window_manager.cc
+++ b/ash/wm/maximize_mode/maximize_mode_window_manager.cc
@@ -115,6 +115,11 @@ void MaximizeModeWindowManager::OnWindowBoundsChanged(
}
}
+void MaximizeModeWindowManager::OnDisplayBoundsChanged(
+ const gfx::Display& display) {
+ // Nothing to do here.
+}
+
void MaximizeModeWindowManager::OnDisplayAdded(const gfx::Display& display) {
DisplayConfigurationChanged();
}
@@ -123,11 +128,6 @@ 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 8bc851a..2b421c5 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;
- // gfx::DisplayObserver overrides:
+ // aura::DisplayObserver overrides:
+ 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;
// 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 04fbccb..3e9a478 100644
--- a/ash/wm/overview/window_selector.cc
+++ b/ash/wm/overview/window_selector.cc
@@ -325,15 +325,14 @@ void WindowSelector::OnTouchEvent(ui::TouchEvent* event) {
SelectWindow(target);
}
-void WindowSelector::OnDisplayAdded(const gfx::Display& display) {
+void WindowSelector::OnDisplayBoundsChanged(const gfx::Display& display) {
+ PositionWindows(/* animate */ false);
}
-void WindowSelector::OnDisplayRemoved(const gfx::Display& display) {
+void WindowSelector::OnDisplayAdded(const gfx::Display& display) {
}
-void WindowSelector::OnDisplayMetricsChanged(const gfx::Display& display,
- uint32_t metrics) {
- PositionWindows(/* animate */ false);
+void WindowSelector::OnDisplayRemoved(const gfx::Display& display) {
}
void WindowSelector::OnWindowAdded(aura::Window* new_window) {
diff --git a/ash/wm/overview/window_selector.h b/ash/wm/overview/window_selector.h
index bfb0c14..9356b13 100644
--- a/ash/wm/overview/window_selector.h
+++ b/ash/wm/overview/window_selector.h
@@ -68,10 +68,9 @@ 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 99f49f5..7c76083 100644
--- a/chrome/browser/extensions/api/system_info/system_info_api.cc
+++ b/chrome/browser/extensions/api/system_info/system_info_api.cc
@@ -66,10 +66,9 @@ 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(
@@ -183,16 +182,16 @@ void SystemInfoEventRouter::OnRemovableStorageDetached(
DispatchEvent(system_storage::OnDetached::kEventName, args.Pass());
}
-void SystemInfoEventRouter::OnDisplayAdded(const gfx::Display& new_display) {
+void SystemInfoEventRouter::OnDisplayBoundsChanged(
+ const gfx::Display& display) {
OnDisplayChanged();
}
-void SystemInfoEventRouter::OnDisplayRemoved(const gfx::Display& old_display) {
+void SystemInfoEventRouter::OnDisplayAdded(const gfx::Display& new_display) {
OnDisplayChanged();
}
-void SystemInfoEventRouter::OnDisplayMetricsChanged(const gfx::Display& display,
- uint32_t metrics) {
+void SystemInfoEventRouter::OnDisplayRemoved(const gfx::Display& old_display) {
OnDisplayChanged();
}
diff --git a/chrome/browser/ui/ash/launcher/browser_status_monitor.cc b/chrome/browser/ui/ash/launcher/browser_status_monitor.cc
index a2a296f..36b1935 100644
--- a/chrome/browser/ui/ash/launcher/browser_status_monitor.cc
+++ b/chrome/browser/ui/ash/launcher/browser_status_monitor.cc
@@ -224,6 +224,11 @@ 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()->
@@ -244,11 +249,6 @@ 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 8b46002..426ef6e 100644
--- a/chrome/browser/ui/ash/launcher/browser_status_monitor.h
+++ b/chrome/browser/ui/ash/launcher/browser_status_monitor.h
@@ -67,10 +67,9 @@ 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 d7d5d92..c176b0b 100644
--- a/chrome/browser/ui/webui/options/chromeos/display_overscan_handler.cc
+++ b/chrome/browser/ui/webui/options/chromeos/display_overscan_handler.cc
@@ -81,6 +81,10 @@ 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");
@@ -91,10 +95,6 @@ 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 dbb4787..65658a0 100644
--- a/chrome/browser/ui/webui/options/chromeos/display_overscan_handler.h
+++ b/chrome/browser/ui/webui/options/chromeos/display_overscan_handler.h
@@ -34,10 +34,9 @@ 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 7670a94..b02b325 100644
--- a/content/browser/renderer_host/render_widget_host_view_aura.cc
+++ b/content/browser/renderer_host/render_widget_host_view_aura.cc
@@ -1528,17 +1528,8 @@ void RenderWidgetHostViewAura::OnCandidateWindowHidden() {
////////////////////////////////////////////////////////////////////////////////
// RenderWidgetHostViewAura, gfx::DisplayObserver implementation:
-void RenderWidgetHostViewAura::OnDisplayAdded(
- const gfx::Display& new_display) {
-}
-
-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.
+void RenderWidgetHostViewAura::OnDisplayBoundsChanged(
+ const gfx::Display& display) {
gfx::Screen* screen = gfx::Screen::GetScreenFor(window_);
if (display.id() == screen->GetDisplayNearestWindow(window_).id()) {
UpdateScreenInfo(window_);
@@ -1547,6 +1538,14 @@ void RenderWidgetHostViewAura::OnDisplayMetricsChanged(
}
}
+void RenderWidgetHostViewAura::OnDisplayAdded(
+ const gfx::Display& new_display) {
+}
+
+void RenderWidgetHostViewAura::OnDisplayRemoved(
+ const gfx::Display& old_display) {
+}
+
////////////////////////////////////////////////////////////////////////////////
// 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 0a9ceb8..a466218 100644
--- a/content/browser/renderer_host/render_widget_host_view_aura.h
+++ b/content/browser/renderer_host/render_widget_host_view_aura.h
@@ -259,10 +259,9 @@ 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 fd213e0..40e6eaa 100644
--- a/media/video/capture/linux/video_capture_device_chromeos.cc
+++ b/media/video/capture/linux/video_capture_device_chromeos.cc
@@ -45,15 +45,14 @@ class VideoCaptureDeviceChromeOS::ScreenObserverDelegate
DCHECK(!capture_device_);
}
- 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;
+ // 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 {}
+
void AddObserverOnUIThread() {
DCHECK(ui_task_runner_->BelongsToCurrentThread());
gfx::Screen* screen =
diff --git a/ui/gfx/display_observer.h b/ui/gfx/display_observer.h
index 0730f26..ca97247 100644
--- a/ui/gfx/display_observer.h
+++ b/ui/gfx/display_observer.h
@@ -5,8 +5,6 @@
#ifndef UI_GFX_DISPLAY_OBSERVER_H_
#define UI_GFX_DISPLAY_OBSERVER_H_
-#include <stdint.h>
-
#include "ui/gfx/gfx_export.h"
namespace gfx {
@@ -17,13 +15,8 @@ class Display;
// |DisplaySettingsProvier|. crbug.com/122863.
class GFX_EXPORT DisplayObserver {
public:
- 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 the |display|'s bound has changed.
+ virtual void OnDisplayBoundsChanged(const Display& display) = 0;
// Called when |new_display| has been added.
virtual void OnDisplayAdded(const Display& new_display) = 0;
@@ -31,11 +24,6 @@ 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 d1116d6..4dd70a4 100644
--- a/ui/message_center/views/message_popup_collection.cc
+++ b/ui/message_center/views/message_popup_collection.cc
@@ -561,6 +561,14 @@ 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) {
}
@@ -572,15 +580,6 @@ 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 955af32..907274e 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 OnDisplayMetricsChanged(), since
+ // This is separated from methods from OnDisplayBoundsChanged(), 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,10 +120,9 @@ 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 5bd2796..7c9b7aa 100644
--- a/ui/message_center/views/toast_contents_view.cc
+++ b/ui/message_center/views/toast_contents_view.cc
@@ -28,8 +28,6 @@
#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
#endif
-using gfx::Screen;
-
namespace message_center {
namespace {
@@ -249,10 +247,8 @@ void ToastContentsView::OnDisplayChanged() {
if (!native_view || !collection_.get())
return;
- collection_->OnDisplayMetricsChanged(
- Screen::GetScreenFor(native_view)->GetDisplayNearestWindow(native_view),
- gfx::DisplayObserver::DISPLAY_METRIC_BOUNDS |
- gfx::DisplayObserver::DISPLAY_METRIC_WORK_AREA);
+ collection_->OnDisplayBoundsChanged(gfx::Screen::GetScreenFor(
+ native_view)->GetDisplayNearestWindow(native_view));
}
void ToastContentsView::OnWorkAreaChanged() {
@@ -264,9 +260,8 @@ void ToastContentsView::OnWorkAreaChanged() {
if (!native_view || !collection_.get())
return;
- collection_->OnDisplayMetricsChanged(
- Screen::GetScreenFor(native_view)->GetDisplayNearestWindow(native_view),
- gfx::DisplayObserver::DISPLAY_METRIC_WORK_AREA);
+ collection_->OnDisplayBoundsChanged(gfx::Screen::GetScreenFor(
+ native_view)->GetDisplayNearestWindow(native_view));
}
// 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 fef23aa..d927780 100644
--- a/ui/views/widget/desktop_aura/desktop_screen_x11.cc
+++ b/ui/views/widget/desktop_aura/desktop_screen_x11.cc
@@ -137,31 +137,15 @@ 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())
- continue;
-
- 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 (new_it->id() == old_it->id()) {
+ if (new_it->bounds() != old_it->bounds()) {
+ FOR_EACH_OBSERVER(gfx::DisplayObserver, observer_list_,
+ OnDisplayBoundsChanged(*new_it));
+ }
- if (metrics != gfx::DisplayObserver::DISPLAY_METRIC_NONE) {
- FOR_EACH_OBSERVER(gfx::DisplayObserver,
- observer_list_,
- OnDisplayMetricsChanged(*new_it, metrics));
+ found = true;
+ break;
}
-
- 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 b892115..8a48ad1 100644
--- a/ui/views/widget/desktop_aura/desktop_screen_x11_unittest.cc
+++ b/ui/views/widget/desktop_aura/desktop_screen_x11_unittest.cc
@@ -176,6 +176,10 @@ 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);
}
@@ -184,11 +188,6 @@ 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);
@@ -211,7 +210,7 @@ TEST_F(DesktopScreenX11Test, AddMonitorToTheRight) {
gfx::Rect(640, 0, 1024, 768)));
screen()->ProcessDisplayChange(displays);
- EXPECT_EQ(1u, changed_display_.size());
+ EXPECT_EQ(0u, changed_display_.size());
EXPECT_EQ(1u, added_display_.size());
EXPECT_EQ(0u, removed_display_.size());
}
@@ -240,7 +239,7 @@ TEST_F(DesktopScreenX11Test, RemoveMonitorOnRight) {
displays.push_back(gfx::Display(kFirstDisplay, gfx::Rect(0, 0, 640, 480)));
screen()->ProcessDisplayChange(displays);
- EXPECT_EQ(1u, changed_display_.size());
+ EXPECT_EQ(0u, changed_display_.size());
EXPECT_EQ(0u, added_display_.size());
EXPECT_EQ(1u, removed_display_.size());
}
@@ -456,97 +455,4 @@ 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