diff options
author | mlamouri@chromium.org <mlamouri@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-20 21:52:35 +0000 |
---|---|---|
committer | mlamouri@chromium.org <mlamouri@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-20 21:52:35 +0000 |
commit | 582507170e6f19ead4447a8e098fc58f79ddbfa9 (patch) | |
tree | dbdd8f80766f4d95bdc1fa43c32f4d56ebf93b5c /ui/message_center | |
parent | df3ecfdef1498c99b11ce31e2cd5e7437a341a21 (diff) | |
download | chromium_src-582507170e6f19ead4447a8e098fc58f79ddbfa9.zip chromium_src-582507170e6f19ead4447a8e098fc58f79ddbfa9.tar.gz chromium_src-582507170e6f19ead4447a8e098fc58f79ddbfa9.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
Review URL: https://codereview.chromium.org/259253002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@271768 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/message_center')
-rw-r--r-- | ui/message_center/views/message_popup_collection.cc | 17 | ||||
-rw-r--r-- | ui/message_center/views/message_popup_collection.h | 5 | ||||
-rw-r--r-- | ui/message_center/views/toast_contents_view.cc | 13 |
3 files changed, 21 insertions, 14 deletions
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 7c9b7aa..5bd2796 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 { @@ -247,8 +249,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() { @@ -260,8 +264,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 |