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
This commit is contained in:
Georges Basile Stavracas Neto
2015-10-27 12:00:49 -02:00
parent 6afa9b98f6
commit b6bec55185
+9 -1
View File
@@ -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)
{