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

Commit 10c415ee authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Cancel wallpaper touch stream when foreground window is gone"

parents 1c30044c ca205504
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -524,13 +524,17 @@ public:

    inline int32_t getAction() const { return mAction; }

    inline int32_t getActionMasked() const { return mAction & AMOTION_EVENT_ACTION_MASK; }
    static int32_t getActionMasked(int32_t action) { return action & AMOTION_EVENT_ACTION_MASK; }

    inline int32_t getActionIndex() const {
        return (mAction & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK)
                >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
    inline int32_t getActionMasked() const { return getActionMasked(mAction); }

    static int32_t getActionIndex(int32_t action) {
        return (action & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >>
                AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
    }

    inline int32_t getActionIndex() const { return getActionIndex(mAction); }

    inline void setAction(int32_t action) { mAction = action; }

    inline int32_t getFlags() const { return mFlags; }
+2 −2
Original line number Diff line number Diff line
@@ -834,9 +834,9 @@ std::string MotionEvent::actionToString(int32_t action) {
        case AMOTION_EVENT_ACTION_OUTSIDE:
            return "OUTSIDE";
        case AMOTION_EVENT_ACTION_POINTER_DOWN:
            return "POINTER_DOWN";
            return StringPrintf("POINTER_DOWN(%" PRId32 ")", MotionEvent::getActionIndex(action));
        case AMOTION_EVENT_ACTION_POINTER_UP:
            return "POINTER_UP";
            return StringPrintf("POINTER_UP(%" PRId32 ")", MotionEvent::getActionIndex(action));
        case AMOTION_EVENT_ACTION_HOVER_MOVE:
            return "HOVER_MOVE";
        case AMOTION_EVENT_ACTION_SCROLL:
+16 −4
Original line number Diff line number Diff line
@@ -1706,13 +1706,13 @@ void InputDispatcher::logOutboundMotionDetails(const char* prefix, const MotionE
    if (DEBUG_OUTBOUND_EVENT_DETAILS) {
        ALOGD("%seventTime=%" PRId64 ", deviceId=%d, source=0x%x, displayId=%" PRId32
              ", policyFlags=0x%x, "
              "action=0x%x, actionButton=0x%x, flags=0x%x, "
              "action=%s, actionButton=0x%x, flags=0x%x, "
              "metaState=0x%x, buttonState=0x%x,"
              "edgeFlags=0x%x, xPrecision=%f, yPrecision=%f, downTime=%" PRId64,
              prefix, entry.eventTime, entry.deviceId, entry.source, entry.displayId,
              entry.policyFlags, entry.action, entry.actionButton, entry.flags, entry.metaState,
              entry.buttonState, entry.edgeFlags, entry.xPrecision, entry.yPrecision,
              entry.downTime);
              entry.policyFlags, MotionEvent::actionToString(entry.action).c_str(),
              entry.actionButton, entry.flags, entry.metaState, entry.buttonState, entry.edgeFlags,
              entry.xPrecision, entry.yPrecision, entry.downTime);

        for (uint32_t i = 0; i < entry.pointerCount; i++) {
            ALOGD("  Pointer %d: id=%d, toolType=%d, "
@@ -4642,6 +4642,18 @@ void InputDispatcher::setInputWindowsLocked(
                    CancelationOptions options(CancelationOptions::CANCEL_POINTER_EVENTS,
                                               "touched window was removed");
                    synthesizeCancelationEventsForInputChannelLocked(touchedInputChannel, options);
                    // Since we are about to drop the touch, cancel the events for the wallpaper as
                    // well.
                    if (touchedWindow.targetFlags & InputTarget::FLAG_FOREGROUND &&
                        touchedWindow.windowHandle->getInfo()->hasWallpaper) {
                        sp<WindowInfoHandle> wallpaper = state.getWallpaperWindow();
                        if (wallpaper != nullptr) {
                            sp<Connection> wallpaperConnection =
                                    getConnectionLocked(wallpaper->getToken());
                            synthesizeCancelationEventsForConnectionLocked(wallpaperConnection,
                                                                           options);
                        }
                    }
                }
                state.windows.erase(state.windows.begin() + i);
            } else {
+10 −0
Original line number Diff line number Diff line
@@ -134,4 +134,14 @@ bool TouchState::isSlippery() const {
    return haveSlipperyForegroundWindow;
}

sp<WindowInfoHandle> TouchState::getWallpaperWindow() const {
    for (size_t i = 0; i < windows.size(); i++) {
        const TouchedWindow& window = windows[i];
        if (window.windowHandle->getInfo()->type == WindowInfo::Type::WALLPAPER) {
            return window.windowHandle;
        }
    }
    return nullptr;
}

} // namespace android::inputdispatcher
+1 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ struct TouchState {
    void filterNonMonitors();
    sp<android::gui::WindowInfoHandle> getFirstForegroundWindowHandle() const;
    bool isSlippery() const;
    sp<android::gui::WindowInfoHandle> getWallpaperWindow() const;
};

} // namespace inputdispatcher
Loading