1 /*****************************************************************
3 Copyright (c) 1996 Digital Equipment Corporation, Maynard, Massachusetts.
5 Permission is hereby granted, free of charge, to any person obtaining a copy
6 of this software and associated documentation files (the "Software"), to deal
7 in the Software without restriction, including without limitation the rights
8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 copies of the Software.
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
18 BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY,
19 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
20 IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 Except as contained in this notice, the name of Digital Equipment Corporation
23 shall not be used in advertising or otherwise to promote the sale, use or other
24 dealings in this Software without prior written authorization from Digital
25 Equipment Corporation.
27 ******************************************************************/
29 #ifdef HAVE_DIX_CONFIG_H
30 #include <dix-config.h>
34 #include <X11/Xproto.h>
37 #include "dixstruct.h"
38 #include "extnsionst.h"
40 #include <X11/extensions/dpmsproto.h>
45 ProcDPMSGetVersion(ClientPtr client
)
47 /* REQUEST(xDPMSGetVersionReq); */
48 xDPMSGetVersionReply rep
= {
50 .sequenceNumber
= client
->sequence
,
52 .majorVersion
= DPMSMajorVersion
,
53 .minorVersion
= DPMSMinorVersion
56 REQUEST_SIZE_MATCH(xDPMSGetVersionReq
);
58 if (client
->swapped
) {
59 swaps(&rep
.sequenceNumber
);
60 swaps(&rep
.majorVersion
);
61 swaps(&rep
.minorVersion
);
63 WriteToClient(client
, sizeof(xDPMSGetVersionReply
), &rep
);
68 ProcDPMSCapable(ClientPtr client
)
70 /* REQUEST(xDPMSCapableReq); */
71 xDPMSCapableReply rep
= {
73 .sequenceNumber
= client
->sequence
,
75 .capable
= DPMSCapableFlag
78 REQUEST_SIZE_MATCH(xDPMSCapableReq
);
80 if (client
->swapped
) {
81 swaps(&rep
.sequenceNumber
);
83 WriteToClient(client
, sizeof(xDPMSCapableReply
), &rep
);
88 ProcDPMSGetTimeouts(ClientPtr client
)
90 /* REQUEST(xDPMSGetTimeoutsReq); */
91 xDPMSGetTimeoutsReply rep
= {
93 .sequenceNumber
= client
->sequence
,
95 .standby
= DPMSStandbyTime
/ MILLI_PER_SECOND
,
96 .suspend
= DPMSSuspendTime
/ MILLI_PER_SECOND
,
97 .off
= DPMSOffTime
/ MILLI_PER_SECOND
100 REQUEST_SIZE_MATCH(xDPMSGetTimeoutsReq
);
102 if (client
->swapped
) {
103 swaps(&rep
.sequenceNumber
);
108 WriteToClient(client
, sizeof(xDPMSGetTimeoutsReply
), &rep
);
113 ProcDPMSSetTimeouts(ClientPtr client
)
115 REQUEST(xDPMSSetTimeoutsReq
);
117 REQUEST_SIZE_MATCH(xDPMSSetTimeoutsReq
);
119 if ((stuff
->off
!= 0) && (stuff
->off
< stuff
->suspend
)) {
120 client
->errorValue
= stuff
->off
;
123 if ((stuff
->suspend
!= 0) && (stuff
->suspend
< stuff
->standby
)) {
124 client
->errorValue
= stuff
->suspend
;
128 DPMSStandbyTime
= stuff
->standby
* MILLI_PER_SECOND
;
129 DPMSSuspendTime
= stuff
->suspend
* MILLI_PER_SECOND
;
130 DPMSOffTime
= stuff
->off
* MILLI_PER_SECOND
;
131 SetScreenSaverTimer();
137 ProcDPMSEnable(ClientPtr client
)
139 Bool was_enabled
= DPMSEnabled
;
141 REQUEST_SIZE_MATCH(xDPMSEnableReq
);
143 if (DPMSCapableFlag
) {
146 SetScreenSaverTimer();
153 ProcDPMSDisable(ClientPtr client
)
155 /* REQUEST(xDPMSDisableReq); */
157 REQUEST_SIZE_MATCH(xDPMSDisableReq
);
159 DPMSSet(client
, DPMSModeOn
);
167 ProcDPMSForceLevel(ClientPtr client
)
169 REQUEST(xDPMSForceLevelReq
);
171 REQUEST_SIZE_MATCH(xDPMSForceLevelReq
);
176 if (stuff
->level
!= DPMSModeOn
&&
177 stuff
->level
!= DPMSModeStandby
&&
178 stuff
->level
!= DPMSModeSuspend
&& stuff
->level
!= DPMSModeOff
) {
179 client
->errorValue
= stuff
->level
;
183 DPMSSet(client
, stuff
->level
);
189 ProcDPMSInfo(ClientPtr client
)
191 /* REQUEST(xDPMSInfoReq); */
192 xDPMSInfoReply rep
= {
194 .sequenceNumber
= client
->sequence
,
196 .power_level
= DPMSPowerLevel
,
200 REQUEST_SIZE_MATCH(xDPMSInfoReq
);
202 if (client
->swapped
) {
203 swaps(&rep
.sequenceNumber
);
204 swaps(&rep
.power_level
);
206 WriteToClient(client
, sizeof(xDPMSInfoReply
), &rep
);
211 ProcDPMSDispatch(ClientPtr client
)
215 switch (stuff
->data
) {
216 case X_DPMSGetVersion
:
217 return ProcDPMSGetVersion(client
);
219 return ProcDPMSCapable(client
);
220 case X_DPMSGetTimeouts
:
221 return ProcDPMSGetTimeouts(client
);
222 case X_DPMSSetTimeouts
:
223 return ProcDPMSSetTimeouts(client
);
225 return ProcDPMSEnable(client
);
227 return ProcDPMSDisable(client
);
228 case X_DPMSForceLevel
:
229 return ProcDPMSForceLevel(client
);
231 return ProcDPMSInfo(client
);
238 SProcDPMSGetVersion(ClientPtr client
)
240 REQUEST(xDPMSGetVersionReq
);
242 swaps(&stuff
->length
);
243 REQUEST_SIZE_MATCH(xDPMSGetVersionReq
);
244 swaps(&stuff
->majorVersion
);
245 swaps(&stuff
->minorVersion
);
246 return ProcDPMSGetVersion(client
);
250 SProcDPMSCapable(ClientPtr client
)
252 REQUEST(xDPMSCapableReq
);
254 swaps(&stuff
->length
);
255 REQUEST_SIZE_MATCH(xDPMSCapableReq
);
257 return ProcDPMSCapable(client
);
261 SProcDPMSGetTimeouts(ClientPtr client
)
263 REQUEST(xDPMSGetTimeoutsReq
);
265 swaps(&stuff
->length
);
266 REQUEST_SIZE_MATCH(xDPMSGetTimeoutsReq
);
268 return ProcDPMSGetTimeouts(client
);
272 SProcDPMSSetTimeouts(ClientPtr client
)
274 REQUEST(xDPMSSetTimeoutsReq
);
276 swaps(&stuff
->length
);
277 REQUEST_SIZE_MATCH(xDPMSSetTimeoutsReq
);
279 swaps(&stuff
->standby
);
280 swaps(&stuff
->suspend
);
282 return ProcDPMSSetTimeouts(client
);
286 SProcDPMSEnable(ClientPtr client
)
288 REQUEST(xDPMSEnableReq
);
290 swaps(&stuff
->length
);
291 REQUEST_SIZE_MATCH(xDPMSEnableReq
);
293 return ProcDPMSEnable(client
);
297 SProcDPMSDisable(ClientPtr client
)
299 REQUEST(xDPMSDisableReq
);
301 swaps(&stuff
->length
);
302 REQUEST_SIZE_MATCH(xDPMSDisableReq
);
304 return ProcDPMSDisable(client
);
308 SProcDPMSForceLevel(ClientPtr client
)
310 REQUEST(xDPMSForceLevelReq
);
312 swaps(&stuff
->length
);
313 REQUEST_SIZE_MATCH(xDPMSForceLevelReq
);
315 swaps(&stuff
->level
);
317 return ProcDPMSForceLevel(client
);
321 SProcDPMSInfo(ClientPtr client
)
323 REQUEST(xDPMSInfoReq
);
325 swaps(&stuff
->length
);
326 REQUEST_SIZE_MATCH(xDPMSInfoReq
);
328 return ProcDPMSInfo(client
);
332 SProcDPMSDispatch(ClientPtr client
)
335 switch (stuff
->data
) {
336 case X_DPMSGetVersion
:
337 return SProcDPMSGetVersion(client
);
339 return SProcDPMSCapable(client
);
340 case X_DPMSGetTimeouts
:
341 return SProcDPMSGetTimeouts(client
);
342 case X_DPMSSetTimeouts
:
343 return SProcDPMSSetTimeouts(client
);
345 return SProcDPMSEnable(client
);
347 return SProcDPMSDisable(client
);
348 case X_DPMSForceLevel
:
349 return SProcDPMSForceLevel(client
);
351 return SProcDPMSInfo(client
);
358 DPMSExtensionInit(void)
360 AddExtension(DPMSExtensionName
, 0, 0,
361 ProcDPMSDispatch
, SProcDPMSDispatch
,
362 NULL
, StandardMinorOpcode
);