diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/events.c | 62 | ||||
-rw-r--r-- | src/events.h | 15 | ||||
-rw-r--r-- | src/map.c | 54 |
3 files changed, 52 insertions, 79 deletions
diff --git a/src/events.c b/src/events.c deleted file mode 100644 index 6c6e250..0000000 --- a/src/events.c +++ /dev/null @@ -1,62 +0,0 @@ -/* Copyright (C) 2016-2019 Michael Mackus */ -#include <gtk/gtk.h> - -#include "events.h" - -/* this is only to queue GDK key events, in order to later send them if the map didn't match */ -static struct { - GSList *list; /* queue holding submitted events */ - bool processing; /* whether or not events are processing */ -} events = {0}; - -static void process_event(GdkEventKey* event); - -/** - * Append an event into the queue. - */ -void queue_event(GdkEventKey *e) -{ - events.list = g_slist_append(events.list, gdk_event_copy((GdkEvent*)e)); -} - -/** - * Process events in the queue, sending the key events to GDK. - */ -void process_events(void) -{ - for (GSList *l = events.list; l != NULL; l = l->next) { - process_event((GdkEventKey*)l->data); - /* TODO take into account qk mapped key? */ - } - free_events(); -} - -/** - * Check if the events are currently processing (i.e. being sent to GDK - * unhandled). - */ -gboolean is_processing_events(void) -{ - return events.processing; -} - -/** - * Clear the events list and free the allocated memory. - */ -void free_events(void) -{ - if (events.list) { - g_slist_free_full(events.list, (GDestroyNotify)gdk_event_free); - events.list = NULL; - } -} - -static void process_event(GdkEventKey* event) -{ - if (event) { - /* signal not to queue other events */ - events.processing = TRUE; - gtk_main_do_event((GdkEvent*)event); - events.processing = FALSE; - } -} diff --git a/src/events.h b/src/events.h deleted file mode 100644 index 75e335b..0000000 --- a/src/events.h +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright (C) 2016-2019 Michael Mackus */ -#ifndef _EVENTS_H -#define _EVENTS_H - -#include <gdk/gdkkeysyms.h> -#include <gdk/gdkkeysyms-compat.h> -#include "main.h" -#include "map.h" - -void queue_event(GdkEventKey *e); -void process_events(void); -gboolean is_processing_events(void); -void free_events(void); - -#endif /* end of include guard: _MAP_H */ @@ -23,7 +23,6 @@ #include "ascii.h" #include "config.h" -#include "events.h" #include "main.h" #include "map.h" #include "util.h" @@ -37,6 +36,10 @@ static gboolean map_delete_by_lhs(Client *c, const char *lhs, int len, char mode static void showcmd(Client *c, int ch); static char *transchar(int c); static int utf_char2bytes(guint c, guchar *buf); +static void queue_event(GdkEventKey *e); +static void process_events(void); +static void free_events(void); +static void process_event(GdkEventKey* event); extern struct Vimb vb; @@ -98,6 +101,12 @@ static struct { {"<F12>", 5, CSI_STR "F2", 3}, }; +/* this is only to queue GDK key events, in order to later send them if the map didn't match */ +static struct { + GSList *list; /* queue holding submitted events */ + gboolean processing; /* whether or not events are processing */ +} events = {0}; + void map_init(Client *c) { c->map.queue = g_string_sized_new(50); @@ -325,7 +334,7 @@ gboolean map_delete(Client *c, const char *in, char mode) */ gboolean on_map_keypress(GtkWidget *widget, GdkEventKey* event, Client *c) { - if (is_processing_events()) { + if (events.processing) { /* events are processing, pass all keys unmodified */ return FALSE; } @@ -679,3 +688,44 @@ static int utf_char2bytes(guint c, guchar *buf) buf[5] = 0x80 + (c & 0x3f); return 6; } + +/** + * Append an event into the queue. + */ +static void queue_event(GdkEventKey *e) +{ + events.list = g_slist_append(events.list, gdk_event_copy((GdkEvent*)e)); +} + +/** + * Process events in the queue, sending the key events to GDK. + */ +static void process_events(void) +{ + for (GSList *l = events.list; l != NULL; l = l->next) { + process_event((GdkEventKey*)l->data); + /* TODO take into account qk mapped key? */ + } + free_events(); +} + +/** + * Clear the events list and free the allocated memory. + */ +static void free_events(void) +{ + if (events.list) { + g_slist_free_full(events.list, (GDestroyNotify)gdk_event_free); + events.list = NULL; + } +} + +static void process_event(GdkEventKey* event) +{ + if (event) { + /* signal not to queue other events */ + events.processing = TRUE; + gtk_main_do_event((GdkEvent*)event); + events.processing = FALSE; + } +} |