1 /* 2 * Copyright (C) 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef _UI_INPUT_INPUTDISPATCHER_TOUCHSTATE_H 18 #define _UI_INPUT_INPUTDISPATCHER_TOUCHSTATE_H 19 20 #include "Monitor.h" 21 #include "TouchedWindow.h" 22 23 namespace android { 24 25 namespace gui { 26 class WindowInfoHandle; 27 } 28 29 namespace inputdispatcher { 30 31 struct TouchState { 32 bool down; 33 bool split; 34 int32_t deviceId; // id of the device that is currently down, others are rejected 35 uint32_t source; // source of the device that is current down, others are rejected 36 int32_t displayId; // id to the display that currently has a touch, others are rejected 37 std::vector<TouchedWindow> windows; 38 39 // This collects the portal windows that the touch has gone through. Each portal window 40 // targets a display (embedded display for most cases). With this info, we can add the 41 // monitoring channels of the displays touched. 42 std::vector<sp<android::gui::WindowInfoHandle>> portalWindows; 43 44 std::vector<TouchedMonitor> gestureMonitors; 45 46 TouchState(); 47 ~TouchState(); 48 void reset(); 49 void copyFrom(const TouchState& other); 50 void addOrUpdateWindow(const sp<android::gui::WindowInfoHandle>& windowHandle, 51 int32_t targetFlags, BitSet32 pointerIds); 52 void addPortalWindow(const sp<android::gui::WindowInfoHandle>& windowHandle); 53 void addGestureMonitors(const std::vector<TouchedMonitor>& monitors); 54 void removeWindowByToken(const sp<IBinder>& token); 55 void filterNonAsIsTouchWindows(); 56 void filterNonMonitors(); 57 sp<android::gui::WindowInfoHandle> getFirstForegroundWindowHandle() const; 58 bool isSlippery() const; 59 }; 60 61 } // namespace inputdispatcher 62 } // namespace android 63 64 #endif // _UI_INPUT_INPUTDISPATCHER_TOUCHSTATE_H 65