2 * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
26 #include <X11/Xlibint.h>
27 #include <X11/extensions/fbpm.h>
28 #include <X11/extensions/fbpmstr.h>
29 #include <X11/extensions/Xext.h>
30 #include <X11/extensions/extutil.h>
33 static XExtensionInfo _fbpm_info_data
;
34 static XExtensionInfo
*fbpm_info
= &_fbpm_info_data
;
35 static char *fbpm_extension_name
= FBPMExtensionName
;
37 #define FBPMCheckExtension(dpy,i,val) \
38 XextCheckExtension (dpy, i, fbpm_extension_name, val)
40 /*****************************************************************************
42 * private utility routines *
44 *****************************************************************************/
46 static int close_display(Display
*dpy
, XExtCodes
*codes
);
47 static /* const */ XExtensionHooks fbpm_extension_hooks
= {
52 NULL
, /* create_font */
54 close_display
, /* close_display */
55 NULL
, /* wire_to_event */
56 NULL
, /* event_to_wire */
58 NULL
/* error_string */
61 static XEXT_GENERATE_FIND_DISPLAY (find_display
, fbpm_info
,
63 &fbpm_extension_hooks
, FBPMNumberEvents
,
66 static XEXT_GENERATE_CLOSE_DISPLAY (close_display
, fbpm_info
)
68 /*****************************************************************************
72 *****************************************************************************/
74 Bool
FBPMQueryExtension (
79 XExtDisplayInfo
*info
= find_display (dpy
);
81 if (XextHasExtension(info
)) {
82 *event_basep
= info
->codes
->first_event
;
83 *error_basep
= info
->codes
->first_error
;
90 Status
FBPMGetVersion(
95 XExtDisplayInfo
*info
= find_display (dpy
);
96 xFBPMGetVersionReply rep
;
97 register xFBPMGetVersionReq
*req
;
99 FBPMCheckExtension (dpy
, info
, 0);
102 GetReq (FBPMGetVersion
, req
);
103 req
->reqType
= info
->codes
->major_opcode
;
104 req
->fbpmReqType
= X_FBPMGetVersion
;
105 if (!_XReply (dpy
, (xReply
*) &rep
, 0, xTrue
)) {
110 *major_versionp
= rep
.majorVersion
;
111 *minor_versionp
= rep
.minorVersion
;
120 XExtDisplayInfo
*info
= find_display (dpy
);
121 register xFBPMCapableReq
*req
;
122 xFBPMCapableReply rep
;
124 FBPMCheckExtension (dpy
, info
, 0);
127 GetReq(FBPMCapable
, req
);
128 req
->reqType
= info
->codes
->major_opcode
;
129 req
->fbpmReqType
= X_FBPMCapable
;
131 if (!_XReply(dpy
, (xReply
*)&rep
, 0, xFalse
)) {
146 XExtDisplayInfo
*info
= find_display (dpy
);
147 register xFBPMEnableReq
*req
;
149 FBPMCheckExtension (dpy
, info
, 0);
151 GetReq(FBPMEnable
, req
);
152 req
->reqType
= info
->codes
->major_opcode
;
153 req
->fbpmReqType
= X_FBPMEnable
;
164 XExtDisplayInfo
*info
= find_display (dpy
);
165 register xFBPMDisableReq
*req
;
167 FBPMCheckExtension (dpy
, info
, 0);
169 GetReq(FBPMDisable
, req
);
170 req
->reqType
= info
->codes
->major_opcode
;
171 req
->fbpmReqType
= X_FBPMDisable
;
177 Status
FBPMForceLevel(
181 XExtDisplayInfo
*info
= find_display (dpy
);
182 register xFBPMForceLevelReq
*req
;
184 FBPMCheckExtension (dpy
, info
, 0);
186 if ((level
!= FBPMModeOn
) &&
187 (level
!= FBPMModeStandby
) &&
188 (level
!= FBPMModeSuspend
) &&
189 (level
!= FBPMModeOff
))
193 GetReq(FBPMForceLevel
, req
);
194 req
->reqType
= info
->codes
->major_opcode
;
195 req
->fbpmReqType
= X_FBPMForceLevel
;
208 XExtDisplayInfo
*info
= find_display (dpy
);
209 register xFBPMInfoReq
*req
;
212 FBPMCheckExtension (dpy
, info
, 0);
215 GetReq(FBPMInfo
, req
);
216 req
->reqType
= info
->codes
->major_opcode
;
217 req
->fbpmReqType
= X_FBPMInfo
;
219 if (!_XReply(dpy
, (xReply
*)&rep
, 0, xTrue
)) {
226 *state
= rep
.power_level
;