diff options
author | Dianne Hackborn <hackbod@google.com> | 2010-07-13 19:50:36 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2010-07-13 19:50:36 -0700 |
commit | 2388ad9eef109fa7f63c196c819c83f0376f0645 (patch) | |
tree | 19c965b6d7efb893604fc448cebc9380ebb60fb6 /native/android/input.cpp | |
parent | fc6d300f408959b11f86623ea7a0ce547ded3563 (diff) | |
parent | f8d9379bd834573feca085284970cf686993c330 (diff) | |
download | frameworks_base-2388ad9eef109fa7f63c196c819c83f0376f0645.zip frameworks_base-2388ad9eef109fa7f63c196c819c83f0376f0645.tar.gz frameworks_base-2388ad9eef109fa7f63c196c819c83f0376f0645.tar.bz2 |
am f8d9379b: am d76b67c3: IME events are now dispatched to native applications.
Merge commit 'f8d9379bd834573feca085284970cf686993c330'
* commit 'f8d9379bd834573feca085284970cf686993c330':
IME events are now dispatched to native applications.
Diffstat (limited to 'native/android/input.cpp')
-rw-r--r-- | native/android/input.cpp | 62 |
1 files changed, 10 insertions, 52 deletions
diff --git a/native/android/input.cpp b/native/android/input.cpp index 89d53e2..a4dde51 100644 --- a/native/android/input.cpp +++ b/native/android/input.cpp @@ -22,6 +22,8 @@ #include <ui/InputTransport.h> #include <utils/PollLoop.h> +#include <android_runtime/android_app_NativeActivity.h> + #include <poll.h> using android::InputEvent; @@ -187,65 +189,21 @@ float AMotionEvent_getHistoricalSize(AInputEvent* motion_event, size_t pointer_i void AInputQueue_attachLooper(AInputQueue* queue, ALooper* looper, ALooper_callbackFunc* callback, void* data) { - queue->setPollLoop(static_cast<android::PollLoop*>(looper)); - ALooper_addFd(looper, queue->getConsumer().getChannel()->getReceivePipeFd(), - POLLIN, callback, data); + queue->attachLooper(looper, callback, data); } void AInputQueue_detachLooper(AInputQueue* queue) { - queue->getPollLoop()->removeCallback( - queue->getConsumer().getChannel()->getReceivePipeFd()); + queue->detachLooper(); } int AInputQueue_hasEvents(AInputQueue* queue) { - struct pollfd pfd; - - pfd.fd = queue->getConsumer().getChannel()->getReceivePipeFd(); - pfd.events = POLLIN; - pfd.revents = 0; - - int nfd = poll(&pfd, 1, 0); - if (nfd <= 0) return nfd; - return pfd.revents == POLLIN ? 1 : -1; + return queue->hasEvents(); } int32_t AInputQueue_getEvent(AInputQueue* queue, AInputEvent** outEvent) { - *outEvent = NULL; - - int32_t res = queue->getConsumer().receiveDispatchSignal(); - if (res != android::OK) { - LOGE("channel '%s' ~ Failed to receive dispatch signal. status=%d", - queue->getConsumer().getChannel()->getName().string(), res); - return -1; - } - - InputEvent* myEvent = NULL; - res = queue->consume(&myEvent); - if (res != android::OK) { - LOGW("channel '%s' ~ Failed to consume input event. status=%d", - queue->getConsumer().getChannel()->getName().string(), res); - queue->getConsumer().sendFinishedSignal(); - return -1; - } - - *outEvent = myEvent; - return 0; -} - -void AInputQueue_finishEvent(AInputQueue* queue, AInputEvent* event, - int handled) { - if (!handled && ((InputEvent*)event)->getType() == INPUT_EVENT_TYPE_KEY - && ((KeyEvent*)event)->hasDefaultAction()) { - // The app didn't handle this, but it may have a default action - // associated with it. We need to hand this back to Java to be - // executed. - queue->doDefaultKey((KeyEvent*)event); - return; - } - - int32_t res = queue->getConsumer().sendFinishedSignal(); - if (res != android::OK) { - LOGW("Failed to send finished signal on channel '%s'. status=%d", - queue->getConsumer().getChannel()->getName().string(), res); - } + return queue->getEvent(outEvent); +} + +void AInputQueue_finishEvent(AInputQueue* queue, AInputEvent* event, int handled) { + queue->finishEvent(event, handled != 0); } |