Index: content/browser/renderer_host/render_widget_host_view_aura.cc |
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc |
index 1a37ff8ca16dda4a37b679b4e8f6c9671039dd6c..1651dd0b763910135cfc6077f7100321ad40fc5c 100644 |
--- a/content/browser/renderer_host/render_widget_host_view_aura.cc |
+++ b/content/browser/renderer_host/render_widget_host_view_aura.cc |
@@ -175,6 +175,19 @@ bool ShouldReleaseFrontSurface() { |
return release_front_surface_allowed; |
} |
+bool PointerEventActivates(const ui::Event& event) { |
+ if (event.type() == ui::ET_MOUSE_PRESSED) |
+ return true; |
+ |
+ if (event.type() == ui::ET_GESTURE_BEGIN) { |
+ const ui::GestureEvent& gesture = |
+ static_cast<const ui::GestureEvent&>(event); |
+ return gesture.details().touch_points() == 1; |
+ } |
+ |
+ return false; |
+} |
+ |
} // namespace |
// We have to implement the WindowObserver interface on a separate object |
@@ -285,8 +298,7 @@ RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host) |
paint_canvas_(NULL), |
synthetic_move_sent_(false), |
accelerated_compositing_state_changed_(false), |
- can_lock_compositor_(YES), |
- pointer_activate_(false) { |
+ can_lock_compositor_(YES) { |
host_->SetView(this); |
window_observer_.reset(new WindowObserver(this)); |
window_->AddObserver(window_observer_.get()); |
@@ -1542,7 +1554,6 @@ ui::EventResult RenderWidgetHostViewAura::OnKeyEvent(ui::KeyEvent* event) { |
ui::EventResult RenderWidgetHostViewAura::OnMouseEvent(ui::MouseEvent* event) { |
TRACE_EVENT0("browser", "RenderWidgetHostViewAura::OnMouseEvent"); |
- pointer_activate_ = event->type() == ui::ET_MOUSE_PRESSED; |
if (mouse_locked_) { |
// Hide the cursor if someone else has shown it. |
@@ -1685,11 +1696,10 @@ ui::EventResult RenderWidgetHostViewAura::OnGestureEvent( |
if (popup_type_ == WebKit::WebPopupTypeNone && !is_fullscreen_) |
delegate = RenderViewHost::From(host_)->GetDelegate(); |
- bool gesture_begin = event->type() == ui::ET_GESTURE_BEGIN && |
- event->details().touch_points() == 1; |
- if (delegate && gesture_begin) |
+ if (delegate && event->type() == ui::ET_GESTURE_BEGIN && |
+ event->details().touch_points() == 1) { |
delegate->HandleGestureBegin(); |
- pointer_activate_ = gesture_begin; |
+ } |
WebKit::WebGestureEvent gesture = MakeWebGestureEvent(event); |
if (event->type() == ui::ET_GESTURE_TAP_DOWN) { |
@@ -1728,17 +1738,15 @@ ui::EventResult RenderWidgetHostViewAura::OnGestureEvent( |
// RenderWidgetHostViewAura, aura::client::ActivationDelegate implementation: |
bool RenderWidgetHostViewAura::ShouldActivate() const { |
+ const ui::Event* event = window_->GetRootWindow()->current_event(); |
+ if (!event) |
+ return true; |
return is_fullscreen_; |
} |
void RenderWidgetHostViewAura::OnActivated() { |
- // |pointer_activate_| will be true when we are activated as the result of |
- // a valid input event. |
- // TODO(sadrul): It would be nice if we could get the currently processed |
- // event from the RootWindow's EventDispatcher, then we could |
- // avoid this extra field and just check the type/details on |
- // the current event here. |
- if (pointer_activate_) |
+ const ui::Event* event = window_->GetRootWindow()->current_event(); |
+ if (event && PointerEventActivates(*event)) |
host_->OnPointerEventActivate(); |
} |