diff options
author | varunjain@chromium.org <varunjain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-17 00:52:21 +0000 |
---|---|---|
committer | varunjain@chromium.org <varunjain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-17 00:52:21 +0000 |
commit | d7e6cb84a462e713f4b67a72b3365ba297088d97 (patch) | |
tree | 8ef4d7694aeef57470f1324c7c5d8c737b1fb306 /ui | |
parent | 09c939aaae025fcb3b0bfc64108e5ecf01118880 (diff) | |
download | chromium_src-d7e6cb84a462e713f4b67a72b3365ba297088d97.zip chromium_src-d7e6cb84a462e713f4b67a72b3365ba297088d97.tar.gz chromium_src-d7e6cb84a462e713f4b67a72b3365ba297088d97.tar.bz2 |
Aura: windows in aura should honor Widget::InitParams::accept_events
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/8570011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110406 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/aura/window.cc | 5 | ||||
-rw-r--r-- | ui/aura/window.h | 5 | ||||
-rw-r--r-- | ui/aura/window_unittest.cc | 30 |
3 files changed, 38 insertions, 2 deletions
diff --git a/ui/aura/window.cc b/ui/aura/window.cc index d8535ff..2d2413d 100644 --- a/ui/aura/window.cc +++ b/ui/aura/window.cc @@ -30,7 +30,8 @@ Window::Window(WindowDelegate* delegate) transient_parent_(NULL), id_(-1), user_data_(NULL), - stops_event_propagation_(false) { + stops_event_propagation_(false), + ignore_events_(false) { } Window::~Window() { @@ -474,7 +475,7 @@ Window* Window::GetWindowForPoint(const gfx::Point& local_point, for (Windows::const_reverse_iterator it = children_.rbegin(); it != children_.rend(); ++it) { Window* child = *it; - if (!child->IsVisible()) + if (!child->IsVisible() || (for_event_handling && child->ignore_events_)) continue; gfx::Point point_in_child_coords(local_point); diff --git a/ui/aura/window.h b/ui/aura/window.h index 485bcb4..20e0e79 100644 --- a/ui/aura/window.h +++ b/ui/aura/window.h @@ -208,6 +208,8 @@ class AURA_EXPORT Window : public ui::LayerDelegate { stops_event_propagation_ = stops_event_propagation; } + void set_ignore_events(bool ignore_events) { ignore_events_ = ignore_events; } + // Returns true if relative-to-this-Window's-origin |local_point| falls // within this Window's bounds. bool ContainsPoint(const gfx::Point& local_point); @@ -340,6 +342,9 @@ class AURA_EXPORT Window : public ui::LayerDelegate { // provided this window has children. See set_stops_event_propagation(). bool stops_event_propagation_; + // Makes the window pass all events through to any windows behind it. + bool ignore_events_; + ObserverList<WindowObserver> observers_; // We're using ViewProp to store the property (for now) instead of diff --git a/ui/aura/window_unittest.cc b/ui/aura/window_unittest.cc index 4485256..2c51f71 100644 --- a/ui/aura/window_unittest.cc +++ b/ui/aura/window_unittest.cc @@ -664,6 +664,36 @@ TEST_F(WindowTest, StopsEventPropagation) { EXPECT_EQ(w121.get(), w1->GetFocusManager()->GetFocusedWindow()); } +TEST_F(WindowTest, IgnoreEventsTest) { + TestWindowDelegate d11; + TestWindowDelegate d12; + TestWindowDelegate d111; + TestWindowDelegate d121; + scoped_ptr<Window> w1(CreateTestWindowWithDelegate(NULL, 1, + gfx::Rect(0, 0, 500, 500), NULL)); + scoped_ptr<Window> w11(CreateTestWindowWithDelegate(&d11, 11, + gfx::Rect(0, 0, 500, 500), w1.get())); + scoped_ptr<Window> w111(CreateTestWindowWithDelegate(&d111, 111, + gfx::Rect(50, 50, 450, 450), w11.get())); + scoped_ptr<Window> w12(CreateTestWindowWithDelegate(&d12, 12, + gfx::Rect(0, 0, 500, 500), w1.get())); + scoped_ptr<Window> w121(CreateTestWindowWithDelegate(&d121, 121, + gfx::Rect(150, 150, 50, 50), w12.get())); + + EXPECT_EQ(w12.get(), w1->GetEventHandlerForPoint(gfx::Point(10, 10))); + w12->set_ignore_events(true); + EXPECT_EQ(w11.get(), w1->GetEventHandlerForPoint(gfx::Point(10, 10))); + w12->set_ignore_events(false); + + EXPECT_EQ(w121.get(), w1->GetEventHandlerForPoint(gfx::Point(160, 160))); + w121->set_ignore_events(true); + EXPECT_EQ(w12.get(), w1->GetEventHandlerForPoint(gfx::Point(160, 160))); + w12->set_ignore_events(true); + EXPECT_EQ(w111.get(), w1->GetEventHandlerForPoint(gfx::Point(160, 160))); + w111->set_ignore_events(true); + EXPECT_EQ(w11.get(), w1->GetEventHandlerForPoint(gfx::Point(160, 160))); +} + // Various assertions for activating/deactivating. TEST_F(WindowTest, Deactivate) { TestWindowDelegate d1; |