summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/panels/display_settings_provider.cc
diff options
context:
space:
mode:
authorjianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-13 04:50:50 +0000
committerjianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-13 04:50:50 +0000
commitc9ccd80a5c1ac51f88ac945ede6f13ec82596bb1 (patch)
treec69a36f7d8d5f6b3048a7813dfdbb196871e4d68 /chrome/browser/ui/panels/display_settings_provider.cc
parent3f021192c48228ae840b15e316e623b6d16c0ebb (diff)
downloadchromium_src-c9ccd80a5c1ac51f88ac945ede6f13ec82596bb1.zip
chromium_src-c9ccd80a5c1ac51f88ac945ede6f13ec82596bb1.tar.gz
chromium_src-c9ccd80a5c1ac51f88ac945ede6f13ec82596bb1.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 Review URL: http://codereview.chromium.org/10051020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132144 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.cc67
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() {