summaryrefslogtreecommitdiffstats
path: root/patches/tslib-1.0/generic/ts_test_add_quit_button.diff
blob: 6f639de8b38268cf80fa7ca5404cd5837ca88420 (plain)
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
ts_test: add quit button

Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
---
# 20081124: wsa: already sent upstream. applied.

 tests/ts_test.c |   19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

Index: tests/ts_test.c
===================================================================
--- tests/ts_test.c.orig
+++ tests/ts_test.c
@@ -44,7 +44,7 @@ static int button_palette [6] =
 	1, 5, 0
 };
 
-#define NR_BUTTONS 2
+#define NR_BUTTONS 3
 static struct ts_button buttons [NR_BUTTONS];
 
 static void sig(int sig)
@@ -112,6 +112,7 @@ int main()
 	int x, y;
 	unsigned int i;
 	unsigned int mode = 0;
+	int quit_pressed = 0;
 
 	char *tsdevice=NULL;
 
@@ -152,13 +153,15 @@ int main()
 
 	/* Initialize buttons */
 	memset (&buttons, 0, sizeof (buttons));
-	buttons [0].w = buttons [1].w = xres / 4;
-	buttons [0].h = buttons [1].h = 20;
-	buttons [0].x = xres / 4 - buttons [0].w / 2;
-	buttons [1].x = (3 * xres) / 4 - buttons [0].w / 2;
-	buttons [0].y = buttons [1].y = 10;
+	buttons [0].w = buttons [1].w = buttons [2].w = xres / 4;
+	buttons [0].h = buttons [1].h = buttons [2].h = 20;
+	buttons [0].x = 0;
+	buttons [1].x = (3 * xres) / 8;
+	buttons [2].x = (3 * xres) / 4;
+	buttons [0].y = buttons [1].y = buttons [2].y = 10;
 	buttons [0].text = "Drag";
 	buttons [1].text = "Draw";
+	buttons [2].text = "Quit";
 
 	refresh_screen ();
 
@@ -196,6 +199,8 @@ int main()
 					mode = 1;
 					refresh_screen ();
 					break;
+				case 2:
+					quit_pressed = 1;
 				}
 
 		printf("%ld.%06ld: %6d %6d %6d\n", samp.tv.tv_sec, samp.tv.tv_usec,
@@ -209,6 +214,8 @@ int main()
 			mode |= 0x80000000;
 		} else
 			mode &= ~0x80000000;
+		if (quit_pressed)
+			break;
 	}
 	close_framebuffer();
 }