From: Michael Dominic Kostrzewa Date: Tue, 21 Nov 2006 11:16:54 +0000 (+0000) Subject: 2006-11-21 Tomas Junnonen X-Git-Url: https://vcs.maemo.org/git/?a=commitdiff_plain;h=186a62d22a0fe52714975092fa0f6b31202ea662;p=hildon 2006-11-21 Tomas Junnonen * hildon-widgets/Makefile.am: * hildon-widgets/hildon-finger.c: * hildon-widgets/hildon-finger.h: Finger events stuff. --- diff --git a/ChangeLog b/ChangeLog index e072a67..cb339ea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-11-21 Tomas Junnonen + + * hildon-widgets/Makefile.am: + * hildon-widgets/hildon-finger.c: + * hildon-widgets/hildon-finger.h: Finger events stuff. + 2006-11-08 Michael Dominic Kostrzewa * hildon-widgets/hildon-libs.c: diff --git a/hildon-widgets/Makefile.am b/hildon-widgets/Makefile.am index badc28b..d29c14d 100644 --- a/hildon-widgets/Makefile.am +++ b/hildon-widgets/Makefile.am @@ -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 index 0000000..0326d6d --- /dev/null +++ b/hildon-widgets/hildon-finger.c @@ -0,0 +1,64 @@ +/* + * This file is part of hildon-libs + * + * Copyright (C) 2006 Nokia Corporation, all rights reserved. + * + * Contact: Michael Dominic Kostrzewa + * Author: Tomas Junnonen + * + * 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 +#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 index 0000000..570fe47 --- /dev/null +++ b/hildon-widgets/hildon-finger.h @@ -0,0 +1,38 @@ +/* + * This file is part of hildon-libs + * + * Copyright (C) 2006 Nokia Corporation, all rights reserved. + * + * Contact: Michael Dominic Kostrzewa + * Author: Tomas Junnonen + * + * 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 + +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 */