*/
void queue_event(GdkEventKey *e)
{
- if (vb.mode->id != 'i') {
- /* events are only needed for input mode */
- return free_events();
- }
-
GdkEventKey **newqueue = realloc(events.queue, (events.qlen + 1) * sizeof **newqueue);
if (newqueue == NULL) {
events.qlen ++;
}
-/**
- * Free latest event & decrement qlen.
- */
-void pop_event()
+void process_event(GdkEventKey* event)
{
- if (events.qlen == 0) {
+ if (event == NULL) {
return;
}
- free(events.queue[events.qlen - 1]);
- events.qlen --;
+ events.processing = true; /* signal not to queue other events */
+ gtk_main_do_event ((GdkEvent *) event);
+ events.processing = false;
+ free(event);
}
/**
* Process events in the queue, sending the key events to GDK.
*/
-void process_events(bool is_timeout)
+void process_events()
{
- if (vb.mode->id != 'i') {
- /* events are only needed for input mode */
- return free_events();
- }
-
- if (!is_timeout || events.qlen > 1) {
- /* pop last event to prevent duplicate input */
- pop_event();
- }
-
- events.processing = true; /* signal not to map our events */
-
for (int i = 0; i < events.qlen; ++i)
{
- GdkEventKey *event = events.queue[i];
- gtk_main_do_event ((GdkEvent *) event);
+ process_event(events.queue[i]); /* process & free the event */
+ /* TODO take into account qk mapped key? */
}
- free_events();
- events.processing = false;
+ events.qlen = 0;
}
/**
#include "map.h"
void queue_event(GdkEventKey *e);
-void free_events();
-void process_events(bool is_timeout);
+void process_events();
bool is_processing_events();
+void free_events();
#endif /* end of include guard: _MAP_H */
MapState res = map_handle_keys(string, len, true);
- /* reset the typed flag */
- vb.state.typed = false;
-
- if (res == MAP_NOMATCH) {
+ if (res == MAP_AMBIGUOUS) {
+ /* prevent typing key */
+ vb.state.processed_key = true;
+ } else {
if (!vb.state.processed_key) {
- /* consume any unprocessed events */
- process_events(false);
+ /* events ready to be consumed */
+ process_events();
+ vb.state.processed_key = true;
} else {
- /* we're done - clear events */
+ /* no ambiguous - key processed elsewhere */
free_events();
}
}
+ /* reset the typed flag */
+ vb.state.typed = false;
+
return vb.state.processed_key;
}
MapState res = map_handle_keys((guchar*)"", 0, true);
/* consume any unprocessed events */
- process_events(true);
+ process_events();
/* we return true to not automatically remove the resource - this is
* required to prevent critical error when we remove the source in