Fix WM input limitations on secondary displays (2/N)
For one DisplayContent contains one InputMonitor now.
Store InputWindowHandles divided by displayId.
setInputWIndow will be updated by displayId
instead of updating all windows from all displays.
Bug: 111363643
Test: atest WindowManagerSmokeTest ActivityManagerMultiDisplayTests
Test: atest libinput_tests inputflinger_tests
Change-Id: I336945abdd36a543207e15650264280b04253eef
diff --git a/services/inputflinger/InputDispatcher.h b/services/inputflinger/InputDispatcher.h
index 31ab339..5cb7fe1 100644
--- a/services/inputflinger/InputDispatcher.h
+++ b/services/inputflinger/InputDispatcher.h
@@ -31,6 +31,7 @@
#include <stddef.h>
#include <unistd.h>
#include <limits.h>
+#include <unordered_map>
#include "InputWindow.h"
#include "InputApplication.h"
@@ -307,7 +308,8 @@
*
* This method may be called on any thread (usually by the input manager).
*/
- virtual void setInputWindows(const Vector<sp<InputWindowHandle> >& inputWindowHandles) = 0;
+ virtual void setInputWindows(const Vector<sp<InputWindowHandle> >& inputWindowHandles,
+ int displayId) = 0;
/* Sets the focused application.
*
@@ -387,7 +389,8 @@
int32_t injectorPid, int32_t injectorUid, int32_t syncMode, int32_t timeoutMillis,
uint32_t policyFlags);
- virtual void setInputWindows(const Vector<sp<InputWindowHandle> >& inputWindowHandles);
+ virtual void setInputWindows(const Vector<sp<InputWindowHandle> >& inputWindowHandles,
+ int displayId);
virtual void setFocusedApplication(const sp<InputApplicationHandle>& inputApplicationHandle);
virtual void setInputDispatchMode(bool enabled, bool frozen);
virtual void setInputFilterEnabled(bool enabled);
@@ -956,10 +959,11 @@
bool mDispatchFrozen;
bool mInputFilterEnabled;
- Vector<sp<InputWindowHandle> > mWindowHandles;
-
+ std::unordered_map<int32_t, Vector<sp<InputWindowHandle>>> mWindowHandlesByDisplay;
+ // Get window handles by display, return an empty vector if not found.
+ Vector<sp<InputWindowHandle>> getWindowHandlesLocked(int32_t displayId) const;
sp<InputWindowHandle> getWindowHandleLocked(const sp<InputChannel>& inputChannel) const;
- bool hasWindowHandleLocked(const sp<InputWindowHandle>& windowHandle) const;
+ bool hasWindowHandleLocked(const sp<InputWindowHandle>& windowHandle, int32_t displayId) const;
// Focus tracking for keys, trackball, etc.
sp<InputWindowHandle> mFocusedWindowHandle;