From 06ef0539e42ec6a32e8dfb5dda3a7e430c875e76 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Sun, 4 May 2025 17:15:47 -0300 Subject: [PATCH] views/week: Properly math out selection positions Commit 69ac7468e2ce3f introduced a regression since it calculates the height of the selection widget based on the Y position of end+1 cell, which is the first cell of the next column in the case of the last cell. Fix that by mathing out properly. Fixes: 69ac7468e2ce3f890e055810cab5d0341264497b Closes: https://gitlab.gnome.org/GNOME/gnome-calendar/-/issues/1397 --- src/gui/views/gcal-week-grid.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/gui/views/gcal-week-grid.c b/src/gui/views/gcal-week-grid.c index 2284d8b3..d3e53269 100644 --- a/src/gui/views/gcal-week-grid.c +++ b/src/gui/views/gcal-week-grid.c @@ -634,6 +634,8 @@ gcal_week_grid_size_allocate (GtkWidget *widget, if (gtk_widget_should_layout (self->selection.widget)) { gint selection_height; + gint start_row; + gint end_row; gint column; gint start; gint end; @@ -654,13 +656,16 @@ gcal_week_grid_size_allocate (GtkWidget *widget, start = start - end; } - column = start * 30 / MINUTES_PER_DAY; + column = (int) floor (start * 30 / (double) MINUTES_PER_DAY); -#define Y_POSITION(cell_) (round (((cell_) * 30 % MINUTES_PER_DAY) * minutes_height)) +#define Y_POSITION(row_) ((gint) round (((row_) * 30) * minutes_height)) + + start_row = start - column * 48; + end_row = (end + 1) - column * 48; x = column * column_width; - y = Y_POSITION (start); - selection_height = Y_POSITION (end + 1) - y; + y = Y_POSITION (start_row); + selection_height = Y_POSITION (end_row) - y; #undef Y_POSITION