From c50ee16f19a09dd1fd6afd29b9758e339fb5468f Mon Sep 17 00:00:00 2001 From: fliep Date: Sun, 1 Mar 2009 22:39:25 +0000 Subject: [PATCH] Refined previous update so that arrow keys and other navigation keys aren't redirected --- src/input.c | 14 ++++++++++++-- src/window.c | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/input.c b/src/input.c index 22f321c..bcd5116 100644 --- a/src/input.c +++ b/src/input.c @@ -236,10 +236,20 @@ on_window_key_press_event(GtkWidget *widget, GdkEventKey *event, winid_t win) /* If this is a text grid window, and line input is active, then redirect the key press to the line input GtkEntry */ if( win->type == wintype_TextGrid && (win->input_request_type == INPUT_REQUEST_LINE || win->input_request_type == INPUT_REQUEST_LINE_UNICODE) ) { - gboolean retval = TRUE; - g_signal_emit_by_name(win->input_entry, "key-press-event", event, &retval); + if(event->keyval == GDK_Up || event->keyval == GDK_KP_Up + || event->keyval == GDK_Down || event->keyval == GDK_KP_Down + || event->keyval == GDK_Left || event->keyval == GDK_KP_Left + || event->keyval == GDK_Right || event->keyval == GDK_KP_Right + || event->keyval == GDK_Tab || event->keyval == GDK_KP_Tab + || event->keyval == GDK_Page_Up || event->keyval == GDK_KP_Page_Up + || event->keyval == GDK_Page_Down || event->keyval == GDK_KP_Page_Down + || event->keyval == GDK_Home || event->keyval == GDK_KP_Home + || event->keyval == GDK_End || event->keyval == GDK_KP_End) + return FALSE; /* Don't redirect these keys */ gtk_widget_grab_focus(win->input_entry); gtk_editable_set_position(GTK_EDITABLE(win->input_entry), -1); + gboolean retval = TRUE; + g_signal_emit_by_name(win->input_entry, "key-press-event", event, &retval); return retval; /* Block this key event if the entry handled it */ } if(win->input_request_type != INPUT_REQUEST_CHARACTER && diff --git a/src/window.c b/src/window.c index 8351378..204daa5 100644 --- a/src/window.c +++ b/src/window.c @@ -385,7 +385,7 @@ glk_window_open(winid_t split, glui32 method, glui32 size, glui32 wintype, } win->width = (glui32)(win->widget->allocation.width / win->unit_width); win->height = (glui32)(win->widget->allocation.height / win->unit_height); - + /* Mark the cursor position */ GtkTextIter begin; GtkTextBuffer *buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(win->widget) ); -- 2.30.2