diff options
author | Chase Douglas <chase.douglas@canonical.com> | 2011-02-14 15:28:26 -0500 |
---|---|---|
committer | Chase Douglas <chase.douglas@canonical.com> | 2011-02-14 15:28:26 -0500 |
commit | 25f020d490737c8622d25bb9b4d1005caaf09316 (patch) | |
tree | a9c4df5b1da3359b8b143bf1c05a4196645c133f | |
parent | eef1845634a8282005fabc0a0878f75d60a78186 (diff) |
Revert "Add touch pointer emulation"multitouch
This reverts commit dafda52e9b5ccad5c642ed956555d8435ca2975d.
Conflicts:
Xi/exevents.c
-rw-r--r-- | Xi/exevents.c | 163 | ||||
-rw-r--r-- | dix/inpututils.c | 4 | ||||
-rw-r--r-- | include/inputstr.h | 1 |
3 files changed, 13 insertions, 155 deletions
diff --git a/Xi/exevents.c b/Xi/exevents.c index 1b618d35a..64e32c982 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -103,8 +103,6 @@ SOFTWARE. #include "eventconvert.h" #include "eventstr.h" #include "xserver-properties.h" -#include "inpututils.h" -#include "mi.h" #include <X11/extensions/XKBproto.h> #include "xkbsrv.h" @@ -1202,8 +1200,6 @@ DeliverTouchBeginSelection(TouchPointInfoPtr ti, DeviceIntPtr sourcedev, } } - UpdateTouchHistory(ti, ev); - return !Success; } @@ -1287,107 +1283,6 @@ DeliverTouchSelection(TouchPointInfoPtr ti, DeviceIntPtr sourcedev, return ret; } -static EventList * -GetEvents(void) -{ - static EventList *events = NULL; - - /* Allocation twice the maximum number of events for motion and button - * emulation. */ - if (!events) - events = InitEventList(2 * GetMaximumEventsNum()); - - return events; -} - -/* Emit pointer emulation events for the given touch event. Touch begin and - * end cause motion then primary button down or up. */ -static void -TouchPointerEmulation(enum EventType evtype, DeviceIntPtr dev, - ValuatorMask *mask) -{ - EventList *emulationEvents = GetEvents(); - int i, nevents; - - if (evtype == ET_TouchBegin) - { - nevents = GetPointerEvents(emulationEvents, dev, - MotionNotify, 0, POINTER_ABSOLUTE, mask); - nevents += GetPointerEvents(emulationEvents + nevents, dev, - ButtonPress, 1, POINTER_ABSOLUTE, mask); - } - else if (evtype == ET_TouchMotion) - nevents = GetPointerEvents(emulationEvents, dev, MotionNotify, 0, - POINTER_ABSOLUTE, mask); - else if (evtype == ET_TouchEnd) - { - nevents = GetPointerEvents(emulationEvents, dev, MotionNotify, 0, - POINTER_ABSOLUTE, mask); - nevents += GetPointerEvents(emulationEvents + nevents, dev, - ButtonRelease, 1, POINTER_ABSOLUTE, mask); - } - - for (i = 0; i < nevents; i++) - mieqEnqueue(dev, (InternalEvent*)((emulationEvents + i)->event)); -} - -/* Helper function to set up touch pointer emulation. */ -static void -SetTouchEmulationMask(InternalEvent *ev, ValuatorMask *mask, int x_axis, - int y_axis) -{ - valuator_mask_zero(mask); - if (BitIsOn(ev->device_event.valuators.mask, x_axis)) - valuator_mask_set(mask, 0, - ev->device_event.valuators.data[x_axis]); - if (BitIsOn(ev->device_event.valuators.mask, y_axis)) - valuator_mask_set(mask, 1, - ev->device_event.valuators.data[y_axis]); -} - -/* Process touch emulation. */ -static void -EmulateTouchEvents(DeviceIntPtr dev, TouchPointInfoPtr ti, InternalEvent *ev) -{ - ValuatorMask mask; - int x_axis = dev->touch->x_axis; - int y_axis = dev->touch->y_axis; - - /* Set the emulation touch for the device. Only one touch may be emulated - * at a time. */ - dev->touch->emulate = ti; - - if (ev->any.type != ET_TouchOwnership) - { - /* Emulate a normal event. */ - SetTouchEmulationMask(ev, &mask, x_axis, y_axis); - TouchPointerEmulation(ev->any.type, dev, &mask); - } - else - { - /* If we got here, then a grabbing client rejected the touch. Replay - all the touches buffered up. */ - ev = ti->begin_event; - - SetTouchEmulationMask(ev, &mask, x_axis, y_axis); - TouchPointerEmulation(ev->any.type, dev, &mask); - - ev = ti->first_history; - while (ev != ti->next_history) - { - SetTouchEmulationMask(ev, &mask, x_axis, y_axis); - TouchPointerEmulation(ev->any.type, dev, &mask); - - if (ev->any.type == ET_TouchEnd) - break; - - ev++; - if (ev == ti->history + ti->history_size) - ev = ti->history; - } - } -} - /** * Delivers a touch event to all interested clients. For TouchBegin events, * will update ti->listeners, ti->num_listeners, and ti->num_grabs. @@ -1507,16 +1402,6 @@ DeliverTouchEvents(DeviceIntPtr sourcedev, TouchPointInfoPtr ti, else if (ti->num_grabs && ti->num_grabs == ti->num_listeners) /* Save other touch events when there isn't a selecting client. */ UpdateTouchHistory(ti, ev); - - /* Emulate a pointer if: - 1. This touch is already being emulated OR - 2. a. No other touch is being emulated for this devices AND - b. There is no one listening to the touch AND - c. The device is a direct touch device */ - if (sourcedev->touch->emulate == ti || - (!sourcedev->touch->emulate && ti->num_listeners == 0 && - sourcedev->touch->mode == XIDirectTouch)) - EmulateTouchEvents(sourcedev, ti, ev); } /** @@ -1530,8 +1415,7 @@ static void ProcessTouchOwnershipEvent(DeviceIntPtr sourcedev, TouchPointInfoPtr ti, TouchOwnershipEvent *ev) { - TouchClassPtr t = sourcedev->touch; - EventList *tel = GetEvents(); + EventList *tel = InitEventList(GetMaximumEventsNum()); InternalEvent *tee; ValuatorMask *mask = valuator_mask_new(0); void *grab; @@ -1550,6 +1434,16 @@ ProcessTouchOwnershipEvent(DeviceIntPtr sourcedev, TouchPointInfoPtr ti, DeliverTouchEvents(sourcedev, ti, tee, ev->resource); } + /* If there are no other listeners left, then don't bother sending an + * ownership change event to no-one; if the touchpoint is pending + * finish, then we can just kill it now. */ + if (ti->num_listeners == 1) + { + if (ti->pending_finish) + EndTouchPoint(sourcedev, ti); + return; + } + /* Remove the resource from the listener list, updating * ti->listeners and ti->num_grabs if it was a grab. */ for (i = 0; i <= ti->num_listeners; i++) @@ -1585,19 +1479,8 @@ ProcessTouchOwnershipEvent(DeviceIntPtr sourcedev, TouchPointInfoPtr ti, DeliverTouchEvents(sourcedev, ti, tee, 0); } EndTouchPoint(sourcedev, ti); + return; } - else if (ti->pending_finish && t->emulate == ti) - { - nev = GetTouchEvents(tel, sourcedev, ti, XI_TouchEnd, 0, mask); - for (i = 0; i < nev; i++) - { - tee = (InternalEvent *) ((tel + i)->event); - EmulateTouchEvents(sourcedev, ti, tee); - } - EndTouchPoint(sourcedev, ti); - } - else if (ti->num_listeners == 0 && ti->pending_finish) - EndTouchPoint(sourcedev, ti); } } else { @@ -1728,7 +1611,7 @@ ProcessTouchEvent(InternalEvent *ev, DeviceIntPtr sourcedev) else { DeliverTouchEvents(sourcedev, ti, (InternalEvent *) ev, 0); - if (ev->any.type == ET_TouchEnd && ti->num_listeners == 0) + if (ev->any.type == ET_TouchEnd) EndTouchPoint(sourcedev, ti); } } @@ -1987,29 +1870,9 @@ InitTouchValuatorAxisStruct(DeviceIntPtr dev, int axnum, Atom label, int minval, ax->label = label; if (ax->label == XIGetKnownProperty(AXIS_LABEL_PROP_ABS_MT_POSITION_X)) - { dev->touch->x_axis = axnum; - if (dev->touch->mode == XIDirectTouch && - (!dev->valuator || dev->valuator->numAxes < 1 || - dev->valuator->axes[0].min_value != minval || - dev->valuator->axes[0].max_value != maxval || - dev->valuator->axes[0].resolution != resolution)) - LogMessage(X_WARNING, "Touch X valuator does not match pointer X " - "valuator, pointer emulation may be " - "incorrect\n"); - } else if (ax->label == XIGetKnownProperty(AXIS_LABEL_PROP_ABS_MT_POSITION_Y)) - { dev->touch->y_axis = axnum; - if (dev->touch->mode == XIDirectTouch && - (!dev->valuator || dev->valuator->numAxes < 2 || - dev->valuator->axes[1].min_value != minval || - dev->valuator->axes[1].max_value != maxval || - dev->valuator->axes[1].resolution != resolution)) - LogMessage(X_WARNING, "Touch Y valuator does not match pointer Y " - "valuator, pointer emulation may be " - "incorrect\n"); - } } static void diff --git a/dix/inpututils.c b/dix/inpututils.c index 9552d33c4..f0f716df6 100644 --- a/dix/inpututils.c +++ b/dix/inpututils.c @@ -675,12 +675,8 @@ EndTouchPoint(DeviceIntPtr dev, TouchPointInfoPtr ti) ti->ddx_id = 0; ti->first_history = ti->history; ti->next_history = ti->history; - ti->select_win = NULL; t->active_touches--; - if (dev->touch->emulate == ti) - dev->touch->emulate = NULL; - for (i = 0; i < ti->num_valuators; i++) ti->valuators[i] = 0; } diff --git a/include/inputstr.h b/include/inputstr.h index bdab35884..b2397a586 100644 --- a/include/inputstr.h +++ b/include/inputstr.h @@ -331,7 +331,6 @@ typedef struct _TouchClassRec { uint32_t next_client_id; /* next client_id to give out */ int x_axis; /* axis number of x axis */ int y_axis; /* axis number of y axis */ - TouchPointInfoPtr emulate; } TouchClassRec; typedef struct _ButtonClassRec { |