diff options
author | Thiago de Arruda <tpadilha84@gmail.com> | 2014-06-20 10:36:58 -0300 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-06-24 13:02:23 -0300 |
commit | ef4c5ccb21bda85cea7fa3c825f865c95f6cdbb4 (patch) | |
tree | feb546e72f9afdcc3f9d6138b7173e223fecbcc7 /src/nvim/os/event.c | |
parent | b00a37544c2d0662e251fd80033509cb6ed8ffe2 (diff) | |
download | rneovim-ef4c5ccb21bda85cea7fa3c825f865c95f6cdbb4.tar.gz rneovim-ef4c5ccb21bda85cea7fa3c825f865c95f6cdbb4.tar.bz2 rneovim-ef4c5ccb21bda85cea7fa3c825f865c95f6cdbb4.zip |
event: Decouple user input checks from `event_poll`
This was done to generalize the usage of `event_poll`, which will now return
`true` only if a event has been processed/deferred before the timeout(if not
-1).
To do that, the `input_ready` calls have been extracted to the input.c
module(the `event_poll` call has been surrounded by `input_ready` calls,
resulting in the same behavior).
The `input_start`/`input_stop` calls still present in `event_poll` are
temporary: When the API becomes the only way to read user input, it will no
longer be necessary to start/stop the input stream.
Diffstat (limited to 'src/nvim/os/event.c')
-rw-r--r-- | src/nvim/os/event.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/nvim/os/event.c b/src/nvim/os/event.c index 8b7bc53978..a8bd6ca886 100644 --- a/src/nvim/os/event.c +++ b/src/nvim/os/event.c @@ -63,11 +63,6 @@ bool event_poll(int32_t ms) { uv_run_mode run_mode = UV_RUN_ONCE; - if (input_ready()) { - // If there's a pending input event to be consumed, do it now - return true; - } - static int recursive = 0; if (!(recursive++)) { @@ -95,13 +90,16 @@ bool event_poll(int32_t ms) run_mode = UV_RUN_NOWAIT; } + bool events_processed; + do { // Run one event loop iteration, blocking for events if run_mode is // UV_RUN_ONCE uv_run(uv_default_loop(), run_mode); + events_processed = event_process(false); } while ( // Continue running if ... - !event_process(false) && // we didn't process any immediate events + !events_processed && // we didn't process any immediate events !event_has_deferred() && // no events are waiting to be processed run_mode != UV_RUN_NOWAIT && // ms != 0 !timer_data.timed_out); // we didn't get a timeout @@ -120,7 +118,7 @@ bool event_poll(int32_t ms) event_process(false); } - return input_ready() || event_has_deferred(); + return !timer_data.timed_out && (events_processed || event_has_deferred()); } bool event_has_deferred() |