main: don't allow ESC key repeat to flood console

If the user holds down ESC the system can easily get
overrun toggling details and the theme back and forth.

This commit changes the code to ignore any ESC key events
that come in while ESC is getting processed.
This commit is contained in:
Ray Strode 2017-03-17 16:35:46 -04:00
parent 63148b20a1
commit 1f1d83bf71

View file

@ -102,6 +102,7 @@ typedef struct
ply_terminal_t *local_console_terminal;
ply_device_manager_t *device_manager;
ply_trigger_t *details_trigger;
ply_trigger_t *deactivate_trigger;
ply_trigger_t *quit_trigger;
@ -1500,8 +1501,24 @@ toggle_between_splash_and_details (state_t *state)
static void
on_escape_pressed (state_t *state)
{
if (state->details_trigger != NULL) {
return;
}
state->details_trigger = ply_trigger_new (&state->details_trigger);
ply_trigger_add_handler (state->details_trigger,
(ply_trigger_handler_t)
toggle_between_splash_details,
state);
ply_trace ("escape key pressed");
toggle_between_splash_and_details (state);
ply_event_loop_watch_for_timeout (state->loop,
0.01,
(ply_event_loop_timeout_handler_t)
ply_trigger_pull
state->details_trigger);
}
static void