From b6bec55185ca92bdf03bbdec91cfdcd033d65127 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Tue, 27 Oct 2015 12:00:49 -0200 Subject: [PATCH] month-view: don't show popover when clicking an invalid cell Because we're using a simple (gint) cast to round y value of the clicked point, a negative y was rounding to a valid cell position and showing the popover even when the user clicked on the blank cells before the actual month view. Fix that by properly checking if y is negative. https://bugzilla.gnome.org/show_bug.cgi?id=755910 --- src/gcal-month-view.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/gcal-month-view.c b/src/gcal-month-view.c index fdb77c52..299326da 100644 --- a/src/gcal-month-view.c +++ b/src/gcal-month-view.c @@ -186,6 +186,9 @@ static gint real_cell (gint cell, gboolean rtl) { + if (cell < 0) + return cell; + return rtl ? MIRROR (cell, 0, 7) - 1 : cell; } @@ -349,7 +352,12 @@ gather_button_event_data (GcalMonthView *view, y = y - start_grid_y - first_row_gap * cell_height; - cell = 7 * (gint)(y / cell_height) + (gint)(x / cell_width); + /* When we're dealing with 5-row months, the first_row_gap + * is never big enought, and (gint)(y / cell_height) always + * rounds to 0, resulting in a valid cell number when it is + * actually invalid. + */ + cell = y < 0 ? -1 : 7 * (gint)(y / cell_height) + (gint)(x / cell_width); if (out_on_indicator != NULL) {