[grits] Add motion threshold when clicking objects
- From: Andy Spencer <andys src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grits] Add motion threshold when clicking objects
- Date: Wed, 23 Jan 2013 06:48:43 +0000 (UTC)
commit d55c77bbf477e582a8525ac831ad97b035b8185d
Author: Andy Spencer <andy753421 gmail com>
Date: Wed Jan 23 06:46:16 2013 +0000
Add motion threshold when clicking objects
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 | 8 +++++---
src/objects/grits-object.h | 5 ++++-
2 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/src/objects/grits-object.c b/src/objects/grits-object.c
index 2eb6b5c..2812b9e 100644
--- a/src/objects/grits-object.c
+++ b/src/objects/grits-object.c
@@ -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) {
diff --git a/src/objects/grits-object.h b/src/objects/grits-object.h
index 9969278..728ac72 100644
--- a/src/objects/grits-object.h
+++ b/src/objects/grits-object.h
@@ -36,11 +36,14 @@
#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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]