Loading include/input/Input.h +8 −6 Original line number Diff line number Diff line Loading @@ -1192,15 +1192,17 @@ public: */ struct PointerCaptureRequest { public: inline PointerCaptureRequest() : enable(false), seq(0) {} inline PointerCaptureRequest(bool enable, uint32_t seq) : enable(enable), seq(seq) {} inline PointerCaptureRequest() : window(), seq(0) {} inline PointerCaptureRequest(sp<IBinder> window, uint32_t seq) : window(window), seq(seq) {} inline bool operator==(const PointerCaptureRequest& other) const { return enable == other.enable && seq == other.seq; return window == other.window && seq == other.seq; } explicit inline operator bool() const { return enable; } inline bool isEnable() const { return window != nullptr; } // True iff this is a request to enable Pointer Capture. bool enable; // The requesting window. // If the request is to enable the capture, this is the input token of the window that requested // pointer capture. Otherwise, this is nullptr. sp<IBinder> window; // The sequence number for the request. uint32_t seq; Loading services/inputflinger/PointerChoreographer.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -277,7 +277,7 @@ void PointerChoreographer::processDeviceReset(const NotifyDeviceResetArgs& args) void PointerChoreographer::notifyPointerCaptureChanged( const NotifyPointerCaptureChangedArgs& args) { if (args.request.enable) { if (args.request.isEnable()) { std::scoped_lock _l(mLock); for (const auto& [_, mousePointerController] : mMousePointersByDisplay) { mousePointerController->fade(PointerControllerInterface::Transition::IMMEDIATE); Loading services/inputflinger/dispatcher/Entry.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -110,7 +110,7 @@ PointerCaptureChangedEntry::PointerCaptureChangedEntry(int32_t id, nsecs_t event std::string PointerCaptureChangedEntry::getDescription() const { return StringPrintf("PointerCaptureChangedEvent(pointerCaptureEnabled=%s)", pointerCaptureRequest.enable ? "true" : "false"); pointerCaptureRequest.isEnable() ? "true" : "false"); } // --- DragEntry --- Loading services/inputflinger/dispatcher/InputDispatcher.cpp +21 −18 Original line number Diff line number Diff line Loading @@ -1715,7 +1715,7 @@ void InputDispatcher::dispatchPointerCaptureChangedLocked( const bool haveWindowWithPointerCapture = mWindowTokenWithPointerCapture != nullptr; sp<IBinder> token; if (entry->pointerCaptureRequest.enable) { if (entry->pointerCaptureRequest.isEnable()) { // Enable Pointer Capture. if (haveWindowWithPointerCapture && (entry->pointerCaptureRequest == mCurrentPointerCaptureRequest)) { Loading @@ -1724,7 +1724,7 @@ void InputDispatcher::dispatchPointerCaptureChangedLocked( ALOGI("Skipping dispatch of Pointer Capture being enabled: no state change."); return; } if (!mCurrentPointerCaptureRequest.enable) { if (!mCurrentPointerCaptureRequest.isEnable()) { // This can happen if a window requests capture and immediately releases capture. ALOGW("No window requested Pointer Capture."); dropReason = DropReason::NO_POINTER_CAPTURE; Loading @@ -1737,6 +1737,8 @@ void InputDispatcher::dispatchPointerCaptureChangedLocked( token = mFocusResolver.getFocusedWindowToken(mFocusedDisplayId); LOG_ALWAYS_FATAL_IF(!token, "Cannot find focused window for Pointer Capture."); LOG_ALWAYS_FATAL_IF(token != entry->pointerCaptureRequest.window, "Unexpected requested window for Pointer Capture."); mWindowTokenWithPointerCapture = token; } else { // Disable Pointer Capture. Loading @@ -1756,8 +1758,8 @@ void InputDispatcher::dispatchPointerCaptureChangedLocked( } token = mWindowTokenWithPointerCapture; mWindowTokenWithPointerCapture = nullptr; if (mCurrentPointerCaptureRequest.enable) { setPointerCaptureLocked(false); if (mCurrentPointerCaptureRequest.isEnable()) { setPointerCaptureLocked(nullptr); } } Loading @@ -1765,8 +1767,8 @@ void InputDispatcher::dispatchPointerCaptureChangedLocked( if (connection == nullptr) { // Window has gone away, clean up Pointer Capture state. mWindowTokenWithPointerCapture = nullptr; if (mCurrentPointerCaptureRequest.enable) { setPointerCaptureLocked(false); if (mCurrentPointerCaptureRequest.isEnable()) { setPointerCaptureLocked(nullptr); } return; } Loading Loading @@ -3832,9 +3834,10 @@ void InputDispatcher::startDispatchCycleLocked(nsecs_t currentTime, case EventEntry::Type::POINTER_CAPTURE_CHANGED: { const auto& captureEntry = static_cast<const PointerCaptureChangedEntry&>(eventEntry); status = connection->inputPublisher status = connection->inputPublisher .publishCaptureEvent(dispatchEntry->seq, captureEntry.id, captureEntry.pointerCaptureRequest.enable); captureEntry.pointerCaptureRequest.isEnable()); break; } Loading Loading @@ -4727,7 +4730,7 @@ void InputDispatcher::notifyDeviceReset(const NotifyDeviceResetArgs& args) { void InputDispatcher::notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs& args) { if (debugInboundEventDetails()) { ALOGD("notifyPointerCaptureChanged - eventTime=%" PRId64 ", enabled=%s", args.eventTime, args.request.enable ? "true" : "false"); args.request.isEnable() ? "true" : "false"); } bool needWake = false; Loading Loading @@ -5798,7 +5801,7 @@ std::string InputDispatcher::dumpPointerCaptureStateLocked() const { std::string dump; dump += StringPrintf(INDENT "Pointer Capture Requested: %s\n", toString(mCurrentPointerCaptureRequest.enable)); toString(mCurrentPointerCaptureRequest.isEnable())); std::string windowName = "None"; if (mWindowTokenWithPointerCapture) { Loading Loading @@ -6217,7 +6220,7 @@ void InputDispatcher::requestPointerCapture(const sp<IBinder>& windowToken, bool return; } if (enabled == mCurrentPointerCaptureRequest.enable) { if (enabled == mCurrentPointerCaptureRequest.isEnable()) { ALOGW("Ignoring request to %s Pointer Capture: " "window has %s requested pointer capture.", enabled ? "enable" : "disable", enabled ? "already" : "not"); Loading @@ -6233,7 +6236,7 @@ void InputDispatcher::requestPointerCapture(const sp<IBinder>& windowToken, bool } } setPointerCaptureLocked(enabled); setPointerCaptureLocked(enabled ? windowToken : nullptr); } // release lock // Wake the thread to process command entries. Loading Loading @@ -6863,14 +6866,14 @@ void InputDispatcher::onFocusChangedLocked( } void InputDispatcher::disablePointerCaptureForcedLocked() { if (!mCurrentPointerCaptureRequest.enable && !mWindowTokenWithPointerCapture) { if (!mCurrentPointerCaptureRequest.isEnable() && !mWindowTokenWithPointerCapture) { return; } ALOGD_IF(DEBUG_FOCUS, "Disabling Pointer Capture because the window lost focus."); if (mCurrentPointerCaptureRequest.enable) { setPointerCaptureLocked(false); if (mCurrentPointerCaptureRequest.isEnable()) { setPointerCaptureLocked(nullptr); } if (!mWindowTokenWithPointerCapture) { Loading @@ -6890,8 +6893,8 @@ void InputDispatcher::disablePointerCaptureForcedLocked() { mInboundQueue.push_front(std::move(entry)); } void InputDispatcher::setPointerCaptureLocked(bool enable) { mCurrentPointerCaptureRequest.enable = enable; void InputDispatcher::setPointerCaptureLocked(const sp<IBinder>& windowToken) { mCurrentPointerCaptureRequest.window = windowToken; mCurrentPointerCaptureRequest.seq++; auto command = [this, request = mCurrentPointerCaptureRequest]() REQUIRES(mLock) { scoped_unlock unlock(mLock); Loading services/inputflinger/dispatcher/InputDispatcher.h +2 −1 Original line number Diff line number Diff line Loading @@ -421,7 +421,8 @@ private: void disablePointerCaptureForcedLocked() REQUIRES(mLock); // Set the Pointer Capture state in the Policy. void setPointerCaptureLocked(bool enable) REQUIRES(mLock); // The window is not nullptr for requests to enable, otherwise it is nullptr. void setPointerCaptureLocked(const sp<IBinder>& window) REQUIRES(mLock); // Dispatcher state at time of last ANR. std::string mLastAnrState GUARDED_BY(mLock); Loading Loading
include/input/Input.h +8 −6 Original line number Diff line number Diff line Loading @@ -1192,15 +1192,17 @@ public: */ struct PointerCaptureRequest { public: inline PointerCaptureRequest() : enable(false), seq(0) {} inline PointerCaptureRequest(bool enable, uint32_t seq) : enable(enable), seq(seq) {} inline PointerCaptureRequest() : window(), seq(0) {} inline PointerCaptureRequest(sp<IBinder> window, uint32_t seq) : window(window), seq(seq) {} inline bool operator==(const PointerCaptureRequest& other) const { return enable == other.enable && seq == other.seq; return window == other.window && seq == other.seq; } explicit inline operator bool() const { return enable; } inline bool isEnable() const { return window != nullptr; } // True iff this is a request to enable Pointer Capture. bool enable; // The requesting window. // If the request is to enable the capture, this is the input token of the window that requested // pointer capture. Otherwise, this is nullptr. sp<IBinder> window; // The sequence number for the request. uint32_t seq; Loading
services/inputflinger/PointerChoreographer.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -277,7 +277,7 @@ void PointerChoreographer::processDeviceReset(const NotifyDeviceResetArgs& args) void PointerChoreographer::notifyPointerCaptureChanged( const NotifyPointerCaptureChangedArgs& args) { if (args.request.enable) { if (args.request.isEnable()) { std::scoped_lock _l(mLock); for (const auto& [_, mousePointerController] : mMousePointersByDisplay) { mousePointerController->fade(PointerControllerInterface::Transition::IMMEDIATE); Loading
services/inputflinger/dispatcher/Entry.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -110,7 +110,7 @@ PointerCaptureChangedEntry::PointerCaptureChangedEntry(int32_t id, nsecs_t event std::string PointerCaptureChangedEntry::getDescription() const { return StringPrintf("PointerCaptureChangedEvent(pointerCaptureEnabled=%s)", pointerCaptureRequest.enable ? "true" : "false"); pointerCaptureRequest.isEnable() ? "true" : "false"); } // --- DragEntry --- Loading
services/inputflinger/dispatcher/InputDispatcher.cpp +21 −18 Original line number Diff line number Diff line Loading @@ -1715,7 +1715,7 @@ void InputDispatcher::dispatchPointerCaptureChangedLocked( const bool haveWindowWithPointerCapture = mWindowTokenWithPointerCapture != nullptr; sp<IBinder> token; if (entry->pointerCaptureRequest.enable) { if (entry->pointerCaptureRequest.isEnable()) { // Enable Pointer Capture. if (haveWindowWithPointerCapture && (entry->pointerCaptureRequest == mCurrentPointerCaptureRequest)) { Loading @@ -1724,7 +1724,7 @@ void InputDispatcher::dispatchPointerCaptureChangedLocked( ALOGI("Skipping dispatch of Pointer Capture being enabled: no state change."); return; } if (!mCurrentPointerCaptureRequest.enable) { if (!mCurrentPointerCaptureRequest.isEnable()) { // This can happen if a window requests capture and immediately releases capture. ALOGW("No window requested Pointer Capture."); dropReason = DropReason::NO_POINTER_CAPTURE; Loading @@ -1737,6 +1737,8 @@ void InputDispatcher::dispatchPointerCaptureChangedLocked( token = mFocusResolver.getFocusedWindowToken(mFocusedDisplayId); LOG_ALWAYS_FATAL_IF(!token, "Cannot find focused window for Pointer Capture."); LOG_ALWAYS_FATAL_IF(token != entry->pointerCaptureRequest.window, "Unexpected requested window for Pointer Capture."); mWindowTokenWithPointerCapture = token; } else { // Disable Pointer Capture. Loading @@ -1756,8 +1758,8 @@ void InputDispatcher::dispatchPointerCaptureChangedLocked( } token = mWindowTokenWithPointerCapture; mWindowTokenWithPointerCapture = nullptr; if (mCurrentPointerCaptureRequest.enable) { setPointerCaptureLocked(false); if (mCurrentPointerCaptureRequest.isEnable()) { setPointerCaptureLocked(nullptr); } } Loading @@ -1765,8 +1767,8 @@ void InputDispatcher::dispatchPointerCaptureChangedLocked( if (connection == nullptr) { // Window has gone away, clean up Pointer Capture state. mWindowTokenWithPointerCapture = nullptr; if (mCurrentPointerCaptureRequest.enable) { setPointerCaptureLocked(false); if (mCurrentPointerCaptureRequest.isEnable()) { setPointerCaptureLocked(nullptr); } return; } Loading Loading @@ -3832,9 +3834,10 @@ void InputDispatcher::startDispatchCycleLocked(nsecs_t currentTime, case EventEntry::Type::POINTER_CAPTURE_CHANGED: { const auto& captureEntry = static_cast<const PointerCaptureChangedEntry&>(eventEntry); status = connection->inputPublisher status = connection->inputPublisher .publishCaptureEvent(dispatchEntry->seq, captureEntry.id, captureEntry.pointerCaptureRequest.enable); captureEntry.pointerCaptureRequest.isEnable()); break; } Loading Loading @@ -4727,7 +4730,7 @@ void InputDispatcher::notifyDeviceReset(const NotifyDeviceResetArgs& args) { void InputDispatcher::notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs& args) { if (debugInboundEventDetails()) { ALOGD("notifyPointerCaptureChanged - eventTime=%" PRId64 ", enabled=%s", args.eventTime, args.request.enable ? "true" : "false"); args.request.isEnable() ? "true" : "false"); } bool needWake = false; Loading Loading @@ -5798,7 +5801,7 @@ std::string InputDispatcher::dumpPointerCaptureStateLocked() const { std::string dump; dump += StringPrintf(INDENT "Pointer Capture Requested: %s\n", toString(mCurrentPointerCaptureRequest.enable)); toString(mCurrentPointerCaptureRequest.isEnable())); std::string windowName = "None"; if (mWindowTokenWithPointerCapture) { Loading Loading @@ -6217,7 +6220,7 @@ void InputDispatcher::requestPointerCapture(const sp<IBinder>& windowToken, bool return; } if (enabled == mCurrentPointerCaptureRequest.enable) { if (enabled == mCurrentPointerCaptureRequest.isEnable()) { ALOGW("Ignoring request to %s Pointer Capture: " "window has %s requested pointer capture.", enabled ? "enable" : "disable", enabled ? "already" : "not"); Loading @@ -6233,7 +6236,7 @@ void InputDispatcher::requestPointerCapture(const sp<IBinder>& windowToken, bool } } setPointerCaptureLocked(enabled); setPointerCaptureLocked(enabled ? windowToken : nullptr); } // release lock // Wake the thread to process command entries. Loading Loading @@ -6863,14 +6866,14 @@ void InputDispatcher::onFocusChangedLocked( } void InputDispatcher::disablePointerCaptureForcedLocked() { if (!mCurrentPointerCaptureRequest.enable && !mWindowTokenWithPointerCapture) { if (!mCurrentPointerCaptureRequest.isEnable() && !mWindowTokenWithPointerCapture) { return; } ALOGD_IF(DEBUG_FOCUS, "Disabling Pointer Capture because the window lost focus."); if (mCurrentPointerCaptureRequest.enable) { setPointerCaptureLocked(false); if (mCurrentPointerCaptureRequest.isEnable()) { setPointerCaptureLocked(nullptr); } if (!mWindowTokenWithPointerCapture) { Loading @@ -6890,8 +6893,8 @@ void InputDispatcher::disablePointerCaptureForcedLocked() { mInboundQueue.push_front(std::move(entry)); } void InputDispatcher::setPointerCaptureLocked(bool enable) { mCurrentPointerCaptureRequest.enable = enable; void InputDispatcher::setPointerCaptureLocked(const sp<IBinder>& windowToken) { mCurrentPointerCaptureRequest.window = windowToken; mCurrentPointerCaptureRequest.seq++; auto command = [this, request = mCurrentPointerCaptureRequest]() REQUIRES(mLock) { scoped_unlock unlock(mLock); Loading
services/inputflinger/dispatcher/InputDispatcher.h +2 −1 Original line number Diff line number Diff line Loading @@ -421,7 +421,8 @@ private: void disablePointerCaptureForcedLocked() REQUIRES(mLock); // Set the Pointer Capture state in the Policy. void setPointerCaptureLocked(bool enable) REQUIRES(mLock); // The window is not nullptr for requests to enable, otherwise it is nullptr. void setPointerCaptureLocked(const sp<IBinder>& window) REQUIRES(mLock); // Dispatcher state at time of last ANR. std::string mLastAnrState GUARDED_BY(mLock); Loading