summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKim Shinwoo <kimcinoo.efl@gmail.com>2012-09-03 04:06:02 +0000
committerCarsten Haitzler <raster@rasterman.com>2012-09-03 04:06:02 +0000
commit4d8b3bea449b1b2fc5b4d5e11b7003b389cc83f0 (patch)
treee7318466c23aca5e47b70a737acdedd767049fd1
parent10c27c792beaca0ee781938181f804b33f1cfa61 (diff)
From: Kim Shinwoo <kimcinoo.efl@gmail.com>
i have revised the access module and attached. you can find the following in the patch. - mouse double tap and move gesture for each direction - two finger flicking for each direction - two finger panning SVN revision: 75945
-rw-r--r--AUTHORS1
-rw-r--r--src/modules/access/e_mod_main.c269
2 files changed, 245 insertions, 25 deletions
diff --git a/AUTHORS b/AUTHORS
index 85ffc91e4..338116677 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -36,3 +36,4 @@ q66 <quaker66@gmail.com>
36Tom Hacohen (TAsn) <tom@stosb.com> 36Tom Hacohen (TAsn) <tom@stosb.com>
37Maxime Villard <rustyBSD@gmx.fr> 37Maxime Villard <rustyBSD@gmx.fr>
38Jeremy Zurcher <jeremy@asynk.ch> 38Jeremy Zurcher <jeremy@asynk.ch>
39Shinwoo Kim <kimcinoo@gmail.com>
diff --git a/src/modules/access/e_mod_main.c b/src/modules/access/e_mod_main.c
index 3a966b512..b12fc89b7 100644
--- a/src/modules/access/e_mod_main.c
+++ b/src/modules/access/e_mod_main.c
@@ -1,18 +1,31 @@
1#include "e.h" 1#include "e.h"
2#include "e_mod_main.h" 2#include "e_mod_main.h"
3#define HISTORY_MAX 8
3 4
4typedef struct 5typedef struct
5{ 6{
6 E_Zone *zone; 7 E_Zone *zone;
7 Ecore_X_Window win; 8 Ecore_X_Window win;
8 Ecore_Timer *timer; 9 Ecore_Timer *timer;
9 int x, y, dx, dy; 10 Ecore_Timer *double_down_timer;
11 int x, y, dx, dy, mx, my;
12 int mouse_history[HISTORY_MAX];
10 unsigned int dt; 13 unsigned int dt;
14 Eina_Inlist *history;
11 Eina_Bool down : 1; 15 Eina_Bool down : 1;
16 Eina_Bool two_finger_down : 1;
17 Eina_Bool mouse_double_down : 1;
12} Cover; 18} Cover;
13 19
20typedef struct
21{
22 EINA_INLIST;
23 int device;
24} Multi;
25
14static Eina_List *covers = NULL; 26static Eina_List *covers = NULL;
15static Eina_List *handlers = NULL; 27static Eina_List *handlers = NULL;
28static int multi_device[3];
16 29
17static Ecore_X_Window 30static Ecore_X_Window
18_mouse_win_in_get(Cover *cov, int x, int y) 31_mouse_win_in_get(Cover *cov, int x, int y)
@@ -21,7 +34,7 @@ _mouse_win_in_get(Cover *cov, int x, int y)
21 Ecore_X_Window *skip, inwin; 34 Ecore_X_Window *skip, inwin;
22 Cover *cov2; 35 Cover *cov2;
23 int i; 36 int i;
24 37
25 skip = alloca(sizeof(Ecore_X_Window) * eina_list_count(covers)); 38 skip = alloca(sizeof(Ecore_X_Window) * eina_list_count(covers));
26 i = 0; 39 i = 0;
27 EINA_LIST_FOREACH(covers, l, cov2) 40 EINA_LIST_FOREACH(covers, l, cov2)
@@ -31,6 +44,7 @@ _mouse_win_in_get(Cover *cov, int x, int y)
31 } 44 }
32 inwin = ecore_x_window_shadow_tree_at_xy_with_skip_get 45 inwin = ecore_x_window_shadow_tree_at_xy_with_skip_get
33 (cov->zone->container->manager->root, x, y, skip, i); 46 (cov->zone->container->manager->root, x, y, skip, i);
47
34 return inwin; 48 return inwin;
35} 49}
36 50
@@ -39,8 +53,9 @@ _mouse_win_fake_tap(Cover *cov, Ecore_Event_Mouse_Button *ev)
39{ 53{
40 Ecore_X_Window inwin; 54 Ecore_X_Window inwin;
41 int x, y; 55 int x, y;
42 56
43 inwin = _mouse_win_in_get(cov, ev->root.x, ev->root.y); 57 inwin = _mouse_win_in_get(cov, ev->root.x, ev->root.y);
58
44 ecore_x_pointer_xy_get(inwin, &x, &y); 59 ecore_x_pointer_xy_get(inwin, &x, &y);
45 ecore_x_mouse_in_send(inwin, x, y); 60 ecore_x_mouse_in_send(inwin, x, y);
46 ecore_x_mouse_move_send(inwin, x, y); 61 ecore_x_mouse_move_send(inwin, x, y);
@@ -49,20 +64,59 @@ _mouse_win_fake_tap(Cover *cov, Ecore_Event_Mouse_Button *ev)
49 ecore_x_mouse_out_send(inwin, x, y); 64 ecore_x_mouse_out_send(inwin, x, y);
50} 65}
51 66
67static void
68_record_mouse_history(Cover *cov, void *event)
69{
70 Ecore_Event_Mouse_Move *ev = event;
71 int i = 0;
72
73 for (i = 0; i < HISTORY_MAX; i++)
74 {
75 if (cov->mouse_history[i] == -1)
76 {
77 cov->mouse_history[i] = ev->multi.device;
78 break;
79 }
80 }
81
82 // if there is not enough space to save device number, shift!
83 if (i == HISTORY_MAX)
84 {
85 for (i = 0; i < (HISTORY_MAX - 1); i++)
86 cov->mouse_history[i] = cov->mouse_history[i + 1];
87 cov->mouse_history[HISTORY_MAX - 1] = ev->multi.device;
88 }
89}
90
91static Eina_Bool
92_check_mouse_history(Cover *cov)
93{
94 int i = 0;
95
96 for (i = 0; i < HISTORY_MAX; i++)
97 {
98 if ((cov->mouse_history[i] != multi_device[0]) &&
99 (cov->mouse_history[i] != -1))
100 return EINA_FALSE;
101 }
102
103 return EINA_TRUE;
104}
105
52static Eina_Bool 106static Eina_Bool
53_mouse_longpress(void *data) 107_mouse_longpress(void *data)
54{ 108{
55 Cover *cov = data; 109 Cover *cov = data;
56 int distance = 40; 110 int distance = 40;
57 int dx, dy; 111 int dx, dy;
58 112
59 cov->timer = NULL; 113 cov->timer = NULL;
60 dx = cov->x - cov->dx; 114 dx = cov->x - cov->dx;
61 dy = cov->y - cov->dy; 115 dy = cov->y - cov->dy;
62 if (((dx * dx) + (dy * dy)) < (distance * distance)) 116 if (((dx * dx) + (dy * dy)) < (distance * distance))
63 { 117 {
64 E_Border *bd = e_border_focused_get(); 118 E_Border *bd = e_border_focused_get();
65 119
66 cov->down = EINA_FALSE; 120 cov->down = EINA_FALSE;
67 printf("longpress\n"); 121 printf("longpress\n");
68 if (bd) 122 if (bd)
@@ -71,18 +125,76 @@ _mouse_longpress(void *data)
71 return EINA_FALSE; 125 return EINA_FALSE;
72} 126}
73 127
128static Eina_Bool
129_mouse_double_down(void *data)
130{
131 Cover *cov = data;
132
133 ecore_timer_del(cov->double_down_timer);
134 cov->double_down_timer = NULL;
135 return EINA_FALSE;
136}
137
138static void
139_mouse_double_down_timeout(Cover *cov)
140{
141 double short_time = 0.3;
142 int distance = 40;
143 int dx, dy;
144
145 dx = cov->x - cov->dx;
146 dy = cov->y - cov->dy;
147
148 if ((cov->double_down_timer) &&
149 (((dx * dx) + (dy * dy)) < (distance * distance)))
150 {
151 // start double tap and move from here
152 cov->mouse_double_down = EINA_TRUE;
153
154 if (cov->timer)
155 {
156 ecore_timer_del(cov->timer);
157 cov->timer = NULL;
158 }
159 }
160
161 if (cov->double_down_timer)
162 {
163 ecore_timer_del(cov->double_down_timer);
164 cov->double_down_timer = NULL;
165 return;
166 }
167
168 cov->double_down_timer = ecore_timer_add(short_time, _mouse_double_down,
169 cov);
170}
171
74static void 172static void
75_mouse_down(Cover *cov, Ecore_Event_Mouse_Button *ev) 173_mouse_down(Cover *cov, Ecore_Event_Mouse_Button *ev)
76{ 174{
175 int x, y;
176 E_Border *bd;
77 double longtime = 0.5; 177 double longtime = 0.5;
78 178
79 cov->dx = ev->x; 179 cov->dx = ev->x;
80 cov->dy = ev->y; 180 cov->dy = ev->y;
181 cov->mx = ev->x;
182 cov->my = ev->y;
81 cov->x = ev->x; 183 cov->x = ev->x;
82 cov->y = ev->y; 184 cov->y = ev->y;
83 cov->dt = ev->timestamp; 185 cov->dt = ev->timestamp;
84 cov->down = EINA_TRUE; 186 cov->down = EINA_TRUE;
85 cov->timer = ecore_timer_add(longtime, _mouse_longpress, cov); 187 cov->timer = ecore_timer_add(longtime, _mouse_longpress, cov);
188
189 // 2nd finger comes...
190 _mouse_double_down_timeout(cov);
191
192 // mouse in should be here
193 bd = e_border_focused_get();
194 if (!bd) return;
195
196 ecore_x_pointer_xy_get(bd->client.win, &x, &y);
197 ecore_x_mouse_in_send(bd->client.win, x, y);
86} 198}
87 199
88static void 200static void
@@ -91,8 +203,22 @@ _mouse_up(Cover *cov, Ecore_Event_Mouse_Button *ev)
91 double timeout = 0.15; 203 double timeout = 0.15;
92 int distance = 40; 204 int distance = 40;
93 int dx, dy; 205 int dx, dy;
206 int x, y;
207
94 E_Border *bd = e_border_focused_get(); 208 E_Border *bd = e_border_focused_get();
95 209
210 // for two finger panning
211 if (cov->two_finger_down)
212 {
213 ecore_x_pointer_xy_get(bd->client.win, &x, &y);
214 ecore_x_mouse_up_send(bd->client.win, x, y, 1);
215 cov->two_finger_down = EINA_FALSE;
216 ecore_x_mouse_out_send(bd->client.win, x, y);
217 }
218
219 // reset double down and moving
220 cov->mouse_double_down = EINA_FALSE;
221
96 if (cov->timer) 222 if (cov->timer)
97 { 223 {
98 ecore_timer_del(cov->timer); 224 ecore_timer_del(cov->timer);
@@ -115,19 +241,26 @@ _mouse_up(Cover *cov, Ecore_Event_Mouse_Button *ev)
115 ecore_x_e_illume_access_action_activate_send(bd->client.win); 241 ecore_x_e_illume_access_action_activate_send(bd->client.win);
116 } 242 }
117 } 243 }
118 else 244 else if (((dx * dx) + (dy * dy)) > (4 * distance * distance)
245 && ((ev->timestamp - cov->dt) < (timeout * 1000)))
119 { 246 {
120 if (abs(dx) > abs(dy)) // left or right 247 if (abs(dx) > abs(dy)) // left or right
121 { 248 {
122 if (dx > 0) // right 249 if (dx > 0) // right
123 { 250 {
124 printf("right\n"); 251 if (_check_mouse_history(cov))
252 printf("single flick right\n");
253 else
254 printf("double flick right\n");
125 if (bd) 255 if (bd)
126 ecore_x_e_illume_access_action_read_next_send(bd->client.win); 256 ecore_x_e_illume_access_action_read_next_send(bd->client.win);
127 } 257 }
128 else // left 258 else // left
129 { 259 {
130 printf("left\n"); 260 if (_check_mouse_history(cov))
261 printf("single flick left\n");
262 else
263 printf("double flick left\n");
131 if (bd) 264 if (bd)
132 ecore_x_e_illume_access_action_read_prev_send(bd->client.win); 265 ecore_x_e_illume_access_action_read_prev_send(bd->client.win);
133 } 266 }
@@ -136,13 +269,20 @@ _mouse_up(Cover *cov, Ecore_Event_Mouse_Button *ev)
136 { 269 {
137 if (dy > 0) // down 270 if (dy > 0) // down
138 { 271 {
139 printf("down\n"); 272 if (_check_mouse_history(cov))
273 printf("single flick down\n");
274 else
275 printf("double flick down\n");
276
140 if (bd) 277 if (bd)
141 ecore_x_e_illume_access_action_next_send(bd->client.win); 278 ecore_x_e_illume_access_action_next_send(bd->client.win);
142 } 279 }
143 else // up 280 else // up
144 { 281 {
145 printf("up\n"); 282 if (_check_mouse_history(cov))
283 printf("single flick up\n");
284 else
285 printf("double flick up\n");
146 if (bd) 286 if (bd)
147 ecore_x_e_illume_access_action_prev_send(bd->client.win); 287 ecore_x_e_illume_access_action_prev_send(bd->client.win);
148 } 288 }
@@ -154,9 +294,50 @@ _mouse_up(Cover *cov, Ecore_Event_Mouse_Button *ev)
154static void 294static void
155_mouse_move(Cover *cov, Ecore_Event_Mouse_Move *ev) 295_mouse_move(Cover *cov, Ecore_Event_Mouse_Move *ev)
156{ 296{
157 if (!cov->down) return; 297 int distance = 5;
298 int x, y;
299 int dx, dy;
300 E_Border *bd;
301
302 //FIXME: why here.. after long press you cannot go below..
303 //if (!cov->down) return;
158 cov->x = ev->x; 304 cov->x = ev->x;
159 cov->y = ev->y; 305 cov->y = ev->y;
306
307 bd = e_border_focused_get();
308 if (!bd) return;
309
310 _record_mouse_history(cov, ev);
311
312 ecore_x_pointer_xy_get(bd->client.win, &x, &y);
313 ecore_x_mouse_move_send(bd->client.win, x, y);
314
315 // for panning, without check two_finger_down, there will be several down_send()
316 if ((ev->multi.device == multi_device[0]) && (cov->mouse_double_down))
317 {
318 dx = ev->x - cov->mx;
319 dy = ev->y - cov->my;
320 if (((dx * dx) + (dy * dy)) > (distance * distance))
321 {
322
323 if (abs(dx) > abs(dy)) // left or right
324 {
325 if (dx > 0) // right
326 printf("mouse double down and moving - right\n");
327 else // left
328 printf("mouse double down and moving - left\n");
329 }
330 else // up or down
331 {
332 if (dy > 0) // down
333 printf("mouse double down and moving - down\n");
334 else // up
335 printf("mouse double down and moving - up\n");
336 }
337 cov->mx = ev->x;
338 cov->my = ev->y;
339 }
340 }
160} 341}
161 342
162static void 343static void
@@ -173,13 +354,38 @@ _cb_mouse_down(void *data __UNUSED__,
173 Ecore_Event_Mouse_Button *ev = event; 354 Ecore_Event_Mouse_Button *ev = event;
174 Eina_List *l; 355 Eina_List *l;
175 Cover *cov; 356 Cover *cov;
176 357 int i = 0;
358 E_Border *bd;
359 int x, y;
360
361 for (i = 0; i < 3; i++)
362 {
363 if (multi_device[i] == -1)
364 {
365 multi_device[i] = ev->multi.device;
366 break;
367 }
368 else if (multi_device[i] == ev->multi.device) break;
369 }
370
177 EINA_LIST_FOREACH(covers, l, cov) 371 EINA_LIST_FOREACH(covers, l, cov)
178 { 372 {
179 if (ev->window == cov->win) 373 if (ev->window == cov->win)
180 { 374 {
181 if ((ev->buttons == 1) && (ev->multi.device == 0)) 375 // XXX change specific number
376 if (ev->multi.device == multi_device[0])
182 _mouse_down(cov, ev); 377 _mouse_down(cov, ev);
378
379 if ((ev->multi.device == multi_device[1]) &&
380 (!cov->two_finger_down))
381 {
382 bd = e_border_focused_get();
383 if (!bd) return ECORE_CALLBACK_PASS_ON;
384 ecore_x_pointer_xy_get(bd->client.win, &x, &y);
385 ecore_x_mouse_move_send(bd->client.win, x, y);
386 ecore_x_mouse_down_send(bd->client.win, x, y, 1);
387 cov->two_finger_down = EINA_TRUE;
388 }
183 return ECORE_CALLBACK_PASS_ON; 389 return ECORE_CALLBACK_PASS_ON;
184 } 390 }
185 } 391 }
@@ -194,12 +400,12 @@ _cb_mouse_up(void *data __UNUSED__,
194 Ecore_Event_Mouse_Button *ev = event; 400 Ecore_Event_Mouse_Button *ev = event;
195 Eina_List *l; 401 Eina_List *l;
196 Cover *cov; 402 Cover *cov;
197 403
198 EINA_LIST_FOREACH(covers, l, cov) 404 EINA_LIST_FOREACH(covers, l, cov)
199 { 405 {
200 if (ev->window == cov->win) 406 if (ev->window == cov->win)
201 { 407 {
202 if ((ev->buttons == 1) && (ev->multi.device == 0)) 408 if (ev->buttons == 1)
203 _mouse_up(cov, ev); 409 _mouse_up(cov, ev);
204 return ECORE_CALLBACK_PASS_ON; 410 return ECORE_CALLBACK_PASS_ON;
205 } 411 }
@@ -215,12 +421,12 @@ _cb_mouse_move(void *data __UNUSED__,
215 Ecore_Event_Mouse_Move *ev = event; 421 Ecore_Event_Mouse_Move *ev = event;
216 Eina_List *l; 422 Eina_List *l;
217 Cover *cov; 423 Cover *cov;
218
219 EINA_LIST_FOREACH(covers, l, cov) 424 EINA_LIST_FOREACH(covers, l, cov)
220 { 425 {
221 if (ev->window == cov->win) 426 if (ev->window == cov->win)
222 { 427 {
223 if (ev->multi.device == 0) 428 if ((ev->multi.device == multi_device[0]) ||
429 (ev->multi.device == multi_device[1]))
224 _mouse_move(cov, ev); 430 _mouse_move(cov, ev);
225 return ECORE_CALLBACK_PASS_ON; 431 return ECORE_CALLBACK_PASS_ON;
226 } 432 }
@@ -236,7 +442,7 @@ _cb_mouse_wheel(void *data __UNUSED__,
236 Ecore_Event_Mouse_Wheel *ev = event; 442 Ecore_Event_Mouse_Wheel *ev = event;
237 Eina_List *l; 443 Eina_List *l;
238 Cover *cov; 444 Cover *cov;
239 445
240 EINA_LIST_FOREACH(covers, l, cov) 446 EINA_LIST_FOREACH(covers, l, cov)
241 { 447 {
242 if (ev->window == cov->win) 448 if (ev->window == cov->win)
@@ -252,7 +458,7 @@ static Cover *
252_cover_new(E_Zone *zone) 458_cover_new(E_Zone *zone)
253{ 459{
254 Cover *cov; 460 Cover *cov;
255 461
256 cov = E_NEW(Cover, 1); 462 cov = E_NEW(Cover, 1);
257 if (!cov) return NULL; 463 if (!cov) return NULL;
258 cov->zone = zone; 464 cov->zone = zone;
@@ -260,6 +466,9 @@ _cover_new(E_Zone *zone)
260 zone->container->x + zone->x, 466 zone->container->x + zone->x,
261 zone->container->y + zone->y, 467 zone->container->y + zone->y,
262 zone->w, zone->h); 468 zone->w, zone->h);
469
470 ecore_x_input_multi_select(cov->win);
471
263 ecore_x_window_ignore_set(cov->win, 1); 472 ecore_x_window_ignore_set(cov->win, 1);
264 ecore_x_window_configure(cov->win, 473 ecore_x_window_configure(cov->win,
265 ECORE_X_WINDOW_CONFIGURE_MASK_SIBLING | 474 ECORE_X_WINDOW_CONFIGURE_MASK_SIBLING |
@@ -268,6 +477,8 @@ _cover_new(E_Zone *zone)
268 zone->container->layers[8].win, 477 zone->container->layers[8].win,
269 ECORE_X_WINDOW_STACK_ABOVE); 478 ECORE_X_WINDOW_STACK_ABOVE);
270 ecore_x_window_show(cov->win); 479 ecore_x_window_show(cov->win);
480 ecore_x_window_raise(cov->win);
481
271 return cov; 482 return cov;
272} 483}
273 484
@@ -276,19 +487,23 @@ _covers_init(void)
276{ 487{
277 Eina_List *l, *l2, *l3; 488 Eina_List *l, *l2, *l3;
278 E_Manager *man; 489 E_Manager *man;
490 int i = 0;
279 491
280 EINA_LIST_FOREACH(e_manager_list(), l, man) 492 EINA_LIST_FOREACH(e_manager_list(), l, man)
281 { 493 {
282 E_Container *con; 494 E_Container *con;
283
284 EINA_LIST_FOREACH(man->containers, l2, con) 495 EINA_LIST_FOREACH(man->containers, l2, con)
285 { 496 {
286 E_Zone *zone; 497 E_Zone *zone;
287
288 EINA_LIST_FOREACH(con->zones, l3, zone) 498 EINA_LIST_FOREACH(con->zones, l3, zone)
289 { 499 {
290 Cover *cov = _cover_new(zone); 500 Cover *cov = _cover_new(zone);
291 if (cov) covers = eina_list_append(covers, cov); 501 if (cov)
502 {
503 covers = eina_list_append(covers, cov);
504 for (i = 0; i < HISTORY_MAX; i++)
505 cov->mouse_history[i] = -1;
506 }
292 } 507 }
293 } 508 }
294 } 509 }
@@ -298,7 +513,7 @@ static void
298_covers_shutdown(void) 513_covers_shutdown(void)
299{ 514{
300 Cover *cov; 515 Cover *cov;
301 516
302 EINA_LIST_FREE(covers, cov) 517 EINA_LIST_FREE(covers, cov)
303 { 518 {
304 ecore_x_window_ignore_set(cov->win, 0); 519 ecore_x_window_ignore_set(cov->win, 0);
@@ -345,6 +560,8 @@ _cb_zone_move_resize(void *data __UNUSED__,
345static void 560static void
346_events_init(void) 561_events_init(void)
347{ 562{
563 int i = 0;
564
348 handlers = eina_list_append 565 handlers = eina_list_append
349 (handlers, ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, 566 (handlers, ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN,
350 _cb_mouse_down, NULL)); 567 _cb_mouse_down, NULL));
@@ -366,6 +583,8 @@ _events_init(void)
366 handlers = eina_list_append 583 handlers = eina_list_append
367 (handlers, ecore_event_handler_add(E_EVENT_ZONE_MOVE_RESIZE, 584 (handlers, ecore_event_handler_add(E_EVENT_ZONE_MOVE_RESIZE,
368 _cb_zone_move_resize, NULL)); 585 _cb_zone_move_resize, NULL));
586
587 for (i = 0; i < 3; i++) multi_device[i] = -1;
369} 588}
370 589
371static void 590static void