Prabir Pradhan | b56e92c | 2023-06-09 23:40:37 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2023 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 | #pragma once |
| 18 | |
| 19 | #include "PointerControllerInterface.h" |
| 20 | |
| 21 | namespace android { |
| 22 | |
| 23 | /** |
| 24 | * The PointerChoreographer policy interface. |
| 25 | * |
| 26 | * This is the interface that PointerChoreographer uses to talk to Window Manager and other |
| 27 | * system components. |
Prabir Pradhan | 5a51a22 | 2024-03-05 03:54:00 +0000 | [diff] [blame] | 28 | * |
| 29 | * NOTE: In general, the PointerChoreographer must not interact with the policy while |
| 30 | * holding any locks. |
Prabir Pradhan | b56e92c | 2023-06-09 23:40:37 +0000 | [diff] [blame] | 31 | */ |
| 32 | class PointerChoreographerPolicyInterface { |
| 33 | public: |
| 34 | virtual ~PointerChoreographerPolicyInterface() = default; |
| 35 | |
| 36 | /** |
| 37 | * A factory method for PointerController. The PointerController implementation has |
| 38 | * dependencies on a graphical library - libgui, used to draw icons on the screen - which |
| 39 | * isn't available for the host. Since we want libinputflinger and its test to be buildable |
| 40 | * for and runnable on the host, the PointerController implementation must be in a separate |
| 41 | * library, libinputservice, that has the additional dependencies. The PointerController |
| 42 | * will be mocked when testing PointerChoreographer. |
Prabir Pradhan | 5a51a22 | 2024-03-05 03:54:00 +0000 | [diff] [blame] | 43 | * |
| 44 | * Since this is a factory method used to work around dependencies, it will not interact with |
| 45 | * other input components and may be called with the PointerChoreographer lock held. |
Prabir Pradhan | b56e92c | 2023-06-09 23:40:37 +0000 | [diff] [blame] | 46 | */ |
Byoungho Jung | da10dd3 | 2023-10-06 17:03:45 +0900 | [diff] [blame] | 47 | virtual std::shared_ptr<PointerControllerInterface> createPointerController( |
| 48 | PointerControllerInterface::ControllerType type) = 0; |
| 49 | |
Prabir Pradhan | 1976760 | 2023-11-03 16:53:31 +0000 | [diff] [blame] | 50 | /** |
| 51 | * Notifies the policy that the default pointer displayId has changed. PointerChoreographer is |
| 52 | * the single source of truth for all pointers on screen. |
| 53 | * @param displayId The updated display on which the mouse cursor is shown |
| 54 | * @param position The new position of the mouse cursor on the logical display |
| 55 | */ |
Linnan Li | 13bf76a | 2024-05-05 19:18:02 +0800 | [diff] [blame^] | 56 | virtual void notifyPointerDisplayIdChanged(ui::LogicalDisplayId displayId, |
| 57 | const FloatPoint& position) = 0; |
Prabir Pradhan | b56e92c | 2023-06-09 23:40:37 +0000 | [diff] [blame] | 58 | }; |
| 59 | |
| 60 | } // namespace android |