summaryrefslogtreecommitdiff
path: root/src/lib/ecore_drm/ecore_drm_evdev.c
diff options
context:
space:
mode:
authorDerek Foreman <derekf@osg.samsung.com>2015-02-27 10:40:38 -0500
committerChris Michael <cp.michael@samsung.com>2015-02-27 10:40:38 -0500
commit95cb1938c22664095675ca21649856371385f393 (patch)
tree1f7ff18fbdff9e678c5dde69613b2455d68580ed /src/lib/ecore_drm/ecore_drm_evdev.c
parent3bb11b938c7efef87a86638ea5427c174c7725ca (diff)
Use doubles to store libinput's mouse motion
Summary: Using can result in motion being completely discarded. Since we only need integer data, we also only actually forward on an event when the mouse moves more than a full unit. Reviewers: zmike, devilhorns Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D2062
Diffstat (limited to '')
-rw-r--r--src/lib/ecore_drm/ecore_drm_evdev.c75
1 files changed, 45 insertions, 30 deletions
diff --git a/src/lib/ecore_drm/ecore_drm_evdev.c b/src/lib/ecore_drm/ecore_drm_evdev.c
index 8320c30ed9..054858adf0 100644
--- a/src/lib/ecore_drm/ecore_drm_evdev.c
+++ b/src/lib/ecore_drm/ecore_drm_evdev.c
@@ -347,15 +347,16 @@ _device_pointer_motion(Ecore_Drm_Evdev *edev, struct libinput_event_pointer *eve
347 347
348 if ((output = edev->output)) 348 if ((output = edev->output))
349 { 349 {
350 if (edev->mouse.x < output->x) 350 if (edev->mouse.ix < output->x)
351 edev->mouse.x = output->x; 351 edev->mouse.dx = edev->mouse.ix = output->x;
352 else if (edev->mouse.x >= (output->x + output->current_mode->width)) 352 else if (edev->mouse.ix >= (output->x + output->current_mode->width))
353 edev->mouse.x = (output->x + output->current_mode->width - 1); 353 edev->mouse.dx =
354 354 edev->mouse.ix = (output->x + output->current_mode->width - 1);
355 if (edev->mouse.y < output->y) 355
356 edev->mouse.y = output->y; 356 if (edev->mouse.iy < output->y)
357 else if (edev->mouse.y >= (output->y + output->current_mode->height)) 357 edev->mouse.dy = edev->mouse.iy = output->y;
358 edev->mouse.y = (output->y + output->current_mode->height - 1); 358 else if (edev->mouse.iy >= (output->y + output->current_mode->height))
359 edev->mouse.dy = edev->mouse.iy = (output->y + output->current_mode->height - 1);
359 } 360 }
360 361
361 ev->window = (Ecore_Window)input->dev->window; 362 ev->window = (Ecore_Window)input->dev->window;
@@ -367,8 +368,8 @@ _device_pointer_motion(Ecore_Drm_Evdev *edev, struct libinput_event_pointer *eve
367 _device_modifiers_update(edev); 368 _device_modifiers_update(edev);
368 ev->modifiers = edev->xkb.modifiers; 369 ev->modifiers = edev->xkb.modifiers;
369 370
370 ev->x = edev->mouse.x; 371 ev->x = edev->mouse.ix;
371 ev->y = edev->mouse.y; 372 ev->y = edev->mouse.iy;
372 ev->root.x = ev->x; 373 ev->root.x = ev->x;
373 ev->root.y = ev->y; 374 ev->root.y = ev->y;
374 375
@@ -393,10 +394,15 @@ _device_handle_pointer_motion(struct libinput_device *device, struct libinput_ev
393 394
394 if (!(edev = libinput_device_get_user_data(device))) return; 395 if (!(edev = libinput_device_get_user_data(device))) return;
395 396
396 edev->mouse.x += libinput_event_pointer_get_dx(event); 397 edev->mouse.dx += libinput_event_pointer_get_dx(event);
397 edev->mouse.y += libinput_event_pointer_get_dy(event); 398 edev->mouse.dy += libinput_event_pointer_get_dy(event);
398 399
399 _device_pointer_motion(edev, event); 400 if (floor(edev->mouse.dx) == edev->mouse.ix &&
401 floor(edev->mouse.dy) == edev->mouse.iy) return;
402
403 edev->mouse.ix = edev->mouse.dx;
404 edev->mouse.iy = edev->mouse.dy;
405 _device_pointer_motion(edev, event);
400} 406}
401 407
402static void 408static void
@@ -406,13 +412,16 @@ _device_handle_pointer_motion_absolute(struct libinput_device *device, struct li
406 412
407 if (!(edev = libinput_device_get_user_data(device))) return; 413 if (!(edev = libinput_device_get_user_data(device))) return;
408 414
409 edev->mouse.x = 415 edev->mouse.dx =
410 libinput_event_pointer_get_absolute_x_transformed(event, 416 libinput_event_pointer_get_absolute_x_transformed(event,
411 edev->output->current_mode->width); 417 edev->output->current_mode->width);
412 edev->mouse.y = 418 edev->mouse.dy =
413 libinput_event_pointer_get_absolute_y_transformed(event, 419 libinput_event_pointer_get_absolute_y_transformed(event,
414 edev->output->current_mode->height); 420 edev->output->current_mode->height);
415 421
422 if (floor(edev->mouse.dx) == edev->mouse.ix &&
423 floor(edev->mouse.dy) == edev->mouse.iy) return;
424
416 _device_pointer_motion(edev, event); 425 _device_pointer_motion(edev, event);
417} 426}
418 427
@@ -447,8 +456,8 @@ _device_handle_button(struct libinput_device *device, struct libinput_event_poin
447 _device_modifiers_update(edev); 456 _device_modifiers_update(edev);
448 ev->modifiers = edev->xkb.modifiers; 457 ev->modifiers = edev->xkb.modifiers;
449 458
450 ev->x = edev->mouse.x; 459 ev->x = edev->mouse.ix;
451 ev->y = edev->mouse.y; 460 ev->y = edev->mouse.iy;
452 ev->root.x = ev->x; 461 ev->root.x = ev->x;
453 ev->root.y = ev->y; 462 ev->root.y = ev->y;
454 463
@@ -529,8 +538,8 @@ _device_handle_axis(struct libinput_device *device, struct libinput_event_pointe
529 _device_modifiers_update(edev); 538 _device_modifiers_update(edev);
530 ev->modifiers = edev->xkb.modifiers; 539 ev->modifiers = edev->xkb.modifiers;
531 540
532 ev->x = edev->mouse.x; 541 ev->x = edev->mouse.ix;
533 ev->y = edev->mouse.y; 542 ev->y = edev->mouse.iy;
534 ev->root.x = ev->x; 543 ev->root.x = ev->x;
535 ev->root.y = ev->y; 544 ev->root.y = ev->y;
536 545
@@ -640,8 +649,8 @@ _device_handle_touch_event(Ecore_Drm_Evdev *edev, struct libinput_event_touch *e
640 _device_modifiers_update(edev); 649 _device_modifiers_update(edev);
641 ev->modifiers = edev->xkb.modifiers; 650 ev->modifiers = edev->xkb.modifiers;
642 651
643 ev->x = edev->mouse.x; 652 ev->x = edev->mouse.ix;
644 ev->y = edev->mouse.y; 653 ev->y = edev->mouse.iy;
645 ev->root.x = ev->x; 654 ev->root.x = ev->x;
646 ev->root.y = ev->y; 655 ev->root.y = ev->y;
647 656
@@ -701,9 +710,9 @@ _device_handle_touch_down(struct libinput_device *device, struct libinput_event_
701 710
702 if (!(edev = libinput_device_get_user_data(device))) return; 711 if (!(edev = libinput_device_get_user_data(device))) return;
703 712
704 edev->mouse.x = 713 edev->mouse.ix = edev->mouse.dx =
705 libinput_event_touch_get_x_transformed(event, edev->output->current_mode->width); 714 libinput_event_touch_get_x_transformed(event, edev->output->current_mode->width);
706 edev->mouse.y = 715 edev->mouse.iy = edev->mouse.dy =
707 libinput_event_touch_get_y_transformed(event, edev->output->current_mode->height); 716 libinput_event_touch_get_y_transformed(event, edev->output->current_mode->height);
708 717
709 edev->mt_slot = libinput_event_touch_get_seat_slot(event); 718 edev->mt_slot = libinput_event_touch_get_seat_slot(event);
@@ -723,11 +732,17 @@ _device_handle_touch_motion(struct libinput_device *device, struct libinput_even
723 732
724 if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Move)))) return; 733 if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Move)))) return;
725 734
726 edev->mouse.x = 735 edev->mouse.dx =
727 libinput_event_touch_get_x_transformed(event, edev->output->current_mode->width); 736 libinput_event_touch_get_x_transformed(event, edev->output->current_mode->width);
728 edev->mouse.y = 737 edev->mouse.dy =
729 libinput_event_touch_get_y_transformed(event, edev->output->current_mode->height); 738 libinput_event_touch_get_y_transformed(event, edev->output->current_mode->height);
730 739
740 if (floor(edev->mouse.dx) == edev->mouse.ix &&
741 floor(edev->mouse.dy) == edev->mouse.iy) return;
742
743 edev->mouse.ix = edev->mouse.dx;
744 edev->mouse.iy = edev->mouse.dy;
745
731 edev->mt_slot = libinput_event_touch_get_seat_slot(event); 746 edev->mt_slot = libinput_event_touch_get_seat_slot(event);
732 747
733 ev->window = (Ecore_Window)input->dev->window; 748 ev->window = (Ecore_Window)input->dev->window;
@@ -740,8 +755,8 @@ _device_handle_touch_motion(struct libinput_device *device, struct libinput_even
740 ev->modifiers = edev->xkb.modifiers; 755 ev->modifiers = edev->xkb.modifiers;
741 ev->modifiers = 0; 756 ev->modifiers = 0;
742 757
743 ev->x = edev->mouse.x; 758 ev->x = edev->mouse.ix;
744 ev->y = edev->mouse.y; 759 ev->y = edev->mouse.iy;
745 ev->root.x = ev->x; 760 ev->root.x = ev->x;
746 ev->root.y = ev->y; 761 ev->root.y = ev->y;
747 762