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/services/inputflinger/dispatcher/TouchState.cpp b/services/inputflinger/dispatcher/TouchState.cpp
index b7ed658..4a50a68 100644
--- a/services/inputflinger/dispatcher/TouchState.cpp
+++ b/services/inputflinger/dispatcher/TouchState.cpp
@@ -134,4 +134,14 @@
return haveSlipperyForegroundWindow;
}
+sp<WindowInfoHandle> TouchState::getWallpaperWindow() const {
+ for (size_t i = 0; i < windows.size(); i++) {
+ const TouchedWindow& window = windows[i];
+ if (window.windowHandle->getInfo()->type == WindowInfo::Type::WALLPAPER) {
+ return window.windowHandle;
+ }
+ }
+ return nullptr;
+}
+
} // namespace android::inputdispatcher