diff options
Diffstat (limited to 'ui/aura/window.cc')
-rw-r--r-- | ui/aura/window.cc | 53 |
1 files changed, 26 insertions, 27 deletions
diff --git a/ui/aura/window.cc b/ui/aura/window.cc index 4755f62..0d609a3 100644 --- a/ui/aura/window.cc +++ b/ui/aura/window.cc @@ -9,6 +9,7 @@ #include "base/logging.h" #include "base/stl_util.h" #include "base/string_util.h" +#include "ui/aura/client/event_client.h" #include "ui/aura/client/stacking_client.h" #include "ui/aura/client/visibility_client.h" #include "ui/aura/env.h" @@ -54,7 +55,6 @@ Window::Window(WindowDelegate* delegate) id_(-1), transparent_(false), user_data_(NULL), - stops_event_propagation_(false), ignore_events_(false), hit_test_bounds_override_outer_(0), hit_test_bounds_override_inner_(0) { @@ -450,12 +450,24 @@ bool Window::HasFocus() const { bool Window::CanFocus() const { if (!IsVisible() || !parent_ || (delegate_ && !delegate_->CanFocus())) return false; - return !IsBehindStopEventsWindow() && parent_->CanFocus(); + + // The client may forbid certain windows from receiving focus at a given point + // in time. + client::EventClient* client = client::GetEventClient(GetRootWindow()); + if (client && !client->CanProcessEventsWithinSubtree(this)) + return false; + + return parent_->CanFocus(); } bool Window::CanReceiveEvents() const { - return parent_ && IsVisible() && !IsBehindStopEventsWindow() && - parent_->CanReceiveEvents(); + // The client may forbid certain windows from receiving events at a given + // point in time. + client::EventClient* client = client::GetEventClient(GetRootWindow()); + if (client && !client->CanProcessEventsWithinSubtree(this)) + return false; + + return parent_ && IsVisible() && parent_->CanReceiveEvents(); } internal::FocusManager* Window::GetFocusManager() { @@ -491,15 +503,6 @@ bool Window::HasCapture() { return root_window && root_window->capture_window() == this; } -bool Window::StopsEventPropagation() const { - if (!stops_event_propagation_ || children_.empty()) - return false; - aura::Window::Windows::const_iterator it = - std::find_if(children_.begin(), children_.end(), - std::mem_fun(&aura::Window::IsVisible)); - return it != children_.end(); -} - void Window::SuppressPaint() { layer_->SuppressPaint(); } @@ -654,6 +657,16 @@ Window* Window::GetWindowForPoint(const gfx::Point& local_point, rend = children_.rend(); it != rend; ++it) { Window* child = *it; + + if (for_event_handling) { + // The client may not allow events to be processed by certain subtrees. + client::EventClient* client = client::GetEventClient(GetRootWindow()); + if (client && !client->CanProcessEventsWithinSubtree(child)) + continue; + } + + // We don't process events for invisible windows or those that have asked + // to ignore events. if (!child->IsVisible() || (for_event_handling && child->ignore_events_)) continue; @@ -664,9 +677,6 @@ Window* Window::GetWindowForPoint(const gfx::Point& local_point, for_event_handling); if (match) return match; - - if (for_event_handling && child->StopsEventPropagation()) - break; } return delegate_ ? this : NULL; @@ -801,15 +811,4 @@ void Window::UpdateLayerName(const std::string& name) { #endif } -bool Window::IsBehindStopEventsWindow() const { - Windows::const_iterator i = std::find(parent_->children().begin(), - parent_->children().end(), - this); - for (++i; i != parent_->children().end(); ++i) { - if ((*i)->StopsEventPropagation()) - return true; - } - return false; -} - } // namespace aura |