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

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

Issue 1260453006: ui: events: Add a class to hold common touch and stylus properties (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address build problems, add accessor and unit tests. Created 5 years, 4 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
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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/trace_event/trace_event.h" 10 #include "base/trace_event/trace_event.h"
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 event->ConvertLocationToTarget(window(), target); 146 event->ConvertLocationToTarget(window(), target);
147 DispatchDetails details = DispatchEvent(target, event); 147 DispatchDetails details = DispatchEvent(target, event);
148 if (details.dispatcher_destroyed) 148 if (details.dispatcher_destroyed)
149 return; 149 return;
150 } 150 }
151 } 151 }
152 152
153 DispatchDetails WindowEventDispatcher::DispatchMouseExitAtPoint( 153 DispatchDetails WindowEventDispatcher::DispatchMouseExitAtPoint(
154 Window* window, 154 Window* window,
155 const gfx::Point& point) { 155 const gfx::Point& point) {
156 ui::MouseEvent event(ui::ET_MOUSE_EXITED, point, point, ui::EventTimeForNow(), 156 ui::MouseEvent event(
157 ui::EF_NONE, ui::EF_NONE); 157 ui::ET_MOUSE_EXITED, point, point, ui::EventTimeForNow(), ui::EF_NONE,
158 ui::EF_NONE,
159 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
158 return DispatchMouseEnterOrExit(window, event, ui::ET_MOUSE_EXITED); 160 return DispatchMouseEnterOrExit(window, event, ui::ET_MOUSE_EXITED);
159 } 161 }
160 162
161 void WindowEventDispatcher::ProcessedTouchEvent(uint32 unique_event_id, 163 void WindowEventDispatcher::ProcessedTouchEvent(uint32 unique_event_id,
162 Window* window, 164 Window* window,
163 ui::EventResult result) { 165 ui::EventResult result) {
164 scoped_ptr<ui::GestureRecognizer::Gestures> gestures( 166 scoped_ptr<ui::GestureRecognizer::Gestures> gestures(
165 ui::GestureRecognizer::Get()->AckTouchEvent(unique_event_id, result, 167 ui::GestureRecognizer::Get()->AckTouchEvent(unique_event_id, result,
166 window)); 168 window));
167 DispatchDetails details = ProcessGestures(gestures.get()); 169 DispatchDetails details = ProcessGestures(gestures.get());
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 Window* new_capture) { 361 Window* new_capture) {
360 // |mouse_moved_handler_| may have been set to a Window in a different root 362 // |mouse_moved_handler_| may have been set to a Window in a different root
361 // (see below). Clear it here to ensure we don't end up referencing a stale 363 // (see below). Clear it here to ensure we don't end up referencing a stale
362 // Window. 364 // Window.
363 if (mouse_moved_handler_ && !window()->Contains(mouse_moved_handler_)) 365 if (mouse_moved_handler_ && !window()->Contains(mouse_moved_handler_))
364 mouse_moved_handler_ = NULL; 366 mouse_moved_handler_ = NULL;
365 367
366 if (old_capture && old_capture->GetRootWindow() == window() && 368 if (old_capture && old_capture->GetRootWindow() == window() &&
367 old_capture->delegate()) { 369 old_capture->delegate()) {
368 // Send a capture changed event with bogus location data. 370 // Send a capture changed event with bogus location data.
369 ui::MouseEvent event(ui::ET_MOUSE_CAPTURE_CHANGED, gfx::Point(), 371 ui::MouseEvent event(
370 gfx::Point(), ui::EventTimeForNow(), 0, 0); 372 ui::ET_MOUSE_CAPTURE_CHANGED, gfx::Point(), gfx::Point(),
373 ui::EventTimeForNow(), 0, 0,
374 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
371 375
372 DispatchDetails details = DispatchEvent(old_capture, &event); 376 DispatchDetails details = DispatchEvent(old_capture, &event);
373 if (details.dispatcher_destroyed) 377 if (details.dispatcher_destroyed)
374 return; 378 return;
375 379
376 if (!details.target_destroyed) 380 if (!details.target_destroyed)
377 old_capture->delegate()->OnCaptureLost(); 381 old_capture->delegate()->OnCaptureLost();
378 } 382 }
379 383
380 if (new_capture) { 384 if (new_capture) {
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 // DRAGGED event can be synthesized in the incorrect host. So avoid 720 // DRAGGED event can be synthesized in the incorrect host. So avoid
717 // synthesizing any events at all. 721 // synthesizing any events at all.
718 if (Env::GetInstance()->mouse_button_flags()) 722 if (Env::GetInstance()->mouse_button_flags())
719 return details; 723 return details;
720 724
721 gfx::Point root_mouse_location = GetLastMouseLocationInRoot(); 725 gfx::Point root_mouse_location = GetLastMouseLocationInRoot();
722 if (!window()->bounds().Contains(root_mouse_location)) 726 if (!window()->bounds().Contains(root_mouse_location))
723 return details; 727 return details;
724 gfx::Point host_mouse_location = root_mouse_location; 728 gfx::Point host_mouse_location = root_mouse_location;
725 host_->ConvertPointToHost(&host_mouse_location); 729 host_->ConvertPointToHost(&host_mouse_location);
726 ui::MouseEvent event(ui::ET_MOUSE_MOVED, host_mouse_location, 730 ui::MouseEvent event(
727 host_mouse_location, ui::EventTimeForNow(), 731 ui::ET_MOUSE_MOVED, host_mouse_location, host_mouse_location,
728 ui::EF_IS_SYNTHESIZED, 0); 732 ui::EventTimeForNow(), ui::EF_IS_SYNTHESIZED, 0,
733 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
729 return OnEventFromSource(&event); 734 return OnEventFromSource(&event);
730 } 735 }
731 736
732 void WindowEventDispatcher::PreDispatchLocatedEvent(Window* target, 737 void WindowEventDispatcher::PreDispatchLocatedEvent(Window* target,
733 ui::LocatedEvent* event) { 738 ui::LocatedEvent* event) {
734 int flags = event->flags(); 739 int flags = event->flags();
735 if (IsNonClientLocation(target, event->location())) 740 if (IsNonClientLocation(target, event->location()))
736 flags |= ui::EF_IS_NON_CLIENT; 741 flags |= ui::EF_IS_NON_CLIENT;
737 event->set_flags(flags); 742 event->set_flags(flags);
738 743
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 } 898 }
894 899
895 // This flag is set depending on the gestures recognized in the call above, 900 // This flag is set depending on the gestures recognized in the call above,
896 // and needs to propagate with the forwarded event. 901 // and needs to propagate with the forwarded event.
897 event->set_may_cause_scrolling(orig_event.may_cause_scrolling()); 902 event->set_may_cause_scrolling(orig_event.may_cause_scrolling());
898 903
899 PreDispatchLocatedEvent(target, event); 904 PreDispatchLocatedEvent(target, event);
900 } 905 }
901 906
902 } // namespace aura 907 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698