blob: cf5f1e58c6cec4e9c33e50da50b73656013cffb4 [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
Prabir Pradhan48108662022-09-09 21:22:04 +000017#pragma once
Garfield Tane84e6f92019-08-29 17:28:41 -070018
19#include "Monitor.h"
20#include "TouchedWindow.h"
21
22namespace android {
23
chaviw98318de2021-05-19 16:45:23 -050024namespace gui {
25class WindowInfoHandle;
26}
Garfield Tane84e6f92019-08-29 17:28:41 -070027
28namespace inputdispatcher {
29
30struct TouchState {
Prabir Pradhane680f9b2022-02-04 04:24:00 -080031 bool down = false;
32 bool split = false;
Prabir Pradhane680f9b2022-02-04 04:24:00 -080033
34 // id of the device that is currently down, others are rejected
35 int32_t deviceId = -1;
36 // source of the device that is current down, others are rejected
37 uint32_t source = 0;
38 // id to the display that currently has a touch, others are rejected
39 int32_t displayId = ADISPLAY_ID_NONE;
40
Garfield Tane84e6f92019-08-29 17:28:41 -070041 std::vector<TouchedWindow> windows;
42
Prabir Pradhane680f9b2022-02-04 04:24:00 -080043 TouchState() = default;
44 ~TouchState() = default;
45 TouchState& operator=(const TouchState&) = default;
46
Garfield Tane84e6f92019-08-29 17:28:41 -070047 void reset();
chaviw98318de2021-05-19 16:45:23 -050048 void addOrUpdateWindow(const sp<android::gui::WindowInfoHandle>& windowHandle,
Vaibhav Devmurari882bd9b2022-06-23 14:54:54 +000049 int32_t targetFlags, BitSet32 pointerIds,
50 std::optional<nsecs_t> eventTime = std::nullopt);
Garfield Tane84e6f92019-08-29 17:28:41 -070051 void removeWindowByToken(const sp<IBinder>& token);
52 void filterNonAsIsTouchWindows();
Prabir Pradhan07e05b62021-11-19 03:57:24 -080053 void filterWindowsExcept(const sp<IBinder>& token);
Vaibhav Devmurariff798f32022-05-09 23:45:04 +000054
55 // Cancel pointers for current set of windows except the window with particular binder token.
56 void cancelPointersForWindowsExcept(const BitSet32 pointerIds, const sp<IBinder>& token);
57 // Cancel pointers for current set of non-pilfering windows i.e. windows with isPilferingWindow
58 // set to false.
59 void cancelPointersForNonPilferingWindows(const BitSet32 pointerIds);
60
chaviw98318de2021-05-19 16:45:23 -050061 sp<android::gui::WindowInfoHandle> getFirstForegroundWindowHandle() const;
Garfield Tane84e6f92019-08-29 17:28:41 -070062 bool isSlippery() const;
Siarhei Vishniakouca205502021-07-16 21:31:58 +000063 sp<android::gui::WindowInfoHandle> getWallpaperWindow() const;
Prabir Pradhan07e05b62021-11-19 03:57:24 -080064 sp<android::gui::WindowInfoHandle> getWindow(const sp<IBinder>&) const;
Garfield Tane84e6f92019-08-29 17:28:41 -070065};
66
67} // namespace inputdispatcher
68} // namespace android