diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2011-11-05 13:32:59 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2011-11-05 13:32:59 +0000 |
commit | bf781c5ff285301ad70ffc5f4321b8906f71edd8 (patch) | |
tree | 3b770f4bf9a8cd11dd9f14e7f758991a73a52d78 /xserver/mi/mieq.c | |
parent | e59d0622d3162f7b5a7420ef87dbebb200348c37 (diff) |
Update to xserver 1.11.2
Diffstat (limited to 'xserver/mi/mieq.c')
-rw-r--r-- | xserver/mi/mieq.c | 92 |
1 files changed, 33 insertions, 59 deletions
diff --git a/xserver/mi/mieq.c b/xserver/mi/mieq.c index 01da52a6c..fc3738a41 100644 --- a/xserver/mi/mieq.c +++ b/xserver/mi/mieq.c @@ -43,6 +43,7 @@ in this Software without prior written authorization from The Open Group. # include "windowstr.h" # include "pixmapstr.h" # include "inputstr.h" +# include "inpututils.h" # include "mi.h" # include "mipointer.h" # include "scrnintstr.h" @@ -64,7 +65,7 @@ in this Software without prior written authorization from The Open Group. #define DequeueScreen(dev) dev->spriteInfo->sprite->pDequeueScreen typedef struct _Event { - EventListPtr events; + InternalEvent* events; ScreenPtr pScreen; DeviceIntPtr pDev; /* device this event _originated_ from */ } EventRec, *EventPtr; @@ -83,17 +84,17 @@ static EventQueueRec miEventQueue; #include <pthread.h> static pthread_mutex_t miEventQueueMutex = PTHREAD_MUTEX_INITIALIZER; -extern BOOL serverInitComplete; -extern pthread_mutex_t serverInitCompleteMutex; -extern pthread_cond_t serverInitCompleteCond; +extern BOOL serverRunning; +extern pthread_mutex_t serverRunningMutex; +extern pthread_cond_t serverRunningCond; static inline void wait_for_server_init(void) { /* If the server hasn't finished initializing, wait for it... */ - if(!serverInitComplete) { - pthread_mutex_lock(&serverInitCompleteMutex); - while(!serverInitComplete) - pthread_cond_wait(&serverInitCompleteCond, &serverInitCompleteMutex); - pthread_mutex_unlock(&serverInitCompleteMutex); + if(!serverRunning) { + pthread_mutex_lock(&serverRunningMutex); + while(!serverRunning) + pthread_cond_wait(&serverRunningCond, &serverRunningMutex); + pthread_mutex_unlock(&serverRunningMutex); } } #endif @@ -111,7 +112,7 @@ mieqInit(void) for (i = 0; i < QUEUE_SIZE; i++) { if (miEventQueue.events[i].events == NULL) { - EventListPtr evlist = InitEventList(1); + InternalEvent* evlist = InitEventList(1); if (!evlist) FatalError("Could not allocate event queue.\n"); miEventQueue.events[i].events = evlist; @@ -146,7 +147,7 @@ void mieqEnqueue(DeviceIntPtr pDev, InternalEvent *e) { unsigned int oldtail = miEventQueue.tail; - EventListPtr evt; + InternalEvent* evt; int isMotion = 0; int evlen; Time time; @@ -156,7 +157,7 @@ mieqEnqueue(DeviceIntPtr pDev, InternalEvent *e) pthread_mutex_lock(&miEventQueueMutex); #endif - CHECKEVENT(e); + verify_internal_event(e); /* avoid merging events from different devices */ if (e->any.type == ET_Motion) @@ -188,21 +189,7 @@ mieqEnqueue(DeviceIntPtr pDev, InternalEvent *e) evlen = e->any.length; evt = miEventQueue.events[oldtail].events; - if (evt->evlen < evlen) - { - evt->evlen = evlen; - evt->event = realloc(evt->event, evt->evlen); - if (!evt->event) - { - ErrorF("[mi] Running out of memory. Tossing event.\n"); -#ifdef XQUARTZ - pthread_mutex_unlock(&miEventQueueMutex); -#endif - return; - } - } - - memcpy(evt->event, e, evlen); + memcpy(evt, e, evlen); time = e->any.time; /* Make sure that event times don't go backwards - this @@ -211,7 +198,7 @@ mieqEnqueue(DeviceIntPtr pDev, InternalEvent *e) miEventQueue.lastEventTime - time < 10000) e->any.time = miEventQueue.lastEventTime; - miEventQueue.lastEventTime = ((InternalEvent*)evt->event)->any.time; + miEventQueue.lastEventTime = evt->any.time; miEventQueue.events[oldtail].pScreen = pDev ? EnqueueScreen(pDev) : NULL; miEventQueue.events[oldtail].pDev = pDev; @@ -292,8 +279,8 @@ static void FixUpEventForMaster(DeviceIntPtr mdev, DeviceIntPtr sdev, InternalEvent* original, InternalEvent *master) { - CHECKEVENT(original); - CHECKEVENT(master); + verify_internal_event(original); + verify_internal_event(master); /* Ensure chained button mappings, i.e. that the detail field is the * value of the mapped button on the SD, not the physical button */ if (original->any.type == ET_ButtonPress || @@ -321,11 +308,12 @@ CopyGetMasterEvent(DeviceIntPtr sdev, DeviceIntPtr mdev; int len = original->any.length; int type = original->any.type; + int mtype; /* which master type? */ - CHECKEVENT(original); + verify_internal_event(original); /* ET_XQuartz has sdev == NULL */ - if (!sdev || !sdev->u.master) + if (!sdev || IsMaster(sdev) || IsFloating(sdev)) return NULL; #if XFreeXDGA @@ -337,20 +325,21 @@ CopyGetMasterEvent(DeviceIntPtr sdev, { case ET_KeyPress: case ET_KeyRelease: - mdev = GetMaster(sdev, MASTER_KEYBOARD); + mtype = MASTER_KEYBOARD; break; case ET_ButtonPress: case ET_ButtonRelease: case ET_Motion: case ET_ProximityIn: case ET_ProximityOut: - mdev = GetMaster(sdev, MASTER_POINTER); + mtype = MASTER_POINTER; break; default: - mdev = sdev->u.master; + mtype = MASTER_ATTACHED; break; } + mdev = GetMaster(sdev, mtype); memcpy(copy, original, len); ChangeDeviceID(mdev, copy); FixUpEventForMaster(mdev, sdev, original, copy); @@ -374,7 +363,7 @@ mieqProcessDeviceEvent(DeviceIntPtr dev, DeviceIntPtr master; InternalEvent mevent; /* master event */ - CHECKEVENT(event); + verify_internal_event(event); /* Custom event handler */ handler = miEventQueue.handlers[event->any.type]; @@ -400,7 +389,7 @@ mieqProcessDeviceEvent(DeviceIntPtr dev, master = CopyGetMasterEvent(dev, event, &mevent); if (master) - master->u.lastSlave = dev; + master->lastSlave = dev; /* If someone's registered a custom event handler, let them * steal it. */ @@ -410,7 +399,7 @@ mieqProcessDeviceEvent(DeviceIntPtr dev, handler(screenNum, event, dev); /* Check for the SD's master in case the device got detached * during event processing */ - if (master && dev->u.master) + if (master && !IsFloating(dev)) handler(screenNum, &mevent, master); } else { @@ -419,7 +408,7 @@ mieqProcessDeviceEvent(DeviceIntPtr dev, /* Check for the SD's master in case the device got detached * during event processing */ - if (master && dev->u.master) + if (master && !IsFloating(dev)) master->public.processInputProc(&mevent, master); } } @@ -429,10 +418,8 @@ void mieqProcessInputEvents(void) { EventRec *e = NULL; - int evlen; ScreenPtr screen; - static InternalEvent *event = NULL; - static size_t event_size = 0; + static InternalEvent event; DeviceIntPtr dev = NULL, master = NULL; @@ -443,20 +430,7 @@ mieqProcessInputEvents(void) while (miEventQueue.head != miEventQueue.tail) { e = &miEventQueue.events[miEventQueue.head]; - evlen = e->events->evlen; - if(evlen > event_size) - { - event = realloc(event, evlen); - event_size = evlen; - } - - - if (!event) - FatalError("[mi] No memory left for event processing.\n"); - - memcpy(event, e->events->event, evlen); - - + event = *e->events; dev = e->pDev; screen = e->pScreen; @@ -466,7 +440,7 @@ mieqProcessInputEvents(void) pthread_mutex_unlock(&miEventQueueMutex); #endif - master = (dev && !IsMaster(dev) && dev->u.master) ? dev->u.master : NULL; + master = (dev) ? GetMaster(dev, MASTER_ATTACHED) : NULL; if (screenIsSaved == SCREEN_SAVER_ON) dixSaveScreens (serverClient, SCREEN_SAVER_OFF, ScreenSaverReset); @@ -478,10 +452,10 @@ mieqProcessInputEvents(void) DPMSSet(serverClient, DPMSModeOn); #endif - mieqProcessDeviceEvent(dev, event, screen); + mieqProcessDeviceEvent(dev, &event, screen); /* Update the sprite now. Next event may be from different device. */ - if (event->any.type == ET_Motion && master) + if (event.any.type == ET_Motion && master) miPointerUpdateSprite(dev); #ifdef XQUARTZ |