gui/window: Set parent widget as last focus when event widget is unfocusable
When selecting an event with a pointer, the keyboard-focused widget was being set instead of the last focus widget, which was then refocused after the event popover closed. This patch fixes that bug by only setting the parent widget as the last focus widget if the event widget itself is unfocusable, like in the agenda view. The `GtkWidget:focus-on-click` property is already enabled, so it takes care of refocusing the event widget if it's focusable. Commit https://gitlab.gnome.org/GNOME/gnome-calendar/-/commit/a3fb57939a307f5b661cc2f205e562f43a0a31fa technically fixed https://gitlab.gnome.org/GNOME/gnome-calendar/-/issues/915, but this patch solidifies the commit. Closes https://gitlab.gnome.org/GNOME/gnome-calendar/-/issues/915
This commit is contained in:
+13
-1
@@ -772,6 +772,18 @@ day_selected (GcalWindow *self)
|
||||
update_active_date (self, gcal_view_get_date (GCAL_VIEW (self->date_chooser)));
|
||||
}
|
||||
|
||||
static GtkWidget*
|
||||
find_first_focusable_widget (GtkWidget *widget)
|
||||
{
|
||||
GtkWidget *aux = widget;
|
||||
|
||||
while (aux && !gtk_widget_get_focusable (aux))
|
||||
aux = gtk_widget_get_parent (aux);
|
||||
|
||||
g_assert (GTK_IS_WIDGET (aux));
|
||||
return aux;
|
||||
}
|
||||
|
||||
static void
|
||||
event_activated (GcalView *view,
|
||||
GcalEventWidget *event_widget,
|
||||
@@ -779,7 +791,7 @@ event_activated (GcalView *view,
|
||||
{
|
||||
GcalWindow *self = GCAL_WINDOW (user_data);
|
||||
|
||||
g_set_weak_pointer (&self->last_focused_widget, gtk_root_get_focus (GTK_ROOT (self)));
|
||||
g_set_weak_pointer (&self->last_focused_widget, find_first_focusable_widget (GTK_WIDGET (event_widget)));
|
||||
|
||||
gcal_event_widget_show_preview (event_widget, event_preview_cb, user_data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user