diff options
author | jianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-16 23:31:17 +0000 |
---|---|---|
committer | jianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-16 23:31:17 +0000 |
commit | aca0c5c993df1bb24b03e50108c0e8574d474928 (patch) | |
tree | bcb82012af39988e0be6a7a6d477c1eb62007afa /chrome/browser/ui/panels/display_settings_provider.cc | |
parent | cfc98633c67d1e5fe258f6e5d212640770f91283 (diff) | |
download | chromium_src-aca0c5c993df1bb24b03e50108c0e8574d474928.zip chromium_src-aca0c5c993df1bb24b03e50108c0e8574d474928.tar.gz chromium_src-aca0c5c993df1bb24b03e50108c0e8574d474928.tar.bz2 |
Move full-screen detection logic from PanelManager to DisplaySettingsProvider.
Also fixed a bug that pnels remain visible with full screen apps on Snow Leopard.
The fix is to also call orderBack/orderFront when full-screen is detected. This is because the full-sreen window is still in normal level and our panel windows stay in the top of z-order when its level is changed to normal.
BUG=123058
TEST=Manual test by launching panels and make an app full-screen
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=132144
Review URL: http://codereview.chromium.org/10051020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132487 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 | 67 |
1 files changed, 63 insertions, 4 deletions
diff --git a/chrome/browser/ui/panels/display_settings_provider.cc b/chrome/browser/ui/panels/display_settings_provider.cc index af3ee88..b2fed3f 100644 --- a/chrome/browser/ui/panels/display_settings_provider.cc +++ b/chrome/browser/ui/panels/display_settings_provider.cc @@ -5,16 +5,61 @@ #include "chrome/browser/ui/panels/display_settings_provider.h" #include "base/logging.h" +#include "chrome/browser/fullscreen.h" #include "ui/gfx/screen.h" +namespace { +// The polling interval to check any display settings change, like full-screen +// mode changes. +const int kFullScreenModeCheckIntervalMs = 1000; +} // namespace + DisplaySettingsProvider::DisplaySettingsProvider() - : display_area_observer_(NULL), - desktop_bar_observer_(NULL) { + : is_full_screen_(false) { } DisplaySettingsProvider::~DisplaySettingsProvider() { } +void DisplaySettingsProvider::AddDisplayAreaObserver( + DisplayAreaObserver* observer) { + display_area_observers_.AddObserver(observer); +} + +void DisplaySettingsProvider::RemoveDisplayAreaObserver( + DisplayAreaObserver* observer) { + display_area_observers_.RemoveObserver(observer); +} + +void DisplaySettingsProvider::AddDesktopBarObserver( + DesktopBarObserver* observer) { + desktop_bar_observers_.AddObserver(observer); +} + +void DisplaySettingsProvider::RemoveDesktopBarObserver( + DesktopBarObserver* observer) { + desktop_bar_observers_.RemoveObserver(observer); +} + +void DisplaySettingsProvider::AddFullScreenObserver( + FullScreenObserver* observer) { + full_screen_observers_.AddObserver(observer); + + if (full_screen_observers_.size() == 1) { + full_screen_mode_timer_.Start(FROM_HERE, + base::TimeDelta::FromMilliseconds(kFullScreenModeCheckIntervalMs), + this, &DisplaySettingsProvider::CheckFullScreenMode); + } +} + +void DisplaySettingsProvider::RemoveFullScreenObserver( + FullScreenObserver* observer) { + full_screen_observers_.RemoveObserver(observer); + + if (full_screen_observers_.size() == 0) + full_screen_mode_timer_.Stop(); +} + gfx::Rect DisplaySettingsProvider::GetDisplayArea() { // Do the first-time initialization if not yet. if (adjusted_work_area_.IsEmpty()) @@ -47,8 +92,11 @@ 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_); + if (old_adjusted_work_area != adjusted_work_area_) { + FOR_EACH_OBSERVER(DisplayAreaObserver, + display_area_observers_, + OnDisplayAreaChanged(adjusted_work_area_)); + } } bool DisplaySettingsProvider::IsAutoHidingDesktopBarEnabled( @@ -87,6 +135,17 @@ void DisplaySettingsProvider::AdjustWorkAreaForAutoHidingDesktopBars() { } } +void DisplaySettingsProvider::CheckFullScreenMode() { + bool is_full_screen = IsFullScreenMode(); + if (is_full_screen == is_full_screen_) + return; + is_full_screen_ = is_full_screen; + + FOR_EACH_OBSERVER(FullScreenObserver, + full_screen_observers_, + OnFullScreenModeChanged(is_full_screen_)); +} + #if defined(USE_AURA) // static DisplaySettingsProvider* DisplaySettingsProvider::Create() { |