diff options
author | jianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-10 17:04:44 +0000 |
---|---|---|
committer | jianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-10 17:04:44 +0000 |
commit | 33190c88674bc70d431bafe9eba88cbe05652b60 (patch) | |
tree | aab802f64f2b76ccb910a5c622045211bbffee4e /chrome/browser/ui/panels/display_settings_provider.cc | |
parent | 6207714a83210aabc7f64af0a9e95378b1f05f37 (diff) | |
download | chromium_src-33190c88674bc70d431bafe9eba88cbe05652b60.zip chromium_src-33190c88674bc70d431bafe9eba88cbe05652b60.tar.gz chromium_src-33190c88674bc70d431bafe9eba88cbe05652b60.tar.bz2 |
Move auto-hiding desktop bar computation from PanelManager to DisplaySettingsProvider
BUG=none
TEST=existing tests due to no new functionality
Review URL: https://chromiumcodereview.appspot.com/9689035
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@131570 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/panels/display_settings_provider.cc')
-rw-r--r-- | chrome/browser/ui/panels/display_settings_provider.cc | 62 |
1 files changed, 49 insertions, 13 deletions
diff --git a/chrome/browser/ui/panels/display_settings_provider.cc b/chrome/browser/ui/panels/display_settings_provider.cc index a6652a1..af3ee88 100644 --- a/chrome/browser/ui/panels/display_settings_provider.cc +++ b/chrome/browser/ui/panels/display_settings_provider.cc @@ -7,15 +7,23 @@ #include "base/logging.h" #include "ui/gfx/screen.h" -DisplaySettingsProvider::DisplaySettingsProvider(Observer* observer) - : observer_(observer) { - DCHECK(observer); +DisplaySettingsProvider::DisplaySettingsProvider() + : display_area_observer_(NULL), + desktop_bar_observer_(NULL) { } DisplaySettingsProvider::~DisplaySettingsProvider() { } -gfx::Rect DisplaySettingsProvider::GetWorkArea() { +gfx::Rect DisplaySettingsProvider::GetDisplayArea() { + // Do the first-time initialization if not yet. + if (adjusted_work_area_.IsEmpty()) + OnDisplaySettingsChanged(); + + return adjusted_work_area_; +} + +gfx::Rect DisplaySettingsProvider::GetWorkArea() const { #if defined(OS_MACOSX) // On OSX, panels should be dropped all the way to the bottom edge of the // screen (and overlap Dock). @@ -23,16 +31,24 @@ gfx::Rect DisplaySettingsProvider::GetWorkArea() { #else gfx::Rect work_area = gfx::Screen::GetPrimaryMonitorWorkArea(); #endif + return work_area; +} - if (work_area_ != work_area) { - work_area_ = work_area; - OnWorkAreaChanged(); - } +void DisplaySettingsProvider::OnDisplaySettingsChanged() { + gfx::Rect work_area = GetWorkArea(); + if (work_area == work_area_) + return; + work_area_ = work_area; - return work_area; + OnAutoHidingDesktopBarChanged(); } -void DisplaySettingsProvider::OnWorkAreaChanged() { +void DisplaySettingsProvider::OnAutoHidingDesktopBarChanged() { + gfx::Rect old_adjusted_work_area = adjusted_work_area_; + AdjustWorkAreaForAutoHidingDesktopBars(); + + if (old_adjusted_work_area != adjusted_work_area_ && display_area_observer_) + display_area_observer_->OnDisplayAreaChanged(adjusted_work_area_); } bool DisplaySettingsProvider::IsAutoHidingDesktopBarEnabled( @@ -51,9 +67,29 @@ DisplaySettingsProvider::GetDesktopBarVisibility( return DESKTOP_BAR_VISIBLE; } -#if !defined(OS_WIN) || defined(USE_AURA) +void DisplaySettingsProvider::AdjustWorkAreaForAutoHidingDesktopBars() { + // Note that we do not care about the top desktop bar since panels could not + // reach so high due to size constraint. We also do not care about the bottom + // desktop bar since we always align the panel to the bottom of the work area. + adjusted_work_area_ = work_area_; + if (IsAutoHidingDesktopBarEnabled( + DisplaySettingsProvider::DESKTOP_BAR_ALIGNED_LEFT)) { + int space = GetDesktopBarThickness( + DisplaySettingsProvider::DESKTOP_BAR_ALIGNED_LEFT); + adjusted_work_area_.set_x(adjusted_work_area_.x() + space); + adjusted_work_area_.set_width(adjusted_work_area_.width() - space); + } + if (IsAutoHidingDesktopBarEnabled( + DisplaySettingsProvider::DESKTOP_BAR_ALIGNED_RIGHT)) { + int space = GetDesktopBarThickness( + DisplaySettingsProvider::DESKTOP_BAR_ALIGNED_RIGHT); + adjusted_work_area_.set_width(adjusted_work_area_.width() - space); + } +} + +#if defined(USE_AURA) // static -DisplaySettingsProvider* DisplaySettingsProvider::Create(Observer* observer) { - return new DisplaySettingsProvider(observer); +DisplaySettingsProvider* DisplaySettingsProvider::Create() { + return new DisplaySettingsProvider(); } #endif |