Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(598)

Side by Side Diff: ui/aura/window_event_dispatcher.cc

Issue 1565013002: Don't send touch events to windows like menus when the touch occurs outside the menu bounds. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove explicit from the ctor for the PreMenuEventDispatchHandler class Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/aura/window_event_dispatcher.h ('k') | ui/aura/window_event_dispatcher_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/aura/window_event_dispatcher.h" 5 #include "ui/aura/window_event_dispatcher.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 ui::GestureRecognizer::Get()->AddGestureEventHelper(this); 93 ui::GestureRecognizer::Get()->AddGestureEventHelper(this);
94 Env::GetInstance()->AddObserver(this); 94 Env::GetInstance()->AddObserver(this);
95 } 95 }
96 96
97 WindowEventDispatcher::~WindowEventDispatcher() { 97 WindowEventDispatcher::~WindowEventDispatcher() {
98 TRACE_EVENT0("shutdown", "WindowEventDispatcher::Destructor"); 98 TRACE_EVENT0("shutdown", "WindowEventDispatcher::Destructor");
99 Env::GetInstance()->RemoveObserver(this); 99 Env::GetInstance()->RemoveObserver(this);
100 ui::GestureRecognizer::Get()->RemoveGestureEventHelper(this); 100 ui::GestureRecognizer::Get()->RemoveGestureEventHelper(this);
101 } 101 }
102 102
103 void WindowEventDispatcher::RepostEvent(const ui::LocatedEvent& event) { 103 void WindowEventDispatcher::RepostEvent(const ui::LocatedEvent* event) {
104 DCHECK(event.type() == ui::ET_MOUSE_PRESSED || 104 DCHECK(event->type() == ui::ET_MOUSE_PRESSED ||
105 event.type() == ui::ET_GESTURE_TAP_DOWN); 105 event->type() == ui::ET_GESTURE_TAP_DOWN ||
106 event->type() == ui::ET_TOUCH_PRESSED);
106 // We allow for only one outstanding repostable event. This is used 107 // We allow for only one outstanding repostable event. This is used
107 // in exiting context menus. A dropped repost request is allowed. 108 // in exiting context menus. A dropped repost request is allowed.
108 if (event.type() == ui::ET_MOUSE_PRESSED) { 109 if ((event->type() == ui::ET_MOUSE_PRESSED) ||
109 held_repostable_event_.reset( 110 (event->type() == ui::ET_TOUCH_PRESSED)) {
110 new ui::MouseEvent( 111 if (event->type() == ui::ET_MOUSE_PRESSED) {
111 static_cast<const ui::MouseEvent&>(event), 112 held_repostable_event_.reset(
112 static_cast<aura::Window*>(event.target()), 113 new ui::MouseEvent(
113 window())); 114 static_cast<const ui::MouseEvent&>(*event),
115 static_cast<aura::Window*>(event->target()),
116 window()));
117 } else {
118 held_repostable_event_.reset(
119 new ui::TouchEvent(static_cast<const ui::TouchEvent&>(*event)));
120 }
114 base::MessageLoop::current()->PostNonNestableTask( 121 base::MessageLoop::current()->PostNonNestableTask(
115 FROM_HERE, base::Bind( 122 FROM_HERE, base::Bind(
116 base::IgnoreResult(&WindowEventDispatcher::DispatchHeldEvents), 123 base::IgnoreResult(&WindowEventDispatcher::DispatchHeldEvents),
117 repost_event_factory_.GetWeakPtr())); 124 repost_event_factory_.GetWeakPtr()));
118 } else { 125 } else {
119 DCHECK(event.type() == ui::ET_GESTURE_TAP_DOWN); 126 DCHECK(event->type() == ui::ET_GESTURE_TAP_DOWN);
120 held_repostable_event_.reset(); 127 held_repostable_event_.reset();
121 // TODO(rbyers): Reposing of gestures is tricky to get 128 // TODO(rbyers): Reposing of gestures is tricky to get
122 // right, so it's not yet supported. crbug.com/170987. 129 // right, so it's not yet supported. crbug.com/170987.
123 } 130 }
124 } 131 }
sadrul 2016/01/13 20:24:24 Can this be like: if (event->type() == ui::ET_M
ananta 2016/01/13 21:34:48 Done.
125 132
126 void WindowEventDispatcher::OnMouseEventsEnableStateChanged(bool enabled) { 133 void WindowEventDispatcher::OnMouseEventsEnableStateChanged(bool enabled) {
127 // Send entered / exited so that visual state can be updated to match 134 // Send entered / exited so that visual state can be updated to match
128 // mouse events state. 135 // mouse events state.
129 PostSynthesizeMouseMove(); 136 PostSynthesizeMouseMove();
130 // TODO(mazda): Add code to disable mouse events when |enabled| == false. 137 // TODO(mazda): Add code to disable mouse events when |enabled| == false.
131 } 138 }
132 139
133 void WindowEventDispatcher::DispatchCancelModeEvent() { 140 void WindowEventDispatcher::DispatchCancelModeEvent() {
134 ui::CancelModeEvent event; 141 ui::CancelModeEvent event;
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 // WindowEventDispatcher, private: 666 // WindowEventDispatcher, private:
660 667
661 ui::EventDispatchDetails WindowEventDispatcher::DispatchHeldEvents() { 668 ui::EventDispatchDetails WindowEventDispatcher::DispatchHeldEvents() {
662 if (!held_repostable_event_ && !held_move_event_) 669 if (!held_repostable_event_ && !held_move_event_)
663 return DispatchDetails(); 670 return DispatchDetails();
664 671
665 CHECK(!dispatching_held_event_); 672 CHECK(!dispatching_held_event_);
666 673
667 DispatchDetails dispatch_details; 674 DispatchDetails dispatch_details;
668 if (held_repostable_event_) { 675 if (held_repostable_event_) {
669 if (held_repostable_event_->type() == ui::ET_MOUSE_PRESSED) { 676 if (held_repostable_event_->type() == ui::ET_MOUSE_PRESSED ||
670 scoped_ptr<ui::MouseEvent> mouse_event( 677 held_repostable_event_->type() == ui::ET_TOUCH_PRESSED) {
671 static_cast<ui::MouseEvent*>(held_repostable_event_.release())); 678 scoped_ptr<ui::LocatedEvent> event;
672 dispatching_held_event_ = mouse_event.get(); 679 event.reset(held_repostable_event_.release());
sadrul 2016/01/13 20:24:24 Use std::move instead?
ananta 2016/01/13 21:34:48 done
673 dispatch_details = OnEventFromSource(mouse_event.get()); 680 dispatching_held_event_ = event.get();
681 dispatch_details = OnEventFromSource(event.get());
674 } else { 682 } else {
675 // TODO(rbyers): GESTURE_TAP_DOWN not yet supported: crbug.com/170987. 683 // TODO(rbyers): GESTURE_TAP_DOWN not yet supported: crbug.com/170987.
676 NOTREACHED(); 684 NOTREACHED();
677 } 685 }
678 if (dispatch_details.dispatcher_destroyed) 686 if (dispatch_details.dispatcher_destroyed)
679 return dispatch_details; 687 return dispatch_details;
680 } 688 }
681 689
682 if (held_move_event_) { 690 if (held_move_event_) {
683 // If a mouse move has been synthesized, the target location is suspect, 691 // If a mouse move has been synthesized, the target location is suspect,
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 } 916 }
909 917
910 // This flag is set depending on the gestures recognized in the call above, 918 // This flag is set depending on the gestures recognized in the call above,
911 // and needs to propagate with the forwarded event. 919 // and needs to propagate with the forwarded event.
912 event->set_may_cause_scrolling(orig_event.may_cause_scrolling()); 920 event->set_may_cause_scrolling(orig_event.may_cause_scrolling());
913 921
914 return PreDispatchLocatedEvent(target, event); 922 return PreDispatchLocatedEvent(target, event);
915 } 923 }
916 924
917 } // namespace aura 925 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/window_event_dispatcher.h ('k') | ui/aura/window_event_dispatcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698