diff options
author | derat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-14 19:20:33 +0000 |
---|---|---|
committer | derat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-14 19:20:33 +0000 |
commit | c1080067f4fe25d3184f7ad2d751e9e378f745fe (patch) | |
tree | 263d5c4e60577aed77fe0674a4e9c12073db2e18 /ui | |
parent | c66359e4155a6a781be4b6c3431d975844fcdc3f (diff) | |
download | chromium_src-c1080067f4fe25d3184f7ad2d751e9e378f745fe.zip chromium_src-c1080067f4fe25d3184f7ad2d751e9e378f745fe.tar.gz chromium_src-c1080067f4fe25d3184f7ad2d751e9e378f745fe.tar.bz2 |
aura: Implement IsFullscreenMode().
We walk down the tree looking for windows that have
delegates, are visible, and are fullscreen.
BUG=99710
TEST=added
Review URL: http://codereview.chromium.org/8233023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@105539 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/aura/window.cc | 12 | ||||
-rw-r--r-- | ui/aura/window.h | 23 | ||||
-rw-r--r-- | ui/aura/window_unittest.cc | 18 |
3 files changed, 43 insertions, 10 deletions
diff --git a/ui/aura/window.cc b/ui/aura/window.cc index d273518..b14f2f3 100644 --- a/ui/aura/window.cc +++ b/ui/aura/window.cc @@ -363,6 +363,18 @@ Window* Window::GetToplevelWindow() { return window && window->parent() ? window : NULL; } +bool Window::IsOrContainsFullscreenWindow() const { + if (delegate_) + return IsVisible() && show_state_ == ui::SHOW_STATE_FULLSCREEN; + + for (Windows::const_iterator it = children_.begin(); + it != children_.end(); ++it) { + if ((*it)->IsOrContainsFullscreenWindow()) + return true; + } + return false; +} + // static ui::Animation* Window::CreateDefaultAnimation() { std::vector<ui::MultiAnimation::Part> parts; diff --git a/ui/aura/window.h b/ui/aura/window.h index e7beacc..4a71023 100644 --- a/ui/aura/window.h +++ b/ui/aura/window.h @@ -69,6 +69,17 @@ class AURA_EXPORT Window : public ui::LayerDelegate { ui::Layer* layer() { return layer_.get(); } const ui::Layer* layer() const { return layer_.get(); } + WindowDelegate* delegate() { return delegate_; } + + const gfx::Rect& bounds() const; + + Window* parent() { return parent_; } + const Window* parent() const { return parent_; } + + // The Window does not own this object. + void set_user_data(void* user_data) { user_data_ = user_data; } + void* user_data() const { return user_data_; } + // Changes the visibility of the window. void Show(); void Hide(); @@ -109,7 +120,6 @@ class AURA_EXPORT Window : public ui::LayerDelegate { // Changes the bounds of the window. void SetBounds(const gfx::Rect& new_bounds); - const gfx::Rect& bounds() const; // Marks the a portion of window as needing to be painted. void SchedulePaintInRect(const gfx::Rect& rect); @@ -120,8 +130,6 @@ class AURA_EXPORT Window : public ui::LayerDelegate { // Sets the parent window of the window. If NULL, the window is parented to // the desktop's window. void SetParent(Window* parent); - Window* parent() { return parent_; } - const Window* parent() const { return parent_; } // Move the specified child of this Window to the front of the z-order. // TODO(beng): this is (obviously) feeble. @@ -159,8 +167,6 @@ class AURA_EXPORT Window : public ui::LayerDelegate { // Handles a key event. Returns true if handled. bool OnKeyEvent(KeyEvent* event); - WindowDelegate* delegate() { return delegate_; } - // Add/remove observer. void AddObserver(WindowObserver* observer); void RemoveObserver(WindowObserver* observer); @@ -207,10 +213,6 @@ class AURA_EXPORT Window : public ui::LayerDelegate { virtual internal::FocusManager* GetFocusManager(); virtual const internal::FocusManager* GetFocusManager() const; - // The Window does not own this object. - void set_user_data(void* user_data) { user_data_ = user_data; } - void* user_data() const { return user_data_; } - // Does a mouse capture on the window. This does nothing if the window isn't // showing (VISIBILITY_SHOWN) or isn't contained in a valid window hierarchy. void SetCapture(); @@ -225,6 +227,9 @@ class AURA_EXPORT Window : public ui::LayerDelegate { // IsToplevelWindowContainer. Window* GetToplevelWindow(); + // Returns true if this window is fullscreen or contains a fullscreen window. + bool IsOrContainsFullscreenWindow() const; + // Returns an animation configured with the default duration. All animations // should use this. Caller owns returned value. static ui::Animation* CreateDefaultAnimation(); diff --git a/ui/aura/window_unittest.cc b/ui/aura/window_unittest.cc index 7d9ac97..d332cb1 100644 --- a/ui/aura/window_unittest.cc +++ b/ui/aura/window_unittest.cc @@ -803,8 +803,24 @@ TEST_F(WindowTest, Deactivate) { EXPECT_EQ(w2.get(), parent->children()[1]); } +TEST_F(WindowTest, IsOrContainsFullscreenWindow) { + scoped_ptr<Window> w1( + CreateTestWindowWithDelegate(NULL, 1, gfx::Rect(0, 0, 100, 100), NULL)); + scoped_ptr<Window> w11( + CreateTestWindow(SK_ColorWHITE, 11, gfx::Rect(0, 0, 10, 10), w1.get())); + + Window* root = Desktop::GetInstance()->window(); + EXPECT_FALSE(root->IsOrContainsFullscreenWindow()); + + w11->Fullscreen(); + EXPECT_TRUE(root->IsOrContainsFullscreenWindow()); + + w11->Hide(); + EXPECT_FALSE(root->IsOrContainsFullscreenWindow()); +} + class WindowObserverTest : public WindowTest, - public WindowObserver { + public WindowObserver { public: WindowObserverTest() : added_count_(0), removed_count_(0) {} |