[longomatch] Delay move events 200ms
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Delay move events 200ms
- Date: Mon, 7 Jul 2014 11:30:39 +0000 (UTC)
commit 2491acb487303924fc4c01225192b29731094888
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Thu Jun 19 18:03:43 2014 +0200
Delay move events 200ms
LongoMatch.Drawing.Cairo/WidgetWrapper.cs | 20 +++++++++++++++++++-
1 files changed, 19 insertions(+), 1 deletions(-)
---
diff --git a/LongoMatch.Drawing.Cairo/WidgetWrapper.cs b/LongoMatch.Drawing.Cairo/WidgetWrapper.cs
index ff4135b..190a36c 100644
--- a/LongoMatch.Drawing.Cairo/WidgetWrapper.cs
+++ b/LongoMatch.Drawing.Cairo/WidgetWrapper.cs
@@ -40,6 +40,8 @@ namespace LongoMatch.Drawing.Cairo
DrawingArea widget;
int currentWidth, currentHeight;
+ bool canMove;
+ uint timerID;
public WidgetWrapper (DrawingArea widget)
{
@@ -162,16 +164,27 @@ namespace LongoMatch.Drawing.Cairo
}
return bm;
}
+
+ bool ReadyToMove () {
+ canMove = true;
+ return false;
+ timerID = 0;
+ }
void HandleMotionNotifyEvent (object o, MotionNotifyEventArgs args)
{
- if (MotionEvent != null) {
+ if (MotionEvent != null && canMove) {
MotionEvent (new Point (args.Event.X, args.Event.Y));
}
}
void HandleButtonReleaseEvent (object o, ButtonReleaseEventArgs args)
{
+ if (timerID != 0) {
+ GLib.Source.Remove (timerID);
+ timerID = 0;
+ }
+
if (ButtonReleasedEvent != null) {
ButtonType bt;
ButtonModifier bm;
@@ -184,6 +197,11 @@ namespace LongoMatch.Drawing.Cairo
void HandleButtonPressEvent (object o, ButtonPressEventArgs args)
{
+ /* Fast button clicks sometimes produced a small move that
+ * should be ignored. Start moving only when the button has been
+ * pressed for more than 200ms */
+ canMove = false;
+ timerID = GLib.Timeout.Add (200, ReadyToMove);
if (ButtonPressEvent != null) {
ButtonType bt;
ButtonModifier bm;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]