Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(660)

Unified Diff: services/ui/ws/event_targeter.h

Issue 2884463002: Make event-targeting asynchronous in window server. (Closed)
Patch Set: rebase and comments Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: services/ui/ws/event_targeter.h
diff --git a/services/ui/ws/event_targeter.h b/services/ui/ws/event_targeter.h
index 91dfaf39626e5cf1e36594e1a3e47278c0cc5921..00864fae241ea35185f91254aa69745f3cfcf9f0 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&,
+ int64_t)>;
+using HitTestCallback =
+ base::OnceCallback<void(const DeepestWindow&, const gfx::Point&, int64_t)>;
+
// Finds the PointerTarget for an event or the DeepestWindow for a location.
class EventTargeter {
public:
@@ -50,21 +58,65 @@ 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,
+ int64_t display_id,
+ PointerTargetForEventCallback callback);
- // 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);
+ // Calls WindowFinder to find the deepest visible window for |location|.
+ // |callback| is called with the window found.
+ void FindDeepestVisibleWindowForLocation(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 PointerTargetForEventOnFoundWindow(const ui::PointerEvent& event,
+ const DeepestWindow& deepest_window,
+ const gfx::Point& location_in_display,
+ int64_t display_id);
+
+ void FindDeepestVisibleWindowForLocationImpl(const gfx::Point& location,
+ int64_t display_id);
+
+ void FindDeepestVisibleWindowForLocationAsync(const gfx::Point& location,
+ int64_t display_id);
+
+ void ProcessNextHittesetRequestFromQueue();
+
EventTargeterDelegate* event_targeter_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);
};

Powered by Google App Engine
This is Rietveld 408576698