Cancel wallpaper touch stream when foreground window is gone
When the foreground window is gone, we should also cancel the touch
stream for its wallpaper window. We already cancel touch for the window
itself, and for global monitor.
Without this patch, the wallpaper window simply stops receiving touches,
and never gets CANCEL, either.
The behaviour is slightly strange for the global monitor in this case.
First of all, the global monitor receives CANCEL, which is questionable
(things like pointer location stop working). Also, it only gets cancel
when a *new* event comes in.
That said, it's probably fine, so let's just document this behaviour by
adding a test for it.
Bug: 192981537
Test: atest inputflinger_tests
Change-Id: I8a2ef7cd552acc5cf64b2e13a6df5d5988bd1808
diff --git a/include/input/Input.h b/include/input/Input.h
index d2d9fd4..f170f0f 100644
--- a/include/input/Input.h
+++ b/include/input/Input.h
@@ -524,13 +524,17 @@
inline int32_t getAction() const { return mAction; }
- inline int32_t getActionMasked() const { return mAction & AMOTION_EVENT_ACTION_MASK; }
+ static int32_t getActionMasked(int32_t action) { return action & AMOTION_EVENT_ACTION_MASK; }
- inline int32_t getActionIndex() const {
- return (mAction & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK)
- >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
+ inline int32_t getActionMasked() const { return getActionMasked(mAction); }
+
+ static int32_t getActionIndex(int32_t action) {
+ return (action & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >>
+ AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
}
+ inline int32_t getActionIndex() const { return getActionIndex(mAction); }
+
inline void setAction(int32_t action) { mAction = action; }
inline int32_t getFlags() const { return mFlags; }