Chromium Code Reviews| Index: services/ui/ws/event_dispatcher.h |
| diff --git a/services/ui/ws/event_dispatcher.h b/services/ui/ws/event_dispatcher.h |
| index 8b084d7994f697a555d078ac1023b4dc5336f825..9ae583429b8f009265b7055e8d23f0a413e87b55 100644 |
| --- a/services/ui/ws/event_dispatcher.h |
| +++ b/services/ui/ws/event_dispatcher.h |
| @@ -122,13 +122,14 @@ class EventDispatcher : public ServerWindowObserver, public DragCursorUpdater { |
| // If the mouse cursor is still over |mouse_cursor_source_window_|, updates |
| // whether we are in the non-client area. Used when |
| - // |mouse_cursor_source_window_| has changed its properties. |
| - void UpdateNonClientAreaForCurrentWindow(); |
| + // |mouse_cursor_source_window_| has changed its properties. |callback| is |
| + // called after the update is finished. |
| + void UpdateNonClientAreaForCurrentWindow(const base::Closure& callback); |
| // Possibly updates the cursor. If we aren't in an implicit capture, we take |
| // the last known location of the mouse pointer, and look for the |
| - // ServerWindow* under it. |
| - void UpdateCursorProviderByLastKnownLocation(); |
| + // ServerWindow* under it. |callback| is called after the update is finished. |
| + void UpdateCursorProviderByLastKnownLocation(const base::Closure& callback); |
| // Adds an accelerator with the given id and event-matcher. If an accelerator |
| // already exists with the same id or the same matcher, then the accelerator |
| @@ -168,6 +169,17 @@ class EventDispatcher : public ServerWindowObserver, public DragCursorUpdater { |
| bool is_pointer_down; |
| }; |
| + using PointerTargetForEventCallback = base::OnceCallback<void(PointerTarget)>; |
| + using HittestCallback = base::OnceCallback<void(DeepestWindow)>; |
| + |
| + struct HittestRequest { |
| + HittestRequest(gfx::Point location, HittestCallback hittest_callback); |
|
sky
2017/05/14 15:59:05
const gfx::Point&
riajiang
2017/05/15 18:34:41
Done.
|
| + ~HittestRequest(); |
| + |
| + gfx::Point hittest_location; |
| + HittestCallback hittest_callback; |
| + }; |
| + |
| void SetMouseCursorSourceWindow(ServerWindow* window); |
| void ProcessKeyEvent(const ui::KeyEvent& event, |
| @@ -187,6 +199,8 @@ class EventDispatcher : public ServerWindowObserver, public DragCursorUpdater { |
| // This also generates exit events as appropriate. For example, if the mouse |
| // moves between one window to another an exit is generated on the first. |
| void ProcessPointerEvent(const ui::PointerEvent& event); |
| + void ProcessPointerEventOnFoundTarget(const ui::PointerEvent& event, |
| + PointerTarget pointer_target_found); |
| // Adds |pointer_target| to |pointer_targets_|. |
| void StartTrackingPointer(int32_t pointer_id, |
| @@ -199,12 +213,18 @@ class EventDispatcher : public ServerWindowObserver, public DragCursorUpdater { |
| // pointer sends the appropriate event to the delegate and updates the |
| // currently tracked PointerTarget appropriately. |
| void UpdateTargetForPointer(int32_t pointer_id, |
| - const ui::LocatedEvent& event); |
| - |
| - // 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); |
| + const ui::PointerEvent& event, |
| + const PointerTarget& pointer_target_found); |
| + |
| + // |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, |
| + PointerTargetForEventCallback callback); |
| + void PointerTargetForEventOnFoundWindow( |
| + const ui::PointerEvent& event, |
| + PointerTargetForEventCallback callback, |
| + DeepestWindow deepest_window); |
| // Returns true if any pointers are in the pressed/down state. |
| bool AreAnyPointersDown() const; |
| @@ -234,7 +254,23 @@ class EventDispatcher : public ServerWindowObserver, public DragCursorUpdater { |
| Accelerator* FindAccelerator(const ui::KeyEvent& event, |
| const ui::mojom::AcceleratorPhase phase); |
| - DeepestWindow FindDeepestVisibleWindowForEvents(const gfx::Point& location); |
| + // Call WindowFinder to find the deepest visible window for |location|. |
| + // |callback| is called with the window found. |
| + void FindDeepestVisibleWindowForEvents(const gfx::Point& location, |
| + HittestCallback callback); |
| + void FindDeepestVisibleWindowForEventsImpl(const gfx::Point& location, |
| + HittestCallback callback); |
| + void FindDeepestVisibleWindowForEventsAsync(const gfx::Point& location, |
| + HittestCallback callback); |
| + |
| + void UpdateNonClientAreaForCurrentWindowOnFoundWindow( |
| + const base::Closure& callback, |
| + DeepestWindow deepest_window); |
| + void UpdateCursorProviderByLastKnownLocationOnFoundWindow( |
| + const base::Closure& callback, |
| + DeepestWindow deepest_window); |
| + |
| + void ProcessNextHittesetRequestFromQueue(); |
| // Clears the implicit captures in |pointer_targets_|, with the exception of |
| // |window|. |window| may be null. |client_id| is the target client of |
| @@ -271,6 +307,10 @@ class EventDispatcher : public ServerWindowObserver, public DragCursorUpdater { |
| std::map<uint32_t, std::unique_ptr<Accelerator>> accelerators_; |
| + // True if we are waiting for the result of a hit-test. False otherwise. |
| + bool hittest_in_flight_; |
| + std::queue<std::unique_ptr<HittestRequest>> hittest_request_queue_; |
| + |
| using PointerIdToTargetMap = std::map<int32_t, PointerTarget>; |
| // |pointer_targets_| contains the active pointers. For a mouse based pointer |
| // a PointerTarget is always active (and present in |pointer_targets_|). For |