diff options
author | Chris Michael <cp.michael@samsung.com> | 2013-11-19 10:34:27 +0000 |
---|---|---|
committer | Chris Michael <cp.michael@samsung.com> | 2013-11-19 10:38:23 +0000 |
commit | 0a32212a79ada418dc12d7e76f93871032e0c4e3 (patch) | |
tree | 055fda9cb4f0aacc6a310c74a25ca8ecc624884e /src/lib/ecore_wayland | |
parent | e1dc4579fdefd25bb1b10575cc7b74288efc0705 (diff) |
Add support for storing mulitple touch points.
Send events to properly focused surface.
Fill in missing parts of the event structures (ev->root, ev->multi).
Signed-off-by: Chris Michael <cp.michael@samsung.com>
Diffstat (limited to 'src/lib/ecore_wayland')
-rw-r--r-- | src/lib/ecore_wayland/ecore_wl_input.c | 114 |
1 files changed, 88 insertions, 26 deletions
diff --git a/src/lib/ecore_wayland/ecore_wl_input.c b/src/lib/ecore_wayland/ecore_wl_input.c index b4d3a33d33..c68669167d 100644 --- a/src/lib/ecore_wayland/ecore_wl_input.c +++ b/src/lib/ecore_wayland/ecore_wl_input.c | |||
@@ -35,6 +35,13 @@ | |||
35 | # define BTN_BACK 0x116 | 35 | # define BTN_BACK 0x116 |
36 | #endif | 36 | #endif |
37 | 37 | ||
38 | typedef struct _Ecore_Wl_Touch_Point | ||
39 | { | ||
40 | int id; | ||
41 | Ecore_Wl_Window *window; | ||
42 | struct wl_list link; | ||
43 | } Ecore_Wl_Touch_Point; | ||
44 | |||
38 | typedef struct _Ecore_Wl_Mouse_Down_Info | 45 | typedef struct _Ecore_Wl_Mouse_Down_Info |
39 | { | 46 | { |
40 | EINA_INLIST; | 47 | EINA_INLIST; |
@@ -315,6 +322,7 @@ _ecore_wl_input_add(Ecore_Wl_Display *ewd, unsigned int id) | |||
315 | input->display = ewd; | 322 | input->display = ewd; |
316 | input->pointer_focus = NULL; | 323 | input->pointer_focus = NULL; |
317 | input->keyboard_focus = NULL; | 324 | input->keyboard_focus = NULL; |
325 | input->touch_focus = NULL; | ||
318 | 326 | ||
319 | input->seat = | 327 | input->seat = |
320 | wl_registry_bind(ewd->wl.registry, id, &wl_seat_interface, 1); | 328 | wl_registry_bind(ewd->wl.registry, id, &wl_seat_interface, 1); |
@@ -324,6 +332,7 @@ _ecore_wl_input_add(Ecore_Wl_Display *ewd, unsigned int id) | |||
324 | &_ecore_wl_seat_listener, input); | 332 | &_ecore_wl_seat_listener, input); |
325 | wl_seat_set_user_data(input->seat, input); | 333 | wl_seat_set_user_data(input->seat, input); |
326 | 334 | ||
335 | wl_list_init(&input->touch_points); | ||
327 | wl_array_init(&input->data_types); | 336 | wl_array_init(&input->data_types); |
328 | 337 | ||
329 | input->data_device = | 338 | input->data_device = |
@@ -347,6 +356,26 @@ _ecore_wl_input_del(Ecore_Wl_Input *input) | |||
347 | if (input->cursor_name) eina_stringshare_del(input->cursor_name); | 356 | if (input->cursor_name) eina_stringshare_del(input->cursor_name); |
348 | input->cursor_name = NULL; | 357 | input->cursor_name = NULL; |
349 | 358 | ||
359 | if (input->touch_focus) | ||
360 | { | ||
361 | Ecore_Wl_Window *win = NULL; | ||
362 | |||
363 | if ((win = input->touch_focus)) | ||
364 | win->touch_device = NULL; | ||
365 | |||
366 | input->touch_focus = NULL; | ||
367 | } | ||
368 | |||
369 | if (input->pointer_focus) | ||
370 | { | ||
371 | Ecore_Wl_Window *win = NULL; | ||
372 | |||
373 | if ((win = input->pointer_focus)) | ||
374 | win->pointer_device = NULL; | ||
375 | |||
376 | input->pointer_focus = NULL; | ||
377 | } | ||
378 | |||
350 | if (input->keyboard_focus) | 379 | if (input->keyboard_focus) |
351 | { | 380 | { |
352 | Ecore_Wl_Window *win = NULL; | 381 | Ecore_Wl_Window *win = NULL; |
@@ -965,24 +994,33 @@ _ecore_wl_input_cb_keyboard_leave(void *data, struct wl_keyboard *keyboard EINA_ | |||
965 | } | 994 | } |
966 | 995 | ||
967 | static void | 996 | static void |
968 | _ecore_wl_input_cb_touch_down(void *data, struct wl_touch *touch EINA_UNUSED, unsigned int serial, unsigned int timestamp, struct wl_surface *surface EINA_UNUSED, int id, wl_fixed_t x, wl_fixed_t y) | 997 | _ecore_wl_input_cb_touch_down(void *data, struct wl_touch *touch EINA_UNUSED, unsigned int serial, unsigned int timestamp, struct wl_surface *surface, int id, wl_fixed_t x, wl_fixed_t y) |
969 | { | 998 | { |
970 | Ecore_Wl_Input *input; | 999 | Ecore_Wl_Input *input; |
1000 | Ecore_Wl_Window *win; | ||
1001 | Ecore_Wl_Touch_Point *point; | ||
971 | 1002 | ||
972 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | 1003 | LOGFN(__FILE__, __LINE__, __FUNCTION__); |
973 | 1004 | ||
974 | if (!surface) return; | 1005 | if (!surface) return; |
975 | if (!(input = data)) return; | 1006 | if (!(input = data)) return; |
976 | 1007 | ||
977 | /* FIXME: NB: Not sure yet if input->timestamp should be set here. | 1008 | if (!(win = ecore_wl_window_surface_find(surface))) return; |
978 | * This needs to be tested with an actual touch device */ | 1009 | |
979 | /* input->timestamp = timestamp; */ | 1010 | if (!(point = malloc(sizeof(Ecore_Wl_Touch_Point)))) |
1011 | return; | ||
1012 | |||
1013 | point->id = id; | ||
1014 | point->window = win; | ||
1015 | wl_list_insert(&input->touch_points, &point->link); | ||
1016 | |||
1017 | input->touch_focus = win; | ||
1018 | input->timestamp = timestamp; | ||
980 | input->display->serial = serial; | 1019 | input->display->serial = serial; |
981 | input->sx = wl_fixed_to_int(x); | 1020 | input->sx = wl_fixed_to_int(x); |
982 | input->sy = wl_fixed_to_int(y); | 1021 | input->sy = wl_fixed_to_int(y); |
983 | /* _ecore_wl_input_mouse_move_send(input, input->pointer_focus, timestamp, id); */ | 1022 | |
984 | /* _ecore_wl_input_cb_pointer_enter(data, NULL, serial, surface, x, y); */ | 1023 | _ecore_wl_input_mouse_down_send(input, input->touch_focus, |
985 | _ecore_wl_input_mouse_down_send(input, input->pointer_focus, | ||
986 | id, 0, timestamp); | 1024 | id, 0, timestamp); |
987 | } | 1025 | } |
988 | 1026 | ||
@@ -990,34 +1028,52 @@ static void | |||
990 | _ecore_wl_input_cb_touch_up(void *data, struct wl_touch *touch EINA_UNUSED, unsigned int serial, unsigned int timestamp, int id) | 1028 | _ecore_wl_input_cb_touch_up(void *data, struct wl_touch *touch EINA_UNUSED, unsigned int serial, unsigned int timestamp, int id) |
991 | { | 1029 | { |
992 | Ecore_Wl_Input *input; | 1030 | Ecore_Wl_Input *input; |
1031 | Ecore_Wl_Touch_Point *point, *tmp; | ||
993 | 1032 | ||
994 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | 1033 | LOGFN(__FILE__, __LINE__, __FUNCTION__); |
995 | 1034 | ||
996 | if (!(input = data)) return; | 1035 | if (!(input = data)) return; |
1036 | if (!input->touch_focus) return; | ||
997 | 1037 | ||
998 | /* FIXME: NB: Not sure yet if input->timestamp should be set here. | 1038 | input->timestamp = timestamp; |
999 | * This needs to be tested with an actual touch device */ | ||
1000 | /* input->timestamp = timestamp; */ | ||
1001 | input->display->serial = serial; | 1039 | input->display->serial = serial; |
1002 | _ecore_wl_input_mouse_up_send(input, input->pointer_focus, | 1040 | |
1003 | id, 0, timestamp); | 1041 | wl_list_for_each_safe(point, tmp, &input->touch_points, link) |
1042 | { | ||
1043 | if (point->id != id) continue; | ||
1044 | |||
1045 | _ecore_wl_input_mouse_up_send(input, input->touch_focus, | ||
1046 | id, 0, timestamp); | ||
1047 | |||
1048 | wl_list_remove(&point->link); | ||
1049 | free(point); | ||
1050 | |||
1051 | return; | ||
1052 | } | ||
1004 | } | 1053 | } |
1005 | 1054 | ||
1006 | static void | 1055 | static void |
1007 | _ecore_wl_input_cb_touch_motion(void *data, struct wl_touch *touch EINA_UNUSED, unsigned int timestamp, int id, wl_fixed_t x, wl_fixed_t y) | 1056 | _ecore_wl_input_cb_touch_motion(void *data, struct wl_touch *touch EINA_UNUSED, unsigned int timestamp, int id, wl_fixed_t x, wl_fixed_t y) |
1008 | { | 1057 | { |
1009 | Ecore_Wl_Input *input; | 1058 | Ecore_Wl_Input *input; |
1059 | Ecore_Wl_Touch_Point *point; | ||
1010 | 1060 | ||
1011 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | 1061 | LOGFN(__FILE__, __LINE__, __FUNCTION__); |
1012 | 1062 | ||
1013 | if (!(input = data)) return; | 1063 | if (!(input = data)) return; |
1064 | if (!input->touch_focus) return; | ||
1014 | 1065 | ||
1015 | /* FIXME: NB: Not sure yet if input->timestamp should be set here. | 1066 | input->timestamp = timestamp; |
1016 | * This needs to be tested with an actual touch device */ | ||
1017 | /* input->timestamp = timestamp; */ | ||
1018 | input->sx = wl_fixed_to_int(x); | 1067 | input->sx = wl_fixed_to_int(x); |
1019 | input->sy = wl_fixed_to_int(y); | 1068 | input->sy = wl_fixed_to_int(y); |
1020 | _ecore_wl_input_mouse_move_send(input, input->pointer_focus, timestamp, id); | 1069 | |
1070 | wl_list_for_each(point, &input->touch_points, link) | ||
1071 | { | ||
1072 | if (point->id != id) continue; | ||
1073 | _ecore_wl_input_mouse_move_send(input, | ||
1074 | input->touch_focus, timestamp, id); | ||
1075 | return; | ||
1076 | } | ||
1021 | } | 1077 | } |
1022 | 1078 | ||
1023 | static void | 1079 | static void |
@@ -1095,8 +1151,8 @@ _ecore_wl_input_mouse_move_send(Ecore_Wl_Input *input, Ecore_Wl_Window *win, uns | |||
1095 | ev->timestamp = timestamp; | 1151 | ev->timestamp = timestamp; |
1096 | ev->x = input->sx; | 1152 | ev->x = input->sx; |
1097 | ev->y = input->sy; | 1153 | ev->y = input->sy; |
1098 | /* ev->root.x = input->sx; */ | 1154 | ev->root.x = input->sx; |
1099 | /* ev->root.y = input->sy; */ | 1155 | ev->root.y = input->sy; |
1100 | ev->modifiers = input->modifiers; | 1156 | ev->modifiers = input->modifiers; |
1101 | ev->multi.device = device; | 1157 | ev->multi.device = device; |
1102 | ev->multi.radius = 1; | 1158 | ev->multi.radius = 1; |
@@ -1106,6 +1162,8 @@ _ecore_wl_input_mouse_move_send(Ecore_Wl_Input *input, Ecore_Wl_Window *win, uns | |||
1106 | ev->multi.angle = 0.0; | 1162 | ev->multi.angle = 0.0; |
1107 | ev->multi.x = input->sx; | 1163 | ev->multi.x = input->sx; |
1108 | ev->multi.y = input->sy; | 1164 | ev->multi.y = input->sy; |
1165 | ev->multi.root.x = input->sx; | ||
1166 | ev->multi.root.y = input->sy; | ||
1109 | 1167 | ||
1110 | if ((down_info = _ecore_wl_mouse_down_info_get(device))) | 1168 | if ((down_info = _ecore_wl_mouse_down_info_get(device))) |
1111 | { | 1169 | { |
@@ -1133,8 +1191,8 @@ _ecore_wl_input_mouse_in_send(Ecore_Wl_Input *input, Ecore_Wl_Window *win, unsig | |||
1133 | 1191 | ||
1134 | ev->x = input->sx; | 1192 | ev->x = input->sx; |
1135 | ev->y = input->sy; | 1193 | ev->y = input->sy; |
1136 | /* ev->root.x = input->sx; */ | 1194 | ev->root.x = input->sx; |
1137 | /* ev->root.y = input->sy; */ | 1195 | ev->root.y = input->sy; |
1138 | ev->modifiers = input->modifiers; | 1196 | ev->modifiers = input->modifiers; |
1139 | ev->timestamp = timestamp; | 1197 | ev->timestamp = timestamp; |
1140 | 1198 | ||
@@ -1158,8 +1216,8 @@ _ecore_wl_input_mouse_out_send(Ecore_Wl_Input *input, Ecore_Wl_Window *win, unsi | |||
1158 | 1216 | ||
1159 | ev->x = input->sx; | 1217 | ev->x = input->sx; |
1160 | ev->y = input->sy; | 1218 | ev->y = input->sy; |
1161 | /* ev->root.x = input->sx; */ | 1219 | ev->root.x = input->sx; |
1162 | /* ev->root.y = input->sy; */ | 1220 | ev->root.y = input->sy; |
1163 | ev->modifiers = input->modifiers; | 1221 | ev->modifiers = input->modifiers; |
1164 | ev->timestamp = timestamp; | 1222 | ev->timestamp = timestamp; |
1165 | 1223 | ||
@@ -1220,8 +1278,8 @@ _ecore_wl_input_mouse_down_send(Ecore_Wl_Input *input, Ecore_Wl_Window *win, int | |||
1220 | ev->timestamp = timestamp; | 1278 | ev->timestamp = timestamp; |
1221 | ev->x = input->sx; | 1279 | ev->x = input->sx; |
1222 | ev->y = input->sy; | 1280 | ev->y = input->sy; |
1223 | /* ev->root.x = input->sx; */ | 1281 | ev->root.x = input->sx; |
1224 | /* ev->root.y = input->sy; */ | 1282 | ev->root.y = input->sy; |
1225 | ev->modifiers = input->modifiers; | 1283 | ev->modifiers = input->modifiers; |
1226 | 1284 | ||
1227 | ev->double_click = 0; | 1285 | ev->double_click = 0; |
@@ -1284,6 +1342,8 @@ _ecore_wl_input_mouse_down_send(Ecore_Wl_Input *input, Ecore_Wl_Window *win, int | |||
1284 | ev->multi.angle = 0.0; | 1342 | ev->multi.angle = 0.0; |
1285 | ev->multi.x = input->sx; | 1343 | ev->multi.x = input->sx; |
1286 | ev->multi.y = input->sy; | 1344 | ev->multi.y = input->sy; |
1345 | ev->multi.root.x = input->sx; | ||
1346 | ev->multi.root.y = input->sy; | ||
1287 | 1347 | ||
1288 | if (win) | 1348 | if (win) |
1289 | { | 1349 | { |
@@ -1327,8 +1387,8 @@ _ecore_wl_input_mouse_up_send(Ecore_Wl_Input *input, Ecore_Wl_Window *win, int d | |||
1327 | ev->timestamp = timestamp; | 1387 | ev->timestamp = timestamp; |
1328 | ev->x = input->sx; | 1388 | ev->x = input->sx; |
1329 | ev->y = input->sy; | 1389 | ev->y = input->sy; |
1330 | /* ev->root.x = input->sx; */ | 1390 | ev->root.x = input->sx; |
1331 | /* ev->root.y = input->sy; */ | 1391 | ev->root.y = input->sy; |
1332 | ev->modifiers = input->modifiers; | 1392 | ev->modifiers = input->modifiers; |
1333 | 1393 | ||
1334 | ev->double_click = 0; | 1394 | ev->double_click = 0; |
@@ -1355,6 +1415,8 @@ _ecore_wl_input_mouse_up_send(Ecore_Wl_Input *input, Ecore_Wl_Window *win, int d | |||
1355 | ev->multi.radius_y = 1; | 1415 | ev->multi.radius_y = 1; |
1356 | ev->multi.pressure = 1.0; | 1416 | ev->multi.pressure = 1.0; |
1357 | ev->multi.angle = 0.0; | 1417 | ev->multi.angle = 0.0; |
1418 | ev->multi.root.x = input->sx; | ||
1419 | ev->multi.root.y = input->sy; | ||
1358 | 1420 | ||
1359 | if (win) | 1421 | if (win) |
1360 | { | 1422 | { |