dix, Xi: make use of deviceid in DevicePresenceNotify
Use the deviceid and control fields in DevicePresenceNotify since the last push to inputproto to send a DPN whenever a control changes on a device.
This commit is contained in:
parent
f08b6b2367
commit
be21630164
99
Xi/chgdctl.c
99
Xi/chgdctl.c
|
@ -66,6 +66,7 @@ SOFTWARE.
|
||||||
#include "extnsionst.h"
|
#include "extnsionst.h"
|
||||||
#include "extinit.h" /* LookupDeviceIntRec */
|
#include "extinit.h" /* LookupDeviceIntRec */
|
||||||
#include "exglobals.h"
|
#include "exglobals.h"
|
||||||
|
#include "exevents.h"
|
||||||
|
|
||||||
#include "chgdctl.h"
|
#include "chgdctl.h"
|
||||||
|
|
||||||
|
@ -98,7 +99,7 @@ int
|
||||||
ProcXChangeDeviceControl(ClientPtr client)
|
ProcXChangeDeviceControl(ClientPtr client)
|
||||||
{
|
{
|
||||||
unsigned len;
|
unsigned len;
|
||||||
int i, status;
|
int i, status, ret = BadValue;
|
||||||
DeviceIntPtr dev;
|
DeviceIntPtr dev;
|
||||||
xDeviceResolutionCtl *r;
|
xDeviceResolutionCtl *r;
|
||||||
xChangeDeviceControlReply rep;
|
xChangeDeviceControlReply rep;
|
||||||
|
@ -108,6 +109,7 @@ ProcXChangeDeviceControl(ClientPtr client)
|
||||||
xDeviceAbsAreaCtl *area;
|
xDeviceAbsAreaCtl *area;
|
||||||
xDeviceCoreCtl *c;
|
xDeviceCoreCtl *c;
|
||||||
xDeviceEnableCtl *e;
|
xDeviceEnableCtl *e;
|
||||||
|
devicePresenceNotify dpn;
|
||||||
|
|
||||||
REQUEST(xChangeDeviceControlReq);
|
REQUEST(xChangeDeviceControlReq);
|
||||||
REQUEST_AT_LEAST_SIZE(xChangeDeviceControlReq);
|
REQUEST_AT_LEAST_SIZE(xChangeDeviceControlReq);
|
||||||
|
@ -115,9 +117,8 @@ ProcXChangeDeviceControl(ClientPtr client)
|
||||||
len = stuff->length - (sizeof(xChangeDeviceControlReq) >> 2);
|
len = stuff->length - (sizeof(xChangeDeviceControlReq) >> 2);
|
||||||
dev = LookupDeviceIntRec(stuff->deviceid);
|
dev = LookupDeviceIntRec(stuff->deviceid);
|
||||||
if (dev == NULL) {
|
if (dev == NULL) {
|
||||||
SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0,
|
ret = BadDevice;
|
||||||
BadDevice);
|
goto out;
|
||||||
return Success;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rep.repType = X_Reply;
|
rep.repType = X_Reply;
|
||||||
|
@ -130,25 +131,22 @@ ProcXChangeDeviceControl(ClientPtr client)
|
||||||
r = (xDeviceResolutionCtl *) & stuff[1];
|
r = (xDeviceResolutionCtl *) & stuff[1];
|
||||||
if ((len < (sizeof(xDeviceResolutionCtl) >> 2)) ||
|
if ((len < (sizeof(xDeviceResolutionCtl) >> 2)) ||
|
||||||
(len != (sizeof(xDeviceResolutionCtl) >> 2) + r->num_valuators)) {
|
(len != (sizeof(xDeviceResolutionCtl) >> 2) + r->num_valuators)) {
|
||||||
SendErrorToClient(client, IReqCode, X_ChangeDeviceControl,
|
ret = BadLength;
|
||||||
0, BadLength);
|
goto out;
|
||||||
return Success;
|
|
||||||
}
|
}
|
||||||
if (!dev->valuator) {
|
if (!dev->valuator) {
|
||||||
SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0,
|
ret = BadMatch;
|
||||||
BadMatch);
|
goto out;
|
||||||
return Success;
|
|
||||||
}
|
}
|
||||||
if ((dev->grab) && !SameClient(dev->grab, client)) {
|
if ((dev->grab) && !SameClient(dev->grab, client)) {
|
||||||
rep.status = AlreadyGrabbed;
|
rep.status = AlreadyGrabbed;
|
||||||
WriteReplyToClient(client, sizeof(xChangeDeviceControlReply), &rep);
|
ret = Success;
|
||||||
return Success;
|
goto out;
|
||||||
}
|
}
|
||||||
resolution = (CARD32 *) (r + 1);
|
resolution = (CARD32 *) (r + 1);
|
||||||
if (r->first_valuator + r->num_valuators > dev->valuator->numAxes) {
|
if (r->first_valuator + r->num_valuators > dev->valuator->numAxes) {
|
||||||
SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0,
|
ret = BadValue;
|
||||||
BadValue);
|
goto out;
|
||||||
return Success;
|
|
||||||
}
|
}
|
||||||
status = ChangeDeviceControl(client, dev, (xDeviceCtl *) r);
|
status = ChangeDeviceControl(client, dev, (xDeviceCtl *) r);
|
||||||
if (status == Success) {
|
if (status == Success) {
|
||||||
|
@ -162,23 +160,21 @@ ProcXChangeDeviceControl(ClientPtr client)
|
||||||
}
|
}
|
||||||
for (i = 0; i < r->num_valuators; i++)
|
for (i = 0; i < r->num_valuators; i++)
|
||||||
(a++)->resolution = *resolution++;
|
(a++)->resolution = *resolution++;
|
||||||
|
|
||||||
|
ret = Success;
|
||||||
} else if (status == DeviceBusy) {
|
} else if (status == DeviceBusy) {
|
||||||
rep.status = DeviceBusy;
|
rep.status = DeviceBusy;
|
||||||
WriteReplyToClient(client, sizeof(xChangeDeviceControlReply), &rep);
|
ret = Success;
|
||||||
return Success;
|
|
||||||
} else {
|
} else {
|
||||||
SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0,
|
ret = BadMatch;
|
||||||
BadMatch);
|
|
||||||
return Success;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DEVICE_ABS_CALIB:
|
case DEVICE_ABS_CALIB:
|
||||||
calib = (xDeviceAbsCalibCtl *)&stuff[1];
|
calib = (xDeviceAbsCalibCtl *)&stuff[1];
|
||||||
|
|
||||||
if (calib->button_threshold < 0 || calib->button_threshold > 255) {
|
if (calib->button_threshold < 0 || calib->button_threshold > 255) {
|
||||||
SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0,
|
ret = BadValue;
|
||||||
BadValue);
|
goto out;
|
||||||
return Success;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
status = ChangeDeviceControl(client, dev, (xDeviceCtl *) calib);
|
status = ChangeDeviceControl(client, dev, (xDeviceCtl *) calib);
|
||||||
|
@ -192,15 +188,12 @@ ProcXChangeDeviceControl(ClientPtr client)
|
||||||
dev->absolute->flip_y = calib->flip_y;
|
dev->absolute->flip_y = calib->flip_y;
|
||||||
dev->absolute->rotation = calib->rotation;
|
dev->absolute->rotation = calib->rotation;
|
||||||
dev->absolute->button_threshold = calib->button_threshold;
|
dev->absolute->button_threshold = calib->button_threshold;
|
||||||
|
ret = Success;
|
||||||
} else if (status == DeviceBusy || status == BadValue) {
|
} else if (status == DeviceBusy || status == BadValue) {
|
||||||
rep.status = status;
|
rep.status = status;
|
||||||
WriteReplyToClient(client, sizeof(xChangeDeviceControlReply),
|
ret = Success;
|
||||||
&rep);
|
|
||||||
return Success;
|
|
||||||
} else {
|
} else {
|
||||||
SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0,
|
ret = BadMatch;
|
||||||
BadMatch);
|
|
||||||
return Success;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -216,15 +209,12 @@ ProcXChangeDeviceControl(ClientPtr client)
|
||||||
dev->absolute->height = area->height;
|
dev->absolute->height = area->height;
|
||||||
dev->absolute->screen = area->screen;
|
dev->absolute->screen = area->screen;
|
||||||
dev->absolute->following = area->following;
|
dev->absolute->following = area->following;
|
||||||
|
ret = Success;
|
||||||
} else if (status == DeviceBusy || status == BadValue) {
|
} else if (status == DeviceBusy || status == BadValue) {
|
||||||
rep.status = status;
|
rep.status = status;
|
||||||
WriteReplyToClient(client, sizeof(xChangeDeviceControlReply),
|
ret = Success;
|
||||||
&rep);
|
|
||||||
return Success;
|
|
||||||
} else {
|
} else {
|
||||||
SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0,
|
ret = Success;
|
||||||
BadMatch);
|
|
||||||
return Success;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -235,15 +225,12 @@ ProcXChangeDeviceControl(ClientPtr client)
|
||||||
|
|
||||||
if (status == Success) {
|
if (status == Success) {
|
||||||
dev->coreEvents = c->status;
|
dev->coreEvents = c->status;
|
||||||
|
ret = Success;
|
||||||
} else if (status == DeviceBusy) {
|
} else if (status == DeviceBusy) {
|
||||||
rep.status = DeviceBusy;
|
rep.status = DeviceBusy;
|
||||||
WriteReplyToClient(client, sizeof(xChangeDeviceControlReply),
|
ret = Success;
|
||||||
&rep);
|
|
||||||
return Success;
|
|
||||||
} else {
|
} else {
|
||||||
SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0,
|
ret = BadMatch;
|
||||||
BadMatch);
|
|
||||||
return Success;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -257,23 +244,35 @@ ProcXChangeDeviceControl(ClientPtr client)
|
||||||
EnableDevice(dev);
|
EnableDevice(dev);
|
||||||
else
|
else
|
||||||
DisableDevice(dev);
|
DisableDevice(dev);
|
||||||
|
ret = Success;
|
||||||
} else if (status == DeviceBusy) {
|
} else if (status == DeviceBusy) {
|
||||||
rep.status = DeviceBusy;
|
rep.status = DeviceBusy;
|
||||||
WriteReplyToClient(client, sizeof(xChangeDeviceControlReply),
|
ret = Success;
|
||||||
&rep);
|
|
||||||
return Success;
|
|
||||||
} else {
|
} else {
|
||||||
SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0,
|
ret = BadMatch;
|
||||||
BadMatch);
|
|
||||||
return Success;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0, BadValue);
|
ret = BadValue;
|
||||||
return Success;
|
|
||||||
}
|
}
|
||||||
WriteReplyToClient(client, sizeof(xChangeDeviceControlReply), &rep);
|
|
||||||
|
out:
|
||||||
|
if (ret == Success) {
|
||||||
|
dpn.type = DevicePresenceNotify;
|
||||||
|
dpn.time = currentTime.milliseconds;
|
||||||
|
dpn.devchange = 1;
|
||||||
|
dpn.deviceid = dev->id;
|
||||||
|
dpn.control = stuff->control;
|
||||||
|
SendEventToAllWindows(dev, DevicePresenceNotifyMask,
|
||||||
|
(xEvent *) &dpn, 1);
|
||||||
|
|
||||||
|
WriteReplyToClient(client, sizeof(xChangeDeviceControlReply), &rep);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0, ret);
|
||||||
|
}
|
||||||
|
|
||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -201,6 +201,8 @@ ActivateDevice(DeviceIntPtr dev)
|
||||||
|
|
||||||
ev.type = DevicePresenceNotify;
|
ev.type = DevicePresenceNotify;
|
||||||
ev.time = currentTime.milliseconds;
|
ev.time = currentTime.milliseconds;
|
||||||
|
ev.devchange = 0;
|
||||||
|
ev.deviceid = 0;
|
||||||
dummyDev.id = 0;
|
dummyDev.id = 0;
|
||||||
SendEventToAllWindows(&dummyDev, DevicePresenceNotifyMask,
|
SendEventToAllWindows(&dummyDev, DevicePresenceNotifyMask,
|
||||||
(xEvent *) &ev, 1);
|
(xEvent *) &ev, 1);
|
||||||
|
@ -557,6 +559,8 @@ RemoveDevice(DeviceIntPtr dev)
|
||||||
if (ret == Success) {
|
if (ret == Success) {
|
||||||
ev.type = DevicePresenceNotify;
|
ev.type = DevicePresenceNotify;
|
||||||
ev.time = currentTime.milliseconds;
|
ev.time = currentTime.milliseconds;
|
||||||
|
ev.devchange = 0;
|
||||||
|
ev.deviceid = 0;
|
||||||
dummyDev.id = 0;
|
dummyDev.id = 0;
|
||||||
SendEventToAllWindows(&dummyDev, DevicePresenceNotifyMask,
|
SendEventToAllWindows(&dummyDev, DevicePresenceNotifyMask,
|
||||||
(xEvent *) &ev, 1);
|
(xEvent *) &ev, 1);
|
||||||
|
|
Loading…
Reference in New Issue