From 855fea34bf3dca653dcb945c8d2ee479fb1b47cb Mon Sep 17 00:00:00 2001 From: Hari Rana Date: Sun, 22 Mar 2026 11:36:36 -0400 Subject: [PATCH] window: Only clear `last_focused_widget` if the widget has been focused When opening the event editor dialog as a new event, `set_new_event_mode()` immediately tries to focus the last focused widget, which won't work because it is unfocusable. `focus_last_focused_widget()` then clears clears the pointer regardless of whether the widget has successfully grabbed focus or not. So, we want to only clear focus if the widget has successfully grabbed focus. Related: https://gitlab.gnome.org/GNOME/gnome-calendar/-/issues/1566 Part-of: --- src/gui/gcal-window.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/gui/gcal-window.c b/src/gui/gcal-window.c index 60e6cc91..7dd4dd65 100644 --- a/src/gui/gcal-window.c +++ b/src/gui/gcal-window.c @@ -223,11 +223,8 @@ update_today_action_enabled (GcalWindow *window) static void focus_last_focused_widget (GcalWindow *self) { - if (self->last_focused_widget) - { - gtk_widget_grab_focus (self->last_focused_widget); - g_clear_weak_pointer (&self->last_focused_widget); - } + if (self->last_focused_widget && gtk_widget_grab_focus (self->last_focused_widget)) + g_clear_weak_pointer (&self->last_focused_widget); } static gchar*