diff options
-rw-r--r-- | mi/mieq.c | 60 | ||||
-rw-r--r-- | xkb/ddxDevBtn.c | 15 |
2 files changed, 40 insertions, 35 deletions
@@ -80,6 +80,7 @@ typedef struct _EventQueue { } EventQueueRec, *EventQueuePtr; static EventQueueRec miEventQueue; +static EventListPtr masterEvents; /* for use in mieqProcessInputEvents */ Bool mieqInit(void) @@ -98,6 +99,17 @@ mieqInit(void) FatalError("Could not allocate event queue.\n"); miEventQueue.events[i].events = evlist; } + + /* XXX: mE is just 1 event long, if we have Motion + Valuator they are + * squashed into the first event to make passing it into the event + * processing handlers easier. This should be fixed when the processing + * handlers switch to EventListPtr instead of xEvent */ + masterEvents = InitEventList(1); + if (!masterEvents) + FatalError("Could not allocated MD event queue.\n"); + SetMinimumEventSize(masterEvents, 1, + (1 + MAX_VALUATOR_EVENTS) * sizeof(xEvent)); + SetInputCheck(&miEventQueue.head, &miEventQueue.tail); return TRUE; } @@ -270,28 +282,21 @@ ChangeDeviceID(DeviceIntPtr dev, xEvent* event) */ void CopyGetMasterEvent(DeviceIntPtr mdev, xEvent* original, - xEvent** master, int count) + EventListPtr master, int count) { - if (count > 1) { - *master = xcalloc(count, sizeof(xEvent)); - if (!*master) - FatalError("[mi] No memory left for master event.\n"); - while(count--) - { - memcpy(&(*master)[count], &original[count], sizeof(xEvent)); - ChangeDeviceID(mdev, &(*master)[count]); - } - } else - { - int len = sizeof(xEvent); - if (original->u.u.type == GenericEvent) - len += GEV(original)->length * 4; - *master = xalloc(len); - if (!*master) - FatalError("[mi] No memory left for master event.\n"); - memcpy(*master, original, len); - ChangeDeviceID(mdev, *master); - } + int len = count * sizeof(xEvent); + + /* Assumption: GenericEvents always have count 1 */ + + if (GEV(original)->type == GenericEvent) + len += GEV(original)->length * 4; + + if (master->evlen < len) + SetMinimumEventSize(master, 1, len); + + memcpy(master->event, original, len); + while (count--) + ChangeDeviceID(mdev, &master->event[count]); } /* Call this from ProcessInputEvents(). */ @@ -303,8 +308,7 @@ mieqProcessInputEvents(void) int x = 0, y = 0; int type, nevents, evlen, i; ScreenPtr screen; - xEvent *event, - *master_event = NULL; + xEvent *event; DeviceIntPtr dev = NULL, master = NULL; @@ -353,10 +357,7 @@ mieqProcessInputEvents(void) } else { if (master) - CopyGetMasterEvent(master, event, - &master_event, nevents); - else - master_event = NULL; + CopyGetMasterEvent(master, event, masterEvents, nevents); /* If someone's registered a custom event handler, let them * steal it. */ @@ -365,19 +366,18 @@ mieqProcessInputEvents(void) handler(DequeueScreen(dev)->myNum, event, dev, nevents); if (master) handler(DequeueScreen(master)->myNum, - master_event, master, nevents); + masterEvents->event, master, nevents); } else { /* process slave first, then master */ dev->public.processInputProc(event, dev, nevents); if (master) - master->public.processInputProc(master_event, master, + master->public.processInputProc(masterEvents->event, master, nevents); } xfree(event); - xfree(master_event); } /* Update the sprite now. Next event may be from different device. */ diff --git a/xkb/ddxDevBtn.c b/xkb/ddxDevBtn.c index b68a28b2a..585ad198e 100644 --- a/xkb/ddxDevBtn.c +++ b/xkb/ddxDevBtn.c @@ -42,13 +42,14 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. extern int DeviceValuator; +static EventListPtr masterEvents = NULL; + void XkbDDXFakeDeviceButton(DeviceIntPtr dev,Bool press,int button) { int * devVal; INT32 * evVal; -xEvent events[2], - *m_events = NULL; /* master dev */ +xEvent events[2]; deviceKeyButtonPointer *btn; deviceValuator * val; int x,y; @@ -107,18 +108,22 @@ DeviceIntPtr master = NULL; * cases, unless dev is both a keyboard and a mouse. */ if (!dev->isMaster && dev->u.master) { + if (!masterEvents) + { + masterEvents = InitEventList(1); + SetMinimumEventSize(masterEvents, 1, (1 + MAX_VALUATOR_EVENTS) * sizeof(xEvent)); + } master = dev->u.master; if (!IsPointerDevice(master)) master = GetPairedDevice(dev->u.master); - CopyGetMasterEvent(master, &events, &m_events, count); + CopyGetMasterEvent(master, &events, masterEvents, count); } (*dev->public.processInputProc)((xEventPtr)btn, dev, count); if (master) { - (*master->public.processInputProc)(m_events, master, count); - xfree(m_events); + (*master->public.processInputProc)(masterEvents->event, master, count); } return; } |