X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=libchimara%2Finput.c;h=9e7eea0cf533242cc7ccbc15f0ed82beefe9385c;hb=4b0bbd6bb235b4cad89d321cdd7f570610a97712;hp=a2e0e4a8bd49d88d0f017a1efda711c4569b4b0a;hpb=5bec9bc0e9bea45cd553116e5d7fd125564d8dbe;p=rodin%2Fchimara.git diff --git a/libchimara/input.c b/libchimara/input.c index a2e0e4a..9e7eea0 100644 --- a/libchimara/input.c +++ b/libchimara/input.c @@ -392,6 +392,35 @@ glk_cancel_line_event(winid_t win, event_t *event) } } +/* Helper function: Turn off shutdown key-press-event signal handler */ +static gboolean +turn_off_handler(GNode *node) +{ + winid_t win = node->data; + g_signal_handler_block(win->widget, win->shutdown_keypress_handler); + return FALSE; /* don't stop */ +} + +/* Internal function: Callback for signal key-press-event while waiting for shutdown. */ +gboolean +on_shutdown_key_press_event(GtkWidget *widget, GdkEventKey *event, winid_t win) +{ + ChimaraGlk *glk = CHIMARA_GLK(gtk_widget_get_ancestor(widget, CHIMARA_TYPE_GLK)); + g_assert(glk); + CHIMARA_GLK_USE_PRIVATE(glk, priv); + + /* Turn off all the signal handlers */ + if(priv->root_window) + g_node_traverse(priv->root_window, G_IN_ORDER, G_TRAVERSE_LEAVES, -1, (GNodeTraverseFunc)turn_off_handler, NULL); + + /* Signal the Glk library that it can shut everything down now */ + g_mutex_lock(priv->shutdown_lock); + g_cond_signal(priv->shutdown_key_pressed); + g_mutex_unlock(priv->shutdown_lock); + + return TRUE; /* block the event */ +} + /* Internal function: General callback for signal key-press-event on a text buffer or text grid window. Used in character input on both text buffers and grids. Blocked when not in use. */ gboolean on_char_input_key_press_event(GtkWidget *widget, GdkEventKey *event, winid_t win)