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

Commit fe3de7d6 authored by Michael Wright's avatar Michael Wright
Browse files

Rename ViewportTypes to avoid repetition

Bug: 160010896
Test: compiles, manual
Change-Id: Id94a671e9bf45b4c73016092757daf5809706d7f
parent 227c5542
Loading
Loading
Loading
Loading
+13 −14
Original line number Diff line number Diff line
@@ -17,12 +17,12 @@
#ifndef _LIBINPUT_DISPLAY_VIEWPORT_H
#define _LIBINPUT_DISPLAY_VIEWPORT_H

#include <cinttypes>
#include <optional>

#include <android-base/stringprintf.h>
#include <input/Input.h>

#include <cinttypes>
#include <optional>

using android::base::StringPrintf;

namespace android {
@@ -39,22 +39,21 @@ enum {
 * Keep in sync with values in InputManagerService.java.
 */
enum class ViewportType : int32_t {
    VIEWPORT_INTERNAL = 1,
    VIEWPORT_EXTERNAL = 2,
    VIEWPORT_VIRTUAL = 3,
    INTERNAL = 1,
    EXTERNAL = 2,
    VIRTUAL = 3,
};

static const char* viewportTypeToString(ViewportType type) {
    switch (type) {
        case ViewportType::VIEWPORT_INTERNAL:
        case ViewportType::INTERNAL:
            return "INTERNAL";
        case ViewportType::VIEWPORT_EXTERNAL:
        case ViewportType::EXTERNAL:
            return "EXTERNAL";
        case ViewportType::VIEWPORT_VIRTUAL:
        case ViewportType::VIRTUAL:
            return "VIRTUAL";
        default:
            return "UNKNOWN";
    }
    return "UNKNOWN";
}

/*
@@ -97,7 +96,7 @@ struct DisplayViewport {
            isActive(false),
            uniqueId(),
            physicalPort(std::nullopt),
            type(ViewportType::VIEWPORT_INTERNAL) {}
            type(ViewportType::INTERNAL) {}

    bool operator==(const DisplayViewport& other) const {
        return displayId == other.displayId && orientation == other.orientation &&
@@ -134,7 +133,7 @@ struct DisplayViewport {
        isActive = false;
        uniqueId.clear();
        physicalPort = std::nullopt;
        type = ViewportType::VIEWPORT_INTERNAL;
        type = ViewportType::INTERNAL;
    }

    std::string toString() const {
+3 −1
Original line number Diff line number Diff line
@@ -14,7 +14,9 @@
 * limitations under the License.
 */

// clang-format off
#include "../Macros.h"
// clang-format on

#include "CursorInputMapper.h"

@@ -184,7 +186,7 @@ void CursorInputMapper::configure(nsecs_t when, const InputReaderConfiguration*
        mOrientation = DISPLAY_ORIENTATION_0;
        if (mParameters.orientationAware && mParameters.hasAssociatedDisplay) {
            std::optional<DisplayViewport> internalViewport =
                    config->getDisplayViewportByType(ViewportType::VIEWPORT_INTERNAL);
                    config->getDisplayViewportByType(ViewportType::INTERNAL);
            if (internalViewport) {
                mOrientation = internalViewport->orientation;
            }
+3 −1
Original line number Diff line number Diff line
@@ -14,7 +14,9 @@
 * limitations under the License.
 */

// clang-format off
#include "../Macros.h"
// clang-format on

#include "KeyboardInputMapper.h"

@@ -138,7 +140,7 @@ std::optional<DisplayViewport> KeyboardInputMapper::findViewport(

    // No associated display defined, try to find default display if orientationAware.
    if (mParameters.orientationAware) {
        return config->getDisplayViewportByType(ViewportType::VIEWPORT_INTERNAL);
        return config->getDisplayViewportByType(ViewportType::INTERNAL);
    }

    return std::nullopt;
+3 −1
Original line number Diff line number Diff line
@@ -14,7 +14,9 @@
 * limitations under the License.
 */

// clang-format off
#include "../Macros.h"
// clang-format on

#include "RotaryEncoderInputMapper.h"

@@ -66,7 +68,7 @@ void RotaryEncoderInputMapper::configure(nsecs_t when, const InputReaderConfigur
    }
    if (!changes || (changes & InputReaderConfiguration::CHANGE_DISPLAY_INFO)) {
        std::optional<DisplayViewport> internalViewport =
                config->getDisplayViewportByType(ViewportType::VIEWPORT_INTERNAL);
                config->getDisplayViewportByType(ViewportType::INTERNAL);
        if (internalViewport) {
            mOrientation = internalViewport->orientation;
        } else {
+4 −4
Original line number Diff line number Diff line
@@ -585,18 +585,18 @@ std::optional<DisplayViewport> TouchInputMapper::findViewport() {

        ViewportType viewportTypeToUse;
        if (mParameters.associatedDisplayIsExternal) {
            viewportTypeToUse = ViewportType::VIEWPORT_EXTERNAL;
            viewportTypeToUse = ViewportType::EXTERNAL;
        } else {
            viewportTypeToUse = ViewportType::VIEWPORT_INTERNAL;
            viewportTypeToUse = ViewportType::INTERNAL;
        }

        std::optional<DisplayViewport> viewport =
                mConfig.getDisplayViewportByType(viewportTypeToUse);
        if (!viewport && viewportTypeToUse == ViewportType::VIEWPORT_EXTERNAL) {
        if (!viewport && viewportTypeToUse == ViewportType::EXTERNAL) {
            ALOGW("Input device %s should be associated with external display, "
                  "fallback to internal one for the external viewport is not found.",
                  getDeviceName().c_str());
            viewport = mConfig.getDisplayViewportByType(ViewportType::VIEWPORT_INTERNAL);
            viewport = mConfig.getDisplayViewportByType(ViewportType::INTERNAL);
        }

        return viewport;
Loading