From 084a495f5c0d57849c2426cb64e48be7054ea9bb Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Sat, 8 Nov 2025 20:08:56 -0300 Subject: [PATCH 1/2] views/month: Hide invisible rows Change the child-visible property of rows when allocating. It's safe to do in allocation because it doesn't affect layout, just rendering. Related: https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/402 Part-of: --- src/gui/views/gcal-month-view.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gui/views/gcal-month-view.c b/src/gui/views/gcal-month-view.c index f6afb6f29..dd5ea0552 100644 --- a/src/gui/views/gcal-month-view.c +++ b/src/gui/views/gcal-month-view.c @@ -1445,6 +1445,7 @@ gcal_month_view_size_allocate (GtkWidget *widget, { GtkAllocation row_allocation; GtkWidget *row; + gboolean child_visible; row = g_ptr_array_index (self->week_rows, i); @@ -1457,6 +1458,9 @@ gcal_month_view_size_allocate (GtkWidget *widget, #undef ROW_Y + child_visible = (row_allocation.y + row_allocation.height > header_height) && row_allocation.y < height; + gtk_widget_set_child_visible (row, child_visible); + gtk_widget_size_allocate (row, &row_allocation, baseline); } -- GitLab From 564ce76349d2d7595c14350c0b3ab608a758f84e Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Sat, 8 Nov 2025 22:02:49 -0300 Subject: [PATCH 2/2] views/month: Don't manually set can-focus property Now that we're meddling with child visibility, hidden rows shouldn't be focusable. At least that's what Hari discovered :) Part-of: --- src/gui/views/gcal-month-view.c | 36 --------------------------------- 1 file changed, 36 deletions(-) diff --git a/src/gui/views/gcal-month-view.c b/src/gui/views/gcal-month-view.c index dd5ea0552..b0b2e1977 100644 --- a/src/gui/views/gcal-month-view.c +++ b/src/gui/views/gcal-month-view.c @@ -424,41 +424,6 @@ update_week_ranges (GcalMonthView *self, dump_row_ranges (self); } -static void -update_row_visuals (GcalMonthView *self) -{ - g_autoptr (GcalRange) first_visible_row_range = NULL; - g_autoptr (GcalRange) last_visible_row_range = NULL; - g_autoptr (GcalRange) union_range = NULL; - g_autoptr (GDateTime) start = NULL; - g_autoptr (GDateTime) middle = NULL; - g_autoptr (GDateTime) end = NULL; - GcalMonthViewRow *first_visible_row; - GcalMonthViewRow *last_visible_row; - - first_visible_row = g_ptr_array_index (self->week_rows, FIRST_VISIBLE_ROW_INDEX); - first_visible_row_range = gcal_month_view_row_get_range (first_visible_row); - - last_visible_row = g_ptr_array_index (self->week_rows, LAST_VISIBLE_ROW_INDEX); - last_visible_row_range = gcal_month_view_row_get_range (last_visible_row); - - union_range = gcal_range_union (first_visible_row_range, last_visible_row_range); - start = gcal_range_get_start (union_range); - end = gcal_range_get_end (union_range); - middle = g_date_time_add_days (start, gcal_date_time_compare_date (end, start) / 2); - - for (gint i = 0; i < self->week_rows->len; i++) - { - GcalMonthViewRow *row; - gboolean can_focus; - - row = g_ptr_array_index (self->week_rows, i); - can_focus = i >= FIRST_VISIBLE_ROW_INDEX && i <= LAST_VISIBLE_ROW_INDEX; - - gtk_widget_set_can_focus (GTK_WIDGET (row), can_focus); - } -} - static inline gint get_grid_height (GcalMonthView *self) { @@ -1198,7 +1163,6 @@ gcal_month_view_set_date (GcalView *view, #endif update_week_ranges (self, date); - update_row_visuals (self); gcal_timeline_subscriber_range_changed (GCAL_TIMELINE_SUBSCRIBER (view)); -- GitLab