#include "config.h"
#endif
+#include <xorg/inputstr.h>
#include <linux/input.h>
#include <linux/types.h>
#include <xorg/mi.h>
//Basic functions
-static InputInfoPtr GesturePreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags);
+static int GesturePreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags);
static void GestureUnInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags);
static pointer GesturePlug(pointer module, pointer options, int *errmaj, int *errmin);
static void GestureUnplug(pointer p);
//utility functions
ErrorStatus GestureRegionsReinit(void);
-void GestureSetDisable(InputInfoPtr pInfo, int enable);
+void GestureEnable(int enable, Bool prop, DeviceIntPtr dev);
+static inline void GestureEnableDisable();
+void GestureCbEventsGrabbed(Mask *pGrabMask, GestureGrabEventPtr *pGrabEvent);
+void GestureCbEventsSelected(Window win, Mask *pEventMask);
WindowPtr GestureGetEventsWindow(void);
+static uint32_t GestureTouchFindDDXIDByTouchID(DeviceIntPtr device, uint32_t touchid);
//Enqueued event handlers and enabler/disabler
static ErrorStatus GestureEnableEventHandler(InputInfoPtr pInfo);
static CARD32 GestureTimerHandler(OsTimerPtr timer, CARD32 time, pointer arg);
static CARD32 GestureEventTimerHandler(OsTimerPtr timer, CARD32 time, pointer arg);
void GestureHandleMTSyncEvent(int screen_num, InternalEvent *ev, DeviceIntPtr device);
-void GestureHandleButtonPressEvent(int screen_num, InternalEvent *ev, DeviceIntPtr device);
-void GestureHandleButtonReleaseEvent(int screen_num, InternalEvent *ev, DeviceIntPtr device);
-void GestureHandleMotionEvent(int screen_num, InternalEvent *ev, DeviceIntPtr device);
+void GestureHandleTouchBeginEvent(int screen_num, InternalEvent *ev, DeviceIntPtr device);
+void GestureHandleTouchUpdateEvent(int screen_num, InternalEvent *ev, DeviceIntPtr device);
+void GestureHandleTouchEndEvent(int screen_num, InternalEvent *ev, DeviceIntPtr device);
//Gesture recognizer helper
static Bool PointInBorderSize(WindowPtr pWin, int x, int y);
void GestureHandleGesture_Hold(int num_fingers, int cx, int cy, Time holdtime, int kinds);
void GestureHandleGesture_TapNHold(int num_fingers, int cx, int cy, Time interval, Time holdtime, int kinds);
void GestureHandleGesture_Pan(int num_fingers, short int dx, short int dy, int direction, int distance, Time duration, int kinds);
-void GestureRecognize(int type, InternalEvent *ev, DeviceIntPtr device);
+void GestureRecognize(int type, InternalEvent *ev, DeviceIntPtr device, int idx);
ErrorStatus GestureFlushOrDrop(void);
#ifdef HAVE_PROPERTIES
switch( type )
{
- case ET_ButtonPress:
+ case ET_TouchBegin:
g_pGesture->fingers[idx].flags |= PressFlagPinchRotation;
if( g_pGesture->num_pressed < 2 )
#endif//__DETAIL_DEBUG__
break;
- case ET_Motion:
+ case ET_TouchUpdate:
if( !(g_pGesture->fingers[idx].flags & PressFlagPinchRotation) )
break;
}
break;
- case ET_ButtonRelease:
+ case ET_TouchEnd:
if( state != GestureEnd && num_pressed >= 2)
{
#ifdef __DETAIL_DEBUG__
if( g_pGesture->filter_mask == GESTURE_FILTER_MASK_ALL )
{
-#if 1//def __DETAIL_DEBUG__
+#ifdef __DETAIL_DEBUG__
ErrorF("[GroupPinchRotation][cleanup] GestureFlushOrDrop() !\n");
#endif//__DETAIL_DEBUG__
switch( type )
{
- case ET_ButtonPress:
+ case ET_TouchBegin:
g_pGesture->fingers[idx].flags |= PressFlagFlick;
if( g_pGesture->num_pressed < 2 )
#endif//__DETAIL_DEBUG__
break;
- case ET_Motion:
+ case ET_TouchUpdate:
if( !(g_pGesture->fingers[idx].flags & PressFlagFlick ) )
break;
}
break;
- case ET_ButtonRelease:
+ case ET_TouchEnd:
if( g_pGesture->num_pressed )
break;
switch( type )
{
- case ET_ButtonPress:
+ case ET_TouchBegin:
g_pGesture->fingers[idx].flags |= PressFlagPan;
if( g_pGesture->num_pressed < 2 )
#endif//__DETAIL_DEBUG__
break;
- case ET_Motion:
+ case ET_TouchUpdate:
if( !(g_pGesture->fingers[idx].flags & PressFlagPan ) )
break;
cx = AREA_CENTER_X(&g_pGesture->area.extents);
cy = AREA_CENTER_Y(&g_pGesture->area.extents);
+
#ifdef __DETAIL_DEBUG__
ErrorF("[GroupPan][M] cx=%d, prev_cx=%d, diff=%d\n", cx, prev_cx, ABS(cx-prev_cx));
ErrorF("[GroupPan][M] cy=%d, prev_cy=%d, diff=%d\n", cy, prev_cy, ABS(cy-prev_cy));
}
break;
- case ET_ButtonRelease:
+ case ET_TouchEnd:
if( state != GestureEnd && num_pressed >= 2)
{
#ifdef __DETAIL_DEBUG__
if( num_pressed )
{
#ifdef __DETAIL_DEBUG__
- ErrorF("[GroupTap][Timer][state=1] Tap time expired !(num_pressed=%d, tap_repeat=%d)\n", tap_repeat, num_pressed, tap_repeat);
+ ErrorF("[GroupTap][Timer][state=1] Tap time expired !(num_pressed=%d, tap_repeat=%d)\n", num_pressed, tap_repeat);
#endif//__DETAIL_DEBUG__
state = 0;
goto cleanup_tap;
switch( type )
{
- case ET_ButtonPress:
+ case ET_TouchBegin:
g_pGesture->fingers[idx].flags |= PressFlagTap;
if( g_pGesture->num_pressed < 2 )
#endif//__DETAIL_DEBUG__
break;
- case ET_Motion:
+ case ET_TouchUpdate:
if( !(g_pGesture->fingers[idx].flags & PressFlagTap ) )
break;
}
break;
- case ET_ButtonRelease:
+ case ET_TouchEnd:
if( g_pGesture->num_pressed )
break;
switch( type )
{
- case ET_ButtonPress:
+ case ET_TouchBegin:
g_pGesture->fingers[idx].flags |= PressFlagTapNHold;
if( g_pGesture->num_pressed < 2 )
#endif//__DETAIL_DEBUG__
break;
- case ET_Motion:
+ case ET_TouchUpdate:
if( !(g_pGesture->fingers[idx].flags & PressFlagTapNHold ) )
break;
}
break;
- case ET_ButtonRelease:
+ case ET_TouchEnd:
if( state != GestureEnd && num_pressed >= 2)
{
#ifdef __DETAIL_DEBUG__
switch( type )
{
- case ET_ButtonPress:
+ case ET_TouchBegin:
g_pGesture->fingers[idx].flags |= PressFlagHold;
if( g_pGesture->num_pressed < 2 )
#endif//__DETAIL_DEBUG__
break;
- case ET_Motion:
+ case ET_TouchUpdate:
if( !(g_pGesture->fingers[idx].flags & PressFlagHold ) )
break;
}
break;
- case ET_ButtonRelease:
+ case ET_TouchEnd:
if( state != GestureEnd && num_pressed >= 2)
{
#ifdef __DETAIL_DEBUG__
return;
}
+static inline void
+GestureEnableDisable()
+{
+ if((g_pGesture->grabMask) || (g_pGesture->lastSelectedWin != None))
+ {
+ GestureEnable(1, FALSE, g_pGesture->this_device);
+ }
+ else
+ {
+ GestureEnable(0, FALSE, g_pGesture->this_device);
+ }
+}
+
+void
+GestureCbEventsGrabbed(Mask *pGrabMask, GestureGrabEventPtr *pGrabEvent)
+{
+ g_pGesture->grabMask = *pGrabMask;
+ g_pGesture->GrabEvents = pGrabEvent;
+ GestureEnableDisable();
+}
+
+void
+GestureCbEventsSelected(Window win, Mask *pEventMask)
+{
+ g_pGesture->lastSelectedWin = win;
+ g_pGesture->lastSelectedMask = (pEventMask) ? *pEventMask : 0;
+ GestureEnableDisable();
+}
+
WindowPtr
GestureGetEventsWindow(void)
{
Mask mask;
WindowPtr pWin;
- //check grabbed event(s)
- if( !GestureHasGrabbedEvents(&g_pGesture->grabMask, &g_pGesture->GrabEvents) )
- g_pGesture->grabMask = 0;
-
pWin = GestureWindowOnXY(g_pGesture->fingers[0].px, g_pGesture->fingers[0].py);
if( pWin )
return NULL;
}
+ if(g_pGesture->gestureWin == g_pGesture->lastSelectedWin)
+ {
+ g_pGesture->eventMask = g_pGesture->lastSelectedMask;
+ goto nonempty_eventmask;
+ }
+
//check selected event(s)
if( !GestureHasSelectedEvents(pWin, &g_pGesture->eventMask) )
+ {
g_pGesture->eventMask = 0;
+ }
+ else
+ {
+ g_pGesture->lastSelectedWin = g_pGesture->gestureWin;
+ g_pGesture->lastSelectedMask = g_pGesture->eventMask;
+ }
- if( !g_pGesture->grabMask && !g_pGesture->eventMask )
+ if((!g_pGesture->eventMask) && (!g_pGesture->grabMask))
{
#ifdef __DETAIL_DEBUG__
- ErrorF("[X11][GestureGetEventsWindow] No events were grabbed/selected for window(0x%x) !\n", pWin->drawable.id);
+ ErrorF("[X11][GestureGetEventsWindow] No grabbed events or no events were selected for window(0x%x) !\n", pWin->drawable.id);
#endif//__DETAIL_DEBUG__
return NULL;
}
+nonempty_eventmask:
+
#ifdef __DETAIL_DEBUG__
- ErrorF("[X11][GestureGetEventsWindow] g_pGesture->grabMask=0x%x, g_pGesture->eventMask=0x%x\n",
- g_pGesture->grabMask, g_pGesture->eventMask);
+ ErrorF("[X11][GestureGetEventsWindow] g_pGesture->eventMask=0x%x\n", g_pGesture->eventMask);
#endif//__DETAIL_DEBUG__
mask = (GESTURE_FILTER_MASK_ALL & ~(g_pGesture->grabMask | g_pGesture->eventMask));
return 0;
}
-void
-GestureRecognize(int type, InternalEvent *ev, DeviceIntPtr device)
+static uint32_t
+GestureTouchFindDDXIDByTouchID(DeviceIntPtr device, uint32_t touchid)
{
int i;
- static OsTimerPtr single_finger_timer = NULL;
- int idx = -1;
+ DDXTouchPointInfoPtr ti;
- if( PROPAGATE_EVENTS == g_pGesture->ehtype ||
- device->id < g_pGesture->first_fingerid )
- return;
+ for( i = 0 ; i < g_pGesture->num_touches ; i++ )
+ {
+#ifdef __DETAIL_DEBUG__
+ ErrorF("[X11][GestureTouchFindDDXIDByTouchID][check existence] fingers[%d].touchid=%d, touchid=%d\n", i, g_pGesture->fingers[i].touchid, touchid);
+#endif//__DETAIL_DEBUG__
+
+ if(g_pGesture->fingers[i].touchid == touchid)
+ {
+#ifdef __DETAIL_DEBUG__
+ ErrorF("[X11][GestureTouchFindDDXIDByTouchID][exist] ddx_id=%d was found !\n", i);
+#endif//__DETAIL_DEBUG__
+
+ return (uint32_t)i;
+ }
+ }
- for( i = 0 ; i < g_pGesture->num_mt_devices ; i++ )
+ for( i = 0 ; i < device->last.num_touches ; i++)
{
- if( device->id == g_pGesture->mt_devices[i]->id )
+ ti = &device->last.touches[i];
+
+#ifdef __DETAIL_DEBUG__
+ ErrorF("[X11][GestureTouchFindDDXIDByTouchID][alloc new] i=%d, ti->client_id=%d, touchid=%d, ti->ddx_id=%d, ti->active=%d\n", i, ti->client_id, touchid, ti->ddx_id, ti->active);
+#endif//__DETAIL_DEBUG__
+
+ if(ti->client_id == touchid)
{
- idx = i;
- break;
+#ifdef __DETAIL_DEBUG__
+ ErrorF("[X11][GestureTouchFindDDXIDByTouchID][new] ddx_id=%d was found !\n", ti->ddx_id);
+#endif//__DETAIL_DEBUG__
+
+ g_pGesture->fingers[ti->ddx_id].touchid = touchid;
+ return ti->ddx_id;
}
}
- if( idx < 0 )
+ return (uint32_t)-1;
+}
+
+void
+GestureRecognize(int type, InternalEvent *ev, DeviceIntPtr device, int idx)
+{
+ int i;
+ static OsTimerPtr single_finger_timer = NULL;
+
+#ifdef __DETAIL_DEBUG__
+ ErrorF("[X11][GestureRecognize] ev->any.type=%d, type=%d, device->id=%d\n", ev->any.type, type, device->id);
+#endif//__DETAIL_DEBUG__
+
+ if((PROPAGATE_EVENTS == g_pGesture->ehtype) || (device->id != g_pGesture->first_fingerid))
return;
+#ifdef __DETAIL_DEBUG__
+ ErrorF("[X11][GestureRecognize] idx=%d\n", idx);
+#endif//__DETAIL_DEBUG__
+
switch( type )
{
- case ET_ButtonPress:
+ case ET_TouchBegin:
if( idx == 0 )
g_pGesture->event_sum[0] = BTN_PRESSED;
g_pGesture->fingers[idx].ptime = ev->any.time;
TimerCancel(single_finger_timer);
}
- if( g_pGesture->num_pressed > g_pGesture->num_mt_devices )
- g_pGesture->num_pressed = g_pGesture->num_mt_devices;
+ if( g_pGesture->num_pressed > g_pGesture->num_touches )
+ g_pGesture->num_pressed = g_pGesture->num_touches;
if( !g_pGesture->pTempWin || g_pGesture->num_pressed != g_pGesture->inc_num_pressed )
{
if( NULL == g_pGesture->pTempWin )
{
#ifdef __DETAIL_DEBUG__
- ErrorF("[X11][GestureRecognize][g_pGesture->num_pressed=%d] No grabbed events and no event masks !\n", g_pGesture->num_pressed);
+ ErrorF("[X11][GestureRecognize][g_pGesture->num_pressed=%d] No events were selected !\n", g_pGesture->num_pressed);
#endif//__DETAIL_DEBUG__
g_pGesture->filter_mask = GESTURE_FILTER_MASK_ALL;
goto flush_or_drop;
}
break;
- case ET_Motion:
+ case ET_TouchUpdate:
if( !g_pGesture->fingers[idx].ptime )
return;
}
break;
- case ET_ButtonRelease:
+ case ET_TouchEnd:
g_pGesture->fingers[idx].rtime = ev->any.time;
g_pGesture->fingers[idx].rx = ev->device_event.root_x;
g_pGesture->fingers[idx].ry = ev->device_event.root_y;
g_pGesture->recognized_gesture = 0;
g_pGesture->num_pressed = 0;
- for( i=0 ; i < g_pGesture->num_mt_devices ; i++ )
+ for( i=0 ; i < g_pGesture->num_touches ; i++ )
+ {
g_pGesture->fingers[i].ptime = 0;
+ g_pGesture->fingers[i].touchid = -1;
+ }
}
else if( MTOUCH_FRAME_SYNC_END == ev->any_event.sync )
{
}
}
-void
-GestureHandleButtonPressEvent(int screen_num, InternalEvent *ev, DeviceIntPtr device)
+void GestureHandleTouchBeginEvent(int screen_num, InternalEvent *ev, DeviceIntPtr device)
{
+ int idx = -1;
+ int touchid;
#ifdef __DEBUG_EVENT_HANDLER__
- ErrorF("[X11][GestureHandleButtonPEvent] devid=%d time:%d cur:%d\n", device->id, ev->any.time, GetTimeInMillis());
+ ErrorF("[X11][GestureHandleTouchBeginEvent] devid=%d, touchid=%d, time:%d cur:%d\n", device->id, ev->device_event.touchid, ev->any.time, GetTimeInMillis());
#endif//__DEBUG_EVENT_HANDLER__
switch( g_pGesture->ehtype )
{
case KEEP_EVENTS:
+ if( !g_pGesture->num_touches )
+ {
+ device->public.processInputProc(ev, device);
+ return;
+ }
+
if( ERROR_INVALPTR == GestureEnqueueEvent(screen_num, ev, device) )
{
GestureControl(g_pGesture->this_device, DEVICE_OFF);
return;
}
- if( g_pGesture->num_mt_devices )
- GestureRecognize(ET_ButtonPress, ev, device);
- else
- device->public.processInputProc(ev, device);
+ if(device->id != g_pGesture->first_fingerid)
+ return;
+
+ touchid = ev->device_event.touchid;
+ idx = GestureTouchFindDDXIDByTouchID(device, touchid);
+
+ if( idx >= 0 )
+ GestureRecognize(ET_TouchBegin, ev, device, idx);
break;
case PROPAGATE_EVENTS:
break;
case IGNORE_EVENTS:
- GestureRecognize(ET_ButtonPress, ev, device);
+ touchid = ev->device_event.touchid;
+ idx = GestureTouchFindDDXIDByTouchID(device, touchid);
+
+ if( idx >= 0 )
+ GestureRecognize(ET_TouchBegin, ev, device, idx);
break;
default:
}
}
-void
-GestureHandleMotionEvent(int screen_num, InternalEvent *ev, DeviceIntPtr device)
+void GestureHandleTouchUpdateEvent(int screen_num, InternalEvent *ev, DeviceIntPtr device)
{
+ int idx = -1;
+ int touchid;
#ifdef __DEBUG_EVENT_HANDLER__
- ErrorF("[X11][GestureHandleMotionEvent] devid=%d time:%d cur:%d\n", device->id, ev->any.time, GetTimeInMillis());
+ ErrorF("[X11][GestureHandleTouchUpdateEvent] devid=%d, touchid=%d, time:%d cur:%d\n", device->id, ev->device_event.touchid, ev->any.time, GetTimeInMillis());
#endif//__DEBUG_EVENT_HANDLER__
switch( g_pGesture->ehtype )
{
case KEEP_EVENTS:
+ if( !g_pGesture->num_touches )
+ {
+ device->public.processInputProc(ev, device);
+ return;
+ }
+
if( ERROR_INVALPTR == GestureEnqueueEvent(screen_num, ev, device) )
{
GestureControl(g_pGesture->this_device, DEVICE_OFF);
return;
}
- if( g_pGesture->num_mt_devices )
- GestureRecognize(ET_Motion, ev, device);
- else
- device->public.processInputProc(ev, device);
+ if(device->id != g_pGesture->first_fingerid)
+ return;
+
+ touchid = ev->device_event.touchid;
+ idx = GestureTouchFindDDXIDByTouchID(device, touchid);
+
+ if( idx >= 0 )
+ GestureRecognize(ET_TouchUpdate, ev, device, idx);
break;
case PROPAGATE_EVENTS:
break;
case IGNORE_EVENTS:
- GestureRecognize(ET_Motion, ev, device);
+ touchid = ev->device_event.touchid;
+ idx = GestureTouchFindDDXIDByTouchID(device, touchid);
+
+ if( idx >= 0 )
+ GestureRecognize(ET_TouchUpdate, ev, device, idx);
break;
default:
break;
}
-
}
-void
-GestureHandleButtonReleaseEvent(int screen_num, InternalEvent *ev, DeviceIntPtr device)
+void GestureHandleTouchEndEvent(int screen_num, InternalEvent *ev, DeviceIntPtr device)
{
+ int idx = -1;
+ int touchid;
#ifdef __DEBUG_EVENT_HANDLER__
- ErrorF("[X11][GestureHandleButtonREvent] devid=%d time:%d cur:%d\n", device->id, ev->any.time, GetTimeInMillis());
+ ErrorF("[X11][GestureHandleTouchEndEvent] devid=%d, touchid=%d, time:%d cur:%d\n", device->id, ev->device_event.touchid, ev->any.time, GetTimeInMillis());
#endif//__DEBUG_EVENT_HANDLER__
switch( g_pGesture->ehtype )
{
case KEEP_EVENTS:
+ if( !g_pGesture->num_touches )
+ {
+ device->public.processInputProc(ev, device);
+ return;
+ }
+
if( ERROR_INVALPTR == GestureEnqueueEvent(screen_num, ev, device) )
{
GestureControl(g_pGesture->this_device, DEVICE_OFF);
return;
}
- if( g_pGesture->num_mt_devices )
- GestureRecognize(ET_ButtonRelease, ev, device);
- else
- device->public.processInputProc(ev, device);
+ if(device->id != g_pGesture->first_fingerid)
+ return;
+
+ touchid = ev->device_event.touchid;
+ idx = GestureTouchFindDDXIDByTouchID(device, touchid);
+
+ if( idx >= 0 )
+ {
+ GestureRecognize(ET_TouchEnd, ev, device, idx);
+ g_pGesture->fingers[idx].touchid = -1;
+ }
break;
case PROPAGATE_EVENTS:
break;
case IGNORE_EVENTS:
- GestureRecognize(ET_ButtonRelease, ev, device);
+ touchid = ev->device_event.touchid;
+ idx = GestureTouchFindDDXIDByTouchID(device, touchid);
+
+ if( idx >= 0 )
+ GestureRecognize(ET_TouchEnd, ev, device, idx);
break;
default:
return ERROR_ABNORMAL;
}
- res = GestureSetMaxNumberOfFingers((int)MAX_MT_DEVICES);
+ res = GestureRegisterCallbacks(GestureCbEventsGrabbed, GestureCbEventsSelected);
if( !res )
{
- ErrorF("[X11][GestureEnableEventHandler] Failed on GestureSetMaxNumberOfFingers(%d) !\n", (int)MAX_MT_DEVICES);
+ ErrorF("[X11][GestureEnableEventHandler] Failed to register callbacks for GestureEventsGrabbed(), GestureEventsSelected() !\n");
goto failed;
}
{
ErrorStatus err = ERROR_NONE;
- mieqSetHandler(ET_ButtonPress, NULL);
- mieqSetHandler(ET_ButtonRelease, NULL);
- mieqSetHandler(ET_Motion, NULL);
+ mieqSetHandler(ET_TouchBegin, NULL);
+ mieqSetHandler(ET_TouchUpdate, NULL);
+ mieqSetHandler(ET_TouchEnd, NULL);
mieqSetHandler(ET_MTSync, NULL);
err = GestureFiniEQ();
ErrorF("[X11][GestureDisableEventHandler] EQ is invalid or was freed already !\n");
}
+ GestureRegisterCallbacks(NULL, NULL);
GestureUninstallResourceStateHooks();
return err;
InputInfoPtr pInfo = (InputInfoPtr)arg;
GestureDevicePtr pGesture = pInfo->private;
- int idx = 0;
+ Bool res;
DeviceIntPtr dev;
for( dev = inputInfo.pointer ; dev; dev = dev->next )
{
continue;
}
- if(IsPointerDevice(dev))
+ if(IsPointerDevice(dev) && dev->touch)
{
- if( idx >= MAX_MT_DEVICES )
- {
- ErrorF("[X11][GestureTimerHandler] Number of mt device is over MAX_MT_DEVICES(%d) !\n",
- MAX_MT_DEVICES);
- continue;
- }
- pGesture->mt_devices[idx] = dev;
- ErrorF("[X11][GestureTimerHandler][id:%d] MT device[%d] name=%s\n", dev->id, idx, pGesture->mt_devices[idx]->name);
- idx++;
+ pGesture->num_touches = dev->touch->num_touches + 1;
+ pGesture->first_fingerid = dev->id;
+#ifdef __DETAIL_DEBUG__
+ ErrorF("[X11][GestureTimerHandler] num_touches = %d, first_fingerid=%d\n", pGesture->num_touches, pGesture->first_fingerid);
+#endif//__DETAIL_DEBUG__
}
}
{
ErrorF("[X11][GestureTimerHandler] Failed to get info of master pointer or XTest pointer !\n");
pGesture->device_setting_timer = TimerSet(pGesture->device_setting_timer, 0, 0, NULL, NULL);
- pGesture->num_mt_devices = 0;
+ pGesture->num_touches = 0;
return 0;
}
pGesture->device_setting_timer = TimerSet(pGesture->device_setting_timer, 0, 0, NULL, NULL);
- pGesture->num_mt_devices = idx;
- if( !pGesture->num_mt_devices )
+ if( !pGesture->num_touches )
{
ErrorF("[X11][GestureTimerHandler] Failed to mt device information !\n");
pGesture->device_setting_timer = TimerSet(pGesture->device_setting_timer, 0, 0, NULL, NULL);
- pGesture->num_mt_devices = 0;
- pGesture->first_fingerid = -1;
+ pGesture->first_fingerid = -1;
return 0;
}
- pGesture->first_fingerid = pGesture->mt_devices[0]->id;
- memset(pGesture->fingers, 0, sizeof(TouchStatus)*pGesture->num_mt_devices);
+ res = GestureSetMaxNumberOfFingers((int)pGesture->num_touches);
+
+ if( !res )
+ {
+ ErrorF("[X11][GestureTimerHandler] Failed on GestureSetMaxNumberOfFingers(%d) !\n", (int)pGesture->num_touches);
+ goto failed;
+ }
+
+ pGesture->finger_rects = (pixman_region16_t *)calloc(sizeof(pixman_region16_t), pGesture->num_touches);
+ pGesture->fingers = (TouchStatus *)calloc(sizeof(TouchStatus), pGesture->num_touches);
+ pGesture->event_sum = (int *)calloc(sizeof(int), pGesture->num_touches);
+
+ if( !pGesture->finger_rects || !pGesture->fingers || !pGesture->event_sum)
+ {
+ ErrorF("[X11][GestureTimerHandler] Failed to allocate memory for finger information\n");
+ goto failed;
+ }
+
pGesture->pRootWin = RootWindow(pGesture->master_pointer);
- g_pGesture->grabMask = g_pGesture->eventMask = 0;
g_pGesture->pTempWin = NULL;
g_pGesture->inc_num_pressed = 0;
goto failed;
}
- mieqSetHandler(ET_ButtonPress, GestureHandleButtonPressEvent);
- mieqSetHandler(ET_ButtonRelease, GestureHandleButtonReleaseEvent);
- mieqSetHandler(ET_Motion, GestureHandleMotionEvent);
+ mieqSetHandler(ET_TouchBegin, GestureHandleTouchBeginEvent);
+ mieqSetHandler(ET_TouchEnd, GestureHandleTouchEndEvent);
+ mieqSetHandler(ET_TouchUpdate, GestureHandleTouchUpdateEvent);
if( pGesture->is_active )
mieqSetHandler(ET_MTSync, GestureHandleMTSyncEvent);
failed:
+ pGesture->num_touches = 0;
GestureUninstallResourceStateHooks();
GestureUnsetMaxNumberOfFingers();
}
void
-GestureSetDisable(InputInfoPtr pInfo, int enable)
+GestureEnable(int enable, Bool prop, DeviceIntPtr dev)
{
- if( !enable )
+ if((!enable) && (g_pGesture->is_active))
{
g_pGesture->ehtype = PROPAGATE_EVENTS;
mieqSetHandler(ET_MTSync, NULL);
g_pGesture->is_active = 0;
- ErrorF("[X11][GestureSetDisable] Disabled !\n");
+ ErrorF("[X11][GestureEnable] Disabled !\n");
}
- else
+ else if((enable) && (!g_pGesture->is_active))
{
g_pGesture->ehtype = KEEP_EVENTS;
mieqSetHandler(ET_MTSync, GestureHandleMTSyncEvent);
g_pGesture->is_active = 1;
- ErrorF("[X11][GestureSetDisable] Enabled !\n");
+ ErrorF("[X11][GestureEnable] Enabled !\n");
}
+
+ if(!prop)
+ XIChangeDeviceProperty(dev, prop_gesture_recognizer_onoff, XA_INTEGER, 32, PropModeReplace, 1, &g_pGesture->is_active, FALSE);
}
ErrorStatus
pixman_region_init(&g_pGesture->area);
- for( i = 0 ; i < MAX_MT_DEVICES ; i++ )
+ for( i = 0 ; i < g_pGesture->num_touches; i++ )
{
pixman_region_init_rect (&g_pGesture->finger_rects[i], 0, 0, FINGER_WIDTH_2T, FINGER_HEIGHT_2T);
}
if( tail >= GESTURE_EQ_SIZE )
{
- ErrorF("[X11][GestureEnqueueEvent] Gesture EQ is full !\n");
+ ErrorF("[X11][GestureEnqueueEvent] Gesture EQ is full...Force Gesture Flush \n");
printk("[X11][GestureEnqueueEvent] Gesture EQ is full...Force Gesture Flush !\n");
GestureEventsFlush();
return ERROR_EQFULL;
#ifdef __DETAIL_DEBUG__
switch( ev->any.type )
{
- case ET_ButtonPress:
- ErrorF("[X11][GestureEnqueueEvent] ET_ButtonPress (id:%d)\n", device->id);
+ case ET_TouchBegin:
+ ErrorF("[X11][GestureEnqueueEvent] ET_TouchBegin (id:%d)\n", device->id);
break;
- case ET_ButtonRelease:
- ErrorF("[X11][GestureEnqueueEvent] ET_ButtonRelease (id:%d)\n", device->id);
+ case ET_TouchEnd:
+ ErrorF("[X11][GestureEnqueueEvent] ET_TouchEnd (id:%d)\n", device->id);
break;
- case ET_Motion:
- ErrorF("[X11][GestureEnqueueEvent] ET_Motion (id:%d)\n", device->id);
+ case ET_TouchUpdate:
+ ErrorF("[X11][GestureEnqueueEvent] ET_TouchUpdate (id:%d)\n", device->id);
break;
}
#endif//__DETAIL_DEBUG__
device->public.processInputProc(g_pGesture->EQ[i].event, device);
}
- for( i = 0 ; i < MAX_MT_DEVICES ; i++ )
+ for( i = 0 ; i < g_pGesture->num_touches; i++ )
g_pGesture->event_sum[i] = 0;
g_pGesture->headEQ = g_pGesture->tailEQ = 0;//Free EQ
if( !checkonly )
{
data = *((int *)val->data);
- GestureSetDisable(pInfo, data);
+ GestureEnable(data, TRUE, dev);
}
}
{
}
-static InputInfoPtr
+static int
GesturePreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
{
int rc = BadAlloc;
pGesture->device = xf86SetStrOption(pInfo->options, "Device", "/dev/null");
pGesture->is_active = xf86SetIntOption(pInfo->options, "Activate", 0);
pGesture->gestureWin = None;
+ pGesture->lastSelectedWin = None;
+ pGesture->num_touches = GESTURE_MAX_TOUCH;
+ g_pGesture->grabMask = g_pGesture->eventMask = 0;
xf86Msg(X_INFO, "%s: Using device %s.\n", pInfo->name, pGesture->device);
xf86ProcessCommonOptions(pInfo, pInfo->options);
pInfo->fd = -1;
-
return Success;
error:
device->public.on = TRUE;
pGesture->this_device = device;
- pGesture->num_mt_devices = 0;
+ GestureSetMaxNumberOfFingers((int)pGesture->num_touches);
if( ERROR_ABNORMAL == GestureEnableEventHandler(pInfo) )
goto device_off;
break;