summaryrefslogtreecommitdiff
path: root/src/lib/ecore_wl2/ecore_wl2_input.c
diff options
context:
space:
mode:
authorDerek Foreman <derekf@osg.samsung.com>2018-07-06 10:16:21 -0400
committerChris Michael <cp.michael@samsung.com>2018-07-06 10:16:21 -0400
commit78f27a3efff24ba3b935cc9e2620718e51af9304 (patch)
tree13a69cef3687cb032c8eae6110a0a95133a804ec /src/lib/ecore_wl2/ecore_wl2_input.c
parentacb125419f922d2a0826960633536969eced5ce7 (diff)
ecore_wl2: Replace window ids with pointers
Summary: There's no benefit to generating ids instead of just using the Ecore_Wl2_Window pointer in events. This has the added benefit of working around a really nasty hash collision bug when multiple ecore_evas engines are used at once. ref T7053 ref T6222 @beta_break Depends on D6521 Reviewers: devilhorns Reviewed By: devilhorns Subscribers: cedric, #committers, zmike Tags: #efl Maniphest Tasks: T7053, T6222 Differential Revision: https://phab.enlightenment.org/D6522
Diffstat (limited to 'src/lib/ecore_wl2/ecore_wl2_input.c')
-rw-r--r--src/lib/ecore_wl2/ecore_wl2_input.c122
1 files changed, 61 insertions, 61 deletions
diff --git a/src/lib/ecore_wl2/ecore_wl2_input.c b/src/lib/ecore_wl2/ecore_wl2_input.c
index 9d6378f1bb..14de4dc9f0 100644
--- a/src/lib/ecore_wl2/ecore_wl2_input.c
+++ b/src/lib/ecore_wl2/ecore_wl2_input.c
@@ -47,10 +47,10 @@ typedef struct _Ecore_Wl2_Mouse_Down_Info
47{ 47{
48 EINA_INLIST; 48 EINA_INLIST;
49 int device, sx, sy; 49 int device, sx, sy;
50 int last_win; 50 Ecore_Wl2_Window *last_win;
51 int last_last_win; 51 Ecore_Wl2_Window *last_last_win;
52 int last_event_win; 52 Ecore_Wl2_Window *last_event_win;
53 int last_last_event_win; 53 Ecore_Wl2_Window *last_last_event_win;
54 unsigned int last_time; 54 unsigned int last_time;
55 unsigned int last_last_time; 55 unsigned int last_last_time;
56 Eina_Bool double_click : 1; 56 Eina_Bool double_click : 1;
@@ -82,14 +82,14 @@ _ecore_wl2_input_mouse_down_info_get(int device)
82} 82}
83 83
84static Ecore_Wl2_Input_Devices * 84static Ecore_Wl2_Input_Devices *
85_ecore_wl2_devices_get(const Ecore_Wl2_Input *input, int window_id) 85_ecore_wl2_devices_get(const Ecore_Wl2_Input *input, const Ecore_Wl2_Window *window)
86{ 86{
87 Ecore_Wl2_Input_Devices *devices; 87 Ecore_Wl2_Input_Devices *devices;
88 Eina_List *l; 88 Eina_List *l;
89 89
90 EINA_LIST_FOREACH(input->devices_list, l, devices) 90 EINA_LIST_FOREACH(input->devices_list, l, devices)
91 { 91 {
92 if (devices->window_id == window_id) 92 if (devices->window == window)
93 return devices; 93 return devices;
94 } 94 }
95 95
@@ -97,11 +97,11 @@ _ecore_wl2_devices_get(const Ecore_Wl2_Input *input, int window_id)
97} 97}
98 98
99static Eo * 99static Eo *
100_ecore_wl2_mouse_dev_get(Ecore_Wl2_Input *input, int window_id) 100_ecore_wl2_mouse_dev_get(Ecore_Wl2_Input *input, Ecore_Wl2_Window *window)
101{ 101{
102 Ecore_Wl2_Input_Devices *devices; 102 Ecore_Wl2_Input_Devices *devices;
103 103
104 devices = _ecore_wl2_devices_get(input, window_id); 104 devices = _ecore_wl2_devices_get(input, window);
105 if (devices && devices->pointer_dev) 105 if (devices && devices->pointer_dev)
106 return efl_ref(devices->pointer_dev); 106 return efl_ref(devices->pointer_dev);
107 107
@@ -109,11 +109,11 @@ _ecore_wl2_mouse_dev_get(Ecore_Wl2_Input *input, int window_id)
109} 109}
110 110
111static Eo * 111static Eo *
112_ecore_wl2_touch_dev_get(Ecore_Wl2_Input *input, int window_id) 112_ecore_wl2_touch_dev_get(Ecore_Wl2_Input *input, Ecore_Wl2_Window *window)
113{ 113{
114 Ecore_Wl2_Input_Devices *devices; 114 Ecore_Wl2_Input_Devices *devices;
115 115
116 devices = _ecore_wl2_devices_get(input, window_id); 116 devices = _ecore_wl2_devices_get(input, window);
117 if (devices && devices->touch_dev) 117 if (devices && devices->touch_dev)
118 return efl_ref(devices->touch_dev); 118 return efl_ref(devices->touch_dev);
119 119
@@ -121,11 +121,11 @@ _ecore_wl2_touch_dev_get(Ecore_Wl2_Input *input, int window_id)
121} 121}
122 122
123static Eo * 123static Eo *
124_ecore_wl2_seat_dev_get(Ecore_Wl2_Input *input, int window_id) 124_ecore_wl2_seat_dev_get(Ecore_Wl2_Input *input, Ecore_Wl2_Window *window)
125{ 125{
126 Ecore_Wl2_Input_Devices *devices; 126 Ecore_Wl2_Input_Devices *devices;
127 127
128 devices = _ecore_wl2_devices_get(input, window_id); 128 devices = _ecore_wl2_devices_get(input, window);
129 if (devices) 129 if (devices)
130 return efl_ref(devices->seat_dev); 130 return efl_ref(devices->seat_dev);
131 131
@@ -150,11 +150,11 @@ _ecore_wl2_input_mouse_in_send(Ecore_Wl2_Input *input, Ecore_Wl2_Window *window)
150 150
151 ev->x = input->pointer.sx; 151 ev->x = input->pointer.sx;
152 ev->y = input->pointer.sy; 152 ev->y = input->pointer.sy;
153 ev->window = window->id; 153 ev->window = (Ecore_Window)window;
154 ev->event_window = window->id; 154 ev->event_window = (Ecore_Window)window;
155 ev->timestamp = input->timestamp; 155 ev->timestamp = input->timestamp;
156 ev->modifiers = input->keyboard.modifiers; 156 ev->modifiers = input->keyboard.modifiers;
157 ev->dev = _ecore_wl2_mouse_dev_get(input, window->id); 157 ev->dev = _ecore_wl2_mouse_dev_get(input, window);
158 158
159 ecore_event_add(ECORE_EVENT_MOUSE_IN, ev, _input_event_cb_free, ev->dev); 159 ecore_event_add(ECORE_EVENT_MOUSE_IN, ev, _input_event_cb_free, ev->dev);
160} 160}
@@ -169,11 +169,11 @@ _ecore_wl2_input_mouse_out_send(Ecore_Wl2_Input *input, Ecore_Wl2_Window *window
169 169
170 ev->x = input->pointer.sx; 170 ev->x = input->pointer.sx;
171 ev->y = input->pointer.sy; 171 ev->y = input->pointer.sy;
172 ev->window = window->id; 172 ev->window = (Ecore_Window)window;
173 ev->event_window = window->id; 173 ev->event_window = (Ecore_Window)window;
174 ev->timestamp = input->timestamp; 174 ev->timestamp = input->timestamp;
175 ev->modifiers = input->keyboard.modifiers; 175 ev->modifiers = input->keyboard.modifiers;
176 ev->dev = _ecore_wl2_mouse_dev_get(input, window->id); 176 ev->dev = _ecore_wl2_mouse_dev_get(input, window);
177 177
178 ecore_event_add(ECORE_EVENT_MOUSE_OUT, ev, _input_event_cb_free, ev->dev); 178 ecore_event_add(ECORE_EVENT_MOUSE_OUT, ev, _input_event_cb_free, ev->dev);
179} 179}
@@ -187,8 +187,8 @@ _ecore_wl2_input_mouse_move_send(Ecore_Wl2_Input *input, Ecore_Wl2_Window *windo
187 ev = calloc(1, sizeof(Ecore_Event_Mouse_Move)); 187 ev = calloc(1, sizeof(Ecore_Event_Mouse_Move));
188 if (!ev) return; 188 if (!ev) return;
189 189
190 ev->window = window->id; 190 ev->window = (Ecore_Window)window;
191 ev->event_window = window->id; 191 ev->event_window = (Ecore_Window)window;
192 ev->timestamp = input->timestamp; 192 ev->timestamp = input->timestamp;
193 ev->x = input->pointer.sx; 193 ev->x = input->pointer.sx;
194 ev->y = input->pointer.sy; 194 ev->y = input->pointer.sy;
@@ -207,9 +207,9 @@ _ecore_wl2_input_mouse_move_send(Ecore_Wl2_Input *input, Ecore_Wl2_Window *windo
207 ev->multi.root.y = input->pointer.sy; 207 ev->multi.root.y = input->pointer.sy;
208 208
209 if ((input->focus.touch) && (input->focus.touch == window)) 209 if ((input->focus.touch) && (input->focus.touch == window))
210 ev->dev = _ecore_wl2_touch_dev_get(input, window->id); 210 ev->dev = _ecore_wl2_touch_dev_get(input, window);
211 else if ((input->focus.pointer) && (input->focus.pointer == window)) 211 else if ((input->focus.pointer) && (input->focus.pointer == window))
212 ev->dev = _ecore_wl2_mouse_dev_get(input, window->id); 212 ev->dev = _ecore_wl2_mouse_dev_get(input, window);
213 213
214 info = _ecore_wl2_input_mouse_down_info_get(device); 214 info = _ecore_wl2_input_mouse_down_info_get(device);
215 if (info) 215 if (info)
@@ -248,27 +248,27 @@ _ecore_wl2_input_mouse_wheel_send(Ecore_Wl2_Input *input, unsigned int axis, int
248 248
249 if (input->grab.window) 249 if (input->grab.window)
250 { 250 {
251 ev->window = input->grab.window->id; 251 ev->window = (Ecore_Window)input->grab.window;
252 ev->event_window = input->grab.window->id; 252 ev->event_window = (Ecore_Window)input->grab.window;
253 } 253 }
254 else if (input->focus.pointer) 254 else if (input->focus.pointer)
255 { 255 {
256 ev->window = input->focus.pointer->id; 256 ev->window = (Ecore_Window)input->focus.pointer;
257 ev->event_window = input->focus.pointer->id; 257 ev->event_window = (Ecore_Window)input->focus.pointer;
258 ev->dev = _ecore_wl2_mouse_dev_get(input, input->focus.pointer->id); 258 ev->dev = _ecore_wl2_mouse_dev_get(input, input->focus.pointer);
259 } 259 }
260 else if (input->focus.touch) 260 else if (input->focus.touch)
261 { 261 {
262 ev->window = input->focus.touch->id; 262 ev->window = (Ecore_Window)input->focus.touch;
263 ev->event_window = input->focus.touch->id; 263 ev->event_window = (Ecore_Window)input->focus.touch;
264 ev->dev = _ecore_wl2_touch_dev_get(input, input->focus.touch->id); 264 ev->dev = _ecore_wl2_touch_dev_get(input, input->focus.touch);
265 } 265 }
266 266
267 if (!ev->dev) 267 if (!ev->dev)
268 { 268 {
269 ev->dev = _ecore_wl2_mouse_dev_get(input, ev->window); 269 ev->dev = _ecore_wl2_mouse_dev_get(input, (Ecore_Wl2_Window *)ev->window);
270 if (!ev->dev) 270 if (!ev->dev)
271 ev->dev = _ecore_wl2_touch_dev_get(input, ev->window); 271 ev->dev = _ecore_wl2_touch_dev_get(input, (Ecore_Wl2_Window *)ev->window);
272 } 272 }
273 273
274 ecore_event_add(ECORE_EVENT_MOUSE_WHEEL, ev, _input_event_cb_free, ev->dev); 274 ecore_event_add(ECORE_EVENT_MOUSE_WHEEL, ev, _input_event_cb_free, ev->dev);
@@ -318,8 +318,8 @@ _ecore_wl2_input_mouse_down_send(Ecore_Wl2_Input *input, Ecore_Wl2_Window *windo
318 } 318 }
319 319
320 if (((int)(timestamp - info->last_time) <= (int)(1000 * 0.25)) && 320 if (((int)(timestamp - info->last_time) <= (int)(1000 * 0.25)) &&
321 ((window) && (window->id == info->last_win) && 321 ((window) && (window == info->last_win) &&
322 (window->id == info->last_event_win))) 322 (window == info->last_event_win)))
323 { 323 {
324 ev->double_click = 1; 324 ev->double_click = 1;
325 info->double_click = EINA_TRUE; 325 info->double_click = EINA_TRUE;
@@ -332,10 +332,10 @@ _ecore_wl2_input_mouse_down_send(Ecore_Wl2_Input *input, Ecore_Wl2_Window *windo
332 332
333 if (((int)(timestamp - info->last_last_time) <= 333 if (((int)(timestamp - info->last_last_time) <=
334 (int)(2 * 1000 * 0.25)) && 334 (int)(2 * 1000 * 0.25)) &&
335 ((window) && (window->id == info->last_win) && 335 ((window) && (window == info->last_win) &&
336 (window->id == info->last_last_win) && 336 (window == info->last_last_win) &&
337 (window->id == info->last_event_win) && 337 (window == info->last_event_win) &&
338 (window->id == info->last_last_event_win))) 338 (window == info->last_last_event_win)))
339 { 339 {
340 ev->triple_click = 1; 340 ev->triple_click = 1;
341 info->triple_click = EINA_TRUE; 341 info->triple_click = EINA_TRUE;
@@ -357,13 +357,13 @@ _ecore_wl2_input_mouse_down_send(Ecore_Wl2_Input *input, Ecore_Wl2_Window *windo
357 357
358 if (window) 358 if (window)
359 { 359 {
360 ev->window = window->id; 360 ev->window = (Ecore_Window)window;
361 ev->event_window = window->id; 361 ev->event_window = (Ecore_Window)window;
362 362
363 if ((input->focus.touch) && (input->focus.touch == window)) 363 if ((input->focus.touch) && (input->focus.touch == window))
364 ev->dev = _ecore_wl2_touch_dev_get(input, window->id); 364 ev->dev = _ecore_wl2_touch_dev_get(input, window);
365 else if ((input->focus.pointer) && (input->focus.pointer == window)) 365 else if ((input->focus.pointer) && (input->focus.pointer == window))
366 ev->dev = _ecore_wl2_mouse_dev_get(input, window->id); 366 ev->dev = _ecore_wl2_mouse_dev_get(input, window);
367 } 367 }
368 368
369 ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, ev, 369 ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, ev,
@@ -372,9 +372,9 @@ _ecore_wl2_input_mouse_down_send(Ecore_Wl2_Input *input, Ecore_Wl2_Window *windo
372 if ((info) && (!info->triple_click)) 372 if ((info) && (!info->triple_click))
373 { 373 {
374 info->last_last_win = info->last_win; 374 info->last_last_win = info->last_win;
375 info->last_win = ev->window; 375 info->last_win = (Ecore_Wl2_Window *)ev->window;
376 info->last_last_event_win = info->last_event_win; 376 info->last_last_event_win = info->last_event_win;
377 info->last_event_win = ev->window; 377 info->last_event_win = (Ecore_Wl2_Window *)ev->window;
378 info->last_last_time = info->last_time; 378 info->last_last_time = info->last_time;
379 info->last_time = timestamp; 379 info->last_time = timestamp;
380 } 380 }
@@ -433,13 +433,13 @@ _ecore_wl2_input_mouse_up_send(Ecore_Wl2_Input *input, Ecore_Wl2_Window *window,
433 ev->multi.root.x = input->pointer.sx; 433 ev->multi.root.x = input->pointer.sx;
434 ev->multi.root.y = input->pointer.sy; 434 ev->multi.root.y = input->pointer.sy;
435 435
436 ev->window = window->id; 436 ev->window = (Ecore_Window)window;
437 ev->event_window = window->id; 437 ev->event_window = (Ecore_Window)window;
438 438
439 if ((input->focus.touch) && (input->focus.touch == window)) 439 if ((input->focus.touch) && (input->focus.touch == window))
440 ev->dev = _ecore_wl2_touch_dev_get(input, window->id); 440 ev->dev = _ecore_wl2_touch_dev_get(input, window);
441 else if ((input->focus.pointer) && (input->focus.pointer == window)) 441 else if ((input->focus.pointer) && (input->focus.pointer == window))
442 ev->dev = _ecore_wl2_mouse_dev_get(input, window->id); 442 ev->dev = _ecore_wl2_mouse_dev_get(input, window);
443 443
444 ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_UP, ev, 444 ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_UP, ev,
445 _input_event_cb_free, ev->dev); 445 _input_event_cb_free, ev->dev);
@@ -464,8 +464,8 @@ _ecore_wl2_input_focus_in_send(Ecore_Wl2_Window *window, Ecore_Wl2_Input *input)
464 if (!ev) return; 464 if (!ev) return;
465 465
466 ev->timestamp = input->timestamp; 466 ev->timestamp = input->timestamp;
467 ev->window = window->id; 467 ev->window = window;
468 ev->dev = _ecore_wl2_seat_dev_get(input, window->id); 468 ev->dev = _ecore_wl2_seat_dev_get(input, window);
469 ev->display = input->display; 469 ev->display = input->display;
470 ev->display->refs++; 470 ev->display->refs++;
471 ecore_event_add(ECORE_WL2_EVENT_FOCUS_IN, ev, _input_event_focus_cb_free, 471 ecore_event_add(ECORE_WL2_EVENT_FOCUS_IN, ev, _input_event_focus_cb_free,
@@ -481,8 +481,8 @@ _ecore_wl2_input_focus_out_send(Ecore_Wl2_Window *window, Ecore_Wl2_Input *input
481 if (!ev) return; 481 if (!ev) return;
482 482
483 ev->timestamp = input->timestamp; 483 ev->timestamp = input->timestamp;
484 ev->window = window->id; 484 ev->window = window;
485 ev->dev = _ecore_wl2_seat_dev_get(input, window->id); 485 ev->dev = _ecore_wl2_seat_dev_get(input, window);
486 ev->display = input->display; 486 ev->display = input->display;
487 ev->display->refs++; 487 ev->display->refs++;
488 ecore_event_add(ECORE_WL2_EVENT_FOCUS_OUT, ev, _input_event_focus_cb_free, 488 ecore_event_add(ECORE_WL2_EVENT_FOCUS_OUT, ev, _input_event_focus_cb_free,
@@ -609,11 +609,11 @@ _ecore_wl2_input_symbol_rep_find(xkb_keysym_t keysym, char *buffer, int size, un
609} 609}
610 610
611static Eo * 611static Eo *
612_ecore_wl2_keyboard_dev_get(Ecore_Wl2_Input *input, int window_id) 612_ecore_wl2_keyboard_dev_get(Ecore_Wl2_Input *input, Ecore_Wl2_Window * window)
613{ 613{
614 Ecore_Wl2_Input_Devices *devices; 614 Ecore_Wl2_Input_Devices *devices;
615 615
616 devices = _ecore_wl2_devices_get(input, window_id); 616 devices = _ecore_wl2_devices_get(input, window);
617 if (devices && devices->keyboard_dev) 617 if (devices && devices->keyboard_dev)
618 return efl_ref(devices->keyboard_dev); 618 return efl_ref(devices->keyboard_dev);
619 619
@@ -649,12 +649,12 @@ _ecore_wl2_input_key_send(Ecore_Wl2_Input *input, Ecore_Wl2_Window *window, xkb_
649 strcpy((char *)ev->key, key); 649 strcpy((char *)ev->key, key);
650 if (comp_len) strcpy((char *)ev->compose, compose); 650 if (comp_len) strcpy((char *)ev->compose, compose);
651 651
652 ev->window = window->id; 652 ev->window = (Ecore_Window)window;
653 ev->event_window = window->id; 653 ev->event_window = (Ecore_Window)window;
654 ev->timestamp = timestamp; 654 ev->timestamp = timestamp;
655 ev->modifiers = input->keyboard.modifiers; 655 ev->modifiers = input->keyboard.modifiers;
656 ev->keycode = code; 656 ev->keycode = code;
657 ev->dev = _ecore_wl2_keyboard_dev_get(input, window->id); 657 ev->dev = _ecore_wl2_keyboard_dev_get(input, window);
658 658
659 /* DBG("Emitting Key event (%s,%s,%s,%s)\n", ev->keyname, ev->key, ev->compose, ev->string); */ 659 /* DBG("Emitting Key event (%s,%s,%s,%s)\n", ev->keyname, ev->key, ev->compose, ev->string); */
660 660
@@ -1535,7 +1535,7 @@ _ecore_wl2_cb_device_event(void *data, int type, void *event)
1535 1535
1536 EINA_LIST_FOREACH(input->devices_list, l, devs) 1536 EINA_LIST_FOREACH(input->devices_list, l, devs)
1537 { 1537 {
1538 if (devs->window_id == ev->window_id) 1538 if (devs->window == ev->window)
1539 { 1539 {
1540 devices = devs; 1540 devices = devs;
1541 break; 1541 break;
@@ -1550,7 +1550,7 @@ _ecore_wl2_cb_device_event(void *data, int type, void *event)
1550 EINA_SAFETY_ON_NULL_RETURN_VAL(devices, ECORE_CALLBACK_PASS_ON); 1550 EINA_SAFETY_ON_NULL_RETURN_VAL(devices, ECORE_CALLBACK_PASS_ON);
1551 input->devices_list = 1551 input->devices_list =
1552 eina_list_append(input->devices_list, devices); 1552 eina_list_append(input->devices_list, devices);
1553 devices->window_id = ev->window_id; 1553 devices->window = ev->window;
1554 } 1554 }
1555 1555
1556 if (ev->type == ECORE_WL2_DEVICE_TYPE_POINTER) 1556 if (ev->type == ECORE_WL2_DEVICE_TYPE_POINTER)
@@ -1747,7 +1747,7 @@ _ecore_wl2_input_window_remove(Ecore_Wl2_Input *input, Ecore_Wl2_Window *window)
1747 } 1747 }
1748 1748
1749 EINA_LIST_FOREACH_SAFE(input->devices_list, l, l_next, devices) 1749 EINA_LIST_FOREACH_SAFE(input->devices_list, l, l_next, devices)
1750 if (devices->window_id == window->id) 1750 if (devices->window == window)
1751 { 1751 {
1752 _ecore_wl2_devices_free(devices); 1752 _ecore_wl2_devices_free(devices);
1753 input->devices_list = eina_list_remove_list(input->devices_list, l); 1753 input->devices_list = eina_list_remove_list(input->devices_list, l);
@@ -1828,7 +1828,7 @@ ecore_wl2_input_seat_device_get(const Ecore_Wl2_Input *input, const Ecore_Wl2_Wi
1828 EINA_SAFETY_ON_NULL_RETURN_VAL(input, NULL); 1828 EINA_SAFETY_ON_NULL_RETURN_VAL(input, NULL);
1829 EINA_SAFETY_ON_NULL_RETURN_VAL(window, NULL); 1829 EINA_SAFETY_ON_NULL_RETURN_VAL(window, NULL);
1830 1830
1831 devices = _ecore_wl2_devices_get(input, window->id); 1831 devices = _ecore_wl2_devices_get(input, window);
1832 return devices ? devices->seat_dev : NULL; 1832 return devices ? devices->seat_dev : NULL;
1833} 1833}
1834 1834