2006-11-26 11:13:41 -07:00
|
|
|
/*****************************************************************
|
|
|
|
|
|
|
|
Copyright (c) 1996 Digital Equipment Corporation, Maynard, Massachusetts.
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software.
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
|
|
|
|
BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY,
|
|
|
|
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
|
|
|
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
|
|
Except as contained in this notice, the name of Digital Equipment Corporation
|
|
|
|
shall not be used in advertising or otherwise to promote the sale, use or other
|
|
|
|
dealings in this Software without prior written authorization from Digital
|
|
|
|
Equipment Corporation.
|
|
|
|
|
|
|
|
******************************************************************/
|
|
|
|
|
|
|
|
#ifdef HAVE_DIX_CONFIG_H
|
|
|
|
#include <dix-config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <X11/X.h>
|
|
|
|
#include <X11/Xproto.h>
|
|
|
|
#include "misc.h"
|
|
|
|
#include "os.h"
|
|
|
|
#include "dixstruct.h"
|
|
|
|
#include "extnsionst.h"
|
|
|
|
#include "opaque.h"
|
2010-04-13 13:54:46 -06:00
|
|
|
#include <X11/extensions/dpmsproto.h>
|
2006-11-26 11:13:41 -07:00
|
|
|
#include "dpmsproc.h"
|
2013-06-07 11:28:45 -06:00
|
|
|
#include "extinit.h"
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
static int
|
2010-07-27 13:02:24 -06:00
|
|
|
ProcDPMSGetVersion(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
/* REQUEST(xDPMSGetVersionReq); */
|
2013-06-07 11:28:45 -06:00
|
|
|
xDPMSGetVersionReply rep = {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = 0,
|
|
|
|
.majorVersion = DPMSMajorVersion,
|
|
|
|
.minorVersion = DPMSMinorVersion
|
|
|
|
};
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xDPMSGetVersionReq);
|
|
|
|
|
|
|
|
if (client->swapped) {
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&rep.sequenceNumber);
|
|
|
|
swaps(&rep.majorVersion);
|
|
|
|
swaps(&rep.minorVersion);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, sizeof(xDPMSGetVersionReply), &rep);
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2009-09-06 13:44:18 -06:00
|
|
|
ProcDPMSCapable(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
/* REQUEST(xDPMSCapableReq); */
|
2013-06-07 11:28:45 -06:00
|
|
|
xDPMSCapableReply rep = {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = 0,
|
|
|
|
.capable = DPMSCapableFlag
|
|
|
|
};
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xDPMSCapableReq);
|
|
|
|
|
|
|
|
if (client->swapped) {
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&rep.sequenceNumber);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, sizeof(xDPMSCapableReply), &rep);
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-07-27 13:02:24 -06:00
|
|
|
ProcDPMSGetTimeouts(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
/* REQUEST(xDPMSGetTimeoutsReq); */
|
2013-06-07 11:28:45 -06:00
|
|
|
xDPMSGetTimeoutsReply rep = {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = 0,
|
|
|
|
.standby = DPMSStandbyTime / MILLI_PER_SECOND,
|
|
|
|
.suspend = DPMSSuspendTime / MILLI_PER_SECOND,
|
|
|
|
.off = DPMSOffTime / MILLI_PER_SECOND
|
|
|
|
};
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xDPMSGetTimeoutsReq);
|
|
|
|
|
|
|
|
if (client->swapped) {
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&rep.sequenceNumber);
|
|
|
|
swaps(&rep.standby);
|
|
|
|
swaps(&rep.suspend);
|
|
|
|
swaps(&rep.off);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, sizeof(xDPMSGetTimeoutsReply), &rep);
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-07-27 13:02:24 -06:00
|
|
|
ProcDPMSSetTimeouts(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xDPMSSetTimeoutsReq);
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xDPMSSetTimeoutsReq);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((stuff->off != 0) && (stuff->off < stuff->suspend)) {
|
|
|
|
client->errorValue = stuff->off;
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
if ((stuff->suspend != 0) && (stuff->suspend < stuff->standby)) {
|
|
|
|
client->errorValue = stuff->suspend;
|
|
|
|
return BadValue;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
DPMSStandbyTime = stuff->standby * MILLI_PER_SECOND;
|
|
|
|
DPMSSuspendTime = stuff->suspend * MILLI_PER_SECOND;
|
|
|
|
DPMSOffTime = stuff->off * MILLI_PER_SECOND;
|
|
|
|
SetScreenSaverTimer();
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-07-27 13:02:24 -06:00
|
|
|
ProcDPMSEnable(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2008-06-14 18:17:32 -06:00
|
|
|
Bool was_enabled = DPMSEnabled;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xDPMSEnableReq);
|
|
|
|
|
2008-06-14 18:17:32 -06:00
|
|
|
if (DPMSCapableFlag) {
|
2012-06-10 07:21:05 -06:00
|
|
|
DPMSEnabled = TRUE;
|
|
|
|
if (!was_enabled)
|
|
|
|
SetScreenSaverTimer();
|
2008-06-14 18:17:32 -06:00
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-07-27 13:02:24 -06:00
|
|
|
ProcDPMSDisable(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
/* REQUEST(xDPMSDisableReq); */
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xDPMSDisableReq);
|
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
DPMSSet(client, DPMSModeOn);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
DPMSEnabled = FALSE;
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-07-27 13:02:24 -06:00
|
|
|
ProcDPMSForceLevel(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xDPMSForceLevelReq);
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xDPMSForceLevelReq);
|
|
|
|
|
|
|
|
if (!DPMSEnabled)
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadMatch;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2009-10-31 08:09:43 -06:00
|
|
|
if (stuff->level != DPMSModeOn &&
|
|
|
|
stuff->level != DPMSModeStandby &&
|
2012-06-10 07:21:05 -06:00
|
|
|
stuff->level != DPMSModeSuspend && stuff->level != DPMSModeOff) {
|
|
|
|
client->errorValue = stuff->level;
|
|
|
|
return BadValue;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
DPMSSet(client, stuff->level);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2009-09-06 13:44:18 -06:00
|
|
|
ProcDPMSInfo(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
/* REQUEST(xDPMSInfoReq); */
|
2013-06-07 11:28:45 -06:00
|
|
|
xDPMSInfoReply rep = {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = 0,
|
|
|
|
.power_level = DPMSPowerLevel,
|
|
|
|
.state = DPMSEnabled
|
|
|
|
};
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xDPMSInfoReq);
|
|
|
|
|
|
|
|
if (client->swapped) {
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&rep.sequenceNumber);
|
|
|
|
swaps(&rep.power_level);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, sizeof(xDPMSInfoReply), &rep);
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcDPMSDispatch(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xReq);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
switch (stuff->data) {
|
2006-11-26 11:13:41 -07:00
|
|
|
case X_DPMSGetVersion:
|
2012-06-10 07:21:05 -06:00
|
|
|
return ProcDPMSGetVersion(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
case X_DPMSCapable:
|
2012-06-10 07:21:05 -06:00
|
|
|
return ProcDPMSCapable(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
case X_DPMSGetTimeouts:
|
2012-06-10 07:21:05 -06:00
|
|
|
return ProcDPMSGetTimeouts(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
case X_DPMSSetTimeouts:
|
2012-06-10 07:21:05 -06:00
|
|
|
return ProcDPMSSetTimeouts(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
case X_DPMSEnable:
|
2012-06-10 07:21:05 -06:00
|
|
|
return ProcDPMSEnable(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
case X_DPMSDisable:
|
2012-06-10 07:21:05 -06:00
|
|
|
return ProcDPMSDisable(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
case X_DPMSForceLevel:
|
2012-06-10 07:21:05 -06:00
|
|
|
return ProcDPMSForceLevel(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
case X_DPMSInfo:
|
2012-06-10 07:21:05 -06:00
|
|
|
return ProcDPMSInfo(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
default:
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadRequest;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-07-27 13:02:24 -06:00
|
|
|
SProcDPMSGetVersion(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xDPMSGetVersionReq);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->length);
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST_SIZE_MATCH(xDPMSGetVersionReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->majorVersion);
|
|
|
|
swaps(&stuff->minorVersion);
|
2006-11-26 11:13:41 -07:00
|
|
|
return ProcDPMSGetVersion(client);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2009-09-06 13:44:18 -06:00
|
|
|
SProcDPMSCapable(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xDPMSCapableReq);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->length);
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST_SIZE_MATCH(xDPMSCapableReq);
|
|
|
|
|
|
|
|
return ProcDPMSCapable(client);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-07-27 13:02:24 -06:00
|
|
|
SProcDPMSGetTimeouts(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xDPMSGetTimeoutsReq);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->length);
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST_SIZE_MATCH(xDPMSGetTimeoutsReq);
|
|
|
|
|
|
|
|
return ProcDPMSGetTimeouts(client);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-07-27 13:02:24 -06:00
|
|
|
SProcDPMSSetTimeouts(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xDPMSSetTimeoutsReq);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->length);
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST_SIZE_MATCH(xDPMSSetTimeoutsReq);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->standby);
|
|
|
|
swaps(&stuff->suspend);
|
|
|
|
swaps(&stuff->off);
|
2006-11-26 11:13:41 -07:00
|
|
|
return ProcDPMSSetTimeouts(client);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-07-27 13:02:24 -06:00
|
|
|
SProcDPMSEnable(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xDPMSEnableReq);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->length);
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST_SIZE_MATCH(xDPMSEnableReq);
|
|
|
|
|
|
|
|
return ProcDPMSEnable(client);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-07-27 13:02:24 -06:00
|
|
|
SProcDPMSDisable(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xDPMSDisableReq);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->length);
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST_SIZE_MATCH(xDPMSDisableReq);
|
|
|
|
|
|
|
|
return ProcDPMSDisable(client);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-07-27 13:02:24 -06:00
|
|
|
SProcDPMSForceLevel(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xDPMSForceLevelReq);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->length);
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST_SIZE_MATCH(xDPMSForceLevelReq);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->level);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
return ProcDPMSForceLevel(client);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-07-27 13:02:24 -06:00
|
|
|
SProcDPMSInfo(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xDPMSInfoReq);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->length);
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST_SIZE_MATCH(xDPMSInfoReq);
|
|
|
|
|
|
|
|
return ProcDPMSInfo(client);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
SProcDPMSDispatch(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
switch (stuff->data) {
|
2006-11-26 11:13:41 -07:00
|
|
|
case X_DPMSGetVersion:
|
2012-06-10 07:21:05 -06:00
|
|
|
return SProcDPMSGetVersion(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
case X_DPMSCapable:
|
2012-06-10 07:21:05 -06:00
|
|
|
return SProcDPMSCapable(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
case X_DPMSGetTimeouts:
|
2012-06-10 07:21:05 -06:00
|
|
|
return SProcDPMSGetTimeouts(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
case X_DPMSSetTimeouts:
|
2012-06-10 07:21:05 -06:00
|
|
|
return SProcDPMSSetTimeouts(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
case X_DPMSEnable:
|
2012-06-10 07:21:05 -06:00
|
|
|
return SProcDPMSEnable(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
case X_DPMSDisable:
|
2012-06-10 07:21:05 -06:00
|
|
|
return SProcDPMSDisable(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
case X_DPMSForceLevel:
|
2012-06-10 07:21:05 -06:00
|
|
|
return SProcDPMSForceLevel(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
case X_DPMSInfo:
|
2012-06-10 07:21:05 -06:00
|
|
|
return SProcDPMSInfo(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
default:
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadRequest;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
void
|
2013-06-07 11:28:45 -06:00
|
|
|
DPMSExtensionInit(void)
|
2010-07-27 13:02:24 -06:00
|
|
|
{
|
|
|
|
AddExtension(DPMSExtensionName, 0, 0,
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcDPMSDispatch, SProcDPMSDispatch,
|
|
|
|
NULL, StandardMinorOpcode);
|
2010-07-27 13:02:24 -06:00
|
|
|
}
|