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

Commit 0dd624a6 authored by Prabir Pradhan's avatar Prabir Pradhan Committed by Automerger Merge Worker
Browse files

Use sequence numbers to synchronize enabling Pointer Capture (1/2) am: f192a108

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/native/+/15871351

Change-Id: I91b57e254e6e3b475cc5c5562f414d530170e868
parents ef4d8edc f192a108
Loading
Loading
Loading
Loading
+19 −0
Original line number Original line Diff line number Diff line
@@ -1015,6 +1015,25 @@ private:
    std::queue<std::unique_ptr<DragEvent>> mDragEventPool;
    std::queue<std::unique_ptr<DragEvent>> mDragEventPool;
};
};


/*
 * Describes a unique request to enable or disable Pointer Capture.
 */
struct PointerCaptureRequest {
public:
    inline PointerCaptureRequest() : enable(false), seq(0) {}
    inline PointerCaptureRequest(bool enable, uint32_t seq) : enable(enable), seq(seq) {}
    inline bool operator==(const PointerCaptureRequest& other) const {
        return enable == other.enable && seq == other.seq;
    }
    explicit inline operator bool() const { return enable; }

    // True iff this is a request to enable Pointer Capture.
    bool enable;

    // The sequence number for the request.
    uint32_t seq;
};

} // namespace android
} // namespace android


#endif // _LIBINPUT_INPUT_H
#endif // _LIBINPUT_INPUT_H
+5 −5
Original line number Original line Diff line number Diff line
@@ -287,16 +287,16 @@ void NotifyDeviceResetArgs::notify(const sp<InputListenerInterface>& listener) c


// --- NotifyPointerCaptureChangedArgs ---
// --- NotifyPointerCaptureChangedArgs ---


NotifyPointerCaptureChangedArgs::NotifyPointerCaptureChangedArgs(int32_t id, nsecs_t eventTime,
NotifyPointerCaptureChangedArgs::NotifyPointerCaptureChangedArgs(
                                                                 bool enabled)
        int32_t id, nsecs_t eventTime, const PointerCaptureRequest& request)
      : NotifyArgs(id, eventTime), enabled(enabled) {}
      : NotifyArgs(id, eventTime), request(request) {}


NotifyPointerCaptureChangedArgs::NotifyPointerCaptureChangedArgs(
NotifyPointerCaptureChangedArgs::NotifyPointerCaptureChangedArgs(
        const NotifyPointerCaptureChangedArgs& other)
        const NotifyPointerCaptureChangedArgs& other)
      : NotifyArgs(other.id, other.eventTime), enabled(other.enabled) {}
      : NotifyArgs(other.id, other.eventTime), request(other.request) {}


bool NotifyPointerCaptureChangedArgs::operator==(const NotifyPointerCaptureChangedArgs& rhs) const {
bool NotifyPointerCaptureChangedArgs::operator==(const NotifyPointerCaptureChangedArgs& rhs) const {
    return id == rhs.id && eventTime == rhs.eventTime && enabled == rhs.enabled;
    return id == rhs.id && eventTime == rhs.eventTime && request == rhs.request;
}
}


void NotifyPointerCaptureChangedArgs::notify(const sp<InputListenerInterface>& listener) const {
void NotifyPointerCaptureChangedArgs::notify(const sp<InputListenerInterface>& listener) const {
+3 −0
Original line number Original line Diff line number Diff line
@@ -67,6 +67,9 @@ std::string InputReaderConfiguration::changesToString(uint32_t changes) {
    if (changes & CHANGE_EXTERNAL_STYLUS_PRESENCE) {
    if (changes & CHANGE_EXTERNAL_STYLUS_PRESENCE) {
        result += "EXTERNAL_STYLUS_PRESENCE | ";
        result += "EXTERNAL_STYLUS_PRESENCE | ";
    }
    }
    if (changes & CHANGE_POINTER_CAPTURE) {
        result += "POINTER_CAPTURE | ";
    }
    if (changes & CHANGE_ENABLED_STATE) {
    if (changes & CHANGE_ENABLED_STATE) {
        result += "ENABLED_STATE | ";
        result += "ENABLED_STATE | ";
    }
    }
+1 −1
Original line number Original line Diff line number Diff line
@@ -113,7 +113,7 @@ private:


    void onPointerDownOutsideFocus(const sp<IBinder>& newToken) override {}
    void onPointerDownOutsideFocus(const sp<IBinder>& newToken) override {}


    void setPointerCapture(bool enabled) override {}
    void setPointerCapture(const PointerCaptureRequest&) override {}


    void notifyDropWindow(const sp<IBinder>&, float x, float y) override {}
    void notifyDropWindow(const sp<IBinder>&, float x, float y) override {}


+4 −5
Original line number Original line Diff line number Diff line
@@ -119,15 +119,15 @@ std::string FocusEntry::getDescription() const {
// PointerCaptureChanged notifications always go to apps, so set the flag POLICY_FLAG_PASS_TO_USER
// PointerCaptureChanged notifications always go to apps, so set the flag POLICY_FLAG_PASS_TO_USER
// for all entries.
// for all entries.
PointerCaptureChangedEntry::PointerCaptureChangedEntry(int32_t id, nsecs_t eventTime,
PointerCaptureChangedEntry::PointerCaptureChangedEntry(int32_t id, nsecs_t eventTime,
                                                       bool hasPointerCapture)
                                                       const PointerCaptureRequest& request)
      : EventEntry(id, Type::POINTER_CAPTURE_CHANGED, eventTime, POLICY_FLAG_PASS_TO_USER),
      : EventEntry(id, Type::POINTER_CAPTURE_CHANGED, eventTime, POLICY_FLAG_PASS_TO_USER),
        pointerCaptureEnabled(hasPointerCapture) {}
        pointerCaptureRequest(request) {}


PointerCaptureChangedEntry::~PointerCaptureChangedEntry() {}
PointerCaptureChangedEntry::~PointerCaptureChangedEntry() {}


std::string PointerCaptureChangedEntry::getDescription() const {
std::string PointerCaptureChangedEntry::getDescription() const {
    return StringPrintf("PointerCaptureChangedEvent(pointerCaptureEnabled=%s)",
    return StringPrintf("PointerCaptureChangedEvent(pointerCaptureEnabled=%s)",
                        pointerCaptureEnabled ? "true" : "false");
                        pointerCaptureRequest.enable ? "true" : "false");
}
}


// --- DragEntry ---
// --- DragEntry ---
@@ -324,8 +324,7 @@ CommandEntry::CommandEntry(Command command)
        keyEntry(nullptr),
        keyEntry(nullptr),
        userActivityEventType(0),
        userActivityEventType(0),
        seq(0),
        seq(0),
        handled(false),
        handled(false) {}
        enabled(false) {}


CommandEntry::~CommandEntry() {}
CommandEntry::~CommandEntry() {}


Loading