2006-11-21 Tomas Junnonen <tomas.junnonen@nokia.com>
authorMichael Dominic Kostrzewa <michael.kostrzewa@nokia.com>
Tue, 21 Nov 2006 11:16:54 +0000 (11:16 +0000)
committerMichael Dominic Kostrzewa <michael.kostrzewa@nokia.com>
Tue, 21 Nov 2006 11:16:54 +0000 (11:16 +0000)
* hildon-widgets/Makefile.am:
* hildon-widgets/hildon-finger.c:
* hildon-widgets/hildon-finger.h: Finger events stuff.

ChangeLog
hildon-widgets/Makefile.am
hildon-widgets/hildon-finger.c [new file with mode: 0644]
hildon-widgets/hildon-finger.h [new file with mode: 0644]

index e072a67..cb339ea 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-11-21  Tomas Junnonen <tomas.junnonen@nokia.com>
+
+       * hildon-widgets/Makefile.am:
+       * hildon-widgets/hildon-finger.c:
+       * hildon-widgets/hildon-finger.h: Finger events stuff.
+
 2006-11-08  Michael Dominic Kostrzewa  <michael.kostrzewa@nokia.com> 
 
        * hildon-widgets/hildon-libs.c:
index badc28b..d29c14d 100644 (file)
@@ -114,6 +114,8 @@ libhildonwidgets_la_SOURCES = \
        hildon-color-chooser-dialog.h \
        hildon-color-chooser-button.c \
        hildon-color-chooser-button.h \
+       hildon-finger.c \
+       hildon-finger.h \
        $(hildonlibs_built_headers) \
        $(hildonlibs_built_cfiles)
 
@@ -175,7 +177,8 @@ hildonwidgetsincludeinst_DATA = \
        hildon-plugin-widget.h \
        hildon-color-chooser.h \
        hildon-color-chooser-dialog.h \
-       hildon-color-chooser-button.h
+       hildon-color-chooser-button.h \
+       hildon-finger.h
 
 headers_to_scan_for_enums = $(hildonwidgetsincludeinst_DATA)
  
diff --git a/hildon-widgets/hildon-finger.c b/hildon-widgets/hildon-finger.c
new file mode 100644 (file)
index 0000000..0326d6d
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * This file is part of hildon-libs
+ *
+ * Copyright (C) 2006 Nokia Corporation, all rights reserved.
+ *
+ * Contact: Michael Dominic Kostrzewa <michael.kostrzewa@nokia.com>
+ *  Author: Tomas Junnonen <tomas.junnonen@nokia.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; version 2.1 of
+ * the License.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+/**
+ * SECTION:hildon-finger
+ * @short_description: Helper functions for finger functionality
+ *
+ */
+
+#include <gdk/gdk.h>
+#include "hildon-finger.h"
+
+#define HILDON_FINGER_BUTTON 8
+#define HILDON_FINGER_ALT_BUTTON 1
+#define HILDON_FINGER_ALT_MASK GDK_MOD4_MASK
+#define HILDON_FINGER_SIMULATE_BUTTON 2
+
+/**
+ * hildon_button_event_is_finger:
+ * 
+ * Check if the event is a finger event
+ **/
+gboolean hildon_button_event_is_finger (GdkEventButton *event)
+{
+  gdouble pressure;
+
+  if (gdk_event_get_axis ((GdkEvent*)event, GDK_AXIS_PRESSURE, &pressure) &&
+      pressure > HILDON_FINGER_PRESSURE_THRESHOLD)
+    return TRUE;
+
+  if (event->button == HILDON_FINGER_BUTTON)
+    return TRUE;
+
+  if (event->button == HILDON_FINGER_ALT_BUTTON &&
+      event->state & HILDON_FINGER_ALT_MASK)
+    return TRUE;
+
+  if (event->button == HILDON_FINGER_SIMULATE_BUTTON)
+    return TRUE;
+
+  return FALSE;
+}
diff --git a/hildon-widgets/hildon-finger.h b/hildon-widgets/hildon-finger.h
new file mode 100644 (file)
index 0000000..570fe47
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * This file is part of hildon-libs
+ *
+ * Copyright (C) 2006 Nokia Corporation, all rights reserved.
+ *
+ * Contact: Michael Dominic Kostrzewa <michael.kostrzewa@nokia.com>
+ *  Author: Tomas Junnonen <tomas.junnonen@nokia.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; version 2.1 of
+ * the License.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#ifndef __HILDON_FINGER_H__
+#define __HILDON_FINGER_H__
+
+#include <gdk/gdkevents.h>
+
+G_BEGIN_DECLS
+
+#define HILDON_FINGER_PRESSURE_THRESHOLD 0.4
+
+gboolean hildon_button_event_is_finger (GdkEventButton *event);
+
+G_END_DECLS
+#endif /* HILDON_FINGER_H */