From e88f77802b267266844a5661dbb4be4e8aa93600 Mon Sep 17 00:00:00 2001 From: Hari Rana Date: Mon, 23 Feb 2026 21:23:03 -0500 Subject: [PATCH] views/month-cell: Override `focus()` virtual function Without this patch, focus immediately goes to the "Previous Month" button at startup, for some unknown reason. So, as a workaround, skip focus if the root cannot retrieve the current focused widget. Part-of: --- src/gui/views/gcal-month-cell.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/gui/views/gcal-month-cell.c b/src/gui/views/gcal-month-cell.c index 8cec9539..60d4eec7 100644 --- a/src/gui/views/gcal-month-cell.c +++ b/src/gui/views/gcal-month-cell.c @@ -344,6 +344,23 @@ on_breakpoint_changed_cb (GcalMonthCell *self) } +/* + * GtkWidget overrides + */ + +static gboolean +gcal_month_cell_focus (GtkWidget *widget, + GtkDirectionType direction) +{ + GtkRoot *root = gtk_widget_get_root (widget); + + if (gtk_root_get_focus (root) == NULL) + return FALSE; + + return GTK_WIDGET_CLASS (gcal_month_cell_parent_class)->focus (widget, direction); +} + + /* * GObject overrides */ @@ -414,6 +431,8 @@ gcal_month_cell_class_init (GcalMonthCellClass *klass) object_class->set_property = gcal_month_cell_set_property; object_class->get_property = gcal_month_cell_get_property; + widget_class->focus = gcal_month_cell_focus; + signals[SHOW_OVERFLOW] = g_signal_new ("show-overflow", GCAL_TYPE_MONTH_CELL, G_SIGNAL_RUN_LAST,