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 class InputWindowHandle; 26 27 namespace inputdispatcher { 28 29 struct TouchState { 30 bool down; 31 bool split; 32 int32_t deviceId; // id of the device that is currently down, others are rejected 33 uint32_t source; // source of the device that is current down, others are rejected 34 int32_t displayId; // id to the display that currently has a touch, others are rejected 35 std::vector<TouchedWindow> windows; 36 37 // This collects the portal windows that the touch has gone through. Each portal window 38 // targets a display (embedded display for most cases). With this info, we can add the 39 // monitoring channels of the displays touched. 40 std::vector<sp<android::InputWindowHandle>> portalWindows; 41 42 std::vector<TouchedMonitor> gestureMonitors; 43 44 TouchState(); 45 ~TouchState(); 46 void reset(); 47 void copyFrom(const TouchState& other); 48 void addOrUpdateWindow(const sp<android::InputWindowHandle>& windowHandle, int32_t targetFlags, 49 BitSet32 pointerIds); 50 void addPortalWindow(const sp<android::InputWindowHandle>& windowHandle); 51 void addGestureMonitors(const std::vector<TouchedMonitor>& monitors); 52 void removeWindow(const sp<android::InputWindowHandle>& windowHandle); 53 void removeWindowByToken(const sp<IBinder>& token); 54 void filterNonAsIsTouchWindows(); 55 void filterNonMonitors(); 56 sp<InputWindowHandle> getFirstForegroundWindowHandle() const; 57 bool isSlippery() const; 58 }; 59 60 } // namespace inputdispatcher 61 } // namespace android 62 63 #endif // _UI_INPUT_INPUTDISPATCHER_TOUCHSTATE_H 64