Loading services/inputflinger/dispatcher/InputDispatcher.cpp +21 −0 Original line number Diff line number Diff line Loading @@ -5645,6 +5645,15 @@ void InputDispatcher::requestPointerCapture(const sp<IBinder>& windowToken, bool return; } if (enabled) { if (std::find(mIneligibleDisplaysForPointerCapture.begin(), mIneligibleDisplaysForPointerCapture.end(), mFocusedDisplayId) != mIneligibleDisplaysForPointerCapture.end()) { ALOGW("Ignoring request to enable Pointer Capture: display is not eligible"); return; } } setPointerCaptureLocked(enabled); } // release lock Loading @@ -5652,6 +5661,16 @@ void InputDispatcher::requestPointerCapture(const sp<IBinder>& windowToken, bool mLooper->wake(); } void InputDispatcher::setDisplayEligibilityForPointerCapture(int32_t displayId, bool isEligible) { { // acquire lock std::scoped_lock _l(mLock); std::erase(mIneligibleDisplaysForPointerCapture, displayId); if (!isEligible) { mIneligibleDisplaysForPointerCapture.push_back(displayId); } } // release lock } std::optional<int32_t> InputDispatcher::findGestureMonitorDisplayByTokenLocked( const sp<IBinder>& token) { for (const auto& it : mGestureMonitorsByDisplay) { Loading Loading @@ -6311,6 +6330,8 @@ void InputDispatcher::displayRemoved(int32_t displayId) { // Call focus resolver to clean up stale requests. This must be called after input windows // have been removed for the removed display. mFocusResolver.displayRemoved(displayId); // Reset pointer capture eligibility, regardless of previous state. std::erase(mIneligibleDisplaysForPointerCapture, displayId); } // release lock // Wake up poll loop since it may need to make new input dispatching choices. Loading services/inputflinger/dispatcher/InputDispatcher.h +5 −0 Original line number Diff line number Diff line Loading @@ -136,6 +136,7 @@ public: status_t pilferPointers(const sp<IBinder>& token) override; void requestPointerCapture(const sp<IBinder>& windowToken, bool enabled) override; bool flushSensor(int deviceId, InputDeviceSensorType sensorType) override; void setDisplayEligibilityForPointerCapture(int displayId, bool isEligible) override; std::array<uint8_t, 32> sign(const VerifiedInputEvent& event) const; Loading Loading @@ -420,6 +421,10 @@ private: // This should be in sync with PointerCaptureChangedEvents dispatched to the input channel. sp<IBinder> mWindowTokenWithPointerCapture GUARDED_BY(mLock); // Displays that are ineligible for pointer capture. // TODO(b/214621487): Remove or move to a display flag. std::vector<int32_t> mIneligibleDisplaysForPointerCapture GUARDED_BY(mLock); // Disable Pointer Capture as a result of loss of window focus. void disablePointerCaptureForcedLocked() REQUIRES(mLock); Loading services/inputflinger/dispatcher/include/InputDispatcherInterface.h +7 −0 Original line number Diff line number Diff line Loading @@ -201,6 +201,13 @@ public: */ virtual void requestPointerCapture(const sp<IBinder>& windowToken, bool enabled) = 0; /** * Sets the eligibility of a given display to enable pointer capture. If a display is marked * ineligible, all attempts to request pointer capture for windows on that display will fail. * TODO(b/214621487): Remove or move to a display flag. */ virtual void setDisplayEligibilityForPointerCapture(int displayId, bool isEligible) = 0; /* Flush input device motion sensor. * * Returns true on success. Loading Loading
services/inputflinger/dispatcher/InputDispatcher.cpp +21 −0 Original line number Diff line number Diff line Loading @@ -5645,6 +5645,15 @@ void InputDispatcher::requestPointerCapture(const sp<IBinder>& windowToken, bool return; } if (enabled) { if (std::find(mIneligibleDisplaysForPointerCapture.begin(), mIneligibleDisplaysForPointerCapture.end(), mFocusedDisplayId) != mIneligibleDisplaysForPointerCapture.end()) { ALOGW("Ignoring request to enable Pointer Capture: display is not eligible"); return; } } setPointerCaptureLocked(enabled); } // release lock Loading @@ -5652,6 +5661,16 @@ void InputDispatcher::requestPointerCapture(const sp<IBinder>& windowToken, bool mLooper->wake(); } void InputDispatcher::setDisplayEligibilityForPointerCapture(int32_t displayId, bool isEligible) { { // acquire lock std::scoped_lock _l(mLock); std::erase(mIneligibleDisplaysForPointerCapture, displayId); if (!isEligible) { mIneligibleDisplaysForPointerCapture.push_back(displayId); } } // release lock } std::optional<int32_t> InputDispatcher::findGestureMonitorDisplayByTokenLocked( const sp<IBinder>& token) { for (const auto& it : mGestureMonitorsByDisplay) { Loading Loading @@ -6311,6 +6330,8 @@ void InputDispatcher::displayRemoved(int32_t displayId) { // Call focus resolver to clean up stale requests. This must be called after input windows // have been removed for the removed display. mFocusResolver.displayRemoved(displayId); // Reset pointer capture eligibility, regardless of previous state. std::erase(mIneligibleDisplaysForPointerCapture, displayId); } // release lock // Wake up poll loop since it may need to make new input dispatching choices. Loading
services/inputflinger/dispatcher/InputDispatcher.h +5 −0 Original line number Diff line number Diff line Loading @@ -136,6 +136,7 @@ public: status_t pilferPointers(const sp<IBinder>& token) override; void requestPointerCapture(const sp<IBinder>& windowToken, bool enabled) override; bool flushSensor(int deviceId, InputDeviceSensorType sensorType) override; void setDisplayEligibilityForPointerCapture(int displayId, bool isEligible) override; std::array<uint8_t, 32> sign(const VerifiedInputEvent& event) const; Loading Loading @@ -420,6 +421,10 @@ private: // This should be in sync with PointerCaptureChangedEvents dispatched to the input channel. sp<IBinder> mWindowTokenWithPointerCapture GUARDED_BY(mLock); // Displays that are ineligible for pointer capture. // TODO(b/214621487): Remove or move to a display flag. std::vector<int32_t> mIneligibleDisplaysForPointerCapture GUARDED_BY(mLock); // Disable Pointer Capture as a result of loss of window focus. void disablePointerCaptureForcedLocked() REQUIRES(mLock); Loading
services/inputflinger/dispatcher/include/InputDispatcherInterface.h +7 −0 Original line number Diff line number Diff line Loading @@ -201,6 +201,13 @@ public: */ virtual void requestPointerCapture(const sp<IBinder>& windowToken, bool enabled) = 0; /** * Sets the eligibility of a given display to enable pointer capture. If a display is marked * ineligible, all attempts to request pointer capture for windows on that display will fail. * TODO(b/214621487): Remove or move to a display flag. */ virtual void setDisplayEligibilityForPointerCapture(int displayId, bool isEligible) = 0; /* Flush input device motion sensor. * * Returns true on success. Loading