| 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..5f686cab8bd6017e3912b62ba0ace08cfb526fc6 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 location;
|
| + int64_t display_id;
|
| + HitTestCallback callback;
|
| + };
|
| +
|
| + void PointerTargetForEventOnFoundWindow(const ui::PointerEvent& event,
|
| + const DeepestWindow& deepest_window,
|
| + const gfx::Point& location_in_display,
|
| + const int64_t 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 hit_test_callback_;
|
| +
|
| + // 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::
|
| + // 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);
|
| };
|
|
|
|
|