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

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

Merge "Use sequence numbers to synchronize enabling Pointer Capture (1/2)" into sc-v2-dev

parents abbb9d8a ac483a63
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -1003,6 +1003,25 @@ private:
    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

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

// --- NotifyPointerCaptureChangedArgs ---

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

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

    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 {}

+4 −5
Original line number 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
// for all entries.
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),
        pointerCaptureEnabled(hasPointerCapture) {}
        pointerCaptureRequest(request) {}

PointerCaptureChangedEntry::~PointerCaptureChangedEntry() {}

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

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

CommandEntry::~CommandEntry() {}

Loading