summaryrefslogtreecommitdiff
path: root/libs/input/Input.cpp
diff options
context:
space:
mode:
author Antonio Kantek <kanant@google.com> 2021-07-13 18:04:53 -0700
committer Antonio Kantek <kanant@google.com> 2021-07-14 17:48:48 -0700
commit7cdf8ef17636cdc5cc5fe41578951b4b1f23865c (patch)
tree56f026c7cbdb7efc01ba46ae526afdfb5d55eb31 /libs/input/Input.cpp
parent81fc73800743003c669f4d2bacdb9ab6408696eb (diff)
TouchEvent (1/n): Adding TouchModeEvent to InputChannel
This CL detaches the touch mode state update from focus update. It does that by introducing a new internal event (TouchModeEvent). This CL also adds this event to InputChannel and related processing logic to InputPublisher and InputConsumer. InputDispatcher will process two different events now: FocusEvent when gaining/losing focus and TouchModeEvent when entering/leaving touch mode. Test: atest libinput_tests Bug: 193718270 Change-Id: Ie4e5b6e8e798f12d7203127b4559fa40d38788de
Diffstat (limited to 'libs/input/Input.cpp')
-rw-r--r--libs/input/Input.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/libs/input/Input.cpp b/libs/input/Input.cpp
index 9390467f55..30d82b6051 100644
--- a/libs/input/Input.cpp
+++ b/libs/input/Input.cpp
@@ -163,6 +163,9 @@ const char* inputEventTypeToString(int32_t type) {
case AINPUT_EVENT_TYPE_DRAG: {
return "DRAG";
}
+ case AINPUT_EVENT_TYPE_TOUCH_MODE: {
+ return "TOUCH_MODE";
+ }
}
return "UNKNOWN";
}
@@ -882,6 +885,19 @@ void DragEvent::initialize(const DragEvent& from) {
mY = from.mY;
}
+// --- TouchModeEvent ---
+
+void TouchModeEvent::initialize(int32_t id, bool isInTouchMode) {
+ InputEvent::initialize(id, ReservedInputDeviceId::VIRTUAL_KEYBOARD_ID, AINPUT_SOURCE_UNKNOWN,
+ ADISPLAY_ID_NONE, INVALID_HMAC);
+ mIsInTouchMode = isInTouchMode;
+}
+
+void TouchModeEvent::initialize(const TouchModeEvent& from) {
+ InputEvent::initialize(from);
+ mIsInTouchMode = from.mIsInTouchMode;
+}
+
// --- PooledInputEventFactory ---
PooledInputEventFactory::PooledInputEventFactory(size_t maxPoolSize) :
@@ -936,6 +952,15 @@ DragEvent* PooledInputEventFactory::createDragEvent() {
return event;
}
+TouchModeEvent* PooledInputEventFactory::createTouchModeEvent() {
+ if (mTouchModeEventPool.empty()) {
+ return new TouchModeEvent();
+ }
+ TouchModeEvent* event = mTouchModeEventPool.front().release();
+ mTouchModeEventPool.pop();
+ return event;
+}
+
void PooledInputEventFactory::recycle(InputEvent* event) {
switch (event->getType()) {
case AINPUT_EVENT_TYPE_KEY: