mirror of
https://gitlab.freedesktop.org/xorg/xserver.git
synced 2026-01-10 10:30:15 +01:00
mi: Avoid possible deadlock in miEq
When the handler for an event requires sending a message to another thread that is waiting for the miEq mutex.
This commit is contained in:
parent
3c69528064
commit
d7d4cd3003
1 changed files with 24 additions and 23 deletions
47
mi/mieq.c
47
mi/mieq.c
|
|
@ -231,7 +231,7 @@ mieqSetHandler(int event, mieqHandler handler)
|
|||
void
|
||||
mieqProcessInputEvents(void)
|
||||
{
|
||||
EventRec *e = NULL;
|
||||
EventRec e;
|
||||
int x = 0, y = 0;
|
||||
DeviceIntPtr dev = NULL;
|
||||
|
||||
|
|
@ -250,45 +250,46 @@ mieqProcessInputEvents(void)
|
|||
DPMSSet(DPMSModeOn);
|
||||
#endif
|
||||
|
||||
e = &miEventQueue.events[miEventQueue.head];
|
||||
memcpy(&e, &miEventQueue.events[miEventQueue.head], sizeof(EventRec));
|
||||
miEventQueue.head = (miEventQueue.head + 1) % QUEUE_SIZE;
|
||||
|
||||
if (miEventQueue.handlers[e->event->u.u.type]) {
|
||||
#ifdef XQUARTZ
|
||||
pthread_mutex_unlock(&miEventQueueMutex);
|
||||
#endif
|
||||
|
||||
if (miEventQueue.handlers[e.event->u.u.type]) {
|
||||
/* If someone's registered a custom event handler, let them
|
||||
* steal it. */
|
||||
miEventQueue.handlers[e->event->u.u.type](miEventQueue.pDequeueScreen->myNum,
|
||||
e->event, dev,
|
||||
e->nevents);
|
||||
miEventQueue.handlers[e.event->u.u.type](e.pScreen->myNum,
|
||||
e.event, e.pDev,
|
||||
e.nevents);
|
||||
}
|
||||
else if (e->pScreen != miEventQueue.pDequeueScreen) {
|
||||
else if (e.pScreen != miEventQueue.pDequeueScreen) {
|
||||
/* Assumption - screen switching can only occur on motion events. */
|
||||
miEventQueue.pDequeueScreen = e->pScreen;
|
||||
x = e->event[0].u.keyButtonPointer.rootX;
|
||||
y = e->event[0].u.keyButtonPointer.rootY;
|
||||
NewCurrentScreen (miEventQueue.pDequeueScreen, x, y);
|
||||
miEventQueue.pDequeueScreen = e.pScreen;
|
||||
x = e.event[0].u.keyButtonPointer.rootX;
|
||||
y = e.event[0].u.keyButtonPointer.rootY;
|
||||
NewCurrentScreen(e.pScreen, x, y);
|
||||
}
|
||||
else {
|
||||
/* If this is a core event, make sure our keymap, et al, is
|
||||
* changed to suit. */
|
||||
if (e->event[0].u.u.type == KeyPress ||
|
||||
e->event[0].u.u.type == KeyRelease) {
|
||||
SwitchCoreKeyboard(e->pDev);
|
||||
if (e.event[0].u.u.type == KeyPress ||
|
||||
e.event[0].u.u.type == KeyRelease) {
|
||||
SwitchCoreKeyboard(e.pDev);
|
||||
dev = inputInfo.keyboard;
|
||||
}
|
||||
else if (e->event[0].u.u.type == MotionNotify ||
|
||||
e->event[0].u.u.type == ButtonPress ||
|
||||
e->event[0].u.u.type == ButtonRelease) {
|
||||
SwitchCorePointer(e->pDev);
|
||||
else if (e.event[0].u.u.type == MotionNotify ||
|
||||
e.event[0].u.u.type == ButtonPress ||
|
||||
e.event[0].u.u.type == ButtonRelease) {
|
||||
SwitchCorePointer(e.pDev);
|
||||
dev = inputInfo.pointer;
|
||||
}
|
||||
else {
|
||||
dev = e->pDev;
|
||||
dev = e.pDev;
|
||||
}
|
||||
|
||||
dev->public.processInputProc(e->event, dev, e->nevents);
|
||||
dev->public.processInputProc(e.event, dev, e.nevents);
|
||||
}
|
||||
}
|
||||
#ifdef XQUARTZ
|
||||
pthread_mutex_unlock(&miEventQueueMutex);
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue