Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b1304210 authored by Arpit Singh's avatar Arpit Singh Committed by Android (Google) Code Review
Browse files

Merge "Move fake display topology population to InputManagerService" into main

parents ebc88082 e0d7c7d8
Loading
Loading
Loading
Loading
+46 −0
Original line number Diff line number Diff line
@@ -553,6 +553,9 @@ private:
    PointerIcon loadPointerIcon(JNIEnv* env, ui::LogicalDisplayId displayId, PointerIconStyle type);
    bool isDisplayInteractive(ui::LogicalDisplayId displayId);

    // TODO(b/362719483) remove when the real topology is available
    void populateFakeDisplayTopology(const std::vector<DisplayViewport>& viewports);

    static inline JNIEnv* jniEnv() { return AndroidRuntime::getJNIEnv(); }
};

@@ -641,6 +644,49 @@ void NativeInputManager::setDisplayViewports(JNIEnv* env, jobjectArray viewportO
    mInputManager->getChoreographer().setDisplayViewports(viewports);
    mInputManager->getReader().requestRefreshConfiguration(
            InputReaderConfiguration::Change::DISPLAY_INFO);

    // TODO(b/362719483) remove when the real topology is available
    populateFakeDisplayTopology(viewports);
}

void NativeInputManager::populateFakeDisplayTopology(
        const std::vector<DisplayViewport>& viewports) {
    if (!com::android::input::flags::connected_displays_cursor()) {
        return;
    }

    // create a fake topology assuming following order
    // default-display (top-edge) -> next-display (right-edge) -> next-display (right-edge) ...
    // This also adds a 100px offset on corresponding edge for better manual testing
    //   ┌────────┐
    //   │ next   ├─────────┐
    // ┌─└───────┐┤ next 2  │ ...
    // │ default │└─────────┘
    // └─────────┘
    DisplayTopologyGraph displaytopology;
    displaytopology.primaryDisplayId = ui::LogicalDisplayId::DEFAULT;

    // treat default display as base, in real topology it should be the primary-display
    ui::LogicalDisplayId previousDisplay = ui::LogicalDisplayId::DEFAULT;
    for (const auto& viewport : viewports) {
        if (viewport.displayId == ui::LogicalDisplayId::DEFAULT) {
            continue;
        }
        if (previousDisplay == ui::LogicalDisplayId::DEFAULT) {
            displaytopology.graph[previousDisplay].push_back(
                    {viewport.displayId, DisplayTopologyPosition::TOP, 100});
            displaytopology.graph[viewport.displayId].push_back(
                    {previousDisplay, DisplayTopologyPosition::BOTTOM, -100});
        } else {
            displaytopology.graph[previousDisplay].push_back(
                    {viewport.displayId, DisplayTopologyPosition::RIGHT, 100});
            displaytopology.graph[viewport.displayId].push_back(
                    {previousDisplay, DisplayTopologyPosition::LEFT, -100});
        }
        previousDisplay = viewport.displayId;
    }

    mInputManager->getChoreographer().setDisplayTopology(displaytopology);
}

void NativeInputManager::setDisplayTopology(JNIEnv* env, jobject topologyGraph) {