summaryrefslogtreecommitdiffstats
path: root/master/marek-010e9b62eabfed042f35b72e8fa510df2dd7f679
blob: 9b411ae3cb81ae50dbc653ace6f312c3f2616a26 (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
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
diff --git a/driver/kobomultitouch_drv.c b/driver/kobomultitouch_drv.c
index fca41b9..4a034c6 100644
--- a/driver/kobomultitouch_drv.c
+++ b/driver/kobomultitouch_drv.c
@@ -193,24 +193,25 @@ static int device_close(LocalDevicePtr local)
 	return Success;
 }
 
-static void tickle_button(LocalDevicePtr local, int id)
+static void tickle_button(LocalDevicePtr local, int id, int posx, int posy)
 {
-	xf86PostButtonEvent(local->dev, FALSE, id, 1, 0, 0);
-	xf86PostButtonEvent(local->dev, FALSE, id, 0, 0, 0);
+	xf86PostMotionEvent(local->dev, 1, 0, 2, posx, posy);
+	xf86PostButtonEvent(local->dev, 1, id, 1, 0, 0);
+	xf86PostButtonEvent(local->dev, 1, id, 0, 0, 0);
 }
 
 static void button_scroll(LocalDevicePtr local,
 			  int btdec, int btinc,
 			  int *scroll, int step,
-			  int delta)
+			  int delta, int posx, int posy)
 {
 	*scroll += delta;
 	while (*scroll > step) {
-		tickle_button(local, btinc);
+		tickle_button(local, btinc, posx, posy);
 		*scroll -= step;
 	}
 	while (*scroll < -step) {
-		tickle_button(local, btdec);
+		tickle_button(local, btdec, posx, posy);
 		*scroll += step;
 	}
 }
@@ -227,47 +228,49 @@ static void handle_gestures(LocalDevicePtr local,
 		vswipe = 0;
 		hswipe = 0;
 	}
-	foreach_bit(i, gs->btmask)
-		xf86PostButtonEvent(local->dev, FALSE,
+	foreach_bit(i, gs->btmask) {
+		xf86PostMotionEvent(local->dev, 1, 0, 2, gs->posx, gs->posy);
+		xf86PostButtonEvent(local->dev, 1,
 				    i + 1, GETBIT(gs->btdata, i), 0, 0);
-	if (GETBIT(gs->type, GS_MOVE))
-		xf86PostMotionEvent(local->dev, 0, 0, 2, gs->dx, gs->dy);
-
+	}
+	if (GETBIT(gs->type, GS_MOVE)) {
+		xf86PostMotionEvent(local->dev, 1, 0, 2, gs->posx, gs->posy);
+	}
 	if (GETBIT(gs->type, GS_VSCROLL)) {
 		int step = 1 + vscroll_fraction * get_cap_ysize(caps);
-		button_scroll(local, 4, 5, &vscroll, step, gs->dy);
+		button_scroll(local, 4, 5, &vscroll, step, gs->dy, gs->posx, gs->posy);
 	}
 	if (GETBIT(gs->type, GS_HSCROLL)) {
 		int step = 1 + hscroll_fraction * get_cap_xsize(caps);
-		button_scroll(local, 6, 7, &hscroll, step, gs->dx);
+		button_scroll(local, 6, 7, &hscroll, step, gs->dx, gs->posx, gs->posy);
 	}
 	if (GETBIT(gs->type, GS_VSWIPE)) {
 		int step = 1 + vswipe_fraction * get_cap_ysize(caps);
-		button_scroll(local, 8, 9, &vswipe, step, gs->dy);
+		button_scroll(local, 8, 9, &vswipe, step, gs->dy, gs->posx, gs->posy);
 	}
 	if (GETBIT(gs->type, GS_HSWIPE)) {
 		int step = 1 + hswipe_fraction * get_cap_xsize(caps);
-		button_scroll(local, 10, 11, &hswipe, step, gs->dx);
+		button_scroll(local, 10, 11, &hswipe, step, gs->dx, gs->posx, gs->posy);
 	}
 	if (GETBIT(gs->type, GS_SCALE)) {
 		int step = 1 + scale_fraction * get_cap_xsize(caps);
-		button_scroll(local, 12, 13, &scale, step, gs->scale);
+		button_scroll(local, 12, 13, &scale, step, gs->scale, gs->posx, gs->posy);
 	}
 	if (GETBIT(gs->type, GS_ROTATE)) {
 		int step = 1 + rot_fraction * get_cap_xsize(caps);
-		button_scroll(local, 14, 15, &rot, step, gs->rot);
+		button_scroll(local, 14, 15, &rot, step, gs->rot, gs->posx, gs->posy);
 	}
 	if (GETBIT(gs->type, GS_TAP) && gs->ntap == 1) {
 		foreach_bit(i, gs->tapmask)
-			tickle_button(local, i + 1);
+			tickle_button(local, i + 1, gs->posx, gs->posy);
 	}
 	if (GETBIT(gs->type, GS_VSWIPE4)) {
 		int step = 1 + vswipe_fraction * get_cap_ysize(caps);
-		button_scroll(local, 16, 17, &vswipe, step, gs->dy);
+		button_scroll(local, 16, 17, &vswipe, step, gs->dy, gs->posx, gs->posy);
 	}
 	if (GETBIT(gs->type, GS_HSWIPE4)) {
 		int step = 1 + hswipe_fraction * get_cap_xsize(caps);
-		button_scroll(local, 18, 19, &hswipe, step, gs->dx);
+		button_scroll(local, 18, 19, &hswipe, step, gs->dx, gs->posx, gs->posy);
 	}
 }
 
@@ -319,7 +322,7 @@ static int preinit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
 		return BadAlloc;
 
 	pInfo->private = mt;
-	pInfo->type_name = XI_TOUCHPAD;
+	pInfo->type_name = XI_TOUCHSCREEN;
 	pInfo->device_control = device_control;
 	pInfo->read_input = read_input;
 	pInfo->switch_mode = 0;
@@ -340,7 +343,7 @@ static InputInfoPtr preinit(InputDriverPtr drv, IDevPtr dev, int flags)
 		goto error;
 
 	local->name = dev->identifier;
-	local->type_name = XI_TOUCHPAD;
+	local->type_name = XI_TOUCHSCREEN;
 	local->device_control = device_control;
 	local->read_input = read_input;
 	local->private = mt;
diff --git a/include/gestures.h b/include/gestures.h
index b512121..659c95a 100644
--- a/include/gestures.h
+++ b/include/gestures.h
@@ -38,7 +38,7 @@
 
 struct Gestures {
 	bitmask_t type, btmask, btdata;
-	int same_fingers, dx, dy, scale, rot;
+	int same_fingers, posx, posy, dx, dy, scale, rot;
 	bitmask_t tapmask;
 	int ntap;
 };
diff --git a/src/gestures.c b/src/gestures.c
index cc95e9b..cbc5ac6 100644
--- a/src/gestures.c
+++ b/src/gestures.c
@@ -82,7 +82,6 @@ static void extract_movement(struct Gestures *gs, struct MTouch* mt)
 	float move, xmove = 0, ymove = 0;
 	float rad, rad2 = 0, scale = 0, rot = 0;
 
-
 	if (!nmove || nmove != npoint)
 		return;
 
@@ -182,9 +181,15 @@ static void extract_movement(struct Gestures *gs, struct MTouch* mt)
 void extract_gestures(struct Gestures *gs, struct MTouch* mt)
 {
 	memset(gs, 0, sizeof(struct Gestures));
+
+	gs->posx = mt->state.finger[0].position_x;
+	gs->posy = mt->state.finger[0].position_y;
+
 	gs->same_fingers = mt->mem.same;
+
 	extract_buttons(gs, mt);
 	extract_movement(gs, mt);
+
 	mt->prev_state = mt->state;
 }
 
@@ -201,6 +206,9 @@ void extract_delayed_gestures(struct Gestures *gs, struct MTouch* mt)
 	memset(gs, 0, sizeof(struct Gestures));
 	mt->mem.wait = 0;
 
+	gs->posx = mt->state.finger[0].position_x;
+	gs->posy = mt->state.finger[0].position_y;
+
 	if (mt->mem.tpdown < mt->mem.tpup) {
 		switch (mt->mem.maxtap) {
 		case 1:
@@ -227,8 +235,10 @@ void output_gesture(const struct Gestures *gs)
 	foreach_bit(i, gs->btmask)
 		xf86Msg(X_INFO, "button bit: %d %d\n",
 			i, GETBIT(gs->btdata, i));
-	if (GETBIT(gs->type, GS_MOVE))
+	if (GETBIT(gs->type, GS_MOVE)) {
+		xf86Msg(X_INFO, "position: %d %d\n", gs->posx, gs->posy);
 		xf86Msg(X_INFO, "motion: %d %d\n", gs->dx, gs->dy);
+	}
 	if (GETBIT(gs->type, GS_VSCROLL))
 		xf86Msg(X_INFO, "vscroll: %d\n", gs->dy);
 	if (GETBIT(gs->type, GS_HSCROLL))