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

Commit 5feba92d authored by Prabir Pradhan's avatar Prabir Pradhan Committed by Android (Google) Code Review
Browse files

Merge changes Ic49d0fe8,If880b9b7

* changes:
  Reland^2 "Enable input window rotation flag"
  Filter DisplayDevices that don't receive input when finding transform
parents 9aafab0e 9c2d28cf
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -116,7 +116,7 @@ private:
// coordinates and SurfaceFlinger includes the display rotation in the input window transforms.
bool isPerWindowInputRotationEnabled() {
    static const bool PER_WINDOW_INPUT_ROTATION =
            sysprop::InputFlingerProperties::per_window_input_rotation().value_or(false);
            sysprop::InputFlingerProperties::per_window_input_rotation().value_or(true);

    return PER_WINDOW_INPUT_ROTATION;
}
+1 −1
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ namespace android {
// projection are part of the input window's transform. This means InputReader should work in the
// un-rotated coordinate space.
static bool isPerWindowInputRotationEnabled() {
    return sysprop::InputFlingerProperties::per_window_input_rotation().value_or(false);
    return sysprop::InputFlingerProperties::per_window_input_rotation().value_or(true);
}

static int32_t getInverseRotation(int32_t orientation) {
+14 −5
Original line number Diff line number Diff line
@@ -3051,20 +3051,29 @@ void SurfaceFlinger::updateInputFlinger() {

bool enablePerWindowInputRotation() {
    static bool value =
            android::base::GetBoolProperty("persist.debug.per_window_input_rotation", false);
            android::base::GetBoolProperty("persist.debug.per_window_input_rotation", true);
    return value;
}

void SurfaceFlinger::notifyWindowInfos() {
    std::vector<WindowInfo> windowInfos;
    std::vector<DisplayInfo> displayInfos;
    std::unordered_map<const DisplayDevice*, const ui::Transform> displayTransforms;
    std::unordered_map<uint32_t /*layerStackId*/, const ui::Transform> displayTransforms;

    if (enablePerWindowInputRotation()) {
        for (const auto& [_, display] : ON_MAIN_THREAD(mDisplays)) {
            if (!display->receivesInput()) {
                continue;
            }
            const uint32_t layerStackId = display->getLayerStack().id;
            const auto& [info, transform] = display->getInputInfo();
            const auto& [it, emplaced] = displayTransforms.try_emplace(layerStackId, transform);
            if (!emplaced) {
                ALOGE("Multiple displays claim to accept input for the same layer stack: %u",
                      layerStackId);
                continue;
            }
            displayInfos.emplace_back(info);
            displayTransforms.emplace(display.get(), transform);
        }
    }

@@ -3074,10 +3083,10 @@ void SurfaceFlinger::notifyWindowInfos() {
        const DisplayDevice* display = ON_MAIN_THREAD(getDisplayWithInputByLayer(layer)).get();
        ui::Transform displayTransform = ui::Transform();

        if (enablePerWindowInputRotation()) {
        if (enablePerWindowInputRotation() && display != nullptr) {
            // When calculating the screen bounds we ignore the transparent region since it may
            // result in an unwanted offset.
            const auto it = displayTransforms.find(display);
            const auto it = displayTransforms.find(display->getLayerStack().id);
            if (it != displayTransforms.end()) {
                displayTransform = it->second;
            }