aboutsummaryrefslogtreecommitdiff
path: root/fastiv-view.c
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2021-11-12 07:23:24 +0100
committerPřemysl Eric Janouch <p@janouch.name>2021-11-22 13:01:43 +0100
commit0bec06b55d847a9faad66f5a3b8331a9eb6bde03 (patch)
tree36980b91d3b802e751c163c836b6edaa81127233 /fastiv-view.c
parent97109b1e58a68ef3cb9b5f85d4ea8bb5a6ff8cd3 (diff)
downloadfiv-0bec06b55d847a9faad66f5a3b8331a9eb6bde03.tar.gz
fiv-0bec06b55d847a9faad66f5a3b8331a9eb6bde03.tar.xz
fiv-0bec06b55d847a9faad66f5a3b8331a9eb6bde03.zip
Fix further focus issues
Diffstat (limited to 'fastiv-view.c')
-rw-r--r--fastiv-view.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/fastiv-view.c b/fastiv-view.c
index 4efb8be..f200bd1 100644
--- a/fastiv-view.c
+++ b/fastiv-view.c
@@ -276,6 +276,20 @@ fastiv_view_draw(GtkWidget *widget, cairo_t *cr)
return TRUE;
}
+static gboolean
+fastiv_view_button_press_event(GtkWidget *widget, GdkEventButton *event)
+{
+ GTK_WIDGET_CLASS(fastiv_view_parent_class)
+ ->button_press_event(widget, event);
+
+ if (event->button == GDK_BUTTON_PRIMARY &&
+ gtk_widget_get_focus_on_click(widget))
+ gtk_widget_grab_focus(widget);
+
+ // TODO(p): Use for left button scroll drag, which may rather be a gesture.
+ return FALSE;
+}
+
#define SCALE_STEP 1.4
static gboolean
@@ -361,6 +375,7 @@ fastiv_view_class_init(FastivViewClass *klass)
widget_class->size_allocate = fastiv_view_size_allocate;
widget_class->realize = fastiv_view_realize;
widget_class->draw = fastiv_view_draw;
+ widget_class->button_press_event = fastiv_view_button_press_event;
widget_class->scroll_event = fastiv_view_scroll_event;
widget_class->key_press_event = fastiv_view_key_press_event;