Fix bug where, after double-clicking to switch sheet view, a spurious release event... 20121009032003/pspp 20121011032101/pspp 20121012032055/pspp 20121013032614/pspp 20121014032548/pspp
authorJohn Darrington <john@darrington.wattle.id.au>
Mon, 8 Oct 2012 20:14:36 +0000 (22:14 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Mon, 8 Oct 2012 20:19:26 +0000 (22:19 +0200)
From http://developer.gnome.org/gdk/2.24/gdk-Event-Structures.html#GdkEventButton

  Double and triple-clicks result in a sequence of events being received. For
  double-clicks the order of events will be:

   1.  GDK_BUTTON_PRESS
   2.  GDK_BUTTON_RELEASE
   3.  GDK_BUTTON_PRESS
   4.  GDK_2BUTTON_PRESS
   5.  GDK_BUTTON_RELEASE

So what was happening was this:  When the var-name was double-clicked, the view switched
from VarView to DataView as soon as  event 4 (GDK_2BUTTON_PRESS) occured.  Then event 5
(GDK_BUTTON_RELEASE) occured.

Now the PsppSheetView object is written such that, it decides to edit a cell, on button
release event. Hence, whichever cell the pointer happended to be in, when the user lifts
his finger after double clicking, starts to be edited.

This change ignores button release events on the object unless a corresponding button press
event was seen.

src/ui/gui/pspp-sheet-view.c

index 4f3ce3b36786b2991fe393daadc3ba340a0ec42f..32627beffdcf2bd8c2db1a8a30f80e148dc80bda 100644 (file)
@@ -2635,6 +2635,10 @@ pspp_sheet_view_button_release_edit (PsppSheetView *tree_view,
   if (event->window != tree_view->priv->bin_window)
     return FALSE;
 
+  /* Ignore a released button, if that button wasn't depressed */
+  if (tree_view->priv->pressed_button != event->button)
+    return FALSE;
+
   if (!find_click (tree_view, event->x, event->y, &node, &column, &background_area,
                    &cell_area))
     return FALSE;