Xi: expose Enable/DisableDevice through XI_PROP_ENABLED property.
This commit is contained in:
parent
c9eb0e870c
commit
5bcc45e07e
|
@ -123,6 +123,7 @@ SOFTWARE.
|
|||
#include "warpdevp.h"
|
||||
#include "xiselev.h"
|
||||
#include "xiproperty.c"
|
||||
#include "xiproperty.h"
|
||||
|
||||
|
||||
static Mask lastExtEventMask = 1;
|
||||
|
@ -1140,6 +1141,7 @@ XInputExtensionInit(void)
|
|||
IEventBase = extEntry->eventBase;
|
||||
AllExtensionVersions[IReqCode - 128] = thisversion;
|
||||
MakeDeviceTypeAtoms();
|
||||
XIInitKnownProperties();
|
||||
RT_INPUTCLIENT = CreateNewResourceType((DeleteType) InputClientGone);
|
||||
RegisterResourceName(RT_INPUTCLIENT, "INPUTCLIENT");
|
||||
FixExtensionEvents(extEntry);
|
||||
|
|
|
@ -39,8 +39,54 @@
|
|||
|
||||
#include "xiproperty.h"
|
||||
|
||||
/**
|
||||
* Properties used or alloced from inside the server.
|
||||
*/
|
||||
static struct dev_properties
|
||||
{
|
||||
Atom type;
|
||||
char *name;
|
||||
} dev_properties[] = {
|
||||
{0, XI_PROP_ENABLED}
|
||||
};
|
||||
|
||||
static long XIPropHandlerID = 1;
|
||||
|
||||
/**
|
||||
* Return the type assigned to the specified atom or 0 if the atom isn't known
|
||||
* to the DIX.
|
||||
*/
|
||||
_X_EXPORT Atom
|
||||
XIGetKnownProperty(char *name)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < (sizeof(dev_properties)/sizeof(struct dev_properties)); i++)
|
||||
{
|
||||
if (strcmp(name, dev_properties[i].name) == 0)
|
||||
return dev_properties[i].type;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Init those properties that are allocated by the server and most likely used
|
||||
* by the DIX or the DDX.
|
||||
*/
|
||||
void
|
||||
XIInitKnownProperties(void)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < (sizeof(dev_properties)/sizeof(struct dev_properties)); i++)
|
||||
{
|
||||
dev_properties[i].type =
|
||||
MakeAtom(dev_properties[i].name,
|
||||
strlen(dev_properties[i].name),
|
||||
TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Registers a new property handler on the given device and returns a unique
|
||||
* identifier for this handler. This identifier is required to unregister the
|
||||
* property handler again.
|
||||
|
|
|
@ -40,4 +40,6 @@ int SProcXChangeDeviceProperty (ClientPtr client);
|
|||
int SProcXDeleteDeviceProperty (ClientPtr client);
|
||||
int SProcXGetDeviceProperty (ClientPtr client);
|
||||
|
||||
void XIInitKnownProperties(void);
|
||||
|
||||
#endif /* XIPROPERTY_C */
|
||||
|
|
|
@ -57,6 +57,7 @@ SOFTWARE.
|
|||
#define NEED_EVENTS
|
||||
#define NEED_REPLIES
|
||||
#include <X11/Xproto.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include "windowstr.h"
|
||||
#include "inputstr.h"
|
||||
#include "scrnintstr.h"
|
||||
|
@ -94,6 +95,30 @@ DevPrivateKey CoreDevicePrivateKey = &CoreDevicePrivateKey;
|
|||
/* Used to sture classes currently not in use by an MD */
|
||||
DevPrivateKey UnusedClassesPrivateKey = &UnusedClassesPrivateKey;
|
||||
|
||||
|
||||
/**
|
||||
* DIX property handler.
|
||||
*/
|
||||
static Bool
|
||||
DeviceSetProperty(DeviceIntPtr dev, Atom property, XIPropertyValuePtr prop)
|
||||
{
|
||||
if (property == XIGetKnownProperty(XI_PROP_ENABLED))
|
||||
{
|
||||
if (prop->format != 8 || prop->type != XA_INTEGER || prop->size != 1)
|
||||
return FALSE;
|
||||
|
||||
if ((*((CARD8*)prop->data)) && !dev->enabled)
|
||||
EnableDevice(dev);
|
||||
else if (!(*((CARD8*)prop->data)) && dev->enabled)
|
||||
DisableDevice(dev);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Create a new input device and init it to sane values. The device is added
|
||||
* to the server's off_devices list.
|
||||
|
@ -195,6 +220,11 @@ AddInputDevice(ClientPtr client, DeviceProc deviceProc, Bool autoStart)
|
|||
*prev = dev;
|
||||
dev->next = NULL;
|
||||
|
||||
XIChangeDeviceProperty(dev, XIGetKnownProperty(XI_PROP_ENABLED),
|
||||
XA_INTEGER, 8, PropModeReplace, 1, &dev->enabled,
|
||||
FALSE, FALSE, FALSE);
|
||||
XIRegisterPropertyHandler(dev, DeviceSetProperty, NULL);
|
||||
|
||||
return dev;
|
||||
}
|
||||
|
||||
|
@ -266,6 +296,7 @@ EnableDevice(DeviceIntPtr dev)
|
|||
mieqResizeEvents(evsize);
|
||||
OsReleaseSignals();
|
||||
|
||||
|
||||
if ((*prev != dev) || !dev->inited ||
|
||||
((ret = (*dev->deviceProc)(dev, DEVICE_ON)) != Success)) {
|
||||
ErrorF("[dix] couldn't enable device %d\n", dev->id);
|
||||
|
@ -279,6 +310,10 @@ EnableDevice(DeviceIntPtr dev)
|
|||
*prev = dev;
|
||||
dev->next = NULL;
|
||||
|
||||
XIChangeDeviceProperty(dev, XIGetKnownProperty(XI_PROP_ENABLED),
|
||||
XA_INTEGER, 8, PropModeReplace, 1, &dev->enabled,
|
||||
TRUE, FALSE, FALSE);
|
||||
|
||||
ev.type = DevicePresenceNotify;
|
||||
ev.time = currentTime.milliseconds;
|
||||
ev.devchange = DeviceEnabled;
|
||||
|
@ -343,6 +378,10 @@ DisableDevice(DeviceIntPtr dev)
|
|||
dev->next = inputInfo.off_devices;
|
||||
inputInfo.off_devices = dev;
|
||||
|
||||
XIChangeDeviceProperty(dev, XIGetKnownProperty(XI_PROP_ENABLED),
|
||||
XA_INTEGER, 8, PropModeReplace, 1, &dev->enabled,
|
||||
TRUE, FALSE, FALSE);
|
||||
|
||||
ev.type = DevicePresenceNotify;
|
||||
ev.time = currentTime.milliseconds;
|
||||
ev.devchange = DeviceDisabled;
|
||||
|
|
|
@ -253,4 +253,8 @@ extern void XIUnRegisterPropertyHandler(
|
|||
long id
|
||||
);
|
||||
|
||||
extern Atom XIGetKnownProperty(
|
||||
char* name
|
||||
);
|
||||
|
||||
#endif /* EXEVENTS_H */
|
||||
|
|
Loading…
Reference in New Issue
Block a user