dix: Force deviced ids of 2 and higher for actual devices.

0 is now reserved for the "AllDevices" virtual device.
1 is now reserved for the "AllMasterDevices" virtual device.

This also means that wherever we passed in (mskidx = 0), we now need to pass
in the deviceid.
This commit is contained in:
Peter Hutterer 2009-03-06 22:27:54 +10:00
parent 70896f6127
commit 43e48900fc
4 changed files with 29 additions and 25 deletions

View File

@ -58,6 +58,7 @@ SOFTWARE.
#include "inputstr.h" /* DeviceIntPtr */
#include "windowstr.h" /* window structure */
#include <X11/extensions/XI.h>
#include <X11/extensions/XI2.h>
#include <X11/extensions/XIproto.h>
#include "exevents.h"
#include "exglobals.h"
@ -103,10 +104,9 @@ HandleDevicePresenceMask(ClientPtr client, WindowPtr win,
if (mask == 0)
return Success;
/* We always only use mksidx = MAXDEVICES for events not bound to
/* We always only use mksidx = AllDevices for events not bound to
* devices */
if (AddExtensionClient (win, client, mask, MAXDEVICES) != Success)
if (AddExtensionClient (win, client, mask, AllDevices) != Success)
return BadAlloc;
RecalculateDeviceDeliverableEvents(win);

View File

@ -56,6 +56,7 @@ SOFTWARE.
#include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h>
#include <X11/extensions/XI2.h>
#include <X11/extensions/XIproto.h>
#include "exevents.h"
#include "exglobals.h"

View File

@ -74,6 +74,7 @@ SOFTWARE.
#include "mipointer.h"
#include <X11/extensions/XI.h>
#include <X11/extensions/XI2.h>
#include <X11/extensions/XIproto.h>
#include "exglobals.h"
#include "exevents.h"
@ -186,13 +187,13 @@ AddInputDevice(ClientPtr client, DeviceProc deviceProc, Bool autoStart)
char devind[MAXDEVICES];
BOOL enabled;
/* Find next available id */
/* Find next available id, 0 and 1 are reserved */
memset(devind, 0, sizeof(char)*MAXDEVICES);
for (devtmp = inputInfo.devices; devtmp; devtmp = devtmp->next)
devind[devtmp->id]++;
for (devtmp = inputInfo.off_devices; devtmp; devtmp = devtmp->next)
devind[devtmp->id]++;
for (devid = 0; devid < MAXDEVICES && devind[devid]; devid++)
for (devid = 2; devid < MAXDEVICES && devind[devid]; devid++)
;
if (devid >= MAXDEVICES)
@ -250,7 +251,7 @@ SendDevicePresenceEvent(int deviceid, int type)
ev.time = currentTime.milliseconds;
ev.devchange = type;
ev.deviceid = deviceid;
dummyDev.id = MAXDEVICES;
dummyDev.id = AllDevices;
SendEventToAllWindows(&dummyDev, DevicePresenceNotifyMask,
(xEvent*)&ev, 1);
}

View File

@ -148,6 +148,7 @@ typedef const char *string;
#include <X11/extensions/XIproto.h>
#include <X11/extensions/XI.h>
#include <X11/extensions/XI2.h>
#include "exglobals.h"
#include "exevents.h"
#include "exglobals.h"
@ -2347,6 +2348,7 @@ DeliverEvents(WindowPtr pWin, xEvent *xE, int count,
{
Mask filter;
int deliveries;
DeviceIntRec dummy;
#ifdef PANORAMIX
if(!noPanoramiXExtension && pWin->drawable.pScreen->myNum)
@ -2355,27 +2357,27 @@ DeliverEvents(WindowPtr pWin, xEvent *xE, int count,
if (!count)
return 0;
/* We don't know a device here. However, this should only ever be called
for a non-device event so we are safe to use 0*/
filter = GetEventFilter(NULL, xE);
dummy.id = AllDevices;
filter = GetEventFilter(&dummy, xE);
if ((filter & SubstructureNotifyMask) && (xE->u.u.type != CreateNotify))
xE->u.destroyNotify.event = pWin->drawable.id;
if (filter != StructureAndSubMask)
return DeliverEventsToWindow(inputInfo.pointer, pWin, xE, count, filter, NullGrab, 0);
deliveries = DeliverEventsToWindow(inputInfo.pointer, pWin, xE, count, StructureNotifyMask,
NullGrab, 0);
return DeliverEventsToWindow(&dummy, pWin, xE, count, filter, NullGrab, dummy.id);
deliveries = DeliverEventsToWindow(&dummy, pWin, xE, count, StructureNotifyMask,
NullGrab, dummy.id);
if (pWin->parent)
{
xE->u.destroyNotify.event = pWin->parent->drawable.id;
deliveries += DeliverEventsToWindow(inputInfo.pointer, pWin->parent, xE, count,
deliveries += DeliverEventsToWindow(&dummy, pWin->parent, xE, count,
SubstructureNotifyMask, NullGrab,
0);
dummy.id);
if (xE->u.u.type == ReparentNotify)
{
xE->u.destroyNotify.event = otherParent->drawable.id;
deliveries += DeliverEventsToWindow(inputInfo.pointer,
deliveries += DeliverEventsToWindow(&dummy,
otherParent, xE, count, SubstructureNotifyMask,
NullGrab, 0);
NullGrab, dummy.id);
}
}
return deliveries;
@ -3435,7 +3437,7 @@ DeliverFocusedEvent(DeviceIntPtr keybd, InternalEvent *event, WindowPtr window)
FixUpEventFromWindow(keybd, &core, focus, None, FALSE);
deliveries = DeliverEventsToWindow(keybd, focus, &core, 1,
GetEventFilter(keybd, &core),
NullGrab, 0);
NullGrab, keybd->id);
}
unwind:
@ -3927,7 +3929,7 @@ CoreEnterLeaveEvent(
else
DeliverEventsToWindow(mouse, pWin, &event, 1,
GetEventFilter(mouse, &event),
NullGrab, 0);
NullGrab, mouse->id);
}
if ((type == EnterNotify) && (mask & KeymapStateMask))
@ -3946,7 +3948,7 @@ CoreEnterLeaveEvent(
mask, KeymapStateMask, grab);
else
DeliverEventsToWindow(mouse, pWin, (xEvent *)&ke, 1,
KeymapStateMask, NullGrab, 0);
KeymapStateMask, NullGrab, mouse->id);
}
}
@ -4028,7 +4030,7 @@ CoreFocusEvent(DeviceIntPtr dev, int type, int mode, int detail, WindowPtr pWin)
event.u.focus.window = pWin->drawable.id;
DeliverEventsToWindow(dev, pWin, &event, 1,
GetEventFilter(dev, &event), NullGrab, 0);
GetEventFilter(dev, &event), NullGrab, dev->id);
if ((type == FocusIn) &&
((pWin->eventMask | wOtherEventMasks(pWin)) & KeymapStateMask))
{
@ -4041,7 +4043,7 @@ CoreFocusEvent(DeviceIntPtr dev, int type, int mode, int detail, WindowPtr pWin)
ke.type = KeymapNotify;
DeliverEventsToWindow(dev, pWin, (xEvent *)&ke, 1,
KeymapStateMask, NullGrab, 0);
KeymapStateMask, NullGrab, dev->id);
}
}
@ -4781,8 +4783,8 @@ ProcSendEvent(ClientPtr client)
if (XaceHook(XACE_SEND_ACCESS, client, NULL, pWin,
&stuff->event, 1))
return Success;
if (DeliverEventsToWindow(PickPointer(client), pWin,
&stuff->event, 1, stuff->eventMask, NullGrab, 0))
if (DeliverEventsToWindow(dev, pWin,
&stuff->event, 1, stuff->eventMask, NullGrab, dev->id))
return Success;
if (pWin == effectiveFocus)
return Success;
@ -4792,8 +4794,8 @@ ProcSendEvent(ClientPtr client)
}
}
else if (!XaceHook(XACE_SEND_ACCESS, client, NULL, pWin, &stuff->event, 1))
DeliverEventsToWindow(PickPointer(client), pWin, &stuff->event,
1, stuff->eventMask, NullGrab, 0);
DeliverEventsToWindow(dev, pWin, &stuff->event,
1, stuff->eventMask, NullGrab, dev->id);
return Success;
}