diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/ecore/src/lib/ecore_x/xlib/ecore_x_dpms.c | 247 |
1 files changed, 247 insertions, 0 deletions
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_dpms.c b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_dpms.c new file mode 100644 index 0000000..74d5344 --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_dpms.c | |||
@@ -0,0 +1,247 @@ | |||
1 | #ifdef HAVE_CONFIG_H | ||
2 | # include <config.h> | ||
3 | #endif /* ifdef HAVE_CONFIG_H */ | ||
4 | |||
5 | #include "ecore_x_private.h" | ||
6 | |||
7 | static Eina_Bool _dpms_available = EINA_FALSE; | ||
8 | |||
9 | void | ||
10 | _ecore_x_dpms_init(void) | ||
11 | { | ||
12 | #ifdef ECORE_XDPMS | ||
13 | int _dpms_major, _dpms_minor; | ||
14 | |||
15 | _dpms_major = 1; | ||
16 | _dpms_minor = 0; | ||
17 | |||
18 | if (DPMSGetVersion(_ecore_x_disp, &_dpms_major, &_dpms_minor)) | ||
19 | _dpms_available = EINA_TRUE; | ||
20 | else | ||
21 | _dpms_available = EINA_FALSE; | ||
22 | |||
23 | #else /* ifdef ECORE_XDPMS */ | ||
24 | _dpms_available = EINA_FALSE; | ||
25 | #endif /* ifdef ECORE_XDPMS */ | ||
26 | } /* _ecore_x_dpms_init */ | ||
27 | |||
28 | /** | ||
29 | * @defgroup Ecore_X_DPMS_Group X DPMS Extension Functions | ||
30 | * | ||
31 | * Functions related to the X DPMS extension. | ||
32 | */ | ||
33 | |||
34 | /** | ||
35 | * Checks if the X DPMS extension is available on the server. | ||
36 | * @return @c 1 if the X DPMS extension is available, @c 0 otherwise. | ||
37 | * @ingroup Ecore_X_DPMS_Group | ||
38 | */ | ||
39 | EAPI Eina_Bool | ||
40 | ecore_x_dpms_query(void) | ||
41 | { | ||
42 | return _dpms_available; | ||
43 | } /* ecore_x_dpms_query */ | ||
44 | |||
45 | /** | ||
46 | * Checks if the X server is capable of DPMS. | ||
47 | * @return @c 1 if the X server is capable of DPMS, @c 0 otherwise. | ||
48 | * @ingroup Ecore_X_DPMS_Group | ||
49 | */ | ||
50 | EAPI Eina_Bool | ||
51 | ecore_x_dpms_capable_get(void) | ||
52 | { | ||
53 | #ifdef ECORE_XDPMS | ||
54 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
55 | return DPMSCapable(_ecore_x_disp) ? EINA_TRUE : EINA_FALSE; | ||
56 | #else /* ifdef ECORE_XDPMS */ | ||
57 | return EINA_FALSE; | ||
58 | #endif /* ifdef ECORE_XDPMS */ | ||
59 | } /* ecore_x_dpms_capable_get */ | ||
60 | |||
61 | /** | ||
62 | * Checks the DPMS state of the display. | ||
63 | * @return @c 1 if DPMS is enabled, @c 0 otherwise. | ||
64 | * @ingroup Ecore_X_DPMS_Group | ||
65 | */ | ||
66 | EAPI Eina_Bool | ||
67 | ecore_x_dpms_enabled_get(void) | ||
68 | { | ||
69 | #ifdef ECORE_XDPMS | ||
70 | unsigned char state; | ||
71 | unsigned short power_lvl; | ||
72 | |||
73 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
74 | DPMSInfo(_ecore_x_disp, &power_lvl, &state); | ||
75 | return state ? EINA_TRUE : EINA_FALSE; | ||
76 | #else /* ifdef ECORE_XDPMS */ | ||
77 | return EINA_FALSE; | ||
78 | #endif /* ifdef ECORE_XDPMS */ | ||
79 | } /* ecore_x_dpms_enabled_get */ | ||
80 | |||
81 | /** | ||
82 | * Sets the DPMS state of the display. | ||
83 | * @param enabled @c 0 to disable DPMS characteristics of the server, enable it otherwise. | ||
84 | * @ingroup Ecore_X_DPMS_Group | ||
85 | */ | ||
86 | EAPI void | ||
87 | ecore_x_dpms_enabled_set(int enabled) | ||
88 | { | ||
89 | #ifdef ECORE_XDPMS | ||
90 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
91 | if (enabled) | ||
92 | DPMSEnable(_ecore_x_disp); | ||
93 | else | ||
94 | DPMSDisable(_ecore_x_disp); | ||
95 | |||
96 | #endif /* ifdef ECORE_XDPMS */ | ||
97 | } /* ecore_x_dpms_enabled_set */ | ||
98 | |||
99 | /** | ||
100 | * Gets the timeouts. The values are in unit of seconds. | ||
101 | * @param standby Amount of time of inactivity before standby mode will be invoked. | ||
102 | * @param suspend Amount of time of inactivity before the screen is placed into suspend mode. | ||
103 | * @param off Amount of time of inactivity before the monitor is shut off. | ||
104 | * @ingroup Ecore_X_DPMS_Group | ||
105 | */ | ||
106 | EAPI void | ||
107 | ecore_x_dpms_timeouts_get(unsigned int *standby, | ||
108 | unsigned int *suspend, | ||
109 | unsigned int *off) | ||
110 | { | ||
111 | #ifdef ECORE_XDPMS | ||
112 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
113 | DPMSGetTimeouts(_ecore_x_disp, (unsigned short *)standby, | ||
114 | (unsigned short *)suspend, (unsigned short *)off); | ||
115 | #endif /* ifdef ECORE_XDPMS */ | ||
116 | } /* ecore_x_dpms_timeouts_get */ | ||
117 | |||
118 | /** | ||
119 | * Sets the timeouts. The values are in unit of seconds. | ||
120 | * @param standby Amount of time of inactivity before standby mode will be invoked. | ||
121 | * @param suspend Amount of time of inactivity before the screen is placed into suspend mode. | ||
122 | * @param off Amount of time of inactivity before the monitor is shut off. | ||
123 | * @ingroup Ecore_X_DPMS_Group | ||
124 | */ | ||
125 | EAPI Eina_Bool | ||
126 | ecore_x_dpms_timeouts_set(unsigned int standby, | ||
127 | unsigned int suspend, | ||
128 | unsigned int off) | ||
129 | { | ||
130 | #ifdef ECORE_XDPMS | ||
131 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
132 | return DPMSSetTimeouts(_ecore_x_disp, standby, suspend, off) ? EINA_TRUE : EINA_FALSE; | ||
133 | #else /* ifdef ECORE_XDPMS */ | ||
134 | return EINA_FALSE; | ||
135 | #endif /* ifdef ECORE_XDPMS */ | ||
136 | } /* ecore_x_dpms_timeouts_set */ | ||
137 | |||
138 | /** | ||
139 | * Returns the amount of time of inactivity before standby mode is invoked. | ||
140 | * @return The standby timeout value. | ||
141 | * @ingroup Ecore_X_DPMS_Group | ||
142 | */ | ||
143 | EAPI unsigned int | ||
144 | ecore_x_dpms_timeout_standby_get(void) | ||
145 | { | ||
146 | #ifdef ECORE_XDPMS | ||
147 | unsigned short standby, suspend, off; | ||
148 | |||
149 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
150 | DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off); | ||
151 | return standby; | ||
152 | #else /* ifdef ECORE_XDPMS */ | ||
153 | return 0; | ||
154 | #endif /* ifdef ECORE_XDPMS */ | ||
155 | } /* ecore_x_dpms_timeout_standby_get */ | ||
156 | |||
157 | /** | ||
158 | * Returns the amount of time of inactivity before the second level of | ||
159 | * power saving is invoked. | ||
160 | * @return The suspend timeout value. | ||
161 | * @ingroup Ecore_X_DPMS_Group | ||
162 | */ | ||
163 | EAPI unsigned int | ||
164 | ecore_x_dpms_timeout_suspend_get(void) | ||
165 | { | ||
166 | #ifdef ECORE_XDPMS | ||
167 | unsigned short standby, suspend, off; | ||
168 | |||
169 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
170 | DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off); | ||
171 | return suspend; | ||
172 | #else /* ifdef ECORE_XDPMS */ | ||
173 | return 0; | ||
174 | #endif /* ifdef ECORE_XDPMS */ | ||
175 | } /* ecore_x_dpms_timeout_suspend_get */ | ||
176 | |||
177 | /** | ||
178 | * Returns the amount of time of inactivity before the third and final | ||
179 | * level of power saving is invoked. | ||
180 | * @return The off timeout value. | ||
181 | * @ingroup Ecore_X_DPMS_Group | ||
182 | */ | ||
183 | EAPI unsigned int | ||
184 | ecore_x_dpms_timeout_off_get(void) | ||
185 | { | ||
186 | #ifdef ECORE_XDPMS | ||
187 | unsigned short standby, suspend, off; | ||
188 | |||
189 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
190 | DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off); | ||
191 | return off; | ||
192 | #else /* ifdef ECORE_XDPMS */ | ||
193 | return 0; | ||
194 | #endif /* ifdef ECORE_XDPMS */ | ||
195 | } /* ecore_x_dpms_timeout_off_get */ | ||
196 | |||
197 | /** | ||
198 | * Sets the standby timeout (in unit of seconds). | ||
199 | * @param new_standby Amount of time of inactivity before standby mode will be invoked. | ||
200 | * @ingroup Ecore_X_DPMS_Group | ||
201 | */ | ||
202 | EAPI void | ||
203 | ecore_x_dpms_timeout_standby_set(unsigned int new_timeout) | ||
204 | { | ||
205 | #ifdef ECORE_XDPMS | ||
206 | unsigned short standby, suspend, off; | ||
207 | |||
208 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
209 | DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off); | ||
210 | DPMSSetTimeouts(_ecore_x_disp, new_timeout, suspend, off); | ||
211 | #endif /* ifdef ECORE_XDPMS */ | ||
212 | } /* ecore_x_dpms_timeout_standby_set */ | ||
213 | |||
214 | /** | ||
215 | * Sets the suspend timeout (in unit of seconds). | ||
216 | * @param suspend Amount of time of inactivity before the screen is placed into suspend mode. | ||
217 | * @ingroup Ecore_X_DPMS_Group | ||
218 | */ | ||
219 | EAPI void | ||
220 | ecore_x_dpms_timeout_suspend_set(unsigned int new_timeout) | ||
221 | { | ||
222 | #ifdef ECORE_XDPMS | ||
223 | unsigned short standby, suspend, off; | ||
224 | |||
225 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
226 | DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off); | ||
227 | DPMSSetTimeouts(_ecore_x_disp, standby, new_timeout, off); | ||
228 | #endif /* ifdef ECORE_XDPMS */ | ||
229 | } /* ecore_x_dpms_timeout_suspend_set */ | ||
230 | |||
231 | /** | ||
232 | * Sets the off timeout (in unit of seconds). | ||
233 | * @param off Amount of time of inactivity before the monitor is shut off. | ||
234 | * @ingroup Ecore_X_DPMS_Group | ||
235 | */ | ||
236 | EAPI void | ||
237 | ecore_x_dpms_timeout_off_set(unsigned int new_timeout) | ||
238 | { | ||
239 | #ifdef ECORE_XDPMS | ||
240 | unsigned short standby, suspend, off; | ||
241 | |||
242 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
243 | DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off); | ||
244 | DPMSSetTimeouts(_ecore_x_disp, standby, suspend, new_timeout); | ||
245 | #endif /* ifdef ECORE_XDPMS */ | ||
246 | } /* ecore_x_dpms_timeout_off_set */ | ||
247 | |||