| OLD | NEW |
| 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" |
| 11 #include "base/threading/thread_task_runner_handle.h" | 11 #include "base/threading/thread_task_runner_handle.h" |
| 12 #include "base/trace_event/trace_event.h" | 12 #include "base/trace_event/trace_event.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "ui/aura/client/capture_client.h" | 14 #include "ui/aura/client/capture_client.h" |
| 15 #include "ui/aura/client/cursor_client.h" | 15 #include "ui/aura/client/cursor_client.h" |
| 16 #include "ui/aura/client/event_client.h" | 16 #include "ui/aura/client/event_client.h" |
| 17 #include "ui/aura/client/focus_client.h" | 17 #include "ui/aura/client/focus_client.h" |
| 18 #include "ui/aura/client/screen_position_client.h" | 18 #include "ui/aura/client/screen_position_client.h" |
| 19 #include "ui/aura/env.h" | 19 #include "ui/aura/env.h" |
| 20 #include "ui/aura/env_input_state_controller.h" | 20 #include "ui/aura/env_input_state_controller.h" |
| 21 #include "ui/aura/mus/mus_mouse_location_updater.h" | 21 #include "ui/aura/mus/mus_mouse_location_updater.h" |
| 22 #include "ui/aura/window.h" | 22 #include "ui/aura/window.h" |
| 23 #include "ui/aura/window_delegate.h" | 23 #include "ui/aura/window_delegate.h" |
| 24 #include "ui/aura/window_targeter.h" | 24 #include "ui/aura/window_targeter.h" |
| 25 #include "ui/aura/window_tracker.h" | 25 #include "ui/aura/window_tracker.h" |
| 26 #include "ui/aura/window_tree_host.h" | 26 #include "ui/aura/window_tree_host.h" |
| 27 #include "ui/base/hit_test.h" | 27 #include "ui/base/hit_test.h" |
| 28 #include "ui/base/ime/input_method.h" |
| 28 #include "ui/compositor/dip_util.h" | 29 #include "ui/compositor/dip_util.h" |
| 29 #include "ui/events/event.h" | 30 #include "ui/events/event.h" |
| 30 #include "ui/events/event_utils.h" | 31 #include "ui/events/event_utils.h" |
| 31 #include "ui/events/gestures/gesture_recognizer.h" | 32 #include "ui/events/gestures/gesture_recognizer.h" |
| 32 #include "ui/events/gestures/gesture_types.h" | 33 #include "ui/events/gestures/gesture_types.h" |
| 33 | 34 |
| 34 typedef ui::EventDispatchDetails DispatchDetails; | 35 typedef ui::EventDispatchDetails DispatchDetails; |
| 35 | 36 |
| 36 namespace aura { | 37 namespace aura { |
| 37 | 38 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 : host_(host), | 86 : host_(host), |
| 86 mouse_pressed_handler_(NULL), | 87 mouse_pressed_handler_(NULL), |
| 87 mouse_moved_handler_(NULL), | 88 mouse_moved_handler_(NULL), |
| 88 event_dispatch_target_(NULL), | 89 event_dispatch_target_(NULL), |
| 89 old_dispatch_target_(NULL), | 90 old_dispatch_target_(NULL), |
| 90 synthesize_mouse_move_(false), | 91 synthesize_mouse_move_(false), |
| 91 move_hold_count_(0), | 92 move_hold_count_(0), |
| 92 dispatching_held_event_(nullptr), | 93 dispatching_held_event_(nullptr), |
| 93 observer_manager_(this), | 94 observer_manager_(this), |
| 94 event_targeter_(new WindowTargeter), | 95 event_targeter_(new WindowTargeter), |
| 96 skip_ime_(false), |
| 95 repost_event_factory_(this), | 97 repost_event_factory_(this), |
| 96 held_event_factory_(this) { | 98 held_event_factory_(this) { |
| 97 ui::GestureRecognizer::Get()->AddGestureEventHelper(this); | 99 ui::GestureRecognizer::Get()->AddGestureEventHelper(this); |
| 98 Env::GetInstance()->AddObserver(this); | 100 Env::GetInstance()->AddObserver(this); |
| 99 if (Env::GetInstance()->mode() == Env::Mode::MUS) | 101 if (Env::GetInstance()->mode() == Env::Mode::MUS) |
| 100 mus_mouse_location_updater_ = base::MakeUnique<MusMouseLocationUpdater>(); | 102 mus_mouse_location_updater_ = base::MakeUnique<MusMouseLocationUpdater>(); |
| 101 } | 103 } |
| 102 | 104 |
| 103 WindowEventDispatcher::~WindowEventDispatcher() { | 105 WindowEventDispatcher::~WindowEventDispatcher() { |
| 104 TRACE_EVENT0("shutdown", "WindowEventDispatcher::Destructor"); | 106 TRACE_EVENT0("shutdown", "WindowEventDispatcher::Destructor"); |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 } | 514 } |
| 513 } | 515 } |
| 514 | 516 |
| 515 DispatchDetails details; | 517 DispatchDetails details; |
| 516 if (event->IsMouseEvent()) { | 518 if (event->IsMouseEvent()) { |
| 517 details = PreDispatchMouseEvent(target_window, event->AsMouseEvent()); | 519 details = PreDispatchMouseEvent(target_window, event->AsMouseEvent()); |
| 518 } else if (event->IsScrollEvent()) { | 520 } else if (event->IsScrollEvent()) { |
| 519 details = PreDispatchLocatedEvent(target_window, event->AsScrollEvent()); | 521 details = PreDispatchLocatedEvent(target_window, event->AsScrollEvent()); |
| 520 } else if (event->IsTouchEvent()) { | 522 } else if (event->IsTouchEvent()) { |
| 521 details = PreDispatchTouchEvent(target_window, event->AsTouchEvent()); | 523 details = PreDispatchTouchEvent(target_window, event->AsTouchEvent()); |
| 524 } else if (event->IsKeyEvent()) { |
| 525 details = PreDispatchKeyEvent(event->AsKeyEvent()); |
| 522 } | 526 } |
| 523 if (details.dispatcher_destroyed || details.target_destroyed) | 527 if (details.dispatcher_destroyed || details.target_destroyed) |
| 524 return details; | 528 return details; |
| 525 | 529 |
| 526 old_dispatch_target_ = event_dispatch_target_; | 530 old_dispatch_target_ = event_dispatch_target_; |
| 527 event_dispatch_target_ = target_window; | 531 event_dispatch_target_ = target_window; |
| 528 return DispatchDetails(); | 532 return DispatchDetails(); |
| 529 } | 533 } |
| 530 | 534 |
| 531 ui::EventDispatchDetails WindowEventDispatcher::PostDispatchEvent( | 535 ui::EventDispatchDetails WindowEventDispatcher::PostDispatchEvent( |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 922 return DispatchDetails(); | 926 return DispatchDetails(); |
| 923 } | 927 } |
| 924 | 928 |
| 925 // This flag is set depending on the gestures recognized in the call above, | 929 // This flag is set depending on the gestures recognized in the call above, |
| 926 // and needs to propagate with the forwarded event. | 930 // and needs to propagate with the forwarded event. |
| 927 event->set_may_cause_scrolling(orig_event.may_cause_scrolling()); | 931 event->set_may_cause_scrolling(orig_event.may_cause_scrolling()); |
| 928 | 932 |
| 929 return PreDispatchLocatedEvent(target, event); | 933 return PreDispatchLocatedEvent(target, event); |
| 930 } | 934 } |
| 931 | 935 |
| 936 ui::EventDispatchDetails WindowEventDispatcher::PreDispatchKeyEvent( |
| 937 ui::KeyEvent* event) { |
| 938 if (skip_ime_ || !host_->has_input_method() || |
| 939 (event->flags() & ui::EF_IS_SYNTHESIZED)) |
| 940 return ui::EventDispatchDetails(); |
| 941 host_->GetInputMethod()->DispatchKeyEvent(event); |
| 942 event->StopPropagation(); |
| 943 return ui::EventDispatchDetails(); |
| 944 } |
| 945 |
| 932 } // namespace aura | 946 } // namespace aura |
| OLD | NEW |