]> Pileus Git - grits/commitdiff
Add motion threshold when clicking objects
authorAndy Spencer <andy753421@gmail.com>
Wed, 23 Jan 2013 06:46:16 +0000 (06:46 +0000)
committerAndy Spencer <andy753421@gmail.com>
Wed, 23 Jan 2013 06:48:16 +0000 (06:48 +0000)
This allows a click to go though even if a small amount of mouse motion
is detected. Currently set to 8 motion events, it might be better to use
pixels instead of events.

src/objects/grits-object.c
src/objects/grits-object.h

index 2eb6b5c2af704ad619b9f4daa7f6e530db052603..2812b9e3d647e72a9919b77936e3e4849237b367 100644 (file)
@@ -211,11 +211,13 @@ gboolean grits_object_event(GritsObject *object, GdkEvent *event)
 
        /* Handle button click */
        if (sig == SIG_BUTTON_PRESS)
-               object->state.clicking = TRUE;
+               object->state.clicking  = GRITS_CLICK_THRESHOLD;
+       if (sig == SIG_MOTION && object->state.clicking)
+               object->state.clicking -= 1;
        if (sig == SIG_BUTTON_RELEASE && object->state.clicking)
                g_signal_emit(object, signals[SIG_CLICKED], 0, event, &rval);
-       if (sig == SIG_BUTTON_RELEASE || sig == SIG_MOTION)
-               object->state.clicking = FALSE;
+       if (sig == SIG_BUTTON_RELEASE)
+               object->state.clicking  = 0;
 
        /* Emit this signal */
        if (rval == FALSE) {
index 9969278b5114891034bb9817cbd692b698d2c29c..728ac720d9165bd2658ca2121091e8751906d04a 100644 (file)
 #define GRITS_SKIP_CENTER  (1<<2)
 #define GRITS_SKIP_STATE   (1<<3)
 
+/* Mouse move threshold for clicking */
+#define GRITS_CLICK_THRESHOLD 8
+
 /* Picking states */
 typedef struct {
        guint picked   : 1;
        guint selected : 1;
-       guint clicking : 1;
+       guint clicking : 6;
 } GritsState;
 
 typedef struct _GritsObject      GritsObject;