Make the browser grab focus when clicked

This commit is contained in:
Přemysl Eric Janouch 2021-11-20 18:45:33 +01:00
parent 35500b8697
commit 5ebfebb8fc
Signed by: p
GPG Key ID: A0420B94F92B9493
1 changed files with 8 additions and 0 deletions

View File

@ -412,9 +412,14 @@ fastiv_browser_draw(GtkWidget *widget, cairo_t *cr)
static gboolean
fastiv_browser_button_press_event(GtkWidget *widget, GdkEventButton *event)
{
GTK_WIDGET_CLASS(fastiv_browser_parent_class)
->button_press_event(widget, event);
FastivBrowser *self = FASTIV_BROWSER(widget);
if (event->type != GDK_BUTTON_PRESS || event->state != 0)
return FALSE;
if (event->button == 1)
gtk_widget_grab_focus(widget);
const Entry *entry = entry_at(self, event->x, event->y);
if (!entry)
@ -437,6 +442,9 @@ fastiv_browser_button_press_event(GtkWidget *widget, GdkEventButton *event)
gboolean
fastiv_browser_motion_notify_event(GtkWidget *widget, GdkEventMotion *event)
{
GTK_WIDGET_CLASS(fastiv_browser_parent_class)
->motion_notify_event(widget, event);
FastivBrowser *self = FASTIV_BROWSER(widget);
if (event->state != 0)
return FALSE;