blob: a4e52b0d83047023acb5846f85ea996aa10526b4 [file] [log] [blame]
Garfield Tane84e6f92019-08-29 17:28:41 -07001/*
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
23namespace android {
24
chaviw3277faf2021-05-19 16:45:23 -050025namespace gui {
26class WindowInfoHandle;
27}
Garfield Tane84e6f92019-08-29 17:28:41 -070028
29namespace inputdispatcher {
30
31struct 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.
chaviw3277faf2021-05-19 16:45:23 -050042 std::vector<sp<android::gui::WindowInfoHandle>> portalWindows;
Garfield Tane84e6f92019-08-29 17:28:41 -070043
44 std::vector<TouchedMonitor> gestureMonitors;
45
46 TouchState();
47 ~TouchState();
48 void reset();
49 void copyFrom(const TouchState& other);
chaviw3277faf2021-05-19 16:45:23 -050050 void addOrUpdateWindow(const sp<android::gui::WindowInfoHandle>& windowHandle,
51 int32_t targetFlags, BitSet32 pointerIds);
52 void addPortalWindow(const sp<android::gui::WindowInfoHandle>& windowHandle);
Garfield Tane84e6f92019-08-29 17:28:41 -070053 void addGestureMonitors(const std::vector<TouchedMonitor>& monitors);
Garfield Tane84e6f92019-08-29 17:28:41 -070054 void removeWindowByToken(const sp<IBinder>& token);
55 void filterNonAsIsTouchWindows();
56 void filterNonMonitors();
chaviw3277faf2021-05-19 16:45:23 -050057 sp<android::gui::WindowInfoHandle> getFirstForegroundWindowHandle() const;
Garfield Tane84e6f92019-08-29 17:28:41 -070058 bool isSlippery() const;
59};
60
61} // namespace inputdispatcher
62} // namespace android
63
64#endif // _UI_INPUT_INPUTDISPATCHER_TOUCHSTATE_H