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

Commit 06349040 authored by Prabir Pradhan's avatar Prabir Pradhan
Browse files

Remove the concept of TOUCH_MODAL from input

We remove modal windows from input. WM will configure modal windows
itself using touchableRegion.

Bug: 216806304
Test: atest inputflinger_tests
Change-Id: I9593865213216b420ab9b5c5b853298f01dabcc6
parent 76bdecb0
Loading
Loading
Loading
Loading
+7 −8
Original line number Diff line number Diff line
@@ -164,18 +164,17 @@ struct WindowInfo : public Parcelable {
        NOT_VISIBLE                  = 1 << 0,
        NOT_FOCUSABLE                = 1 << 1,
        NOT_TOUCHABLE                = 1 << 2,
        TOUCH_MODAL                  = 1 << 3,
        PREVENT_SPLITTING            = 1 << 4,
        DUPLICATE_TOUCH_TO_WALLPAPER = 1 << 5,
        IS_WALLPAPER                 = 1 << 6,
        PAUSE_DISPATCHING            = 1 << 7,
        PREVENT_SPLITTING            = 1 << 3,
        DUPLICATE_TOUCH_TO_WALLPAPER = 1 << 4,
        IS_WALLPAPER                 = 1 << 5,
        PAUSE_DISPATCHING            = 1 << 6,
        // This flag is set when the window is of a trusted type that is allowed to silently
        // overlay other windows for the purpose of implementing the secure views feature.
        // Trusted overlays, such as IME windows, can partly obscure other windows without causing
        // motion events to be delivered to them with AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED.
        TRUSTED_OVERLAY              = 1 << 8,
        WATCH_OUTSIDE_TOUCH          = 1 << 9,
        SLIPPERY                     = 1 << 10,
        TRUSTED_OVERLAY              = 1 << 7,
        WATCH_OUTSIDE_TOUCH          = 1 << 8,
        SLIPPERY                     = 1 << 9,
        // clang-format on
    };

+1 −2
Original line number Diff line number Diff line
@@ -509,8 +509,7 @@ bool windowAcceptsTouchAt(const WindowInfo& windowInfo, int32_t displayId, int32
    if (inputConfig.test(WindowInfo::InputConfig::NOT_TOUCHABLE) && !windowCanInterceptTouch) {
        return false;
    }
    if (!inputConfig.test(WindowInfo::InputConfig::TOUCH_MODAL) &&
        !windowInfo.touchableRegionContainsPoint(x, y)) {
    if (!windowInfo.touchableRegionContainsPoint(x, y)) {
        return false;
    }
    return true;
+0 −25
Original line number Diff line number Diff line
@@ -1032,10 +1032,6 @@ public:
        mInfo.setInputConfig(WindowInfo::InputConfig::PAUSE_DISPATCHING, paused);
    }

    void setTouchModal(bool touchModal) {
        mInfo.setInputConfig(WindowInfo::InputConfig::TOUCH_MODAL, touchModal);
    }

    void setPreventSplitting(bool preventSplitting) {
        mInfo.setInputConfig(WindowInfo::InputConfig::PREVENT_SPLITTING, preventSplitting);
    }
@@ -6411,27 +6407,6 @@ TEST_F(InputDispatcherSpyWindowTest, TouchableRegion) {
    spy->consumeMotionDown();
}

/**
 * A spy window that is a modal window will receive gestures outside of its frame and touchable
 * region.
 */
TEST_F(InputDispatcherSpyWindowTest, ModalWindow) {
    auto window = createForeground();
    auto spy = createSpy();
    // Our current policy dictates that modal windows must be focusable.
    spy->setFocusable(true);
    spy->setTouchModal(true);
    spy->setFrame(Rect{0, 0, 20, 20});
    mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {spy, window}}});

    // Inject an event outside the spy window's frame and touchable region.
    ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
              injectMotionDown(mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT))
            << "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
    window->consumeMotionDown();
    spy->consumeMotionDown();
}

/**
 * A spy window can listen for touches outside its touchable region using the WATCH_OUTSIDE_TOUCHES
 * flag, but it will get zero-ed out coordinates if the foreground has a different owner.
+0 −2
Original line number Diff line number Diff line
@@ -2159,7 +2159,6 @@ Rect Layer::getInputBounds() const {
void Layer::fillInputFrameInfo(WindowInfo& info, const ui::Transform& screenToDisplay) {
    Rect tmpBounds = getInputBounds();
    if (!tmpBounds.isValid()) {
        info.setInputConfig(WindowInfo::InputConfig::TOUCH_MODAL, false);
        info.setInputConfig(WindowInfo::InputConfig::NOT_FOCUSABLE, true);
        info.touchableRegion.clear();
        // A layer could have invalid input bounds and still expect to receive touch input if it has
@@ -2307,7 +2306,6 @@ WindowInfo Layer::fillInputInfo(const ui::Transform& displayTransform, bool disp
        mDrawingState.inputInfo.ownerUid = mOwnerUid;
        mDrawingState.inputInfo.ownerPid = mOwnerPid;
        mDrawingState.inputInfo.inputFeatures = WindowInfo::Feature::NO_INPUT_CHANNEL;
        mDrawingState.inputInfo.setInputConfig(WindowInfo::InputConfig::TOUCH_MODAL, false);
        mDrawingState.inputInfo.displayId = getLayerStack().id;
    }