android: add poll_looper_pause
authorAlexis Laferrière <alexis.laf@xymus.net>
Sun, 15 Oct 2017 02:18:07 +0000 (22:18 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Wed, 17 Jan 2018 17:38:40 +0000 (12:38 -0500)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/android/native_app_glue.nit

index 1769e0c..1c21dec 100644 (file)
@@ -216,7 +216,7 @@ redef class App
        # Raised when the soft input window being shown or hidden, and similar events.
        fun content_rect_changed do end
 
-       # Call the `ALooper` to retrieve events and callback the application
+       # Call the `ALooper_pollAll` to retrieve events and callback the application
        fun poll_looper(timeout_ms: Int) import handle_looper_event `{
                int ident;
                int event;
@@ -226,6 +226,16 @@ redef class App
                }
        `}
 
+       # Call the `ALooper_pollOnce` to retrieve at most one event and callback the application
+       fun poll_looper_pause(timeout_ms: Int) import handle_looper_event `{
+               int event;
+               void* source;
+               int ident = ALooper_pollOnce(timeout_ms, NULL, &event, &source);
+               if (ident >= 0) {
+                       App_handle_looper_event(self, ident, event, source);
+               }
+       `}
+
        # Handle an event retrieved by the `ALooper` and `poll_looper` without a callback
        protected fun handle_looper_event(ident, event: Int, data: Pointer) import native_app_glue,
                save_state, init_window, term_window, gained_focus, lost_focus, pause, stop,