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

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

Issue 2884463002: Make event-targeting asynchronous in window server. (Closed)
Patch Set: comments Created 3 years, 6 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
« no previous file with comments | « services/ui/ws/event_dispatcher_unittest.cc ('k') | services/ui/ws/event_targeter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..a1f75013510e3a409bd56f0243047f59f650fabb 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,55 @@ 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 ProcessFindTarget(const gfx::Point& location,
+ int64_t display_id,
+ HitTestCallback callback);
+
+ void FindTargetForLocationNow(const gfx::Point& location,
+ int64_t display_id,
+ HitTestCallback callback);
+
+ void ProcessNextHitTestRequestFromQueue();
+
EventTargeterDelegate* event_targeter_delegate_;
+ // True if we are waiting for the result of a hit-test. False otherwise.
+ bool hit_test_in_flight_;
+
+ // Requests for a new location while waiting on an existing request are added
+ // here.
+ std::queue<std::unique_ptr<HitTestRequest>> hit_test_request_queue_;
+
+ base::WeakPtrFactory<EventTargeter> weak_ptr_factory_;
+
DISALLOW_COPY_AND_ASSIGN(EventTargeter);
};
« no previous file with comments | « services/ui/ws/event_dispatcher_unittest.cc ('k') | services/ui/ws/event_targeter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698