Move setDisplayViewport to InputReader.
InputReader is responsible to associate device and display so it makes sense to allow it set display viewport for pointer controller. Bug: 146385350 Test: Cursor can be associated with external freeform displays as expected. Change-Id: I00d664dd180f1e693b1900582feea8f7ff02f93c Merged-In: I00d664dd180f1e693b1900582feea8f7ff02f93c
This commit is contained in:
@@ -100,6 +100,7 @@ public:
|
||||
virtual int32_t getDisplayId() const;
|
||||
virtual void fade(Transition transition);
|
||||
virtual void unfade(Transition transition);
|
||||
virtual void setDisplayViewport(const DisplayViewport& viewport);
|
||||
|
||||
virtual void setPresentation(Presentation presentation);
|
||||
virtual void setSpots(const PointerCoords* spotCoords,
|
||||
@@ -108,7 +109,6 @@ public:
|
||||
|
||||
void updatePointerIcon(int32_t iconId);
|
||||
void setCustomPointerIcon(const SpriteIcon& icon);
|
||||
void setDisplayViewport(const DisplayViewport& viewport);
|
||||
void setInactivityTimeout(InactivityTimeout inactivityTimeout);
|
||||
void reloadPointerResources();
|
||||
|
||||
|
||||
@@ -319,7 +319,6 @@ private:
|
||||
void updateInactivityTimeoutLocked();
|
||||
void handleInterceptActions(jint wmActions, nsecs_t when, uint32_t& policyFlags);
|
||||
void ensureSpriteControllerLocked();
|
||||
const DisplayViewport* findDisplayViewportLocked(int32_t displayId);
|
||||
int32_t getPointerDisplayId();
|
||||
void updatePointerDisplayLocked();
|
||||
static bool checkAndClearExceptionFromCallback(JNIEnv* env, const char* methodName);
|
||||
@@ -397,16 +396,6 @@ bool NativeInputManager::checkAndClearExceptionFromCallback(JNIEnv* env, const c
|
||||
return false;
|
||||
}
|
||||
|
||||
const DisplayViewport* NativeInputManager::findDisplayViewportLocked(int32_t displayId)
|
||||
REQUIRES(mLock) {
|
||||
for (const DisplayViewport& v : mLocked.viewports) {
|
||||
if (v.displayId == displayId) {
|
||||
return &v;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void NativeInputManager::setDisplayViewports(JNIEnv* env, jobjectArray viewportObjArray) {
|
||||
std::vector<DisplayViewport> viewports;
|
||||
|
||||
@@ -555,6 +544,8 @@ void NativeInputManager::getReaderConfiguration(InputReaderConfiguration* outCon
|
||||
|
||||
outConfig->setDisplayViewports(mLocked.viewports);
|
||||
|
||||
outConfig->defaultPointerDisplayId = mLocked.pointerDisplayId;
|
||||
|
||||
outConfig->disabledDevices = mLocked.disabledInputDevices;
|
||||
} // release lock
|
||||
}
|
||||
@@ -572,8 +563,6 @@ sp<PointerControllerInterface> NativeInputManager::obtainPointerController(int32
|
||||
updateInactivityTimeoutLocked();
|
||||
}
|
||||
|
||||
updatePointerDisplayLocked();
|
||||
|
||||
return controller;
|
||||
}
|
||||
|
||||
@@ -588,23 +577,6 @@ int32_t NativeInputManager::getPointerDisplayId() {
|
||||
return pointerDisplayId;
|
||||
}
|
||||
|
||||
void NativeInputManager::updatePointerDisplayLocked() REQUIRES(mLock) {
|
||||
ATRACE_CALL();
|
||||
|
||||
sp<PointerController> controller = mLocked.pointerController.promote();
|
||||
if (controller != nullptr) {
|
||||
const DisplayViewport* viewport = findDisplayViewportLocked(mLocked.pointerDisplayId);
|
||||
if (viewport == nullptr) {
|
||||
ALOGW("Can't find pointer display viewport, fallback to default display.");
|
||||
viewport = findDisplayViewportLocked(ADISPLAY_ID_DEFAULT);
|
||||
}
|
||||
|
||||
if (viewport != nullptr) {
|
||||
controller->setDisplayViewport(*viewport);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NativeInputManager::ensureSpriteControllerLocked() REQUIRES(mLock) {
|
||||
if (mLocked.spriteController == nullptr) {
|
||||
JNIEnv* env = jniEnv();
|
||||
|
||||
Reference in New Issue
Block a user