Add NO_FOCUS_CHANGE flag to pointer gestures to disallow focus changes

When using a multi-touch trackpad, it is the expected behavior in most
operating systems that the user is allowed to perform gestures (like
scroll, pinch, etc.) on an unfocused window without bringing it into
focus. The previous behavior in Android was that any DOWN event on an
unfocused window would bring the unfocused window into focus, including
any pointer gesture.

This change adds the NO_FOCUS_CHANGE flag to the MotionEvents generated
by certain pointer gestures so that it does not change window focus.
Gestures such as tap and tap drag are not affected.

Bug: 173733166
Test: atest inputflinger_tests
Test: manual: in multi-display scenario with freeform windows and a
trackpad: open two freeform windows so that they overlap, perform
gesture (scroll/pinch) on unfocused window, observe that the window is
not focused; perform tap on unfocused window, observe that the window is
focused.

Change-Id: I74e52f8daa13d4e6c047bc23982ec56942c555f6
diff --git a/include/input/Input.h b/include/input/Input.h
index 7b522bb..a4a7f8b 100644
--- a/include/input/Input.h
+++ b/include/input/Input.h
@@ -70,6 +70,14 @@
      */
     AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE = 0x8,
 
+    /**
+     * This flag indicates that the event will not cause a focus change if it is directed to an
+     * unfocused window, even if it an ACTION_DOWN. This is typically used with pointer
+     * gestures to allow the user to direct gestures to an unfocused window without bringing it
+     * into focus.
+     */
+    AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE = 0x40,
+
     /* Motion event is inconsistent with previously sent motion events. */
     AMOTION_EVENT_FLAG_TAINTED = 0x80000000,
 };