Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "jni/eventloop.h" | 5 #include "embedders/android/eventloop.h" |
| 6 #include "jni/log.h" | 6 #include "embedders/android/log.h" |
| 7 | 7 |
| 8 EventLoop::EventLoop(android_app* application) | 8 EventLoop::EventLoop(android_app* application) |
| 9 : enabled_(false), | 9 : enabled_(false), |
| 10 quit_(false), | 10 quit_(false), |
| 11 application_(application), | 11 application_(application), |
| 12 activity_handler_(NULL), | 12 activity_handler_(NULL), |
| 13 input_handler_(NULL) { | 13 input_handler_(NULL) { |
| 14 application_->onAppCmd = ActivityCallback; | 14 application_->onAppCmd = ActivityCallback; |
| 15 application_->onInputEvent = InputCallback; | 15 application_->onInputEvent = InputCallback; |
| 16 application_->userData = this; | 16 application_->userData = this; |
| 17 } | 17 } |
| 18 | 18 |
| 19 void EventLoop::Run(ActivityHandler* activity_handler, | 19 void EventLoop::Run(ActivityHandler* activity_handler, |
| 20 Context* context) { | 20 Context* context) { |
| 21 int32_t result; | 21 int32_t result; |
| 22 int32_t events; | 22 int32_t events; |
| 23 android_poll_source* source; | 23 android_poll_source* source; |
| 24 | 24 |
| 25 app_dummy(); | |
|
gram
2013/01/09 17:51:36
Actually this line is very important and must be r
vsm
2013/01/09 18:41:24
Added a comment to try to get this back in.
| |
| 26 activity_handler_ = activity_handler; | 25 activity_handler_ = activity_handler; |
| 27 input_handler_ = context->input_handler; | 26 input_handler_ = context->input_handler; |
| 28 LOGI("Starting event loop"); | 27 LOGI("Starting event loop"); |
| 29 while (true) { | 28 while (true) { |
| 30 // If not enabled, block on events. If enabled, don't block | 29 // If not enabled, block on events. If enabled, don't block |
| 31 // so we can do useful work in onStep. | 30 // so we can do useful work in onStep. |
| 32 while ((result = ALooper_pollAll(enabled_ ? 0 : -1, | 31 while ((result = ALooper_pollAll(enabled_ ? 0 : -1, |
| 33 NULL, | 32 NULL, |
| 34 &events, | 33 &events, |
| 35 reinterpret_cast<void**>(&source))) >= 0) { | 34 reinterpret_cast<void**>(&source))) >= 0) { |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 138 void EventLoop::ActivityCallback(android_app* application, int32_t command) { | 137 void EventLoop::ActivityCallback(android_app* application, int32_t command) { |
| 139 EventLoop* event_loop = reinterpret_cast<EventLoop*>(application->userData); | 138 EventLoop* event_loop = reinterpret_cast<EventLoop*>(application->userData); |
| 140 event_loop->ProcessActivityEvent(command); | 139 event_loop->ProcessActivityEvent(command); |
| 141 } | 140 } |
| 142 | 141 |
| 143 int32_t EventLoop::InputCallback(android_app* application, | 142 int32_t EventLoop::InputCallback(android_app* application, |
| 144 AInputEvent* event) { | 143 AInputEvent* event) { |
| 145 EventLoop* event_loop = reinterpret_cast<EventLoop*>(application->userData); | 144 EventLoop* event_loop = reinterpret_cast<EventLoop*>(application->userData); |
| 146 return event_loop->ProcessInputEvent(event); | 145 return event_loop->ProcessInputEvent(event); |
| 147 } | 146 } |
| OLD | NEW |