mirror of
https://github.com/X11Libre/xserver.git
synced 2026-01-26 14:03:17 +00:00
Xext: dpms: use REQUEST_HEAD_STRUCT and REQUEST_FIELD_* macros
Use the new macros to make request struct parsing / field swapping much easier. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
7b72ce3a23
commit
2a6b886563
63
Xext/dpms.c
63
Xext/dpms.c
@ -129,11 +129,8 @@ SDPMSInfoNotifyEvent(xGenericEvent * from,
|
|||||||
static int
|
static int
|
||||||
ProcDPMSSelectInput(register ClientPtr client)
|
ProcDPMSSelectInput(register ClientPtr client)
|
||||||
{
|
{
|
||||||
REQUEST(xDPMSSelectInputReq);
|
X_REQUEST_HEAD_STRUCT(xDPMSSelectInputReq);
|
||||||
REQUEST_SIZE_MATCH(xDPMSSelectInputReq);
|
X_REQUEST_FIELD_CARD32(eventMask);
|
||||||
|
|
||||||
if (client->swapped)
|
|
||||||
swapl(&stuff->eventMask);
|
|
||||||
|
|
||||||
DPMSEventPtr pEvent, pNewEvent, *pHead;
|
DPMSEventPtr pEvent, pNewEvent, *pHead;
|
||||||
XID clientResource;
|
XID clientResource;
|
||||||
@ -306,15 +303,10 @@ DPMSSet(ClientPtr client, int level)
|
|||||||
static int
|
static int
|
||||||
ProcDPMSGetVersion(ClientPtr client)
|
ProcDPMSGetVersion(ClientPtr client)
|
||||||
{
|
{
|
||||||
REQUEST(xDPMSGetVersionReq);
|
X_REQUEST_HEAD_STRUCT(xDPMSGetVersionReq);
|
||||||
REQUEST_SIZE_MATCH(xDPMSGetVersionReq);
|
X_REQUEST_FIELD_CARD16(majorVersion);
|
||||||
|
X_REQUEST_FIELD_CARD16(minorVersion);
|
||||||
|
|
||||||
if (client->swapped) {
|
|
||||||
swaps(&stuff->majorVersion);
|
|
||||||
swaps(&stuff->minorVersion);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* REQUEST(xDPMSGetVersionReq); */
|
|
||||||
xDPMSGetVersionReply reply = {
|
xDPMSGetVersionReply reply = {
|
||||||
.majorVersion = SERVER_DPMS_MAJOR_VERSION,
|
.majorVersion = SERVER_DPMS_MAJOR_VERSION,
|
||||||
.minorVersion = SERVER_DPMS_MINOR_VERSION
|
.minorVersion = SERVER_DPMS_MINOR_VERSION
|
||||||
@ -331,28 +323,26 @@ ProcDPMSGetVersion(ClientPtr client)
|
|||||||
static int
|
static int
|
||||||
ProcDPMSCapable(ClientPtr client)
|
ProcDPMSCapable(ClientPtr client)
|
||||||
{
|
{
|
||||||
/* REQUEST(xDPMSCapableReq); */
|
X_REQUEST_HEAD_STRUCT(xDPMSCapableReq);
|
||||||
|
|
||||||
xDPMSCapableReply reply = {
|
xDPMSCapableReply reply = {
|
||||||
.capable = TRUE
|
.capable = TRUE
|
||||||
};
|
};
|
||||||
|
|
||||||
REQUEST_SIZE_MATCH(xDPMSCapableReq);
|
|
||||||
|
|
||||||
return X_SEND_REPLY_SIMPLE(client, reply);
|
return X_SEND_REPLY_SIMPLE(client, reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ProcDPMSGetTimeouts(ClientPtr client)
|
ProcDPMSGetTimeouts(ClientPtr client)
|
||||||
{
|
{
|
||||||
/* REQUEST(xDPMSGetTimeoutsReq); */
|
X_REQUEST_HEAD_STRUCT(xDPMSGetTimeoutsReq);
|
||||||
|
|
||||||
xDPMSGetTimeoutsReply reply = {
|
xDPMSGetTimeoutsReply reply = {
|
||||||
.standby = DPMSStandbyTime / MILLI_PER_SECOND,
|
.standby = DPMSStandbyTime / MILLI_PER_SECOND,
|
||||||
.suspend = DPMSSuspendTime / MILLI_PER_SECOND,
|
.suspend = DPMSSuspendTime / MILLI_PER_SECOND,
|
||||||
.off = DPMSOffTime / MILLI_PER_SECOND
|
.off = DPMSOffTime / MILLI_PER_SECOND
|
||||||
};
|
};
|
||||||
|
|
||||||
REQUEST_SIZE_MATCH(xDPMSGetTimeoutsReq);
|
|
||||||
|
|
||||||
if (client->swapped) {
|
if (client->swapped) {
|
||||||
swaps(&reply.standby);
|
swaps(&reply.standby);
|
||||||
swaps(&reply.suspend);
|
swaps(&reply.suspend);
|
||||||
@ -365,14 +355,10 @@ ProcDPMSGetTimeouts(ClientPtr client)
|
|||||||
static int
|
static int
|
||||||
ProcDPMSSetTimeouts(ClientPtr client)
|
ProcDPMSSetTimeouts(ClientPtr client)
|
||||||
{
|
{
|
||||||
REQUEST(xDPMSSetTimeoutsReq);
|
X_REQUEST_HEAD_STRUCT(xDPMSSetTimeoutsReq);
|
||||||
REQUEST_SIZE_MATCH(xDPMSSetTimeoutsReq);
|
X_REQUEST_FIELD_CARD16(standby);
|
||||||
|
X_REQUEST_FIELD_CARD16(suspend);
|
||||||
if (client->swapped) {
|
X_REQUEST_FIELD_CARD16(off);
|
||||||
swaps(&stuff->standby);
|
|
||||||
swaps(&stuff->suspend);
|
|
||||||
swaps(&stuff->off);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((stuff->off != 0) && (stuff->off < stuff->suspend)) {
|
if ((stuff->off != 0) && (stuff->off < stuff->suspend)) {
|
||||||
client->errorValue = stuff->off;
|
client->errorValue = stuff->off;
|
||||||
@ -394,9 +380,9 @@ ProcDPMSSetTimeouts(ClientPtr client)
|
|||||||
static int
|
static int
|
||||||
ProcDPMSEnable(ClientPtr client)
|
ProcDPMSEnable(ClientPtr client)
|
||||||
{
|
{
|
||||||
Bool was_enabled = DPMSEnabled;
|
X_REQUEST_HEAD_STRUCT(xDPMSEnableReq);
|
||||||
|
|
||||||
REQUEST_SIZE_MATCH(xDPMSEnableReq);
|
Bool was_enabled = DPMSEnabled;
|
||||||
|
|
||||||
DPMSEnabled = TRUE;
|
DPMSEnabled = TRUE;
|
||||||
if (!was_enabled) {
|
if (!was_enabled) {
|
||||||
@ -410,12 +396,10 @@ ProcDPMSEnable(ClientPtr client)
|
|||||||
static int
|
static int
|
||||||
ProcDPMSDisable(ClientPtr client)
|
ProcDPMSDisable(ClientPtr client)
|
||||||
{
|
{
|
||||||
|
X_REQUEST_HEAD_STRUCT(xDPMSDisableReq);
|
||||||
|
|
||||||
Bool was_enabled = DPMSEnabled;
|
Bool was_enabled = DPMSEnabled;
|
||||||
|
|
||||||
/* REQUEST(xDPMSDisableReq); */
|
|
||||||
|
|
||||||
REQUEST_SIZE_MATCH(xDPMSDisableReq);
|
|
||||||
|
|
||||||
DPMSSet(client, DPMSModeOn);
|
DPMSSet(client, DPMSModeOn);
|
||||||
|
|
||||||
DPMSEnabled = FALSE;
|
DPMSEnabled = FALSE;
|
||||||
@ -428,16 +412,12 @@ ProcDPMSDisable(ClientPtr client)
|
|||||||
static int
|
static int
|
||||||
ProcDPMSForceLevel(ClientPtr client)
|
ProcDPMSForceLevel(ClientPtr client)
|
||||||
{
|
{
|
||||||
REQUEST(xDPMSForceLevelReq);
|
X_REQUEST_HEAD_STRUCT(xDPMSForceLevelReq);
|
||||||
REQUEST_SIZE_MATCH(xDPMSForceLevelReq);
|
X_REQUEST_FIELD_CARD16(level);
|
||||||
|
|
||||||
if (!DPMSEnabled)
|
if (!DPMSEnabled)
|
||||||
return BadMatch;
|
return BadMatch;
|
||||||
|
|
||||||
if (client->swapped) {
|
|
||||||
swaps(&stuff->level);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stuff->level != DPMSModeOn &&
|
if (stuff->level != DPMSModeOn &&
|
||||||
stuff->level != DPMSModeStandby &&
|
stuff->level != DPMSModeStandby &&
|
||||||
stuff->level != DPMSModeSuspend && stuff->level != DPMSModeOff) {
|
stuff->level != DPMSModeSuspend && stuff->level != DPMSModeOff) {
|
||||||
@ -453,14 +433,13 @@ ProcDPMSForceLevel(ClientPtr client)
|
|||||||
static int
|
static int
|
||||||
ProcDPMSInfo(ClientPtr client)
|
ProcDPMSInfo(ClientPtr client)
|
||||||
{
|
{
|
||||||
/* REQUEST(xDPMSInfoReq); */
|
X_REQUEST_HEAD_STRUCT(xDPMSInfoReq);
|
||||||
|
|
||||||
xDPMSInfoReply reply = {
|
xDPMSInfoReply reply = {
|
||||||
.power_level = DPMSPowerLevel,
|
.power_level = DPMSPowerLevel,
|
||||||
.state = DPMSEnabled
|
.state = DPMSEnabled
|
||||||
};
|
};
|
||||||
|
|
||||||
REQUEST_SIZE_MATCH(xDPMSInfoReq);
|
|
||||||
|
|
||||||
if (client->swapped) {
|
if (client->swapped) {
|
||||||
swaps(&reply.power_level);
|
swaps(&reply.power_level);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user