X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=libchimara%2Fevent.c;h=88b09f02c1f31ce0fba2dfec6c35e2eb2f15432b;hb=a547d7c1b896ecae9afe07273dfb0fc744a84cb8;hp=4bbb391b597bb028dc7e5a75994de54ee188858f;hpb=d5610e149e0384a24d00727a5815df12e85de026;p=projects%2Fchimara%2Fchimara.git diff --git a/libchimara/event.c b/libchimara/event.c index 4bbb391..88b09f0 100644 --- a/libchimara/event.c +++ b/libchimara/event.c @@ -1,6 +1,7 @@ #include "event.h" #include "magic.h" #include "glk.h" +#include "window.h" #include #include "chimara-glk.h" @@ -69,10 +70,13 @@ glk_select(event_t *event) ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + /* Emit the "waiting" signal to let listeners know we are ready for input */ + g_signal_emit_by_name(glk_data->self, "waiting"); + g_mutex_lock(glk_data->event_lock); /* Wait for an event */ - while( g_queue_is_empty(glk_data->event_queue) ) + if( g_queue_is_empty(glk_data->event_queue) ) g_cond_wait(glk_data->event_queue_not_empty, glk_data->event_lock); event_t *retrieved_event = g_queue_pop_tail(glk_data->event_queue); @@ -92,6 +96,15 @@ glk_select(event_t *event) /* Check for interrupt */ glk_tick(); + + /* If the event was a line input event, the library must release the buffer */ + if(event->type == evtype_LineInput && glk_data->unregister_arr) + { + if(event->win->input_request_type == INPUT_REQUEST_LINE_UNICODE) + (*glk_data->unregister_arr)(event->win->line_input_buffer_unicode, event->win->line_input_buffer_max_len, "&+#!Iu", event->win->buffer_rock); + else + (*glk_data->unregister_arr)(event->win->line_input_buffer, event->win->line_input_buffer_max_len, "&+#!Cn", event->win->buffer_rock); + } /* If an abort event was generated, the thread should have exited by now */ g_assert(event->type != evtype_Abort); @@ -190,4 +203,4 @@ glk_select_poll(event_t *event) /* If an abort event was generated, the thread should have exited by now */ g_assert(event->type != evtype_Abort); -} \ No newline at end of file +}