From 25040239f17b406e33c714f56bf082d76005d20e Mon Sep 17 00:00:00 2001 From: Hiroki Sato Date: Thu, 22 Feb 2024 17:21:22 +0900 Subject: Use input token in PointerCaptureRequest Instead of sending boolean to indicate the capture state, InputDispatcher now sends an input window token that requests a pointer capture, or nullptr otherwise. This is useful for some InputReader implementations. Also, this token can be used to verify if a pointer capture changed event from a reader is valid. Bug: 259346762 Bug: 301628662 Test: inputflinger_tests Test: android.view.cts.PointerCaptureTest WindowFocusTests#testPointerCapture Change-Id: Ie8343db6744dc2080f7f1dcff5a630be5c87fa3e --- include/input/Input.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'include/input/Input.h') diff --git a/include/input/Input.h b/include/input/Input.h index ddc376809e..19f4ab38e8 100644 --- a/include/input/Input.h +++ b/include/input/Input.h @@ -1192,15 +1192,17 @@ public: */ struct PointerCaptureRequest { public: - inline PointerCaptureRequest() : enable(false), seq(0) {} - inline PointerCaptureRequest(bool enable, uint32_t seq) : enable(enable), seq(seq) {} + inline PointerCaptureRequest() : window(), seq(0) {} + inline PointerCaptureRequest(sp window, uint32_t seq) : window(window), seq(seq) {} inline bool operator==(const PointerCaptureRequest& other) const { - return enable == other.enable && seq == other.seq; + return window == other.window && seq == other.seq; } - explicit inline operator bool() const { return enable; } + inline bool isEnable() const { return window != nullptr; } - // True iff this is a request to enable Pointer Capture. - bool enable; + // The requesting window. + // If the request is to enable the capture, this is the input token of the window that requested + // pointer capture. Otherwise, this is nullptr. + sp window; // The sequence number for the request. uint32_t seq; -- cgit v1.2.3-59-g8ed1b