SyncPointerCapture (3/n): Add Capture event to InputChannel
This CL adds the ability to send a CAPTURE event through the
InputChannel, and adds the appropriate processing logic to
InputPublisher and InputConsumer.
This will be used by the InputDispatcher to notify windows when they
have either lost or gained Pointer Capture.
Bug: 141749603
Test: atest libinput_tests
Change-Id: I102833e6f0fd1e8e9c4b3c12e7a5a737eeda2377
diff --git a/include/input/InputTransport.h b/include/input/InputTransport.h
index ad0a14e..8744ef7 100644
--- a/include/input/InputTransport.h
+++ b/include/input/InputTransport.h
@@ -67,6 +67,7 @@
MOTION,
FINISHED,
FOCUS,
+ CAPTURE,
};
struct Header {
@@ -166,6 +167,13 @@
inline size_t size() const { return sizeof(Focus); }
} focus;
+
+ struct Capture {
+ int32_t eventId;
+ uint32_t pointerCaptureEnabled; // actually a bool, but we maintain 8-byte alignment
+
+ inline size_t size() const { return sizeof(Capture); }
+ } capture;
} __attribute__((aligned(8))) body;
bool isValid(size_t actualSize) const;
@@ -182,6 +190,8 @@
return "FINISHED";
case Type::FOCUS:
return "FOCUS";
+ case Type::CAPTURE:
+ return "CAPTURE";
}
}
};
@@ -341,6 +351,15 @@
*/
status_t publishFocusEvent(uint32_t seq, int32_t eventId, bool hasFocus, bool inTouchMode);
+ /* Publishes a capture event to the input channel.
+ *
+ * Returns OK on success.
+ * Returns WOULD_BLOCK if the channel is full.
+ * Returns DEAD_OBJECT if the channel's peer has been closed.
+ * Other errors probably indicate that the channel is broken.
+ */
+ status_t publishCaptureEvent(uint32_t seq, int32_t eventId, bool pointerCaptureEnabled);
+
/* Receives the finished signal from the consumer in reply to the original dispatch signal.
* If a signal was received, returns the message sequence number,
* and whether the consumer handled the message.
@@ -576,6 +595,7 @@
static void initializeKeyEvent(KeyEvent* event, const InputMessage* msg);
static void initializeMotionEvent(MotionEvent* event, const InputMessage* msg);
static void initializeFocusEvent(FocusEvent* event, const InputMessage* msg);
+ static void initializeCaptureEvent(CaptureEvent* event, const InputMessage* msg);
static void addSample(MotionEvent* event, const InputMessage* msg);
static bool canAddSample(const Batch& batch, const InputMessage* msg);
static ssize_t findSampleNoLaterThan(const Batch& batch, nsecs_t time);