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 c71650a5d2efc716c36e5db6374cc5717074ad04..e70723d244939c719dce077646704d912ab26d9a 100644 |
| --- a/services/ui/ws/event_targeter.h |
| +++ b/services/ui/ws/event_targeter.h |
| @@ -6,8 +6,11 @@ |
| #define SERVICES_UI_WS_EVENT_TARGETER_H_ |
| #include <stdint.h> |
| +#include <queue> |
| +#include "base/callback.h" |
| #include "base/macros.h" |
| +#include "base/memory/weak_ptr.h" |
| #include "services/ui/ws/window_finder.h" |
| #include "ui/display/types/display_constants.h" |
| #include "ui/gfx/geometry/point.h" |
| @@ -24,20 +27,58 @@ struct LocationTarget { |
| int64_t display_id = display::kInvalidDisplayId; |
| }; |
| +using HitTestCallback = base::OnceCallback<void(const LocationTarget&)>; |
| + |
| // Finds the target window for a location. |
| class EventTargeter { |
| public: |
| explicit EventTargeter(EventTargeterDelegate* event_targeter_delegate); |
| ~EventTargeter(); |
| - // Returns a LocationTarget for the supplied |location|. If there is no valid |
| - // root window, |window| in the returned value is null. |
| - LocationTarget FindTargetForLocation(const gfx::Point& location, |
| - int64_t display_id); |
| + // Calls WindowFinder to find the target for |location|. |
| + // |callback| is called with the LocationTarget found. |
| + void FindTargetForLocation(const gfx::Point& location, |
| + int64_t display_id, |
| + HitTestCallback callback); |
| + |
| + bool IsHitTestInFlight() const; |
| private: |
| + struct HitTestRequest { |
| + HitTestRequest(const gfx::Point& location, |
| + int64_t display_id, |
| + HitTestCallback hittest_callback); |
| + ~HitTestRequest(); |
| + |
| + gfx::Point location; |
| + int64_t display_id; |
| + HitTestCallback callback; |
| + }; |
| + |
| + void FindTargetForLocationImpl(const gfx::Point& location, |
| + int64_t display_id, |
| + HitTestCallback callback); |
| + |
| + void FindTargetForLocationAsync(const gfx::Point& location, |
| + int64_t display_id, |
| + HitTestCallback callback); |
| + |
| + void ProcessNextHittesetRequestFromQueue(); |
|
sky
2017/06/07 17:05:07
HitTestRequest
riajiang
2017/06/07 18:15:04
Done.
|
| + |
| EventTargeterDelegate* event_targeter_delegate_; |
| + // True if we are waiting for the result of a hit-test. False otherwise. |
| + bool hit_test_in_flight_; |
| + |
| + // Request would go into this queue if it's coming from EventDispatcher:: |
|
sky
2017/06/07 17:05:07
Update description.
riajiang
2017/06/07 18:15:04
This is still valid? Even though we call FindTarge
sky
2017/06/07 19:46:41
This description is entirely in terms of other cla
riajiang
2017/06/07 21:46:25
Oh I see, done.
|
| + // 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>> hit_test_request_queue_; |
| + |
| + base::WeakPtrFactory<EventTargeter> weak_ptr_factory_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(EventTargeter); |
| }; |