/* this is only to queue GDK key events, in order to later send them if the map didn't match */
static struct {
- GdkEventKey **queue; /* queue holding submitted events */
- int qlen; /* pointer to last char in queue */
- bool processing; /* whether or not events are processing */
+ GSList *list; /* queue holding submitted events */
+ bool processing; /* whether or not events are processing */
} events;
extern VbCore vb;
*/
void queue_event(GdkEventKey *e)
{
- events.queue = g_realloc(events.queue, (events.qlen + 1) * sizeof(GdkEventKey*));
-
+ GdkEventKey *copy = g_memdup(e, sizeof(GdkEventKey));
/* copy memory (otherwise event gets cleared by gdk) */
- events.queue[events.qlen] = g_memdup(e, sizeof(GdkEventKey));
- events.qlen ++;
+ events.list = g_slist_append(events.list, copy);
}
/**
*/
void process_events()
{
- for (int i = 0; i < events.qlen; ++i) {
- process_event(events.queue[i]);
- g_free(events.queue[i]);
+ for (GSList *l = events.list; l != NULL; l = l->next) {
+ process_event((GdkEventKey*)l->data);
+ g_free(l->data);
+ events.list = g_slist_delete_link(events.list, l);
/* TODO take into account qk mapped key? */
}
-
- events.qlen = 0;
}
static void process_event(GdkEventKey *event)
return;
}
- events.processing = true; /* signal not to queue other events */
+ /* signal not to queue other events */
+ events.processing = true;
gtk_main_do_event((GdkEvent*)event);
events.processing = false;
}
*/
void free_events()
{
- for (int i = 0; i < events.qlen; ++i) {
- g_free(events.queue[i]);
+ if (events.list) {
+ g_slist_free_full(events.list, (GDestroyNotify)g_free);
+ events.list = NULL;
}
-
- events.qlen = 0;
}