path: root/apps/action.c
diff options
authorThomas Martitz <>2012-07-18 10:25:32 +0200
committerThomas Martitz <>2012-08-15 23:08:26 +0200
commit54e6bafada0f0b55246e208c3ffb85394756135f (patch)
treeb68be330724ebab3cf105417c9025a18423b1795 /apps/action.c
parent3c002659fb80d56a3f0ae30b282a9ada5a028c32 (diff)
Fix missed buttons in action.c if action_wait_for_release() was called
with no button pressed. If e.g. two yesno screens directly follow each other the button release of the first one was incorrectly accepted in the second one. The fix exposed another problem in action.c if action_wait_for_release() is called when no button is actually pressed. The next press was silently eaten. This time re-introducing FS#12723 is avoided by leaving the offending hunk out in yesno.c. Change-Id: Icfe57375067f51f5c8177f3585cd47ceec9dcf0d
Diffstat (limited to 'apps/action.c')
1 files changed, 24 insertions, 0 deletions
diff --git a/apps/action.c b/apps/action.c
index 5ebcbf771b..2492a7d08e 100644
--- a/apps/action.c
+++ b/apps/action.c
@@ -232,11 +232,30 @@ static int get_action_worker(int context, int timeout,
/* Data from sys events can be pulled with button_get_data
* multimedia button presses don't go through the action system */
if (button == BUTTON_NONE || button & (SYS_EVENT|BUTTON_MULTIMEDIA))
+ {
+ /* no button pressed so no point in waiting for release */
+ if (button == BUTTON_NONE)
+ wait_for_release = false;
return button;
+ }
/* the special redraw button should result in a screen refresh */
if (button == BUTTON_REDRAW)
+ /* if action_wait_for_release() was called without a button being pressed
+ * then actually waiting for release would do the wrong thing, i.e.
+ * the next key press is entirely ignored. So, if here comes a normal
+ * button press (neither release nor repeat) the press is a fresh one and
+ * no point in waiting for release
+ *
+ * This logic doesn't work for touchscreen which can send normal
+ * button events repeatedly before the first repeat (as in BUTTON_REPEAT).
+ * These cannot be distinguished from the very first touch
+ * but there's nothing we can do about it here */
+ if ((button & (BUTTON_REPEAT|BUTTON_REL)) == 0)
+ wait_for_release = false;
/* Don't send any buttons through untill we see the release event */
if (wait_for_release)
@@ -487,6 +506,11 @@ int action_get_touchscreen_press_in_vp(short *x1, short *y1, struct viewport *vp
/* Don't let get_action*() return any ACTION_* values until the current buttons
* have been released. SYS_* and BUTTON_NONE will go through.
* Any actions relying on _RELEASE won't get seen.
+ *
+ * Note this doesn't currently work for touchscreen targets if called
+ * when the screen isn't currently touched, because they can send normal
+ * (non-BUTTON_REPEAT) events repeatedly, if the touch coordinates change.
+ * This cannot be distinguished from normal buttons events.
void action_wait_for_release(void)