ecore_cocoa: fix scrollwheel behavior

- prioritize vertical scroll over horizontal
  - set amount to either -1 or 1, since EFL doesn't handle other value properly
  - fix wheel bouncing with some devices (X:0,Y:0 scrolling events)

  @fix
This commit is contained in:
pierre lamot 2015-04-02 15:44:45 +02:00 committed by Nicolas Aguirre
parent 35f47f43af
commit 869ed025a2
1 changed files with 26 additions and 2 deletions

View File

@ -324,16 +324,40 @@ ecore_cocoa_feed_events(void *anEvent)
EcoreCocoaWindow *window = (EcoreCocoaWindow *)[event window];
Ecore_Event_Mouse_Wheel *ev;
float dx, dy = 0;
ev = malloc(sizeof(Ecore_Event_Mouse_Wheel));
if (!ev) return pass;
if ([event hasPreciseScrollingDeltas])
{
dx = -[event scrollingDeltaX];
dy = -[event scrollingDeltaY];
}
else
{
dx = -[event deltaX];
dy = -[event deltaY];
}
if (dx == 0 && dy == 0)
{
break;
}
ev->window = (Ecore_Window)window.ecore_window_data;
ev->event_window = ev->window;
ev->modifiers = 0; /* FIXME: keep modifier around. */
ev->timestamp = time;
ev->z = [event deltaX] != 0 ? [event deltaX] : -([event deltaY]);
ev->direction = [event deltaX] != 0 ? 1 : 0;
if (dy != 0)
{
ev->z = (dy > 0) ? 1 : -1;
}
else
{
ev->z = (dx > 0) ? 1 : -1;
}
ev->direction = (dy != 0) ? 0 : 1;
ecore_event_add(ECORE_EVENT_MOUSE_WHEEL, ev, NULL, NULL);