Thank you to anyone who has already donated - your generous donations helped make three months of treatment possible.

My brother Nate continues to fight stage IV Hodgkin's lymphoma. He's just 31, with a wife and baby girl. They have no active income (since he's been unable to return to work), no insurance, and cannot afford the treatment he needs. Nate and his family need your help. Please consider a donation, every dollar helps. Thanks.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
diff --git a/apps/gui/quickscreen.c b/apps/gui/quickscreen.c
index 402b1e2..863bd54 100644
--- a/apps/gui/quickscreen.c
+++ b/apps/gui/quickscreen.c
@@ -285,15 +285,8 @@ static bool gui_quickscreen_do_button(struct gui_quickscreen * qs, int button)
     talk_qs_option((struct settings_list *)qs->items[item], false);
     return true;
 }
-#ifdef HAVE_TOUCHSCREEN
-/* figure out which button was pressed... */
-static bool xy_is_within_viewport(int x, int y, const struct viewport *vp)
-{
-    bool is_x = (x > vp->x && x < (vp->x + vp->width));
-    bool is_y = (y > vp->y && y < (vp->y + vp->height));
-    return (is_x && is_y);
-}

+#ifdef HAVE_TOUCHSCREEN
 static int quickscreen_touchscreen_button(const struct viewport
                                                     vps[QUICKSCREEN_ITEM_COUNT])
 {
@@ -301,17 +294,18 @@ static int quickscreen_touchscreen_button(const struct viewport
     /* only hitting the text counts, everything else is exit */
     if (action_get_touchscreen_press(&x, &y) != BUTTON_REL)
         return ACTION_NONE;
-    else if (xy_is_within_viewport(x,y,&vps[QUICKSCREEN_TOP]))
+    else if (viewport_point_within_vp(&vps[QUICKSCREEN_TOP], x, y))
         return ACTION_QS_TOP;
-    else if (xy_is_within_viewport(x,y,&vps[QUICKSCREEN_BOTTOM]))
+    else if (viewport_point_within_vp(&vps[QUICKSCREEN_BOTTOM], x, y))
         return ACTION_QS_DOWN;
-    else if (xy_is_within_viewport(x,y,&vps[QUICKSCREEN_LEFT]))
+    else if (viewport_point_within_vp(&vps[QUICKSCREEN_LEFT], x, y))
         return ACTION_QS_LEFT;
-    else if (xy_is_within_viewport(x,y,&vps[QUICKSCREEN_RIGHT]))
+    else if (viewport_point_within_vp(&vps[QUICKSCREEN_RIGHT], x, y))
         return ACTION_QS_RIGHT;
     return ACTION_STD_CANCEL;
 }    
 #endif
+
 static bool gui_syncquickscreen_run(struct gui_quickscreen * qs, int button_enter)
 {
     int button, i, j;
diff --git a/apps/gui/viewport.c b/apps/gui/viewport.c
index e05cd78..63f0b8f 100644
--- a/apps/gui/viewport.c
+++ b/apps/gui/viewport.c
@@ -401,4 +401,13 @@ static unsigned viewport_init_ui_vp(void)
     return ret;
 }

+#ifdef HAVE_TOUCHSCREEN
+/* check if a point (x and y coordinates) are within a viewport */
+bool viewport_point_within_vp(const struct viewport *vp, int x, int y)
+{
+    bool is_x = (x >= vp->x && x < (vp->x + vp->width));
+    bool is_y = (y >= vp->y && y < (vp->y + vp->height));
+    return (is_x && is_y);
+}
+#endif /* HAVE_TOUCHSCREEN */
 #endif /* HAVE_LCD_BITMAP */
diff --git a/apps/gui/viewport.h b/apps/gui/viewport.h
index 2ed138b..93b5c70 100644
--- a/apps/gui/viewport.h
+++ b/apps/gui/viewport.h
@@ -116,6 +116,10 @@ struct viewport* viewport_get_current_vp(void);
  */
 void viewport_set_current_vp(struct viewport* vp);

+#ifdef HAVE_TOUCHSCREEN
+bool viewport_point_within_vp(const struct viewport *vp, int x, int y);
+#endif
+
 #else /* HAVE_LCD_CHARCELL */
 #define viewport_set_current_vp(a)
 #define viewport_get_current_vp() NULL
diff --git a/apps/gui/wps.c b/apps/gui/wps.c
index 99bc731..f336f77 100644
--- a/apps/gui/wps.c
+++ b/apps/gui/wps.c
@@ -601,13 +601,12 @@ int wps_get_touchaction(struct wps_data *data)
             regions = regions->next;
             continue;
         }
-        /* reposition the touch inside the viewport */    
-        vx = x - r->wvp->vp.x;
-        vy = y - r->wvp->vp.y;
         /* check if it's inside this viewport */
-        if (vx >= 0 && vx < r->wvp->vp.x + r->wvp->vp.width &&
-            vy >= 0 && vy < r->wvp->vp.y + r->wvp->vp.height)
-        {
+        if (viewport_point_within_vp(&(r->wvp->vp), x, y))
+        {   /* reposition the touch inside the viewport since touchregions
+             * are relative to a preceding viewport */
+            vx = x - r->wvp->vp.x;
+            vy = y - r->wvp->vp.y;
             /* now see if the point is inside this region */
             if (vx >= r->x && vx < r->x+r->width &&
                 vy >= r->y && vy < r->y+r->height)