Commit b308dbf2 authored by Daniel Stone's avatar Daniel Stone Committed by Daniel Stone

add DEVICE_TOUCHSCREEN and DEVICE_CORE Xi controls (DeviceIntRec ABI break)

Add DEVICE_TOUCHSCREEN and DEVICE_CORE controls to the Xi code, and the
TouchscreenClassRec and a coreEvents flag, to toggle propagation of core
events.
parent c9a3d9ba
......@@ -104,6 +104,8 @@ ProcXChangeDeviceControl(ClientPtr client)
xChangeDeviceControlReply rep;
AxisInfoPtr a;
CARD32 *resolution;
xDeviceTSCtl *ts;
xDeviceCoreCtl *c;
REQUEST(xChangeDeviceControlReq);
REQUEST_AT_LEAST_SIZE(xChangeDeviceControlReq);
......@@ -168,6 +170,54 @@ ProcXChangeDeviceControl(ClientPtr client)
return Success;
}
break;
case DEVICE_TOUCHSCREEN:
ts = (xDeviceTSCtl *)&stuff[1];
if (ts->button_threshold < 0 || ts->button_threshold > 255) {
SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0,
BadValue);
return Success;
}
status = ChangeDeviceControl(client, dev, (xDeviceCtl *) ts);
if (status == Success) {
dev->touchscreen->min_x = ts->min_x;
dev->touchscreen->max_x = ts->max_x;
dev->touchscreen->min_y = ts->min_y;
dev->touchscreen->max_y = ts->max_y;
dev->touchscreen->button_threshold = ts->button_threshold;
} else if (status == DeviceBusy) {
rep.status = DeviceBusy;
WriteReplyToClient(client, sizeof(xChangeDeviceControlReply),
&rep);
return Success;
} else {
SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0,
BadMatch);
return Success;
}
break;
case DEVICE_CORE:
c = (xDeviceCoreCtl *)&stuff[1];
status = ChangeDeviceControl(client, dev, (xDeviceCtl *) c);
if (status == Success) {
dev->coreEvents = c->status;
} else if (status == DeviceBusy) {
rep.status = DeviceBusy;
WriteReplyToClient(client, sizeof(xChangeDeviceControlReply),
&rep);
return Success;
} else {
SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0,
BadMatch);
return Success;
}
break;
default:
SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0, BadValue);
return Success;
......
......@@ -124,6 +124,18 @@ ProcXGetDeviceControl(ClientPtr client)
total_length = sizeof(xDeviceResolutionState) +
(3 * sizeof(int) * dev->valuator->numAxes);
break;
case DEVICE_TOUCHSCREEN:
if (!dev->touchscreen) {
SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0,
BadMatch);
return Success;
}
total_length = sizeof(xDeviceTSCtl);
break;
case DEVICE_CORE:
total_length = sizeof(xDeviceCoreCtl);
break;
default:
SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0, BadValue);
return Success;
......@@ -140,6 +152,11 @@ ProcXGetDeviceControl(ClientPtr client)
case DEVICE_RESOLUTION:
CopySwapDeviceResolution(client, dev->valuator, buf, total_length);
break;
case DEVICE_TOUCHSCREEN:
CopySwapDeviceTouchscreen(client, dev->touchscreen, buf);
break;
case DEVICE_CORE:
CopySwapDeviceCore(client, dev, buf);
default:
break;
}
......@@ -189,6 +206,48 @@ CopySwapDeviceResolution(ClientPtr client, ValuatorClassPtr v, char *buf,
}
}
void CopySwapDeviceTouchscreen (ClientPtr client, TouchscreenClassPtr dts,
char *buf)
{
register char n;
xDeviceTSState *ts = (xDeviceTSState *) buf;
ts->control = DEVICE_TOUCHSCREEN;
ts->length = sizeof(ts);
ts->min_x = dts->min_x;
ts->max_x = dts->max_x;
ts->min_y = dts->min_y;
ts->max_y = dts->max_y;
ts->button_threshold = dts->button_threshold;
if (client->swapped) {
swaps(&ts->control, n);
swaps(&ts->length, n);
swapl(&ts->min_x, n);
swapl(&ts->max_x, n);
swapl(&ts->min_y, n);
swapl(&ts->max_y, n);
swapl(&ts->button_threshold, n);
}
}
void CopySwapDeviceCore (ClientPtr client, DeviceIntPtr dev, char *buf)
{
register char n;
xDeviceCoreState *c = (xDeviceCoreState *) buf;
c->control = DEVICE_CORE;
c->length = sizeof(c);
c->status = dev->coreEvents;
if (client->swapped) {
swaps(&c->control, n);
swaps(&c->length, n);
swaps(&c->status, n);
}
}
/***********************************************************************
*
* This procedure writes the reply for the xGetDeviceControl function,
......
......@@ -42,6 +42,16 @@ void CopySwapDeviceResolution(ClientPtr /* client */ ,
int /* length */
);
void CopySwapDeviceTouchscreen(ClientPtr /* client */ ,
TouchscreenClassPtr /* ts */ ,
char * /* buf */
);
void CopySwapDeviceCore(ClientPtr /* client */ ,
DeviceIntPtr /* dev */ ,
char * /* buf */
);
void SRepXGetDeviceControl(ClientPtr /* client */ ,
int /* size */ ,
xGetDeviceControlReply * /* rep */
......
......@@ -287,6 +287,10 @@ ChangeDeviceControl(register ClientPtr client, DeviceIntPtr dev,
switch (control->control) {
case DEVICE_RESOLUTION:
return (BadMatch);
case DEVICE_TOUCHSCREEN:
return (BadMatch);
case DEVICE_CORE:
return (BadMatch);
default:
return (BadMatch);
}
......
......@@ -177,6 +177,14 @@ typedef struct _ProximityClassRec {
char pad;
} ProximityClassRec, *ProximityClassPtr;
typedef struct _TouchscreenClassRec {
int min_x;
int max_x;
int min_y;
int max_y;
int button_threshold;
} TouchscreenClassRec, *TouchscreenClassPtr;
typedef struct _KbdFeedbackClassRec *KbdFeedbackPtr;
typedef struct _PtrFeedbackClassRec *PtrFeedbackPtr;
typedef struct _IntegerFeedbackClassRec *IntegerFeedbackPtr;
......@@ -250,6 +258,7 @@ typedef struct _DeviceIntRec {
used to initialize, turn on, or
turn off the device */
Bool inited; /* TRUE if INIT returns Success */
Bool coreEvents; /* TRUE if device also sends core */
GrabPtr grab; /* the grabber - used by DIX */
struct {
Bool frozen;
......@@ -276,6 +285,7 @@ typedef struct _DeviceIntRec {
ButtonClassPtr button;
FocusClassPtr focus;
ProximityClassPtr proximity;
TouchscreenClassPtr touchscreen;
KbdFeedbackPtr kbdfeed;
PtrFeedbackPtr ptrfeed;
IntegerFeedbackPtr intfeed;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment