summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Garcia Campos <[email protected]>2013-05-07 17:45:01 +0200
committerraveit65 <[email protected]>2017-08-31 13:28:21 +0200
commitf7d2ae99fb4a5e3d3a72b6af9300f286069a6d0d (patch)
tree6f353ae0853e58f35d35554519577e065244861c
parent396585d62f8430da79520dc0d7e304581a553c1f (diff)
downloadatril-f7d2ae99fb4a5e3d3a72b6af9300f286069a6d0d.tar.bz2
atril-f7d2ae99fb4a5e3d3a72b6af9300f286069a6d0d.tar.xz
ev-view: Forward key events to the focused form field
This allows to move between words with CTRL+Left/Right in text form fields instead of rotating the view. https://bugzilla.gnome.org/show_bug.cgi?id=699630 origin commit: https://git.gnome.org/browse/evince/commit/?id=ac22e8f
-rw-r--r--libview/ev-view.c52
1 files changed, 32 insertions, 20 deletions
diff --git a/libview/ev-view.c b/libview/ev-view.c
index 14a9fae0..a4915746 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -4519,6 +4519,36 @@ ev_view_button_release_event (GtkWidget *widget,
}
static gboolean
+ev_view_forward_key_event_to_focused_child (EvView *view,
+ GdkEventKey *event)
+{
+ GtkWidget *child_widget = NULL;
+ GdkEventKey *new_event;
+ gboolean handled;
+
+ if (view->window_child_focus) {
+ child_widget = view->window_child_focus->window;
+ } else if (view->children) {
+ EvViewChild *child = (EvViewChild *)view->children->data;
+
+ child_widget = child->widget;
+ } else {
+ return FALSE;
+ }
+
+ new_event = (GdkEventKey *) gdk_event_copy ((GdkEvent *)event);
+ g_object_unref (new_event->window);
+ new_event->window = gtk_widget_get_window (child_widget);
+ if (new_event->window)
+ g_object_ref (new_event->window);
+ gtk_widget_realize (child_widget);
+ handled = gtk_widget_event (child_widget, (GdkEvent *)new_event);
+ gdk_event_free ((GdkEvent *)new_event);
+
+ return handled;
+}
+
+static gboolean
ev_view_key_press_event (GtkWidget *widget,
GdkEventKey *event)
{
@@ -4527,26 +4557,8 @@ ev_view_key_press_event (GtkWidget *widget,
if (!view->document)
return FALSE;
- if (!gtk_widget_has_focus (widget)) {
- /* Forward key events to current focused window child */
- if (view->window_child_focus) {
- GdkEventKey *new_event;
- gboolean handled;
-
- new_event = (GdkEventKey *) gdk_event_copy ((GdkEvent *)event);
- g_object_unref (new_event->window);
- new_event->window = gtk_widget_get_window (view->window_child_focus->window);
- if (new_event->window)
- g_object_ref (new_event->window);
- gtk_widget_realize (view->window_child_focus->window);
- handled = gtk_widget_event (view->window_child_focus->window, (GdkEvent *)new_event);
- gdk_event_free ((GdkEvent *)new_event);
-
- return handled;
- }
-
- return FALSE;
- }
+ if (!gtk_widget_has_focus (widget))
+ return ev_view_forward_key_event_to_focused_child (view, event);
return gtk_bindings_activate_event (G_OBJECT (widget), event);
}