[gnome-calendar/gnome-3-18] month-view: don't show popover when clicking an invalid cell



commit f5298b49d05610c8387a2fac44de58442d5c2416
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Tue Oct 27 12:00:49 2015 -0200

    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 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/src/gcal-month-view.c b/src/gcal-month-view.c
index fdb77c5..299326d 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)
     {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]