Fixed the buglet that caused unwanted bogus drag & drop operations to

start, and added some initial resistance to the drag & drop operation
itself.

svn path=/trunk/; revision=3307
This commit is contained in:
Ettore Perazzoli
2000-05-31 02:19:51 +00:00
parent 0f0ab78afd
commit e4e38ebdc9
2 changed files with 31 additions and 4 deletions

View File

@ -1,3 +1,15 @@
2000-05-31 Ettore Perazzoli <ettore@helixcode.com>
* e-storage-set-view.c: New constant `DRAG_RESISTANCE'. New
members `button_x', `button_y' in `EStorageSetViewPrivate'.
(init): Initialize to zero.
(button_press_event): Set.
(motion_notify_event): Don't start drag unless the current x/y
position is farther than `DRAG_RESISTANCE', in any of the two
directions, from the original position of the button click.
(button_release_event): Always ungrab the pointer, even if
`selected_row_path' is NULL.
2000-05-31 Ettore Perazzoli <ettore@helixcode.com>
* evolution-shell-component.c (class_init): Eeek!

View File

@ -56,11 +56,16 @@ struct _EStorageSetViewPrivate {
/* Whether we are currently performing a drag from this view. */
int in_drag : 1;
/* X/Y position for the last button click. */
int button_x, button_y;
/* Button used for the drag. This is initialized in the `button_press_event'
handler. */
int drag_button;
};
#define DRAG_RESISTANCE 3
enum {
FOLDER_SELECTED,
@ -257,6 +262,8 @@ button_press_event (GtkWidget *widget,
return FALSE;
priv->drag_button = event->button;
priv->button_x = event->x;
priv->button_y = event->y;
/* KLUDGE ALERT. So look at this. We need to grab the pointer now, to check for
motion events and maybe start a drag operation. And GtkCTree seems to do it
@ -293,6 +300,10 @@ motion_notify_event (GtkWidget *widget,
if (priv->in_drag || priv->drag_button == 0)
return FALSE;
if (ABS (event->x - priv->button_x) < DRAG_RESISTANCE
&& ABS (event->y - priv->button_y) < DRAG_RESISTANCE)
return FALSE;
priv->in_drag = TRUE;
priv->dragged_row_path = priv->selected_row_path;
@ -315,14 +326,16 @@ button_release_event (GtkWidget *widget,
storage_set_view = E_STORAGE_SET_VIEW (widget);
priv = storage_set_view->priv;
if (! priv->in_drag && priv->selected_row_path != NULL) {
if (! priv->in_drag) {
gdk_pointer_ungrab (GDK_CURRENT_TIME);
gtk_grab_remove (widget);
gdk_flush ();
gtk_signal_emit (GTK_OBJECT (widget), signals[FOLDER_SELECTED],
priv->selected_row_path);
priv->selected_row_path = NULL;
if (priv->selected_row_path != NULL) {
gtk_signal_emit (GTK_OBJECT (widget), signals[FOLDER_SELECTED],
priv->selected_row_path);
priv->selected_row_path = NULL;
}
}
priv->selected_row_path_before_click = NULL;
@ -641,6 +654,8 @@ init (EStorageSetView *storage_set_view)
priv->dragged_row_path = NULL;
priv->selected_row_path_before_click = NULL;
priv->in_drag = FALSE;
priv->button_x = 0;
priv->button_y = 0;
storage_set_view->priv = priv;
}