blob: 9efb2808c51c9886d8a04eb98de571937176bb16 [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
chaviw98318de2021-05-19 16:45:23 -050025namespace gui {
26class WindowInfoHandle;
27}
Garfield Tane84e6f92019-08-29 17:28:41 -070028
29namespace inputdispatcher {
30
31struct TouchState {
Prabir Pradhane680f9b2022-02-04 04:24:00 -080032 bool down = false;
33 bool split = false;
34 bool preventNewTargets = false;
35
36 // id of the device that is currently down, others are rejected
37 int32_t deviceId = -1;
38 // source of the device that is current down, others are rejected
39 uint32_t source = 0;
40 // id to the display that currently has a touch, others are rejected
41 int32_t displayId = ADISPLAY_ID_NONE;
42
Garfield Tane84e6f92019-08-29 17:28:41 -070043 std::vector<TouchedWindow> windows;
44
Prabir Pradhane680f9b2022-02-04 04:24:00 -080045 TouchState() = default;
46 ~TouchState() = default;
47 TouchState& operator=(const TouchState&) = default;
48
Garfield Tane84e6f92019-08-29 17:28:41 -070049 void reset();
chaviw98318de2021-05-19 16:45:23 -050050 void addOrUpdateWindow(const sp<android::gui::WindowInfoHandle>& windowHandle,
51 int32_t targetFlags, BitSet32 pointerIds);
Garfield Tane84e6f92019-08-29 17:28:41 -070052 void removeWindowByToken(const sp<IBinder>& token);
53 void filterNonAsIsTouchWindows();
Prabir Pradhan07e05b62021-11-19 03:57:24 -080054 void filterWindowsExcept(const sp<IBinder>& token);
chaviw98318de2021-05-19 16:45:23 -050055 sp<android::gui::WindowInfoHandle> getFirstForegroundWindowHandle() const;
Garfield Tane84e6f92019-08-29 17:28:41 -070056 bool isSlippery() const;
Siarhei Vishniakouca205502021-07-16 21:31:58 +000057 sp<android::gui::WindowInfoHandle> getWallpaperWindow() const;
Prabir Pradhan07e05b62021-11-19 03:57:24 -080058 sp<android::gui::WindowInfoHandle> getWindow(const sp<IBinder>&) const;
Garfield Tane84e6f92019-08-29 17:28:41 -070059};
60
61} // namespace inputdispatcher
62} // namespace android
63
64#endif // _UI_INPUT_INPUTDISPATCHER_TOUCHSTATE_H