Merge lp:~tkluck/grail/coordinate-transform into lp:grail

Proposed by Timo Kluck
Status: Merged
Merged at revision: 168
Proposed branch: lp:~tkluck/grail/coordinate-transform
Merge into: lp:grail
Diff against target: 60 lines (+14/-3)
3 files modified
configure.ac (+3/-3)
include/grail.h (+5/-0)
src/grail-api.c (+6/-0)
To merge this branch: bzr merge lp:~tkluck/grail/coordinate-transform
Reviewer Review Type Date Requested Status
Chase Douglas (community) Approve
Stephen M. Webb (community) Approve
Timo Kluck (community) Needs Resubmitting
Review via email: mp+73392@code.launchpad.net

This proposal supersedes a proposal from 2011-08-29.

To post a comment you must log in.
Revision history for this message
Chase Douglas (chasedouglas) wrote : Posted in a previous version of this proposal

Small note: I don't think the callback needs to be in a new deprecated api section. You can add it just below grail_get_contact_frame() in grail.h.

The changes use malloc to allocate memory. malloc is not signal context safe (see "safe functions" in the signal(2) manpage). You probably aren't aware, or might have forgotten if you were (I almost forgot :), that X input module event handling is run in signal context. If we were to merge this code, we would find it works just fine on many machines, usually fine but occasionally crashy on some machines, and very crashy on other machines. It's a very indeterminate bug, and very difficult to try to figure out!

I'm not sure how to get around this. You could try alloca, but it's not an officially "safe" function to call in signal context, and in general alloca use is frowned upon. You could try to compile it with c99 standard variable length arrays, but I don't know if that's safe either, and we would have to switch grail to a c99 library. Alternatively, you could allocate a constant number of touches, but there's no bounds on how many touches there might actually be. If you set it to 10 touches and then ran it on a 20 touch monitor and touched with 11 touches you would crash.

This all begins to feel like this isn't the best place to implement the transformation. Perhaps the transformation should be called from within utouch-frame instead.

I really appreciate the thought and effort you put into this! I don't want you to be discouraged by my disapproval, especially since it is likely due to something you weren't aware of. I look forward to reviewing another iteration of changes :).

review: Disapprove
Revision history for this message
Timo Kluck (tkluck) wrote :

Chase: thank you for your extensive comments! I hadn't realized the issue with being in a signal handler at all, so thanks for teaching me.

I moved the transformation code to utouch-frame. The code changes are now minimal and clean. Additionally, the patch doesn't have the issue I mentioned previously, of transformed frames containing pointers to non-transformed frames. Neither does it have the issue of having to call malloc.

Revision history for this message
Chase Douglas (chasedouglas) wrote :

The code looks reasonable. However it will depend on a newer version of utouch frame. Please add a commit to check for utouch-frame 1.2.0 in configure.ac.

review: Needs Fixing
170. By Timo Kluck

Bump version (note API extension)

Revision history for this message
Timo Kluck (tkluck) wrote :

Done. I also bumped the version because of the API extension, just like in utouch-frame.

I accidently tagged it with both "v1.2.0" and "v2.1.0", but I can't seem to remove the first one from launchpad.

review: Needs Resubmitting
Revision history for this message
Stephen M. Webb (bregma) wrote :

This looks OK now. Don;t worry about the tags.

review: Approve
Revision history for this message
Chase Douglas (chasedouglas) wrote :

Everything looks good now!

As with utouch-frame, I realize now that we don't want to tag this until we've runtime tested it and everything looks good.

For future reference, if you want to delete a tag on launchpad use the -d flag:

bzr tag -d lp:~tkluck/utouch-grail/coordinate-transform --delete v2.1.0

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'configure.ac'
2--- configure.ac 2011-08-09 21:52:30 +0000
3+++ configure.ac 2011-08-31 13:18:37 +0000
4@@ -1,7 +1,7 @@
5 # Initialize Autoconf
6 AC_PREREQ([2.60])
7 AC_INIT([Gesture Recognition And Instantiation Library],
8- [2.0.1],
9+ [2.1.0],
10 [],
11 [utouch-grail])
12 AC_CONFIG_SRCDIR([Makefile.am])
13@@ -12,7 +12,7 @@
14 AM_INIT_AUTOMAKE([foreign dist-bzip2])
15 AM_MAINTAINER_MODE
16
17-LIB_VERSION=2:0:1
18+LIB_VERSION=3:0:2
19 AC_SUBST([LIB_VERSION])
20
21 # Initialize libtool
22@@ -24,7 +24,7 @@
23
24 PKG_CHECK_MODULES([MTDEV], [mtdev >= 1.1])
25 PKG_CHECK_MODULES([EVEMU], [utouch-evemu >= 1.0.5])
26-PKG_CHECK_MODULES([FRAME], [utouch-frame >= 1.0])
27+PKG_CHECK_MODULES([FRAME], [utouch-frame >= 1.2])
28
29 AC_ARG_WITH([xi], AS_HELP_STRING([--with-xi], [Build with XI2.1 support]))
30 AM_CONDITIONAL([HAVE_XI], [test "x$with_xi" != "x"])
31
32=== modified file 'include/grail.h'
33--- include/grail.h 2011-05-18 16:41:41 +0000
34+++ include/grail.h 2011-08-31 13:18:37 +0000
35@@ -468,6 +468,11 @@
36
37 #endif
38
39+void GRAIL_PUBLIC grail_set_coordinate_transform_callback(struct grail *ge,
40+ utouch_coordinate_transform_cb callback,
41+ void *user_data);
42+
43+
44 #ifdef __cplusplus
45 }
46 #endif
47
48=== modified file 'src/grail-api.c'
49--- src/grail-api.c 2011-08-09 10:03:32 +0000
50+++ src/grail-api.c 2011-08-31 13:18:37 +0000
51@@ -321,3 +321,9 @@
52
53 return count > 0 ? count : ret;
54 }
55+
56+void GRAIL_PUBLIC grail_set_coordinate_transform_callback(struct grail *ge,
57+ utouch_coordinate_transform_cb callback,
58+ void *user_data) {
59+ utouch_frame_set_coordinate_transform_callback(ge->impl->fh, callback, user_data);
60+}

Subscribers

People subscribed via source and target branches