Chromium Code Reviews| Index: services/ui/ws/event_targeter.h |
| diff --git a/services/ui/ws/event_targeter.h b/services/ui/ws/event_targeter.h |
| index a59aba2b5b3d3e6c5b5ceb26167a3de0109e2421..c85972fe40a2682c233901d1efdc4bbebbeeed02 100644 |
| --- a/services/ui/ws/event_targeter.h |
| +++ b/services/ui/ws/event_targeter.h |
| @@ -6,15 +6,15 @@ |
| #define SERVICES_UI_WS_EVENT_TARGETER_H_ |
| #include <stdint.h> |
| +#include <queue> |
| +#include "base/callback.h" |
| #include "base/macros.h" |
| - |
| -namespace gfx { |
| -class Point; |
| -} |
| +#include "base/memory/weak_ptr.h" |
| +#include "ui/gfx/geometry/point.h" |
| namespace ui { |
| -class LocatedEvent; |
| +class PointerEvent; |
| namespace ws { |
| struct DeepestWindow; |
| @@ -43,6 +43,14 @@ struct PointerTarget { |
| bool is_pointer_down; |
| }; |
| +using PointerTargetForEventCallback = |
| + base::OnceCallback<void(const PointerTarget&, |
| + const DeepestWindow&, |
| + const gfx::Point&, |
| + const int64_t)>; |
| +using HitTestCallback = base::OnceCallback< |
| + void(const DeepestWindow&, const gfx::Point&, const int64_t)>; |
| + |
| // Finds the PointerTarget for an event or the DeepestWindow for a location. |
| class EventTargeter { |
| public: |
| @@ -50,21 +58,64 @@ class EventTargeter { |
| ModalWindowController* modal_window_controller); |
| ~EventTargeter(); |
| - // Returns a PointerTarget for the supplied |event|. If there is no valid |
| - // event target for the specified location |window| in the returned value is |
| - // null. |
| - PointerTarget PointerTargetForEvent(const ui::LocatedEvent& event, |
| - int64_t* display_id); |
| + // |callback| is called with a PointerTarget for the supplied |event|. If |
| + // there is no valid event target for the specified location |window| in the |
| + // returned value is null. |
| + void PointerTargetForEvent(const ui::PointerEvent& event, |
| + const int64_t display_id, |
| + PointerTargetForEventCallback callback); |
| + |
| + // Calls WindowFinder to find the deepest visible window for |location|. |
| + // |callback| is called with the window found. |
| + void FindDeepestVisibleWindowForEvents(const gfx::Point& location, |
| + const int64_t display_id, |
| + HitTestCallback callback); |
| + |
| + void ProcessNextHittesetRequestFromQueue(); |
| - // Returns a DeepestWindow for the supplied |location|. If there is no valid |
| - // root window, |window| in the returned value is null. |
| - DeepestWindow FindDeepestVisibleWindowForEvents(gfx::Point* location, |
| - int64_t* display_id); |
| + bool IsHitTestInFlight() const; |
| private: |
| + struct HitTestRequest { |
| + HitTestRequest(const gfx::Point& location, |
| + const int64_t display_id, |
| + HitTestCallback hittest_callback); |
| + ~HitTestRequest(); |
| + |
| + gfx::Point hittest_location; |
|
sky
2017/05/31 23:36:35
Be consistent. You have HitTest and yet these are
riajiang
2017/06/01 18:22:12
Make sense, removed hittest_.
|
| + int64_t hittest_display_id; |
| + HitTestCallback hittest_callback; |
| + }; |
| + |
| + void PointerTargetForEventOnFoundWindow(const ui::PointerEvent& event, |
| + const DeepestWindow& deepest_window, |
| + const gfx::Point& new_location, |
| + const int64_t new_display_id); |
| + |
| + void FindDeepestVisibleWindowForEventsImpl(const gfx::Point& location, |
| + const int64_t display_id); |
| + |
| + void FindDeepestVisibleWindowForEventsAsync(const gfx::Point& location, |
| + const int64_t display_id); |
| + |
| EventDispatcherDelegate* event_dispatcher_delegate_; |
| ModalWindowController* modal_window_controller_; |
| + PointerTargetForEventCallback target_callback_; |
| + HitTestCallback hittest_callback_; |
|
sky
2017/05/31 23:36:35
hit_test
riajiang
2017/06/01 18:22:12
Done.
|
| + |
| + // True if we are waiting for the result of a hit-test. False otherwise. |
| + bool hittest_in_flight_; |
|
sky
2017/05/31 23:36:34
hit_test
riajiang
2017/06/01 18:22:12
Done.
|
| + |
| + // Request would go into this queue if it's coming from EventDispatcher:: |
| + // UpdateNonClientAreaForCurrentWindow() or EventDispatcher:: |
| + // UpdateCursorProviderByLastKnownLocation(). If it's an event that needs |
| + // targeting, it would only go to WindowManagerState::event_queue_ when it's |
| + // waiting for an active hit-test. |
| + std::queue<std::unique_ptr<HitTestRequest>> hittest_request_queue_; |
|
sky
2017/05/31 23:36:34
hit_test
riajiang
2017/06/01 18:22:12
Done.
|
| + |
| + base::WeakPtrFactory<EventTargeter> weak_ptr_factory_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(EventTargeter); |
| }; |